Merge. Revision history for source files should be all back now.

--HG--
branch : trunk
rename : sql/CMakeLists.txt => sql/tools/CMakeLists.txt
rename : src/server/game/Pools/PoolHandler.cpp => src/server/game/Pools/PoolMgr.cpp
rename : src/server/game/Pools/PoolHandler.h => src/server/game/Pools/PoolMgr.h
rename : src/server/game/PrecompiledHeaders/NixCorePCH.cpp => src/server/game/PrecompiledHeaders/gamePCH.cpp
rename : src/server/game/PrecompiledHeaders/NixCorePCH.h => src/server/game/PrecompiledHeaders/gamePCH.h
This commit is contained in:
Xanadu
2010-07-20 02:49:28 +02:00
3587 changed files with 301677 additions and 181018 deletions

View File

@@ -1,7 +1,7 @@
# use glob syntax.
syntax: glob
src/shared/revision.h
src/server/shared/revision.h
build/
bin/
.directory
@@ -10,15 +10,16 @@ bin/
*~
.git/
win/VC90/*/
src/tools/bin/*/
src/tools/map_extractor/VC90/*/
src/tools/vmap3_assembler/VC90/*/
src/tools/vmap3_extractor/VC90/*/
externals/lib/*/
*.ncb
*.suo
dep/lib/win32*
src/bindings/scripts/VC90/*/
src/mangosd/
src/realmd/
*.*-*
# use regexp syntax.
syntax: regexp
^src/shared/revision\.h
^src/shared/server/shared/revision\.h

View File

@@ -26,3 +26,6 @@ b048ef8c4b39afb28c66f5c16a2d2cc5eb8d12d2 3.2.2a-really-last
50ede8e9dc8a83776fb6a0bfe17af9391c17b625 Teacher's & SoulForge's birthday
e653a5b8d0100c99337e012e4b66848efd028cfb UP30
556e3ed4965e7f03267e8ae2a6c6ad8a34715ac5 Repository restructuring
01713607e30dfe526819c8151acb0421395e9341 UP31
0410a47ee355040447f516bde5a7d21775829788 3.3.3a-LAST
1d84e402c47448d0f609c6d8ad8f409a0d24ce48 3.3.5a-clientsupport

View File

@@ -1,191 +1,271 @@
# Copyright (C) 2005-2010 Trinity <http://www.trinitycore.org/>
#
# This file is free software; as a special exception the author gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
project(Trinity)
# CMake policies
cmake_minimum_required(VERSION 2.6)
cmake_policy(SET CMP0005 OLD)
include(CheckIncludeFiles)
include(cmake/FindAce.cmake)
include(cmake/FindMySql.cmake)
include(cmake/FindReadline.cmake)
include(cmake/FindTermcap.cmake)
include(cmake/PCH.cmake)
#
# Override configuration-types - we don't use anything else than debug and release
#
if(CMAKE_CONFIGURATION_TYPES)
set(CMAKE_CONFIGURATION_TYPES Debug Release)
set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING
"Reset the configurations to what we need"
FORCE)
endif()
# Force out-of-source build
string(COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" BUILDING_IN_SOURCE)
if(BUILDING_IN_SOURCE)
message(FATAL_ERROR "This project requires an out of source build. Remove the file 'CMakeCache.txt' found in this directory before continuing, and create a separate build directory and run 'cmake path_to_project [options]' from there.")
endif(BUILDING_IN_SOURCE)
if( BUILDING_IN_SOURCE )
message(FATAL_ERROR "
This project requires an out of source build. Remove the file 'CMakeCache.txt'
found in this directory before continuing, create a separate build directory
and run 'cmake path_to_project [options]' from there.
")
endif()
#
# Basic packagesearching and setup (further support will be needed, this is a preliminary release!)
#
include(CheckIncludeFiles)
include(cmake/FindPlatform.cmake)
include(cmake/FindPCHSupport.cmake)
if(WIN32)
set(ACE_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/externals)
endif()
include(cmake/FindACE.cmake)
include(cmake/FindMySQL.cmake)
include(cmake/FindOpenSSL.cmake)
#
# *nix-specific packages ( zlib and bzip2 libraries will be built from sourcetree on WIN32-platforms)
#
if( UNIX )
include(cmake/FindReadline.cmake)
include(cmake/FindTermcap.cmake)
include(FindZLIB)
include(FindBZip2)
endif()
# Select the Release build configuration by default.
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
endif(NOT CMAKE_BUILD_TYPE)
if( NOT CMAKE_BUILD_TYPE )
set(CMAKE_BUILD_TYPE "Release")
endif()
CONFIGURE_FILE(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
add_custom_target(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
if( UNIX )
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY
)
option(DO_MYSQL "With MySQL support" 1)
option(DO_SCRIPTS "With trinityscripts" 1)
add_custom_target(uninstall
"${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
)
endif()
option(DO_AUTHSERVER "Build authserver" 1)
option(DO_WORLDSERVER "Build worldserver" 1)
option(DO_CLI "With CLI" 1)
option(DO_RA "With RA" 0)
option(DO_DEBUG "Debug mode" 0)
option(DO_WARN "Enable all compile warnings" 0)
option(DO_WARN "Enable all compile warnings" 0)
option(CENTOS "CENTOS" 0)
option(DO_SQL "Copy SQL files" 0)
option(DO_PCH "Use precompiled headers" 1)
option(DO_TOOLS "Compile tools" 0)
option(DO_RA "With RA" 0)
option(DO_SCRIPTS "With trinityscripts" 1)
option(DO_SQL "Copy SQL files" 0)
option(DO_TOOLS "Build tools" 0)
option(DO_WARN "Enable all compile warnings" 0)
if( UNIX )
option(CENTOS "CENTOS" 0)
if( CENTOS )
add_definitions(-DCENTOS)
find_termcap()
else()
find_readline()
endif()
endif()
# Set up the installation-prefix
if( PREFIX )
set(CMAKE_INSTALL_PREFIX ${PREFIX})
endif()
set(GENREV_SRC
src/genrevision/genrevision.cpp
src/genrevision/genrevision.cpp
)
if(DO_DEBUG)
add_executable(genrev
${GENREV_SRC}
)
add_custom_target("revision.h" ALL
COMMAND "${CMAKE_BINARY_DIR}/genrev"
${CMAKE_SOURCE_DIR}
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/src/shared"
DEPENDS genrev
)
else (DO_DEBUG)
add_executable(genrev
${GENREV_SRC}
)
add_custom_target("revision.h" ALL
COMMAND "${CMAKE_BINARY_DIR}/genrev"
${CMAKE_SOURCE_DIR}
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/src/server/shared"
DEPENDS genrev
)
endif(DO_DEBUG)
# Handle debugmode compiles (this will require further work for proper WIN32-setups)
if( DO_DEBUG )
set(CMAKE_BUILD_TYPE Debug)
endif()
#
# Generate revision-extractor
#
add_executable(genrev
${GENREV_SRC}
)
if( CMAKE_GENERATOR MATCHES "Visual Studio" )
add_custom_target("revision.h" ALL
COMMAND "${CMAKE_BINARY_DIR}/$(ConfigurationName)/genrev"
${CMAKE_SOURCE_DIR}
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
DEPENDS genrev
)
else()
add_custom_target("revision.h" ALL
COMMAND "${CMAKE_BINARY_DIR}/genrev"
${CMAKE_SOURCE_DIR}
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
DEPENDS genrev
)
endif()
execute_process(
COMMAND hg tip --template {rev}
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
OUTPUT_VARIABLE HG_REVISION
COMMAND hg tip --template {rev}
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
OUTPUT_VARIABLE HG_REVISION
)
message("* TrinityCore revision: ${HG_REVISION}")
message("")
message("* TrinityCore revision : ${HG_REVISION}")
message("* Build binaries in : ${CMAKE_BUILD_TYPE} mode")
message("")
if(PREFIX)
set(CMAKE_INSTALL_PREFIX ${PREFIX})
endif(PREFIX)
if( NOT CONF_DIR )
set(CONF_DIR ${CMAKE_INSTALL_PREFIX}/etc)
endif()
if(CONF_DIR)
else(CONF_DIR)
set(CONF_DIR ${PREFIX}/etc)
endif(CONF_DIR)
set(LIBSDIR ${CMAKE_INSTALL_PREFIX}/lib)
message("* Will install to: ${CMAKE_INSTALL_PREFIX}")
message("* With config dir at: ${CONF_DIR}")
message("* Libs install dir at: ${LIBSDIR}")
message("* Install core to : ${CMAKE_INSTALL_PREFIX}")
message("* Install libraries to : ${LIBSDIR}")
message("* Install configs to : ${CONF_DIR}")
message("")
find_library(SSLLIB NAMES ssl DOC "SSL library")
find_library(ZLIB z "Zlib library")
if( DO_AUTHSERVER )
message("* Build authserver : Yes (default)")
else()
message("* Build authserver : No")
endif()
if(DO_MYSQL)
message("* With MySQL")
FIND_MYSQL()
ADD_DEFINITIONS(-DDO_MYSQL)
endif(DO_MYSQL)
if( DO_WORLDSERVER )
message("* Build worldserver : Yes (default)")
else()
message("* Build worldserver : No")
endif()
if(DO_SCRIPTS)
message("* With Trinity Scripts")
ADD_DEFINITIONS(-DDO_SCRIPTS)
add_definitions(-D_TRINITY_SCRIPT_CONFIG='"${CONF_DIR}/trinitycore.conf"')
else (DO_SCRIPTS)
message("* Without Trinity Scripts")
endif(DO_SCRIPTS)
if( DO_SCRIPTS )
message("* Build Trinityscripts : Yes (default)")
add_definitions(-DDO_SCRIPTS)
else()
message("* Build Trinityscripts : No")
endif()
message("-- Miscellaneus options:")
if( DO_TOOLS )
message("* Build map/vmap tools : Yes")
else()
message("* Build map/vmap tools : No (default)")
endif()
if(DO_CLI)
message("* With CLI")
add_definitions(-DENABLE_CLI)
else (DO_CLI)
message(* Without CLI)
endif(DO_CLI)
if( DO_CLI )
message("* Build with CLI : Yes (default)")
add_definitions(-DENABLE_CLI)
else()
message("* Build with CLI : No")
endif()
if(DO_RA)
message("* With RA")
add_definitions(-DENABLE_RA)
else(DO_RA)
message("* Without RA")
endif(DO_RA)
if( DO_RA )
message("* Build with RA : Yes")
add_definitions(-DENABLE_RA)
else()
message("* Build with RA : No (default)")
endif()
if(DO_DEBUG)
message("* Debug mode ON")
add_definitions(-g -DTRINITY_DEBUG)
endif(DO_DEBUG)
if( DO_DEBUG )
message("* Build in debug-mode : Yes")
add_definitions(-g -DTRINITY_DEBUG)
else()
message("* Build in debug-mode : No (default)")
endif()
if(DO_WARN)
message("* All warnings mode")
if( DO_PCH )
message("* Use PCH : Yes (default)")
else()
message("* Use PCH : No")
endif()
if( DO_WARN )
message("* Show all warnings : Yes")
if( UNIX )
add_definitions(-Wall -Wfatal-errors -Wextra)
endif(DO_WARN)
endif()
else()
message("* Show compile-warnings : No (default)")
if( UNIX )
add_definitions(--no-warnings) # makes build look nice, no warnings shown at all, only errors
elseif( WIN32 )
# Disable warnings in Visual Studio 8 and above
if(MSVC AND NOT CMAKE_GENERATOR MATCHES "Visual Studio 7")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /wd4996 /wd4355 /wd4244 /wd4985 /wd4267")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /wd4996 /wd4355 /wd4244 /wd4267")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /wd4996 /wd4355 /wd4244 /wd4985 /wd4267")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /wd4996 /wd4355 /wd4244 /wd4985 /wd4267")
endif()
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
endif()
endif()
if(UNIX)
if(CENTOS)
add_definitions(-DCENTOS)
message("* Building with termcap")
FIND_TERMCAP()
else(CENTOS)
message("* Building with readline")
FIND_READLINE()
endif(CENTOS)
endif(UNIX)
if( DO_SQL )
message("* Install SQL-files : Yes")
else()
message("* Install SQL-files : No (default)")
endif()
FIND_ACE(ACE)
if(ACE_FOUND)
message(STATUS "Found ACE library: ${ACE_LIBRARY}")
message(STATUS "Include dir is: ${ACE_INCLUDE_DIR}")
else(ACE_FOUND)
message(SEND_ERROR "** ACE library not found! Trinity Core cannot be compiled!")
message(SEND_ERROR "** Please build ACE from http://www.cs.wustl.edu/~schmidt/ACE.html")
#For now remove msg about install from repo, as ubuntu/debian don't have needed ver in repos.
#message(SEND_ERROR "** your distro may provide a binary for ACE e.g. for ubuntu try apt-get install libace-dev")
return()
#set(BUILD_ACE 1)
#set(ACE_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/dep/ACE_wrappers ${CMAKE_BINARY_DIR}/dep/ACE_wrappers")
#set(ACE_LIBRARY ACE)
#message(STATUS "I will try to build ACE from: ${ACE_INCLUDE_DIR}")
#message(STATUS "And link using: ${ACE_LIBRARY}")
endif(ACE_FOUND)
#somehow line below don't work. so for now change it to if exist
#check_include_files(${ACE_INCLUDE_DIR}/ace/Stack_Trace.h HAVE_ACE_STACK_TRACE_H)
if(EXISTS ${ACE_INCLUDE_DIR}/ace/Stack_Trace.h)
set(HAVE_ACE_STACK_TRACE_H 1)
else(EXISTS ${ACE_INCLUDE_DIR}/ace/Stack_Trace.h)
message(STATUS "** Your libace is out of date. Please update your libace!")
endif(EXISTS ${ACE_INCLUDE_DIR}/ace/Stack_Trace.h)
message("")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
# Little tweak for OS X
if( CMAKE_SYSTEM_NAME MATCHES "Darwin" )
set(MACOSX 1)
set(OSX_LIBS /opt/local/lib/libcrypto.dylib)
add_definitions(-D__ASSERTMACROS__)
endif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
endif()
# Some small tweaks for Visual Studio 7 and above.
if( MSVC )
# Mark 32 bit executables large address aware so they can use > 2GB address space
if(CMAKE_SIZEOF_VOID_P MATCHES 4)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /LARGEADDRESSAWARE")
endif()
endif()
add_definitions(--no-warnings) #to make build look nice, no gcc nazi warnings.
set(CMAKE_SKIP_BUILD_RPATH FALSE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
set(CMAKE_SKIP_BUILD_RPATH 0)
set(CMAKE_BUILD_WITH_INSTALL_RPATH 0)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH 1)
add_subdirectory(dep)
add_subdirectory(externals)
add_subdirectory(src)
if(DO_SQL)
message("* Copy SQL files ON")
add_subdirectory(sql)
endif(DO_SQL)
if( DO_SQL )
add_subdirectory(sql)
endif()

2
README
View File

@@ -40,4 +40,4 @@ SQL files to create the database can be found in the sql directory. Files
to update your database from an older revision/version can be found in the
sql/updates directory.
See the INSTALL.linux file for installation instructions on Linux.
See the docs/UnixInstall.txt file for installation instructions on Linux.

2
THANKS
View File

@@ -64,4 +64,4 @@ footman, elron103, make_the_king, destros, MetaphysicalDrama, disassebler,
Malcrom, Vladmimír Lipták, retriman, hyriuu, Smakapotatis, PainKiller,
bkhorizon, n0n4m3, Chesterfield, Frankir, Wowka321, Morpheux, p0wer,
Ouden, toshik, laise, yavi, Splinter, Syntec, Arthas, denyde, unholy,
Vaughner, blackmanos, edrinn, Supabad.
Vaughner, blackmanos, edrinn, Supabad, click, silverice, SupaBad, Xanadu

65
cmake/FindACE.cmake Normal file
View File

@@ -0,0 +1,65 @@
#
# Find the ACE client includes and library
#
# This module defines
# ACE_INCLUDE_DIR, where to find ace.h
# ACE_LIBRARIES, the libraries to link against
# ACE_FOUND, if false, you cannot build anything that requires ACE
# also defined, but not for general use are
# ACE_LIBRARY, where to find the ACE library.
set( ACE_FOUND 0 )
if ( UNIX )
FIND_PATH( ACE_INCLUDE_DIR
NAMES
ace/ACE.h
PATHS
/usr/include
/usr/include/ace
/usr/local/include
/usr/local/include/ace
$ENV{ACE_ROOT}
$ENV{ACE_ROOT}/include
${CMAKE_SOURCE_DIR}/externals/ace
DOC
"Specify include-directories that might contain ace.h here."
)
FIND_LIBRARY( ACE_LIBRARY
NAMES
ace ACE
PATHS
/usr/lib
/usr/lib/ace
/usr/local/lib
/usr/local/lib/ace
/usr/local/ace/lib
$ENV{ACE_ROOT}/lib
$ENV{ACE_ROOT}
DOC "Specify library-locations that might contain the ACE library here."
)
# FIND_LIBRARY( ACE_EXTRA_LIBRARIES
# NAMES
# z zlib
# PATHS
# /usr/lib
# /usr/local/lib
# DOC
# "if more libraries are necessary to link into ACE, specify them here."
# )
if ( ACE_LIBRARY )
if ( ACE_INCLUDE_DIR )
set( ACE_FOUND 1 )
message( STATUS "Found ACE library: ${ACE_LIBRARY}")
message( STATUS "Found ACE headers: ${ACE_INCLUDE_DIR}")
else ( ACE_INCLUDE_DIR )
message(FATAL_ERROR "Could not find ACE headers! Please install ACE libraries and headers")
endif ( ACE_INCLUDE_DIR )
endif ( ACE_LIBRARY )
mark_as_advanced( ACE_FOUND ACE_LIBRARY ACE_EXTRA_LIBRARIES ACE_INCLUDE_DIR )
endif (UNIX)

View File

@@ -1,31 +0,0 @@
# This script is taken from BFilter project, thanks to original authors.
# - Locate the ACE library
# This module defines
# ACE_FOUND -- true if ACE was found
# ACE_LIBRARY -- the library to link against
# ACE_INCLUDE_DIR -- path to ace/ACE.h
MACRO(FIND_ACE LIBNAME)
GET_FILENAME_COMPONENT(parent_dir_ "${PROJECT_SOURCE_DIR}/.." ABSOLUTE)
FIND_PATH(
ACE_INCLUDE_DIR ace/ACE.h
PATHS /usr/include /usr/local/include
"${CMAKE_INSTALL_PREFIX}/include" "${parent_dir_}/ACE_wrappers"
DOC "Path to ace/ACE.h"
)
# This prevents it being taken from cache. - but also broke cmake -i, so we dont use it
# SET(ACE_LIBRARY ACE_LIBRARY-NOTFOUND)
FIND_LIBRARY(
ACE_LIBRARY "${LIBNAME}"
PATHS /usr/lib /usr/local/lib
"${CMAKE_INSTALL_PREFIX}/lib" "${parent_dir_}/ACE_wrappers/ace"
DOC "Path to ACE library file"
)
IF(ACE_INCLUDE_DIR AND ACE_LIBRARY)
SET(ACE_FOUND TRUE)
ELSE(ACE_INCLUDE_DIR AND ACE_LIBRARY)
SET(ACE_FOUND FALSE)
ENDIF(ACE_INCLUDE_DIR AND ACE_LIBRARY)
ENDMACRO(FIND_ACE)

152
cmake/FindMySQL.cmake Normal file
View File

@@ -0,0 +1,152 @@
#
# Find the MySQL client includes and library
#
# This module defines
# MYSQL_INCLUDE_DIR, where to find mysql.h
# MYSQL_LIBRARIES, the libraries to link against to connect to MySQL
# MYSQL_FOUND, if false, you cannot build anything that requires MySQL.
# also defined, but not for general use are
# MYSQL_LIBRARY, where to find the MySQL library.
set( MYSQL_FOUND 0 )
if( UNIX )
set(MYSQL_CONFIG_PREFER_PATH "$ENV{MYSQL_HOME}/bin" CACHE FILEPATH
"preferred path to MySQL (mysql_config)"
)
find_program(MYSQL_CONFIG mysql_config
${MYSQL_CONFIG_PREFER_PATH}
/usr/local/mysql/bin/
/usr/local/bin/
/usr/bin/
)
if( MYSQL_CONFIG )
message(STATUS "Using mysql-config: ${MYSQL_CONFIG}")
# set INCLUDE_DIR
exec_program(${MYSQL_CONFIG}
ARGS --include
OUTPUT_VARIABLE MY_TMP
)
string(REGEX REPLACE "-I([^ ]*)( .*)?" "\\1" MY_TMP "${MY_TMP}")
set(MYSQL_ADD_INCLUDE_PATH ${MY_TMP} CACHE FILEPATH INTERNAL)
#message("[DEBUG] MYSQL ADD_INCLUDE_PATH : ${MYSQL_ADD_INCLUDE_PATH}")
# set LIBRARY_DIR
exec_program(${MYSQL_CONFIG}
ARGS --libs_r
OUTPUT_VARIABLE MY_TMP
)
set(MYSQL_ADD_LIBRARIES "")
string(REGEX MATCHALL "-l[^ ]*" MYSQL_LIB_LIST "${MY_TMP}")
foreach(LIB ${MYSQL_LIB_LIST})
string(REGEX REPLACE "[ ]*-l([^ ]*)" "\\1" LIB "${LIB}")
list(APPEND MYSQL_ADD_LIBRARIES "${LIB}")
#message("[DEBUG] MYSQL ADD_LIBRARIES : ${MYSQL_ADD_LIBRARIES}")
endforeach(LIB ${MYSQL_LIB_LIST})
set(MYSQL_ADD_LIBRARIES_PATH "")
string(REGEX MATCHALL "-L[^ ]*" MYSQL_LIBDIR_LIST "${MY_TMP}")
foreach(LIB ${MYSQL_LIBDIR_LIST})
string(REGEX REPLACE "[ ]*-L([^ ]*)" "\\1" LIB "${LIB}")
list(APPEND MYSQL_ADD_LIBRARIES_PATH "${LIB}")
#message("[DEBUG] MYSQL ADD_LIBRARIES_PATH : ${MYSQL_ADD_LIBRARIES_PATH}")
endforeach(LIB ${MYSQL_LIBS})
else( MYSQL_CONFIG )
set(MYSQL_ADD_LIBRARIES "")
list(APPEND MYSQL_ADD_LIBRARIES "mysqlclient_r")
endif( MYSQL_CONFIG )
endif( UNIX )
find_path(MYSQL_INCLUDE_DIR
NAMES
mysql.h
PATHS
${MYSQL_ADD_INCLUDE_PATH}
/usr/include
/usr/include/mysql
/usr/local/include
/usr/local/include/mysql
/usr/local/mysql/include
"C:/Program Files/MySQL/include"
"C:/Program Files/MySQL/MySQL Server 5.0/include"
"C:/Program Files/MySQL/MySQL Server 5.1/include"
"C:/MySQL/include"
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\MySQL AB\\MySQL Server 5.0;Location]/include"
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\MySQL AB\\MySQL Server 5.1;Location]/include"
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\MySQL AB\\MySQL Server 5.0;Location]/include"
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\MySQL AB\\MySQL Server 5.1;Location]/include"
"c:/msys/local/include"
DOC
"Specify the directory containing mysql.h."
)
if( UNIX )
foreach(LIB ${MYSQL_ADD_LIBRARIES})
find_library( MYSQL_LIBRARY
NAMES
mysql libmysql ${LIB}
PATHS
${MYSQL_ADD_LIBRARIES_PATH}
/usr/lib
/usr/lib/mysql
/usr/local/lib
/usr/local/lib/mysql
/usr/local/mysql/lib
DOC "Specify the location of the mysql library here."
)
endforeach(LIB ${MYSQL_ADD_LIBRARY})
endif( UNIX )
if( WIN32 )
find_library( MYSQL_LIBRARY
NAMES
mysql libmysql ${LIB}
PATHS
${MYSQL_ADD_LIBRARIES_PATH}
"C:/Program Files/MySQL/lib"
"C:/Program Files/MySQL/MySQL Server 5.0/lib/opt"
"C:/Program Files/MySQL/MySQL Server 5.1/lib/opt"
"C:/MySQL/lib/debug"
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\MySQL AB\\MySQL Server 5.0;Location]/lib/opt"
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\MySQL AB\\MySQL Server 5.1;Location]/lib/opt"
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\MySQL AB\\MySQL Server 5.0;Location]/lib/opt"
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\MySQL AB\\MySQL Server 5.1;Location]/lib/opt"
"c:/msys/local/include"
DOC "Specify the location of the mysql library here."
)
endif( WIN32 )
# On Windows you typically don't need to include any extra libraries
# to build MYSQL stuff.
if( NOT WIN32 )
find_library( MYSQL_EXTRA_LIBRARIES
NAMES
z zlib
PATHS
/usr/lib
/usr/local/lib
DOC
"if more libraries are necessary to link in a MySQL client (typically zlib), specify them here."
)
else( NOT WIN32 )
set( MYSQL_EXTRA_LIBRARIES "" )
endif( NOT WIN32 )
if( MYSQL_LIBRARY )
if( MYSQL_INCLUDE_DIR )
set( MYSQL_FOUND 1 )
message(STATUS "Found MySQL library: ${MYSQL_LIBRARY}")
message(STATUS "Found MySQL headers: ${MYSQL_INCLUDE_DIR}")
else( MYSQL_INCLUDE_DIR )
message(FATAL_ERROR "Could not find MySQL headers! Please install the development-libraries and headers.")
endif( MYSQL_INCLUDE_DIR )
mark_as_advanced( MYSQL_FOUND MYSQL_LIBRARY MYSQL_EXTRA_LIBRARIES MYSQL_INCLUDE_DIR )
else( MYSQL_LIBRARY )
message(FATAL_ERROR "Could not find the MySQL libraries! Please install the development-libraries and headers.")
endif( MYSQL_LIBRARY )

View File

@@ -1,102 +0,0 @@
# - Find MySQL
# Find the MySQL includes and client library
# This module defines
# MYSQL_INCLUDE_DIR, where to find mysql.h
# MYSQL_LIBRARIES, the libraries needed to use MySQL.
# MYSQL_FOUND, If false, do not try to use MySQL.
#
# Copyright (c) 2006, Jaroslaw Staniek, <js@iidea.pl>
# Lot of adustmens by Michal Cihar <michal@cihar.com>
#
# vim: expandtab sw=4 ts=4 sts=4:
#
# Redistribution and use is allowed according to the terms of the BSD license.
MACRO(FIND_MYSQL)
if(UNIX)
set(MYSQL_CONFIG_PREFER_PATH "$ENV{MYSQL_HOME}/bin" CACHE FILEPATH
"preferred path to MySQL (mysql_config)")
find_program(MYSQL_CONFIG mysql_config
${MYSQL_CONFIG_PREFER_PATH}
/usr/local/mysql/bin/
/usr/local/bin/
/usr/bin/
)
if(MYSQL_CONFIG)
message(STATUS "Using mysql-config: ${MYSQL_CONFIG}")
# set INCLUDE_DIR
exec_program(${MYSQL_CONFIG}
ARGS --include
OUTPUT_VARIABLE MY_TMP)
string(REGEX REPLACE "-I([^ ]*)( .*)?" "\\1" MY_TMP "${MY_TMP}")
set(MYSQL_ADD_INCLUDE_DIR ${MY_TMP} CACHE FILEPATH INTERNAL)
# set LIBRARY_DIR
exec_program(${MYSQL_CONFIG}
ARGS --libs_r
OUTPUT_VARIABLE MY_TMP)
set(MYSQL_ADD_LIBRARIES "")
string(REGEX MATCHALL "-l[^ ]*" MYSQL_LIB_LIST "${MY_TMP}")
foreach(LIB ${MYSQL_LIB_LIST})
string(REGEX REPLACE "[ ]*-l([^ ]*)" "\\1" LIB "${LIB}")
list(APPEND MYSQL_ADD_LIBRARIES "${LIB}")
endforeach(LIB ${MYSQL_LIBS})
set(MYSQL_ADD_LIBRARY_PATH "")
string(REGEX MATCHALL "-L[^ ]*" MYSQL_LIBDIR_LIST "${MY_TMP}")
foreach(LIB ${MYSQL_LIBDIR_LIST})
string(REGEX REPLACE "[ ]*-L([^ ]*)" "\\1" LIB "${LIB}")
list(APPEND MYSQL_ADD_LIBRARY_PATH "${LIB}")
endforeach(LIB ${MYSQL_LIBS})
else(MYSQL_CONFIG)
set(MYSQL_ADD_LIBRARIES "")
list(APPEND MYSQL_ADD_LIBRARIES "mysqlclient")
endif(MYSQL_CONFIG)
else(UNIX)
set(MYSQL_ADD_INCLUDE_DIR "c:/msys/local/include" CACHE FILEPATH INTERNAL)
set(MYSQL_ADD_LIBRARY_PATH "c:/msys/local/lib" CACHE FILEPATH INTERNAL)
ENDIF(UNIX)
find_path(MYSQL_INCLUDE_DIR mysql.h
/usr/local/include
/usr/local/include/mysql
/usr/local/mysql/include
/usr/local/mysql/include/mysql
/usr/include
/usr/include/mysql
${MYSQL_ADD_INCLUDE_DIR}
)
set(TMP_MYSQL_LIBRARIES "")
foreach(LIB ${MYSQL_ADD_LIBRARIES})
find_library("MYSQL_LIBRARIES_${LIB}" NAMES ${LIB}
PATHS
${MYSQL_ADD_LIBRARY_PATH}
/usr/lib/mysql
/usr/local/lib
/usr/local/lib/mysql
/usr/local/mysql/lib
)
list(APPEND TMP_MYSQL_LIBRARIES "${MYSQL_LIBRARIES_${LIB}}")
endforeach(LIB ${MYSQL_ADD_LIBRARIES})
set(MYSQL_LIBRARIES ${TMP_MYSQL_LIBRARIES} CACHE FILEPATH INTERNAL)
if(MYSQL_INCLUDE_DIR AND MYSQL_LIBRARIES)
set(MYSQL_FOUND TRUE CACHE INTERNAL "MySQL found")
message(STATUS "Found MySQL: ${MYSQL_INCLUDE_DIR}, ${MYSQL_LIBRARIES}")
else(MYSQL_INCLUDE_DIR AND MYSQL_LIBRARIES)
set(MYSQL_FOUND FALSE CACHE INTERNAL "MySQL found")
message(STATUS "MySQL not found.")
endif(MYSQL_INCLUDE_DIR AND MYSQL_LIBRARIES)
mark_as_advanced(MYSQL_INCLUDE_DIR MYSQL_LIBRARIES)
ENDMACRO(FIND_MYSQL)

92
cmake/FindOpenSSL.cmake Normal file
View File

@@ -0,0 +1,92 @@
#
# Find the OpenSSL client includes and library
#
# This module defines
# OPENSSL_INCLUDE_DIR, where to find openssl.h
# OPENSSL_LIBRARIES, the libraries to link against to connect to MySQL
# OPENSSL_FOUND, if false, you cannot build anything that requires MySQL.
# also defined, but not for general use are
# OPENSSL_LIBRARY, where to find the MySQL library.
if( OPENSSL_INCLUDE_DIR AND OPENSSL_LIBRARIES )
# in cache already
set(OPENSSL_FOUND 1)
else( OPENSSL_INCLUDE_DIR AND OPENSSL_LIBRARIES )
set(OPENSSL_FOUND 0)
if(WIN32)
if(PLATFORM MATCHES X64)
set(TMP_OPENSSL_INCLUDE_DIR
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (64-bit)_is1;InstallLocation]/include/openssl"
)
set(TMP_OPENSSL_LIBRARIES
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (64-bit)_is1;InstallLocation]/lib"
)
else()
set(TMP_OPENSSL_INCLUDE_DIR
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (32-bit)_is1;InstallLocation]/include/openssl"
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (32-bit)_is1;InstallLocation]/include/openssl"
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (32-bit)_is1;InstallLocation]/include/openssl"
)
set(TMP_OPENSSL_LIBRARIES
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (32-bit)_is1;InstallLocation]/lib"
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (32-bit)_is1;InstallLocation]/lib"
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (32-bit)_is1;InstallLocation]/lib"
)
endif()
endif()
find_path(OPENSSL_INCLUDE_DIR
NAMES
ssl.h
PATHS
/usr/include
/usr/include/openssl
/usr/local/include
/usr/local/include/openssl
/usr/local/openssl/include
${TMP_OPENSSL_INCLUDE_DIR}
DOC
"Specify the directory containing openssl.h."
)
find_library(OPENSSL_LIBRARIES
NAMES
ssleay32
ssl
PATHS
/usr/lib
/usr/lib/ssl
/usr/local/lib
/usr/local/lib/ssl
/usr/local/ssl/lib
${TMP_OPENSSL_LIBRARIES}
DOC "Specify the OpenSSL library here."
)
if( WIN32 )
find_library(OPENSSL_EXTRA_LIBRARIES
NAMES
libeay32
PATHS
${TMP_OPENSSL_LIBRARIES}
DOC
"if more libraries are necessary to link in a OpenSSL client, specify them here."
)
endif( WIN32 )
if( OPENSSL_LIBRARIES )
if( OPENSSL_INCLUDE_DIR )
set( OPENSSL_FOUND 1 )
message(STATUS "Found OpenSSL library: ${OPENSSL_LIBRARIES}")
message(STATUS "Found OpenSSL headers: ${OPENSSL_INCLUDE_DIR}")
else ( OPENSSL_INCLUDE_DIR )
message(FATAL_ERROR "Could not find OpenSSL headers! Please install the development-headers")
endif( OPENSSL_INCLUDE_DIR )
else( OPENSSL_LIBRARIES )
message(FATAL_ERROR "Could not find OpenSSL libraries! Please install the library before continuing")
endif( OPENSSL_LIBRARIES )
mark_as_advanced( OPENSSL_FOUND OPENSSL_LIBRARIES OPENSSL_EXTRA_LIBRARIES OPENSSL_INCLUDE_DIR )
endif( OPENSSL_INCLUDE_DIR AND OPENSSL_LIBRARIES )

View File

@@ -1,7 +1,4 @@
#
# This file is for CMake 2.6
#
# - Try to find precompiled headers support for GCC 3.4 and 4.x
# - Try to find precompiled headers support for GCC 3.4 and 4.x (and MSVC)
# Once done this will define:
#
# Variable:
@@ -16,107 +13,116 @@
IF(CMAKE_COMPILER_IS_GNUCXX)
EXEC_PROGRAM(
${CMAKE_CXX_COMPILER}
ARGS ${CMAKE_CXX_COMPILER_ARG1} -dumpversion
OUTPUT_VARIABLE gcc_compiler_version)
${CMAKE_CXX_COMPILER}
ARGS ${CMAKE_CXX_COMPILER_ARG1} -dumpversion
OUTPUT_VARIABLE gcc_compiler_version
)
#MESSAGE("GCC Version: ${gcc_compiler_version}")
IF(gcc_compiler_version MATCHES "4\\.[0-9]\\.[0-9]")
SET(PCHSupport_FOUND TRUE)
ELSE(gcc_compiler_version MATCHES "4\\.[0-9]\\.[0-9]")
IF(gcc_compiler_version MATCHES "3\\.4\\.[0-9]")
SET(PCHSupport_FOUND TRUE)
ENDIF(gcc_compiler_version MATCHES "3\\.4\\.[0-9]")
ENDIF(gcc_compiler_version MATCHES "4\\.[0-9]\\.[0-9]")
SET(_PCH_include_prefix "-I")
ELSE(CMAKE_COMPILER_IS_GNUCXX)
IF(WIN32)
SET(PCHSupport_FOUND TRUE) # for experimental msvc support
SET(_PCH_include_prefix "/I")
ELSE(WIN32)
SET(PCHSupport_FOUND FALSE)
ENDIF(WIN32)
ENDIF(CMAKE_COMPILER_IS_GNUCXX)
MACRO(_PCH_GET_COMPILE_FLAGS _out_compile_flags)
STRING(TOUPPER "CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}" _flags_var_name)
SET(return_value ${${_flags_var_name}} )
SET(${_out_compile_flags} ${${_flags_var_name}} )
IF(CMAKE_COMPILER_IS_GNUCXX)
GET_TARGET_PROPERTY(_targetType ${_PCH_current_target} TYPE)
IF(${_targetType} STREQUAL SHARED_LIBRARY)
LIST(APPEND return_value "${return_value} -fPIC")
ENDIF(${_targetType} STREQUAL SHARED_LIBRARY)
IF(${_targetType} STREQUAL SHARED_LIBRARY AND NOT WIN32)
LIST(APPEND ${_out_compile_flags} "${${_out_compile_flags}} -fPIC")
ENDIF()
ELSE(CMAKE_COMPILER_IS_GNUCXX)
## TODO ... ? or does it work out of the box
ENDIF(CMAKE_COMPILER_IS_GNUCXX)
GET_DIRECTORY_PROPERTY(DIRINC INCLUDE_DIRECTORIES )
FOREACH(item ${DIRINC})
LIST(APPEND return_value "${_PCH_include_prefix}${item}")
LIST(APPEND ${_out_compile_flags} "${_PCH_include_prefix}${item}")
ENDFOREACH(item)
SET(_build_type "${CMAKE_BUILD_TYPE}")
#MESSAGE(STATUS "build type: `${CMAKE_BUILD_TYPE}'")
IF (NOT _build_type)
SET(_build_type "Debug")
ENDIF (NOT _build_type)
string(TOUPPER ${_build_type} _build_type)
SET(_def_name "COMPILE_DEFINITIONS_${_build_type}")
GET_DIRECTORY_PROPERTY(_directory_flags ${_def_name})
FOREACH(item ${_directory_flags})
LIST(APPEND return_value "-D${item}")
ENDFOREACH(item)
GET_DIRECTORY_PROPERTY(_directory_flags COMPILE_DEFINITIONS)
LIST(APPEND ${_out_compile_flags} ${return_value})
FOREACH(_def ${_directory_flags})
LIST(APPEND ${_out_compile_flags} "-D${_def}")
ENDFOREACH(_def)
GET_DIRECTORY_PROPERTY(_directory_flags DEFINITIONS)
GET_DIRECTORY_PROPERTY(_global_definitions DIRECTORY ${CMAKE_SOURCE_DIR} DEFINITIONS)
#MESSAGE("_directory_flags ${_directory_flags} ${_global_definitions}" )
LIST(APPEND ${_out_compile_flags} ${_directory_flags})
LIST(APPEND ${_out_compile_flags} ${_global_definitions})
LIST(APPEND ${_out_compile_flags} ${CMAKE_CXX_FLAGS} )
SEPARATE_ARGUMENTS(${_out_compile_flags})
ENDMACRO(_PCH_GET_COMPILE_FLAGS)
#
#
#
SEPARATE_ARGUMENTS(${_out_compile_flags})
ENDMACRO(_PCH_GET_COMPILE_FLAGS)
MACRO(_PCH_WRITE_PCHDEP_CXX _targetName _include_file _dephelp)
SET(${_dephelp} ${CMAKE_CURRENT_BINARY_DIR}/${_targetName}_pch_dephelp.cxx)
FILE(WRITE ${${_dephelp}}
"#include \"${_include_file}\"
"#include \"${_include_file}\"
int testfunction()
{
return 0;
}
"
)
)
ENDMACRO(_PCH_WRITE_PCHDEP_CXX )
#
#
#
MACRO(_PCH_GET_COMPILE_COMMAND out_command _input _output)
FILE(TO_NATIVE_PATH ${_input} _native_input)
FILE(TO_NATIVE_PATH ${_output} _native_output)
FILE(TO_NATIVE_PATH ${_input} _native_input)
FILE(TO_NATIVE_PATH ${_output} _native_output)
IF(CMAKE_COMPILER_IS_GNUCXX)
IF(CMAKE_CXX_COMPILER_ARG1)
# remove leading space in compiler argument
STRING(REGEX REPLACE "^ +" "" pchsupport_compiler_cxx_arg1 ${CMAKE_CXX_COMPILER_ARG1})
SET(${out_command}
${CMAKE_CXX_COMPILER} ${pchsupport_compiler_cxx_arg1} ${_compile_FLAGS} -x c++-header -o ${_output} ${_input}
)
ELSE(CMAKE_CXX_COMPILER_ARG1)
SET(${out_command}
${CMAKE_CXX_COMPILER} ${_compile_FLAGS} -x c++-header -o ${_output} ${_input}
)
ENDIF(CMAKE_CXX_COMPILER_ARG1)
ELSE(CMAKE_COMPILER_IS_GNUCXX)
SET(_dummy_str "#include <${_input}>")
FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/pch_dummy.cpp ${_dummy_str})
SET(${out_command}
${CMAKE_CXX_COMPILER} ${_compile_FLAGS} /c /Fp${_native_output} /Yc${_native_input} pch_dummy.cpp
)
#/out:${_output}
ENDIF(CMAKE_COMPILER_IS_GNUCXX)
IF(CMAKE_COMPILER_IS_GNUCXX)
SET(${out_command}
${CMAKE_CXX_COMPILER} ${_compile_FLAGS} -x c++-header -o ${_output} ${_input}
)
ENDIF(CMAKE_COMPILER_IS_GNUCXX)
ENDMACRO(_PCH_GET_COMPILE_COMMAND )
#
#
#
MACRO(_PCH_GET_TARGET_COMPILE_FLAGS _cflags _header_name _pch_path _dowarn )
FILE(TO_NATIVE_PATH ${_pch_path} _native_pch_path)
IF(CMAKE_COMPILER_IS_GNUCXX)
# for use with distcc and gcc >4.0.1 if preprocessed files are accessible
# on all remote machines set
@@ -130,22 +136,22 @@ MACRO(_PCH_GET_TARGET_COMPILE_FLAGS _cflags _header_name _pch_path _dowarn )
SET(${_cflags} "${PCH_ADDITIONAL_COMPILER_FLAGS} -include ${CMAKE_CURRENT_BINARY_DIR}/${_header_name} " )
ENDIF (_dowarn)
ELSE(CMAKE_COMPILER_IS_GNUCXX)
set(${_cflags} "/Fp${_native_pch_path} /Yu${_header_name}" )
ENDIF(CMAKE_COMPILER_IS_GNUCXX)
set(${_cflags} "/Fp${_native_pch_path} /Yu${_header_name}" )
ENDIF(CMAKE_COMPILER_IS_GNUCXX)
ENDMACRO(_PCH_GET_TARGET_COMPILE_FLAGS )
MACRO(GET_PRECOMPILED_HEADER_OUTPUT _targetName _input _output)
GET_FILENAME_COMPONENT(_name ${_input} NAME)
GET_FILENAME_COMPONENT(_path ${_input} PATH)
SET(_output "${CMAKE_CURRENT_BINARY_DIR}/${_name}.gch/${_targetName}_${CMAKE_BUILD_TYPE}.h++")
SET(_output "${CMAKE_CURRENT_BINARY_DIR}/${_name}.gch/${_targetName}_${CMAKE_BUILD_TYPE}.gch")
ENDMACRO(GET_PRECOMPILED_HEADER_OUTPUT _targetName _input)
MACRO(ADD_PRECOMPILED_HEADER_TO_TARGET _targetName _input _pch_output_to_use )
# to do: test whether compiler flags match between target _targetName
# and _pch_output_to_use
GET_FILENAME_COMPONENT(_name ${_input} NAME)
@@ -159,26 +165,26 @@ MACRO(ADD_PRECOMPILED_HEADER_TO_TARGET _targetName _input _pch_output_to_use )
_PCH_GET_TARGET_COMPILE_FLAGS(_target_cflags ${_name} ${_pch_output_to_use} ${_dowarn})
# MESSAGE("Add flags ${_target_cflags} to ${_targetName} " )
SET_TARGET_PROPERTIES(${_targetName}
PROPERTIES
COMPILE_FLAGS ${_target_cflags}
)
SET_TARGET_PROPERTIES(${_targetName}
PROPERTIES
COMPILE_FLAGS ${_target_cflags}
)
ADD_CUSTOM_TARGET(pch_Generate_${_targetName}
DEPENDS ${_pch_output_to_use}
)
DEPENDS ${_pch_output_to_use}
)
ADD_DEPENDENCIES(${_targetName} pch_Generate_${_targetName} )
ENDMACRO(ADD_PRECOMPILED_HEADER_TO_TARGET)
MACRO(ADD_PRECOMPILED_HEADER _targetName _input)
SET(_PCH_current_target ${_targetName})
IF(NOT CMAKE_BUILD_TYPE)
MESSAGE(FATAL_ERROR
"This is the ADD_PRECOMPILED_HEADER macro. "
MESSAGE(FATAL_ERROR
"This is the ADD_PRECOMPILED_HEADER macro. "
"You must set CMAKE_BUILD_TYPE!"
)
ENDIF(NOT CMAKE_BUILD_TYPE)
@@ -189,7 +195,6 @@ MACRO(ADD_PRECOMPILED_HEADER _targetName _input)
SET(_dowarn 1)
ENDIF("${ARGN}" STREQUAL "0")
GET_FILENAME_COMPONENT(_name ${_input} NAME)
GET_FILENAME_COMPONENT(_path ${_input} PATH)
GET_PRECOMPILED_HEADER_OUTPUT( ${_targetName} ${_input} _output)
@@ -200,42 +205,39 @@ MACRO(ADD_PRECOMPILED_HEADER _targetName _input)
_PCH_WRITE_PCHDEP_CXX(${_targetName} ${_input} _pch_dephelp_cxx)
IF(${_targetType} STREQUAL SHARED_LIBRARY)
ADD_LIBRARY(${_targetName}_pch_dephelp SHARED ${_pch_dephelp_cxx} )
ADD_LIBRARY(${_targetName}_pch_dephelp STATIC ${_pch_dephelp_cxx} )
ELSE(${_targetType} STREQUAL SHARED_LIBRARY)
ADD_LIBRARY(${_targetName}_pch_dephelp STATIC ${_pch_dephelp_cxx})
ENDIF(${_targetType} STREQUAL SHARED_LIBRARY)
FILE(MAKE_DIRECTORY ${_outdir})
_PCH_GET_COMPILE_FLAGS(_compile_FLAGS)
#MESSAGE("_compile_FLAGS: ${_compile_FLAGS}")
#message("COMMAND ${CMAKE_CXX_COMPILER} ${_compile_FLAGS} -x c++-header -o ${_output} ${_input}")
#message("COMMAND ${CMAKE_CXX_COMPILER} ${_compile_FLAGS} -x c++-header -o ${_output} ${_input}")
SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_BINARY_DIR}/${_name} PROPERTIES GENERATED 1)
ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_name}
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_name}
COMMAND ${CMAKE_COMMAND} -E copy ${_input} ${CMAKE_CURRENT_BINARY_DIR}/${_name} # ensure same directory! Required by gcc
DEPENDS ${_input}
)
#message("_command ${_input} ${_output}")
_PCH_GET_COMPILE_COMMAND(_command ${CMAKE_CURRENT_BINARY_DIR}/${_name} ${_output} )
#message("${_command}")
#message(${_input} )
#message("_output ${_output}")
ADD_CUSTOM_COMMAND(
OUTPUT ${_output}
OUTPUT ${_output}
COMMAND ${_command}
DEPENDS ${_input} ${CMAKE_CURRENT_BINARY_DIR}/${_name} ${_targetName}_pch_dephelp
)
)
ADD_PRECOMPILED_HEADER_TO_TARGET(${_targetName} ${_input} ${_output} ${_dowarn})
ENDMACRO(ADD_PRECOMPILED_HEADER)
# Generates the use of precompiled in a target,
# without using depency targets (2 extra for each target)
# Using Visual, must also add ${_targetName}_pch to sources
@@ -243,73 +245,71 @@ ENDMACRO(ADD_PRECOMPILED_HEADER)
MACRO(GET_NATIVE_PRECOMPILED_HEADER _targetName _input)
if(CMAKE_GENERATOR MATCHES Visual*)
if(CMAKE_GENERATOR MATCHES Visual*)
SET(_dummy_str "#include \"${_input}\"\n"
"// This is required to suppress LNK4221. Very annoying.\n"
"void *g_${_targetName}Dummy = 0\;\n")
SET(_dummy_str "#include \"${_input}\"\n"
"// This is required to suppress LNK4221. Very annoying.\n"
"void *g_${_targetName}Dummy = 0\;\n")
# Use of cxx extension for generated files (as Qt does)
SET(${_targetName}_pch ${CMAKE_CURRENT_BINARY_DIR}/${_targetName}_pch.cxx)
if(EXISTS ${${_targetName}_pch})
# Check if contents is the same, if not rewrite
# todo
else(EXISTS ${${_targetName}_pch})
FILE(WRITE ${${_targetName}_pch} ${_dummy_str})
endif(EXISTS ${${_targetName}_pch})
endif(CMAKE_GENERATOR MATCHES Visual*)
# Use of cxx extension for generated files (as Qt does)
SET(${_targetName}_pch ${CMAKE_CURRENT_BINARY_DIR}/${_targetName}_pch.cxx)
if(EXISTS ${${_targetName}_pch})
# Check if contents is the same, if not rewrite
# todo
else(EXISTS ${${_targetName}_pch})
FILE(WRITE ${${_targetName}_pch} ${_dummy_str})
endif(EXISTS ${${_targetName}_pch})
endif(CMAKE_GENERATOR MATCHES Visual*)
ENDMACRO(GET_NATIVE_PRECOMPILED_HEADER)
MACRO(ADD_NATIVE_PRECOMPILED_HEADER _targetName _input)
IF( "${ARGN}" STREQUAL "0")
SET(_dowarn 0)
ELSE( "${ARGN}" STREQUAL "0")
SET(_dowarn 1)
ENDIF("${ARGN}" STREQUAL "0")
if(CMAKE_GENERATOR MATCHES Visual*)
# Auto include the precompile (useful for moc processing, since the use of
# precompiled is specified at the target level
# and I don't want to specifiy /F- for each moc/res/ui generated files (using Qt)
IF( "${ARGN}" STREQUAL "0")
SET(_dowarn 0)
ELSE( "${ARGN}" STREQUAL "0")
SET(_dowarn 1)
ENDIF("${ARGN}" STREQUAL "0")
GET_TARGET_PROPERTY(oldProps ${_targetName} COMPILE_FLAGS)
if (${oldProps} MATCHES NOTFOUND)
SET(oldProps "")
endif(${oldProps} MATCHES NOTFOUND)
if(CMAKE_GENERATOR MATCHES Visual*)
# Auto include the precompile (useful for moc processing, since the use of
# precompiled is specified at the target level
# and I don't want to specifiy /F- for each moc/res/ui generated files (using Qt)
SET(newProperties "${oldProps} /Yu\"${_input}\" /FI\"${_input}\"")
SET_TARGET_PROPERTIES(${_targetName} PROPERTIES COMPILE_FLAGS "${newProperties}")
#also inlude ${oldProps} to have the same compile options
SET_SOURCE_FILES_PROPERTIES(${${_targetName}_pch} PROPERTIES COMPILE_FLAGS "${oldProps} /Yc\"${_input}\"")
else(CMAKE_GENERATOR MATCHES Visual*)
if (CMAKE_GENERATOR MATCHES Xcode)
# For Xcode, cmake needs my patch to process
# GCC_PREFIX_HEADER and GCC_PRECOMPILE_PREFIX_HEADER as target properties
GET_TARGET_PROPERTY(oldProps ${_targetName} COMPILE_FLAGS)
if (${oldProps} MATCHES NOTFOUND)
SET(oldProps "")
endif(${oldProps} MATCHES NOTFOUND)
GET_TARGET_PROPERTY(oldProps ${_targetName} COMPILE_FLAGS)
if (${oldProps} MATCHES NOTFOUND)
SET(oldProps "")
endif(${oldProps} MATCHES NOTFOUND)
# When buiding out of the tree, precompiled may not be located
# Use full path instead.
GET_FILENAME_COMPONENT(fullPath ${_input} ABSOLUTE)
SET(newProperties "${oldProps} /Yu\"${_input}.h\" /FI\"${_input}.h\"")
SET_TARGET_PROPERTIES(${_targetName} PROPERTIES COMPILE_FLAGS "${newProperties}")
SET_TARGET_PROPERTIES(${_targetName} PROPERTIES XCODE_ATTRIBUTE_GCC_PREFIX_HEADER "${fullPath}")
SET_TARGET_PROPERTIES(${_targetName} PROPERTIES XCODE_ATTRIBUTE_GCC_PRECOMPILE_PREFIX_HEADER "YES")
#also inlude ${oldProps} to have the same compile options
SET_SOURCE_FILES_PROPERTIES(${_input}.cpp PROPERTIES COMPILE_FLAGS "${oldProps} /Yc\"${_input}.h\"")
else (CMAKE_GENERATOR MATCHES Xcode)
else(CMAKE_GENERATOR MATCHES Visual*)
#Fallback to the "old" precompiled suppport
#ADD_PRECOMPILED_HEADER(${_targetName} ${_input} ${_dowarn})
endif(CMAKE_GENERATOR MATCHES Xcode)
endif(CMAKE_GENERATOR MATCHES Visual*)
if (CMAKE_GENERATOR MATCHES Xcode)
# For Xcode, cmake needs my patch to process
# GCC_PREFIX_HEADER and GCC_PRECOMPILE_PREFIX_HEADER as target properties
ENDMACRO(ADD_NATIVE_PRECOMPILED_HEADER)
GET_TARGET_PROPERTY(oldProps ${_targetName} COMPILE_FLAGS)
if (${oldProps} MATCHES NOTFOUND)
SET(oldProps "")
endif(${oldProps} MATCHES NOTFOUND)
# When buiding out of the tree, precompiled may not be located
# Use full path instead.
GET_FILENAME_COMPONENT(fullPath ${_input} ABSOLUTE)
SET_TARGET_PROPERTIES(${_targetName} PROPERTIES XCODE_ATTRIBUTE_GCC_PREFIX_HEADER "${fullPath}")
SET_TARGET_PROPERTIES(${_targetName} PROPERTIES XCODE_ATTRIBUTE_GCC_PRECOMPILE_PREFIX_HEADER "YES")
else (CMAKE_GENERATOR MATCHES Xcode)
#Fallback to the "old" precompiled suppport
#ADD_PRECOMPILED_HEADER(${_targetName} ${_input} ${_dowarn})
endif(CMAKE_GENERATOR MATCHES Xcode)
endif(CMAKE_GENERATOR MATCHES Visual*)
ENDMACRO(ADD_NATIVE_PRECOMPILED_HEADER)

16
cmake/FindPlatform.cmake Normal file
View File

@@ -0,0 +1,16 @@
# default to x86 platform. We'll check for X64 in a bit
SET(PLATFORM X86)
# This definition is necessary to work around a bug with Intellisense described
# here: http://tinyurl.com/2cb428. Syntax highlighting is important for proper
# debugger functionality.
IF(CMAKE_SIZEOF_VOID_P MATCHES 8)
MESSAGE(STATUS "Detected 64-bit platform.")
if(WIN32)
ADD_DEFINITIONS("-D_WIN64")
ENDIF()
SET (PLATFORM X64)
ELSE()
MESSAGE(STATUS "Detected 32-bit platform.")
ENDIF()

View File

@@ -1,6 +0,0 @@
#if(BUILD_ACE)
#add_subdirectory(ACE_wrappers)
#endif(BUILD_ACE)
#add_subdirectory(include)
#add_subdirectory(lib)
add_subdirectory(src)

View File

@@ -1,12 +0,0 @@
// -*- C++ -*-
//
// $Id: Cleanup.inl 80826 2008-03-04 14:51:23Z wotte $
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_INLINE
ACE_Cleanup::ACE_Cleanup (void)
{
}
ACE_END_VERSIONED_NAMESPACE_DECL

View File

@@ -1,227 +0,0 @@
// -*- C++ -*-
//
// $Id: Dev_Poll_Reactor.inl 80826 2008-03-04 14:51:23Z wotte $
#include "ace/Log_Msg.h"
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_INLINE
ACE_Dev_Poll_Event_Tuple::ACE_Dev_Poll_Event_Tuple (void)
: event_handler (0),
mask (ACE_Event_Handler::NULL_MASK),
suspended (0)
{
}
// ---------------------------------------------------------------------
#if 0
ACE_INLINE
ACE_Dev_Poll_Ready_Set::ACE_Dev_Poll_Ready_Set (void)
: pfds (0),
nfds (0)
{
}
#endif /* 0 */
// ---------------------------------------------------------------------
ACE_INLINE void
ACE_Dev_Poll_Reactor_Handler_Repository::mask (ACE_HANDLE handle,
ACE_Reactor_Mask mask)
{
ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::mask");
// Only bother to search for the handle if it's in range.
if (this->handle_in_range (handle))
this->handlers_[handle].mask = mask;
}
ACE_INLINE ACE_Reactor_Mask
ACE_Dev_Poll_Reactor_Handler_Repository::mask (ACE_HANDLE handle)
{
ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::mask");
ACE_Reactor_Mask mask = ACE_Event_Handler::NULL_MASK;
// Only bother to search for the handle if it's in range.
if (this->handle_in_range (handle))
mask = this->handlers_[handle].mask;
if (mask == ACE_Event_Handler::NULL_MASK)
errno = ENOENT;
return mask;
}
ACE_INLINE void
ACE_Dev_Poll_Reactor_Handler_Repository::suspend (ACE_HANDLE handle)
{
ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::suspend");
// Only bother to search for the handle if it's in range.
if (this->handle_in_range (handle))
this->handlers_[handle].suspended = 1;
}
ACE_INLINE void
ACE_Dev_Poll_Reactor_Handler_Repository::resume (ACE_HANDLE handle)
{
ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::resume");
// Only bother to search for the handle if it's in range.
if (this->handle_in_range (handle))
this->handlers_[handle].suspended = 0;
}
ACE_INLINE int
ACE_Dev_Poll_Reactor_Handler_Repository::suspended (ACE_HANDLE handle) const
{
ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::suspended");
if (this->handle_in_range (handle))
return this->handlers_[handle].suspended;
return -1;
}
ACE_INLINE size_t
ACE_Dev_Poll_Reactor_Handler_Repository::size (void) const
{
ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::size");
return this->max_size_;
}
// -----------------------------------------------------------------
ACE_INLINE
ACE_Dev_Poll_Handler_Guard::ACE_Dev_Poll_Handler_Guard
(ACE_Event_Handler *eh,
bool do_incr)
: eh_ (eh),
refcounted_ (false)
{
if (eh == 0)
return;
this->refcounted_ =
eh->reference_counting_policy ().value () ==
ACE_Event_Handler::Reference_Counting_Policy::ENABLED;
if (do_incr && this->refcounted_)
eh->add_reference ();
/**
* The below comments were here when I replaced the old refcount
* scheme was replaced. They may still need addressing. -Steve Huston
*/
/**
* @todo Suspend the handler so that other threads will not cause
* an event that is already in an upcall from being dispatched
* again.
*
* @note The naive approach would be to simply call
* suspend_handler_i() on the reactor. However, that would
* cause a system call (write()) to occur. Obviously this
* can potentially have an adverse affect on performance.
* Ideally, the handler would only be marked as "suspended" in
* the handler repository. If an event arrives for a
* suspended handler that event can be "queued" in a
* "handle readiness queue." "Queued" is quoted since a real
* queue need not be used since duplicate events can be
* coalesced, thus avoiding unbounded queue growth. Event
* coalescing is already done by Linux's event poll driver
* (/dev/epoll) so Solaris' poll driver (/dev/poll) is the
* main concern here. The largest the queue can be is the
* same size as the number of handlers stored in the handler
* repository.
*/
}
ACE_INLINE
ACE_Dev_Poll_Handler_Guard::~ACE_Dev_Poll_Handler_Guard (void)
{
if (this->refcounted_ && this->eh_ != 0)
this->eh_->remove_reference ();
/**
* The below comments were here when I replaced the old refcount
* scheme was replaced. They may still need addressing. -Steve Huston
*/
/**
* @todo Resume the handler so that other threads will be allowed to
* dispatch the handler.
*/
}
ACE_INLINE void
ACE_Dev_Poll_Handler_Guard::release (void)
{
this->eh_ = 0;
}
// ---------------------------------------------------------------------
ACE_INLINE int
ACE_Dev_Poll_Reactor::upcall (ACE_Event_Handler *event_handler,
int (ACE_Event_Handler::*callback)(ACE_HANDLE),
ACE_HANDLE handle)
{
// If the handler returns positive value (requesting a reactor
// callback) just call back as many times as the handler requests
// it. Other threads are off handling other things.
int status = 0;
do
{
status = (event_handler->*callback) (handle);
}
while (status > 0);
return status;
}
/************************************************************************/
// Methods for ACE_Dev_Poll_Reactor::Token_Guard
/************************************************************************/
ACE_INLINE
ACE_Dev_Poll_Reactor::Token_Guard::Token_Guard (ACE_Dev_Poll_Reactor_Token &token)
: token_ (token),
owner_ (0)
{
}
ACE_INLINE
ACE_Dev_Poll_Reactor::Token_Guard::~Token_Guard (void)
{
if (this->owner_ == 1)
{
ACE_MT (this->token_.release ());
this->owner_ = 0;
}
}
ACE_INLINE void
ACE_Dev_Poll_Reactor::Token_Guard::release_token (void)
{
if (this->owner_)
{
ACE_MT (this->token_.release ());
// We are not the owner anymore..
this->owner_ = 0;
}
}
ACE_INLINE int
ACE_Dev_Poll_Reactor::Token_Guard::is_owner (void)
{
return this->owner_;
}
ACE_END_VERSIONED_NAMESPACE_DECL

View File

@@ -1,12 +0,0 @@
// -*- C++ -*-
//
// $Id: OS_Log_Msg_Attributes.inl 80826 2008-03-04 14:51:23Z wotte $
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_INLINE
ACE_OS_Log_Msg_Attributes::ACE_OS_Log_Msg_Attributes (void)
{
}
ACE_END_VERSIONED_NAMESPACE_DECL

View File

@@ -1,41 +0,0 @@
// -*- C++ -*-
//
// $Id: OS_NS_math.inl 80826 2008-03-04 14:51:23Z wotte $
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
namespace ACE_OS {
ACE_INLINE double
floor (double x)
{
// This method computes the largest integral value not greater than x.
if(x > 0)
return static_cast<long> (x);
else if (static_cast<long> (x) == x)
return x;
else
return static_cast<long>(x) - 1;
}
ACE_INLINE double
ceil (double x)
{
// This method computes the smallest integral value not less than x.
if (x < 0)
return static_cast<long> (x);
else if (static_cast<long> (x) == x)
return x;
else
return static_cast<long> (x) + 1;
}
ACE_INLINE double
log2 (double x)
{
return ace_log2_helper (x);
}
} // ACE_OS namespace
ACE_END_VERSIONED_NAMESPACE_DECL

View File

@@ -1,19 +0,0 @@
// -*- C++ -*-
//
// $Id: Obstack_T.inl 80826 2008-03-04 14:51:23Z wotte $
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
template <class CHAR> ACE_INLINE size_t
ACE_Obstack_T<CHAR>::length () const
{
return this->size_ / sizeof (CHAR);
}
template <class CHAR> ACE_INLINE size_t
ACE_Obstack_T<CHAR>::size () const
{
return this->size_;
}
ACE_END_VERSIONED_NAMESPACE_DECL

View File

@@ -1,15 +0,0 @@
// -*- C++ -*-
//
// $Id: SPIPE_Connector.inl 80826 2008-03-04 14:51:23Z wotte $
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_INLINE int
ACE_SPIPE_Connector::reset_new_handle (ACE_HANDLE handle)
{
ACE_UNUSED_ARG (handle);
// Nothing to do here since the handle is not a socket
return 0;
}
ACE_END_VERSIONED_NAMESPACE_DECL

View File

@@ -1,158 +0,0 @@
// -*- C++ -*-
//
// $Id: String_Base.inl 80826 2008-03-04 14:51:23Z wotte $
#include "ace/Malloc_Base.h"
#include "ace/Min_Max.h"
#include "ace/OS_NS_string.h"
#include "ace/OS_Memory.h"
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
template <class CHAR> ACE_INLINE void
ACE_String_Base<CHAR>::dump (void) const
{
#if defined (ACE_HAS_DUMP)
ACE_TRACE ("ACE_String_Base<CHAR>::dump");
#endif /* ACE_HAS_DUMP */
}
// Assignment method (does not copy memory)
template <class CHAR> ACE_INLINE ACE_String_Base<CHAR> &
ACE_String_Base<CHAR>::assign_nocopy (const ACE_String_Base<CHAR> &s)
{
ACE_TRACE ("ACE_String_Base<CHAR>::assign_nocopy");
this->set (s.rep_, s.len_, false);
return *this;
}
template <class CHAR> ACE_INLINE typename ACE_String_Base<CHAR>::size_type
ACE_String_Base<CHAR>::length (void) const
{
ACE_TRACE ("ACE_String_Base<CHAR>::length");
return this->len_;
}
template <class CHAR> ACE_INLINE size_t
ACE_String_Base<CHAR>::capacity (void) const
{
ACE_TRACE ("ACE_String_Base<CHAR>::capacity");
return this->buf_len_;
}
template <class CHAR> ACE_INLINE bool
ACE_String_Base<CHAR>::is_empty (void) const
{
return this->len_ == 0;
}
template <class CHAR> ACE_INLINE bool
ACE_String_Base<CHAR>::empty (void) const
{
return this->is_empty ();
}
template <class CHAR> ACE_INLINE ACE_String_Base<CHAR>
ACE_String_Base<CHAR>::substr (
typename ACE_String_Base<CHAR>::size_type offset,
typename ACE_String_Base<CHAR>::size_type length) const
{
ACE_TRACE ("ACE_String_Base<CHAR>::substr");
return this->substring (offset, length);
}
// Return the <slot'th> character in the string.
template <class CHAR> ACE_INLINE const CHAR &
ACE_String_Base<CHAR>::operator[] (
typename ACE_String_Base<CHAR>::size_type slot) const
{
ACE_TRACE ("ACE_String_Base<CHAR>::operator[]");
return this->rep_[slot];
}
// Return the <slot'th> character in the string by reference.
template <class CHAR> ACE_INLINE CHAR &
ACE_String_Base<CHAR>::operator[] (
typename ACE_String_Base<CHAR>::size_type slot)
{
ACE_TRACE ("ACE_String_Base<CHAR>::operator[]");
return this->rep_[slot];
}
template <class CHAR> ACE_INLINE const CHAR *
ACE_String_Base<CHAR>::fast_rep (void) const
{
return this->rep_;
}
template <class CHAR> ACE_INLINE const CHAR *
ACE_String_Base<CHAR>::c_str (void) const
{
return this->rep_;
}
// Less than comparison operator.
template <class CHAR> ACE_INLINE bool
ACE_String_Base<CHAR>::operator < (const ACE_String_Base<CHAR> &s) const
{
ACE_TRACE ("ACE_String_Base<CHAR>::operator <");
return compare (s) < 0;
}
// Greater than comparison operator.
template <class CHAR> ACE_INLINE bool
ACE_String_Base<CHAR>::operator > (const ACE_String_Base &s) const
{
ACE_TRACE ("ACE_String_Base<CHAR>::operator >");
return compare (s) > 0;
}
// Comparison operator.
template <class CHAR> ACE_INLINE bool
ACE_String_Base<CHAR>::operator!= (const ACE_String_Base<CHAR> &s) const
{
ACE_TRACE ("ACE_String_Base<CHAR>::operator!=");
return !(*this == s);
}
template <class CHAR> ACE_INLINE bool
ACE_String_Base<CHAR>::operator!= (const CHAR *s) const
{
return !(*this == s);
}
template <class CHAR> ACE_INLINE typename ACE_String_Base<CHAR>::size_type
ACE_String_Base<CHAR>::find (const ACE_String_Base<CHAR>&str,
typename ACE_String_Base<CHAR>::size_type pos) const
{
ACE_TRACE ("ACE_String_Base<CHAR>::find");
return this->find (str.rep_, pos);
}
template <class CHAR> ACE_INLINE typename ACE_String_Base<CHAR>::size_type
ACE_String_Base<CHAR>::strstr (const ACE_String_Base<CHAR> &s) const
{
ACE_TRACE ("ACE_String_Base<CHAR>::strstr");
return this->find (s.rep_);
}
template <class CHAR> ACE_INLINE bool
operator== (const CHAR *s,
const ACE_String_Base<CHAR> &t)
{
return t == s;
}
template <class CHAR> ACE_INLINE bool
operator!= (const CHAR *s,
const ACE_String_Base<CHAR> &t)
{
return !(t == s);
}
ACE_END_VERSIONED_NAMESPACE_DECL

View File

@@ -1,29 +0,0 @@
// -*- C++ -*-
//
// $Id: Timer_Queue_Adapters.inl 80826 2008-03-04 14:51:23Z wotte $
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
template<class TQ> ACE_INLINE TQ *
ACE_Thread_Timer_Queue_Adapter<TQ>::timer_queue (void) const
{
return this->timer_queue_;
}
template<class TQ> ACE_INLINE int
ACE_Thread_Timer_Queue_Adapter<TQ>::timer_queue (TQ *tq)
{
if (this->delete_timer_queue_)
delete this->timer_queue_;
this->timer_queue_ = tq;
this->delete_timer_queue_ = false;
return 0;
}
template<class TQ> ACE_INLINE ACE_thread_t
ACE_Thread_Timer_Queue_Adapter<TQ>::thr_id (void) const
{
return this->thr_id_;
}
ACE_END_VERSIONED_NAMESPACE_DECL

View File

@@ -1,10 +0,0 @@
// -*- C++ -*-
// $Id: Version.h 82705 2008-09-15 11:08:20Z sma $
// This is file was automatically generated by \$ACE_ROOT/bin/make_release.
#define ACE_MAJOR_VERSION 5
#define ACE_MINOR_VERSION 6
#define ACE_BETA_VERSION 6
#define ACE_VERSION "5.6.6"

View File

@@ -1,67 +0,0 @@
// -*- C++ -*-
//$Id: config-borland-common.h 82294 2008-07-12 13:03:37Z johnnyw $
// The following configuration file contains defines for Borland compilers.
#ifndef ACE_CONFIG_BORLAND_COMMON_H
#define ACE_CONFIG_BORLAND_COMMON_H
#include /**/ "ace/pre.h"
#define ACE_HAS_CUSTOM_EXPORT_MACROS
#define ACE_Proper_Export_Flag __declspec (dllexport)
#define ACE_Proper_Import_Flag __declspec (dllimport)
#define ACE_EXPORT_SINGLETON_DECLARATION(T) template class __declspec (dllexport) T
#define ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) template class __declspec (dllexport) SINGLETON_TYPE<CLASS, LOCK>;
#define ACE_IMPORT_SINGLETON_DECLARATION(T) template class __declspec (dllimport) T
#define ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) template class __declspec (dllimport) SINGLETON_TYPE <CLASS, LOCK>;
// In later versions of C++Builder we will prefer inline functions by
// default. The debug configuration of ACE is built with functions
// out-of-line, so when linking your application against a debug ACE
// build, you can choose to use the out-of-line functions by adding
// ACE_NO_INLINE=1 to your project settings.
# if !defined (__ACE_INLINE__)
# define __ACE_INLINE__ 1
# endif /* __ACE_INLINE__ */
# define ACE_CC_NAME ACE_TEXT ("Borland C++ Builder")
# define ACE_CC_MAJOR_VERSION (__BORLANDC__ / 0x100)
# define ACE_CC_MINOR_VERSION (__BORLANDC__ % 0x100)
# define ACE_CC_BETA_VERSION (0)
# ifndef ACE_USING_MCPP_PREPROCESSOR
# define ACE_CC_PREPROCESSOR_ARGS "-q -P- -o%s"
# endif
# define ACE_EXPORT_NESTED_CLASSES 1
# define ACE_HAS_CPLUSPLUS_HEADERS 1
# define ACE_HAS_EXCEPTIONS
# define ACE_HAS_GNU_CSTRING_H 1
# define ACE_HAS_NONCONST_SELECT_TIMEVAL
# define ACE_HAS_SIG_ATOMIC_T
# define ACE_HAS_STANDARD_CPP_LIBRARY 1
# define ACE_HAS_STDCPP_STL_INCLUDES 1
# define ACE_HAS_STRERROR
# define ACE_HAS_STRING_CLASS 1
# define ACE_HAS_TEMPLATE_TYPEDEFS 1
# define ACE_HAS_USER_MODE_MASKS 1
# define ACE_LACKS_ACE_IOSTREAM 1
# define ACE_LACKS_LINEBUFFERED_STREAMBUF 1
# define ACE_LACKS_STRPTIME 1
# if (__BORLANDC__ < 0x590)
# define ACE_LACKS_PLACEMENT_OPERATOR_DELETE 1
# endif
# define ACE_LACKS_PRAGMA_ONCE 1
# define ACE_HAS_NEW_NOTHROW
# define ACE_TEMPLATES_REQUIRE_SOURCE 1
# define ACE_SIZEOF_LONG_DOUBLE 10
# define ACE_UINT64_FORMAT_SPECIFIER ACE_TEXT ("%Lu")
# define ACE_INT64_FORMAT_SPECIFIER ACE_TEXT ("%Ld")
# define ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB 1
# define ACE_USES_STD_NAMESPACE_FOR_STDC_LIB 0
# define ACE_ENDTHREADEX(STATUS) ::_endthreadex ((DWORD) STATUS)
# define ACE_LACKS_SWAB
#include /**/ "ace/post.h"
#endif /* ACE_CONFIG_BORLAND_COMMON_H */

View File

@@ -1,19 +0,0 @@
// -*- C++ -*-
// $Id: config-irix6.5.x-sgic++.h 80826 2008-03-04 14:51:23Z wotte $
// Use this file for IRIX 6.5.x
#ifndef ACE_CONFIG_IRIX65X_H
#define ACE_CONFIG_IRIX65X_H
#include /**/ "ace/pre.h"
// Include IRIX 6.[234] configuration
#include "ace/config-irix6.x-sgic++.h"
// Irix 6.5 man pages show that they exist
#undef ACE_LACKS_CONDATTR_PSHARED
#undef ACE_LACKS_MUTEXATTR_PSHARED
#include /**/ "ace/post.h"
#endif /* ACE_CONFIG_IRIX65X_H */

View File

@@ -1,257 +0,0 @@
/* -*- C++ -*- */
//
// $Id: config-irix6.x-common.h 81697 2008-05-14 18:33:11Z johnnyw $
//
// This file contains the common configuration options for both
// SGI/MIPSPro C++ and g++ under IRIX 6.X
//
// For IRIX 6.2 there are several patches that should be applied to
// get reliable operation with multi-threading and exceptions.
// Specifically you should get a reasonable current IRIX, Compiler
// and POSIX patch-sets.
// For IRIX 6.[34] it's less critical, but it's still recommended
// that you apply the applicable patch-sets (IRIX and Compiler I believe).
// These patches are updated frequently, so you should ask your support
// contact or search SGI's web site (http://www.sgi.com) for the latest
// version.
// Use this file for IRIX 6.[234] if you have the pthreads patches
// installed.
#ifndef ACE_CONFIG_IRIX6X_COMMON_H
#ifndef IRIX6
# define IRIX6
#endif
#if ! defined(ACE_CONFIG_H)
#error "This file may only be included by config-irix6.x-sgic++.h, config-irix6.x-kcc.h or config-irix6.x-g++.h"
#endif
// The Irix 6.x float.h doesn't allow us to distinguish between a
// double and a long double. So, we have to hard-code this. Thanks
// to Bob Laferriere <laferrie@gsao.med.ge.com> for figuring it out.
#if defined (_MIPS_SIM) /* 6.X System */
# include <sgidefs.h>
# if defined (__GNUC__)
# define ACE_SIZEOF_LONG_DOUBLE 16
# elif defined (_MIPS_SIM_NABI32) && (_MIPS_SIM == _MIPS_SIM_NABI32)
# define ACE_SIZEOF_LONG_DOUBLE 16
# elif defined (_MIPS_SIM_ABI32) && (_MIPS_SIM == _MIPS_SIM_ABI32)
# define ACE_SIZEOF_LONG_DOUBLE 8
# elif defined (_MIPS_SIM_ABI64) && (_MIPS_SIM == _MIPS_SIM_ABI64)
# define ACE_SIZEOF_LONG_DOUBLE 16
# elif !defined (ACE_SIZEOF_LONG_DOUBLE)
# define ACE_SIZEOF_LONG_DOUBLE 8
# endif
#else
# define ACE_SIZEOF_LONG_DOUBLE 8 /* 5.3 System */
#endif
// petern, Next part of it:
// Platform supports getpagesize() call.
#define ACE_HAS_GETPAGESIZE
// Platform has no implementation of pthread_condattr_setpshared(),
// even though it supports pthreads! (like Irix 6.2)
#define ACE_LACKS_CONDATTR_PSHARED
#define ACE_LACKS_MUTEXATTR_PSHARED
#define ACE_LACKS_SUSECONDS_T
// Platform/compiler has the sigwait(2) prototype
#define ACE_HAS_SIGWAIT
#define ACE_HAS_SIGTIMEDWAIT
#define ACE_HAS_SIGSUSPEND
// Platform supports System V IPC (most versions of UNIX, but not Win32)
#define ACE_HAS_SYSV_IPC
// Platform requires void * for mmap().
#define ACE_HAS_VOIDPTR_MMAP
// Platform supports recvmsg and sendmsg.
#define ACE_HAS_MSG
// Compiler/platform contains the <sys/syscall.h> file.
#define ACE_HAS_SYS_SYSCALL_H
// Compiler/platform supports alloca()
// Although ACE does have alloca() on this compiler/platform combination, it is
// disabled by default since it can be dangerous. Uncomment the following line
// if you ACE to use it.
//#define ACE_HAS_ALLOCA
// Compiler/platform has <alloca.h>
#define ACE_HAS_ALLOCA_H
// Irix needs to define bzero() in this odd file <bstring.h>
#define ACE_HAS_BSTRING
// Compiler/platform has the getrusage() system call.
#define ACE_HAS_GETRUSAGE
// Platform supports POSIX O_NONBLOCK semantics.
#define ACE_HAS_POSIX_NONBLOCK
// Compiler/platform has correctly prototyped header files.
#define ACE_HAS_CPLUSPLUS_HEADERS
// Platform contains <poll.h>.
#define ACE_HAS_POLL
// Platform supports the /proc file system.
#define ACE_HAS_PROC_FS
// Compiler/platform defines the sig_atomic_t typedef.
#define ACE_HAS_SIG_ATOMIC_T
// Platform supports SVR4 extended signals.
#define ACE_HAS_SIGINFO_T
#define ACE_HAS_UCONTEXT_T
// Compiler supports the ssize_t typedef.
#define ACE_HAS_SSIZE_T
// Platform supports STREAMS.
#define ACE_HAS_STREAMS
// Compiler/platform supports strerror ().
#define ACE_HAS_STRERROR
// Compiler/platform supports struct strbuf.
#define ACE_HAS_STRBUF_T
// Compiler/platform supports SVR4 dynamic linking semantics.
#define ACE_HAS_SVR4_DYNAMIC_LINKING
// Platform provides <sys/filio.h> header.
#define ACE_HAS_SYS_FILIO_H
// Compiler/platform defines a union semun for SysV shared memory.
#define ACE_HAS_SEMUN
// Platform supports IP multicast
#define ACE_HAS_IP_MULTICAST
#ifdef ACE_LACKS_PERFECT_MULTICAST_FILTERING
#undef ACE_LACKS_PERFECT_MULTICAST_FILTERING
#endif
#define ACE_LACKS_PERFECT_MULTICAST_FILTERING 1
//**************************************************************
// Not so sure how next lines should look like
// Platform supports POSIX timers via timestruc_t.
#define ACE_HAS_POSIX_TIME
//**************************************************************
// IRIX 6.4 and below do not support reentrant netdb functions
// (getprotobyname_r, getprotobynumber_r, gethostbyaddr_r,
// gethostbyname_r, getservbyname_r).
#if (ACE_IRIX_VERS <= 64) && !defined (ACE_HAS_NETDB_REENTRANT_FUNCTIONS)
#define ACE_LACKS_NETDB_REENTRANT_FUNCTIONS
#endif /* ACE_HAS_NETDB_REENTRANT_FUNCTIONS */
#define ACE_HAS_DIRENT
// Unless the thread enabled version is used the readdir_r interface
// does not get defined in IRIX 6.2
#define ACE_LACKS_READDIR_R
#define ACE_LACKS_RWLOCK_T
#define ACE_HAS_GPERF
#define ACE_HAS_NONCONST_SELECT_TIMEVAL
#define ACE_HAS_BROKEN_DGRAM_SENDV
#define ACE_LACKS_PLACEMENT_OPERATOR_DELETE
#define ACE_PI_CONTROL_BLOCK_ALIGN_LONGS 2
// Platform has POSIX terminal interface.
#define ACE_HAS_TERMIOS
// IRIX 6.5 supports AIO
#define ACE_HAS_AIO_CALLS
#define ACE_POSIX_AIOCB_PROACTOR
#define ACE_HAS_SGIDLADD
#define ACE_HAS_P_READ_WRITE
#define ACE_LACKS_LINEBUFFERED_STREAMBUF
#define ACE_LACKS_STDINT_H
#define ACE_HAS_SYSENT_H
#define ACE_HAS_SYSINFO
#define ACE_HAS_SYS_SYSTEMINFO_H
// Platform has support for multi-byte character support compliant
// with the XPG4 Worldwide Portability Interface wide-character
// classification.
#define ACE_HAS_XPG4_MULTIBYTE_CHAR
// We need to setup a very high address or Naming_Test won't run.
#define ACE_DEFAULT_BASE_ADDR ((char *) (1024U * 1024 * 1024))
#define ACE_LACKS_SIGNED_CHAR
// Platform supports reentrant functions (i.e., all the POSIX *_r
// functions).
#define ACE_HAS_REENTRANT_FUNCTIONS
// Optimize ACE_Handle_Set for select().
#define ACE_HAS_HANDLE_SET_OPTIMIZED_FOR_SELECT
// Platform does not support reentrant password file accessor functiions.
#define ACE_LACKS_PWD_REENTRANT_FUNCTIONS
// uses ctime_r & asctime_r with only two parameters vs. three
#define ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R
// Prototypes for both signal() and struct sigaction are consistent.
#define ACE_HAS_CONSISTENT_SIGNAL_PROTOTYPES
#define ACE_HAS_UALARM
// Scheduling functions are declared in <sched.h>
#define ACE_NEEDS_SCHED_H
// Compile using multi-thread libraries by default
#if !defined (ACE_MT_SAFE)
#define ACE_MT_SAFE 1
#endif /* ACE_MT_SAFE */
#if (ACE_MT_SAFE != 0)
// Add threading support
#define ACE_HAS_IRIX62_THREADS
// Needed for the threading stuff?
#include /**/ <task.h>
#define PTHREAD_MIN_PRIORITY PX_PRIO_MIN
#define PTHREAD_MAX_PRIORITY PX_PRIO_MAX
// ACE supports threads.
#define ACE_HAS_THREADS
// Platform has no implementation of pthread_condattr_setpshared(),
// even though it supports pthreads! (like Irix 6.2)
#define ACE_LACKS_CONDATTR_PSHARED
#define ACE_LACKS_MUTEXATTR_PSHARED
// IRIX 6.2 supports a variant of POSIX Pthreads, supposedly POSIX 1c
#define ACE_HAS_PTHREADS
// Compiler/platform has thread-specific storage
#define ACE_HAS_THREAD_SPECIFIC_STORAGE
// The pthread_cond_timedwait call does not reset the timer.
#define ACE_LACKS_COND_TIMEDWAIT_RESET 1
// When threads are enabled READDIR_R is supported on IRIX.
#undef ACE_LACKS_READDIR_R
#endif /* (ACE_MT_SAFE == 0) */
#endif /* ACE_CONFIG_IRIX6X_COMMON_H */

View File

@@ -1,24 +0,0 @@
/* -*- C++ -*- */
// $Id: config-irix6.x-g++.h 80826 2008-03-04 14:51:23Z wotte $
// The following configuration file is designed to work for the SGI
// Indigo2EX running Irix 6.2 platform using the GNU C++ Compiler
#ifndef ACE_CONFIG_H
#define ACE_CONFIG_H
#include /**/ "ace/pre.h"
// config-g++-common.h undef's ACE_HAS_STRING_CLASS with -frepo, so
// this must appear before its #include.
#define ACE_HAS_STRING_CLASS
#include "ace/config-g++-common.h"
#include "ace/config-irix6.x-common.h"
// Denotes that GNU has cstring.h as standard
// which redefines memchr()
#define ACE_HAS_GNU_CSTRING_H
#include /**/ "ace/post.h"
#endif /* ACE_CONFIG_H */

View File

@@ -1,37 +0,0 @@
/* -*- C++ -*- */
// $Id: config-irix6.x-sgic++.h 81935 2008-06-12 22:01:53Z jtc $
// Use this file for IRIX 6.[234] if you have the pthreads patches
// installed.
#ifndef ACE_CONFIG_H
#define ACE_CONFIG_H
#include /**/ "ace/pre.h"
#include "ace/config-irix6.x-common.h"
// This is the config file for IRIX 6.2, 6.4 and hopefully 6.3, using
// the SGI C++ compiler (7.1 or higher).
// The following three should be enabled/disabled together.
#if _COMPILER_VERSION < 720
#define ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA
#endif /* _COMPILER_VERSION < 720 */
#define ACE_TEMPLATES_REQUIRE_SOURCE
#define ACE_NEEDS_FUNC_DEFINITIONS
// Platform supports STREAM pipes (note that this is disabled by
// default, see the manual page on pipe(2) to find out how to enable
// it).
// #define ACE_HAS_STREAM_PIPES
#if defined (_COMPILER_VERSION)
# define ACE_CC_NAME ACE_TEXT ("SGI/MIPSPro")
# define ACE_CC_MAJOR_VERSION (_COMPILER_VERSION / 100)
# define ACE_CC_MINOR_VERSION (_COMPILER_VERSION % 100)
# define ACE_CC_BETA_VERSION (0)
#endif /* _COMPILER_VERSION */
#include /**/ "ace/post.h"
#endif /* ACE_CONFIG_H */

View File

@@ -1,15 +0,0 @@
/* -*- C++ -*- */
// $Id: config-sco-5.0.0-nothread.h 80826 2008-03-04 14:51:23Z wotte $
#ifndef ACE_CONFIG_H
#define ACE_CONFIG_H
#include /**/ "ace/pre.h"
#include "ace/config-g++-common.h"
#include "ace/config-sco-5.0.0.h"
#define ACE_HAS_GNU_CSTRING_H
#include /**/ "ace/post.h"
#endif /* ACE_CONFIG_H */

View File

@@ -1,182 +0,0 @@
/* -*- C++ -*- */
// $Id: config-sunos5.4-g++.h 81697 2008-05-14 18:33:11Z johnnyw $
// The following configuration file is designed to work for SunOS 5.4
// platforms using the GNU g++ compiler.
#ifndef ACE_CONFIG_H
#define ACE_CONFIG_H
#include /**/ "ace/pre.h"
#if ! defined (__ACE_INLINE__)
# define __ACE_INLINE__
#endif /* ! __ACE_INLINE__ */
// config-g++-common.h undef's ACE_HAS_STRING_CLASS with -frepo, so
// this must appear before its #include.
#define ACE_HAS_STRING_CLASS
#include "ace/config-g++-common.h"
#define ACE_HAS_GNU_CSTRING_H
#define ACE_HAS_HANDLE_SET_OPTIMIZED_FOR_SELECT
// Platform supports pread() and pwrite()
#define ACE_HAS_P_READ_WRITE
#define ACE_HAS_XPG4_MULTIBYTE_CHAR
// Platform has POSIX terminal interface.
#define ACE_HAS_TERMIOS
// Platform supports System V IPC (most versions of UNIX, but not Win32)
#define ACE_HAS_SYSV_IPC
// Sun has the wrong prototype for sendmsg.
#define ACE_HAS_NONCONST_SENDMSG
// The SunOS 5.x version of rand_r is inconsistent with the header files...
#define ACE_HAS_BROKEN_RANDR
// Platform supports system configuration information.
#define ACE_HAS_SYS_SYSTEMINFO_H
#define ACE_HAS_SYSINFO
// Platform supports the POSIX regular expression library
#define ACE_HAS_REGEX
// Platform supports recvmsg and sendmsg.
#define ACE_HAS_MSG
// Compiler/platform contains the <sys/syscall.h> file.
#define ACE_HAS_SYS_SYSCALL_H
// Compiler/platform correctly calls init()/fini() for shared libraries.
#define ACE_HAS_AUTOMATIC_INIT_FINI
// Platform supports POSIX O_NONBLOCK semantics.
#define ACE_HAS_POSIX_NONBLOCK
// Compiler/platform has correctly prototyped header files.
#define ACE_HAS_CPLUSPLUS_HEADERS
// Compiler/platform supports SunOS high resolution timers.
#define ACE_HAS_HI_RES_TIMER
// Platform supports IP multicast
#define ACE_HAS_IP_MULTICAST
// Compiler/platform supports alloca()
// Although ACE does have alloca() on this compiler/platform combination, it is
// disabled by default since it can be dangerous. Uncomment the following line
// if you ACE to use it.
//#define ACE_HAS_ALLOCA
// Compiler/platform has <alloca.h>
#define ACE_HAS_ALLOCA_H
// Platform contains <poll.h>.
#define ACE_HAS_POLL
// Platform supports POSIX timers via timestruc_t.
#define ACE_HAS_POSIX_TIME
// Platform supports the /proc file system.
#define ACE_HAS_PROC_FS
// Platform supports the prusage_t struct.
#define ACE_HAS_PRUSAGE_T
// Compiler/platform defines the sig_atomic_t typedef.
#define ACE_HAS_SIG_ATOMIC_T
// Platform supports SVR4 extended signals.
#define ACE_HAS_SIGINFO_T
#define ACE_HAS_UCONTEXT_T
// Compiler/platform provides the sockio.h file.
#define ACE_HAS_SYS_SOCKIO_H
// Compiler supports the ssize_t typedef.
#define ACE_HAS_SSIZE_T
// Platform supports STREAMS.
#define ACE_HAS_STREAMS
// Platform supports STREAM pipes.
#define ACE_HAS_STREAM_PIPES
// Compiler/platform supports strerror ().
#define ACE_HAS_STRERROR
// Compiler/platform supports struct strbuf.
#define ACE_HAS_STRBUF_T
// Compiler/platform supports SVR4 dynamic linking semantics.
#define ACE_HAS_SVR4_DYNAMIC_LINKING
// Compiler/platform supports SVR4 gettimeofday() prototype.
#define ACE_HAS_SVR4_GETTIMEOFDAY
// Platform lacks pthread_sigaction
#define ACE_LACKS_PTHREAD_THR_SIGSETMASK
// Compiler/platform supports SVR4 TLI (in particular, T_GETNAME stuff)...
#define ACE_HAS_SVR4_TLI
// Platform provides <sys/filio.h> header.
#define ACE_HAS_SYS_FILIO_H
// Compiler/platform supports sys_siglist array.
#define ACE_HAS_SYS_SIGLIST
/* Turn off the following defines if you want to disable threading. */
// Compile using multi-thread libraries.
#if !defined (ACE_MT_SAFE)
# define ACE_MT_SAFE 1
# if !defined (_REENTRANT)
# define _REENTRANT
# endif /* _REENTRANT */
#endif /* !ACE_MT_SAFE */
// Platform supports Solaris threads.
#define ACE_HAS_STHREADS
// Platform supports threads.
#define ACE_HAS_THREADS
// Compiler/platform has thread-specific storage
#define ACE_HAS_THREAD_SPECIFIC_STORAGE
// Platform supports reentrant functions (i.e., all the POSIX *_r functions).
#define ACE_HAS_REENTRANT_FUNCTIONS
/* end threading defines */
#define ACE_HAS_PRIOCNTL
#define ACE_NEEDS_LWP_PRIO_SET
// Platform supports TLI timod STREAMS module.
#define ACE_HAS_TIMOD_H
// Platform supports TLI tiuser header.
#define ACE_HAS_TIUSER_H
// Platform provides TLI function prototypes.
#define ACE_HAS_TLI_PROTOTYPES
// Platform supports TLI.
#define ACE_HAS_TLI
// Use the poll() event demultiplexor rather than select().
//#define ACE_USE_POLL
// Defines the page size of the system.
#define ACE_PAGE_SIZE 4096
#define ACE_HAS_IDTYPE_T
#define ACE_HAS_GPERF
#define ACE_HAS_DIRENT
#include /**/ "ace/post.h"
#endif /* ACE_CONFIG_H */

View File

@@ -1,191 +0,0 @@
/* -*- C++ -*- */
// $Id: config-sunos5.4-sunc++-4.x.h 81935 2008-06-12 22:01:53Z jtc $
// The following configuration file is designed to work for SunOS 5.4
// platforms using the SunC++ 4.0.x compiler.
#ifndef ACE_CONFIG_H
#define ACE_CONFIG_H
#include /**/ "ace/pre.h"
#if ! defined (__ACE_INLINE__)
# define __ACE_INLINE__
#endif /* ! __ACE_INLINE__ */
// Optimize ACE_Handle_Set for select().
#define ACE_HAS_HANDLE_SET_OPTIMIZED_FOR_SELECT
// Platform supports pread() and pwrite()
#define ACE_HAS_P_READ_WRITE
#define ACE_HAS_XPG4_MULTIBYTE_CHAR
// Platform supports System V IPC (most versions of UNIX, but not Win32)
#define ACE_HAS_SYSV_IPC
// Sun has the wrong prototype for sendmsg.
#define ACE_HAS_NONCONST_SENDMSG
// The SunOS 5.x version of rand_r is inconsistent with the header files...
#define ACE_HAS_BROKEN_RANDR
// Platform supports system configuration information.
#define ACE_HAS_SYS_SYSTEMINFO_H
#define ACE_HAS_SYSINFO
// Platform supports the POSIX regular expression library.
#define ACE_HAS_REGEX
// Platform supports recvmsg and sendmsg.
#define ACE_HAS_MSG
// Compiler/platform contains the <sys/syscall.h> file.
#define ACE_HAS_SYS_SYSCALL_H
// Platform has POSIX terminal interface.
#define ACE_HAS_TERMIOS
// Compiler/platform correctly calls init()/fini() for shared libraries.
#define ACE_HAS_AUTOMATIC_INIT_FINI
// Platform supports POSIX O_NONBLOCK semantics.
#define ACE_HAS_POSIX_NONBLOCK
// Compiler/platform has correctly prototyped header files.
#define ACE_HAS_CPLUSPLUS_HEADERS
// Compiler/platform supports SunOS high resolution timers.
#define ACE_HAS_HI_RES_TIMER
// Platform supports IP multicast
#define ACE_HAS_IP_MULTICAST
// Compiler/platform supports alloca()
// Although ACE does have alloca() on this compiler/platform combination, it is
// disabled by default since it can be dangerous. Uncomment the following line
// if you ACE to use it.
//#define ACE_HAS_ALLOCA
// Compiler/platform has <alloca.h>
#define ACE_HAS_ALLOCA_H
// Platform contains <poll.h>.
#define ACE_HAS_POLL
// Platform supports POSIX timers via timestruc_t.
#define ACE_HAS_POSIX_TIME
// Platform supports the /proc file system.
#define ACE_HAS_PROC_FS
// Platform supports the prusage_t struct.
#define ACE_HAS_PRUSAGE_T
// Compiler/platform defines the sig_atomic_t typedef.
#define ACE_HAS_SIG_ATOMIC_T
// Platform supports SVR4 extended signals.
#define ACE_HAS_SIGINFO_T
#define ACE_HAS_UCONTEXT_T
// Compiler/platform provides the sockio.h file.
#define ACE_HAS_SYS_SOCKIO_H
// Compiler supports the ssize_t typedef.
#define ACE_HAS_SSIZE_T
// Platform supports STREAMS.
#define ACE_HAS_STREAMS
// Platform supports STREAM pipes.
#define ACE_HAS_STREAM_PIPES
// Compiler/platform supports strerror ().
#define ACE_HAS_STRERROR
// Compiler/platform supports struct strbuf.
#define ACE_HAS_STRBUF_T
// Compiler/platform supports SVR4 dynamic linking semantics.
#define ACE_HAS_SVR4_DYNAMIC_LINKING
// Compiler/platform supports SVR4 gettimeofday() prototype.
#define ACE_HAS_SVR4_GETTIMEOFDAY
// Compiler/platform supports SVR4 signal typedef.
#define ACE_HAS_SVR4_SIGNAL_T
// Platform lacks pthread_sigaction
#define ACE_LACKS_PTHREAD_THR_SIGSETMASK
// Compiler/platform supports SVR4 ACE_TLI (in particular, T_GETNAME stuff)...
#define ACE_HAS_SVR4_TLI
// Platform provides <sys/filio.h> header.
#define ACE_HAS_SYS_FILIO_H
// Compiler/platform supports sys_siglist array.
#define ACE_HAS_SYS_SIGLIST
/* Turn off the following defines if you want to disable threading. */
// Compile using multi-thread libraries.
#if !defined (ACE_MT_SAFE)
# define ACE_MT_SAFE 1
#endif
// Platform supports Solaris threads.
#define ACE_HAS_STHREADS
// Platform supports threads.
#define ACE_HAS_THREADS
// Compiler/platform has thread-specific storage
#define ACE_HAS_THREAD_SPECIFIC_STORAGE
// Platform supports reentrant functions (i.e., all the POSIX *_r functions).
#define ACE_HAS_REENTRANT_FUNCTIONS
/* end threading defines */
#define ACE_HAS_PRIOCNTL
#define ACE_NEEDS_LWP_PRIO_SET
// Reactor detects deadlock
// #define ACE_REACTOR_HAS_DEADLOCK_DETECTION
// Platform supports ACE_TLI timod STREAMS module.
#define ACE_HAS_TIMOD_H
// Platform supports ACE_TLI tiuser header.
#define ACE_HAS_TIUSER_H
// Platform provides ACE_TLI function prototypes.
#define ACE_HAS_TLI_PROTOTYPES
// Platform supports ACE_TLI.
#define ACE_HAS_TLI
#define ACE_LACKS_LINEBUFFERED_STREAMBUF
#define ACE_LACKS_SIGNED_CHAR
// Use the poll() event demultiplexor rather than select().
//#define ACE_USE_POLL
#define ACE_NEEDS_DEV_IO_CONVERSION
// Defines the page size of the system.
#define ACE_PAGE_SIZE 4096
#define ACE_HAS_IDTYPE_T
#define ACE_HAS_GPERF
#define ACE_HAS_DIRENT
# if defined (ACE_HAS_EXCEPTIONS)
// If exceptions are enabled and we are using Sun/CC then
// <operator new> throws an exception instead of returning 0.
# define ACE_NEW_THROWS_EXCEPTIONS
# endif /* ACE_HAS_EXCEPTIONS */
#include /**/ "ace/post.h"
#endif /* ACE_CONFIG_H */

View File

@@ -1,346 +0,0 @@
/* -*- C++ -*- */
// $Id: config-vxworks5.x.h 81850 2008-06-06 08:39:54Z vzykov $
// The following configuration file is designed to work for VxWorks
// 5.5.x platforms using one of these compilers:
// 1) The GNU g++ compiler that is shipped with Tornado 2.2 or newer.
// 2) The Green Hills 1.8.8 and newer 1.8.9 compilers (not tested
// already for a long time)
// 3) The WindRiver Compiler (formerly known as Diab)
#ifndef ACE_CONFIG_H
#define ACE_CONFIG_H
#include /**/ "ace/pre.h"
#if ! defined (VXWORKS)
# define VXWORKS
#endif /* ! VXWORKS */
#if ! defined (ACE_VXWORKS)
# define ACE_VXWORKS 0x551
#endif /* ! ACE_VXWORKS */
#if ! defined (__ACE_INLINE__)
# define __ACE_INLINE__
#endif /* ! __ACE_INLINE__ */
// Compiler-specific configuration.
#if defined (__GNUG__)
# include "ace/config-g++-common.h"
# define ACE_LACKS_IOSTREAM_FX
# if !defined (ACE_MAIN)
# define ACE_MAIN ace_main
# endif /* ! ACE_MAIN */
# define ACE_LACKS_LINEBUFFERED_STREAMBUF
# if (__GNUC__ == 2)
# define ACE_CDR_IMPLEMENT_WITH_NATIVE_DOUBLE 1
# endif
# if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3))
// GNU 3.3+ toolchain supports long long types but fails to define this so STL
// skips some definitions
# if !defined (_GLIBCPP_USE_LONG_LONG)
# define _GLIBCPP_USE_LONG_LONG
# endif
# endif /* (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)) */
#elif defined (ghs)
// Processor type, if necessary. Green Hills defines "ppc".
# if defined (ppc)
# define ACE_HAS_POWERPC_TIMER
# define ACE_LACKS_CLEARERR
# endif /* ppc */
# define ACE_CONFIG_INCLUDE_GHS_COMMON
# include "ace/config-ghs-common.h"
# define ACE_LACKS_UNISTD_H
# define ACE_LACKS_IOSTREAM_TOTALLY
// Short-circuit the include of <arpa/inet.h>
// Green Hills has a problem with multiply defined functions
// with different parameters.
# define __INCineth
#elif defined (__DCPLUSPLUS__) || defined (__DCC__)
// Diab 4.2a or later.
# if !defined (ACE_LACKS_PRAGMA_ONCE)
// We define it with a -D with make depend.
# define ACE_LACKS_PRAGMA_ONCE
# endif /* ! ACE_LACKS_PRAGMA_ONCE */
// Diab doesn't support VxWorks' iostream libraries.
# define ACE_LACKS_IOSTREAM_TOTALLY
# define ACE_LACKS_ACE_IOSTREAM
# define ACE_HAS_STANDARD_CPP_LIBRARY 1
# define ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB 0
# define ACE_TEMPLATES_REQUIRE_SOURCE
#else /* ! __GNUG__ && ! ghs && !__DCC__ */
# ifdef __cplusplus /* Let it slide for C compilers. */
# error unsupported compiler on VxWorks
# endif /* __cplusplus */
#endif /* ! __GNUG__ && ! ghs */
// OS-specific configuration
#define ACE_HAS_4_4BSD_SENDMSG_RECVMSG
#define ACE_HAS_SIZET_PTR_ASCTIME_R_AND_CTIME_R
#define ACE_MKDIR_LACKS_MODE
#define ACE_HAS_NONCONST_GETBY
#define ACE_HAS_NONCONST_STAT
#define ACE_HAS_NONCONST_SWAB
#define ACE_HAS_NONCONST_READV
#define ACE_HAS_NONCONST_CHDIR
#define ACE_HAS_NONCONST_UNLINK
#define ACE_HAS_NONCONST_OPENDIR
#define ACE_LACKS_UNIX_SYSLOG
#define ACE_DEFAULT_MAX_SOCKET_BUFSIZ 32768
#define ACE_DEFAULT_THREAD_KEYS 16
#define ACE_HAS_BROKEN_ACCEPT_ADDR
#define ACE_HAS_NONCONST_SENDMSG
#define ACE_HAS_NONCONST_WRITEV
#define ACE_HAS_CHARPTR_DL
#define ACE_HAS_CHARPTR_SOCKOPT
#define ACE_HAS_CLOCK_GETTIME
#define ACE_HAS_CLOCK_SETTIME
#define ACE_HAS_CONSISTENT_SIGNAL_PROTOTYPES
#define ACE_HAS_CPLUSPLUS_HEADERS
#define ACE_HAS_DIRENT
#define ACE_HAS_DLL 0
#define ACE_HAS_HANDLE_SET_OPTIMIZED_FOR_SELECT
#define ACE_HAS_IOCTL_INT_3_PARAM
#define ACE_HAS_MSG
#define ACE_HAS_NONCONST_READV
#define ACE_HAS_NONCONST_SELECT_TIMEVAL
#define ACE_HAS_NONSTATIC_OBJECT_MANAGER
#define ACE_HAS_POSIX_NONBLOCK
#define ACE_HAS_POSIX_TIME
#define ACE_HAS_REENTRANT_FUNCTIONS
#define ACE_HAS_SIGINFO_T
#define ACE_HAS_SIGWAIT
#define ACE_HAS_SIG_ATOMIC_T
#define ACE_HAS_SOCKADDR_IN_SIN_LEN
#define ACE_HAS_SOCKADDR_IN6_SIN6_LEN
#define ACE_HAS_STRDUP_EMULATION
#define ACE_HAS_STRERROR
#define ACE_HAS_THREADS
#define ACE_LACKS_ALPHASORT
#define ACE_LACKS_ACCESS
#define ACE_LACKS_EXEC
#define ACE_LACKS_FCNTL
#define ACE_LACKS_FILELOCKS
#define ACE_LACKS_FORK
#define ACE_LACKS_FSYNC
#define ACE_LACKS_GETHOSTENT
#define ACE_LACKS_GETOPT
#define ACE_LACKS_GETPID
#define ACE_LACKS_GETPPID
#define ACE_LACKS_GETSERVBYNAME
#define ACE_LACKS_KEY_T
#define ACE_LACKS_LSTAT
#define ACE_LACKS_MADVISE
#define ACE_LACKS_MALLOC_H
#define ACE_LACKS_MEMORY_H
#define ACE_LACKS_MKFIFO
#define ACE_LACKS_MKTEMP
#define ACE_LACKS_MKSTEMP
#define ACE_LACKS_MMAP
#define ACE_LACKS_MPROTECT
#define ACE_LACKS_MSYNC
#define ACE_LACKS_NUMERIC_LIMITS
#define ACE_LACKS_GETPROTOBYNAME
#define ACE_LACKS_GETPROTOBYNUMBER
#define ACE_LACKS_GETHOSTBYADDR
#define ACE_LACKS_GETHOSTBYNAME
#define ACE_LACKS_NETDB_REENTRANT_FUNCTIONS
#define ACE_LACKS_SYS_PARAM_H
#define ACE_LACKS_PWD_FUNCTIONS
#define ACE_LACKS_RAND_REENTRANT_FUNCTIONS
#define ACE_LACKS_READDIR_R
#define ACE_LACKS_READLINK
#define ACE_LACKS_REALPATH
#define ACE_LACKS_RLIMIT
#define ACE_LACKS_RWLOCK_T
#define ACE_LACKS_SBRK
#define ACE_LACKS_SEEKDIR
#define ACE_LACKS_SEMBUF_T
#define ACE_LACKS_SIGINFO_H
#define ACE_LACKS_SI_ADDR
#define ACE_LACKS_SOCKETPAIR
#define ACE_LACKS_STRCASECMP
#define ACE_LACKS_STRRECVFD
#define ACE_LACKS_SYSCALL
#define ACE_LACKS_SYSCONF
#define ACE_LACKS_SYS_SYSCTL_H
#define ACE_LACKS_SYSV_SHMEM
#define ACE_LACKS_TELLDIR
#define ACE_LACKS_TEMPNAM
#define ACE_LACKS_TIMESPEC_T
#define ACE_LACKS_TRUNCATE
#define ACE_LACKS_UCONTEXT_H
#define ACE_LACKS_UMASK
#define ACE_LACKS_UTSNAME_T
#define ACE_LACKS_UNAME
#define ACE_LACKS_STRPTIME
#define ACE_LACKS_VSNPRINTF
#define ACE_LACKS_WAIT
#define ACE_LACKS_WAITPID
#define ACE_LACKS_DUP2
#define ACE_LACKS_DUP
#define ACE_LACKS_SUSECONDS_T
#define ACE_LACKS_USECONDS_T
#define ACE_LACKS_INTPTR_T
#define ACE_PAGE_SIZE 4096
#define ACE_THR_PRI_FIFO_DEF 101
#define ACE_THR_PRI_OTHER_DEF ACE_THR_PRI_FIFO_DEF
#define ACE_HAS_SIGTIMEDWAIT
#define ACE_HAS_SIGSUSPEND
#if !defined (ACE_VXWORKS_SPARE)
# define ACE_VXWORKS_SPARE spare4
#endif /* ! ACE_VXWORKS_SPARE */
#define ACE_LACKS_SETEGID
#define ACE_LACKS_SETPGID
#define ACE_LACKS_SETREGID
#define ACE_LACKS_SETREUID
#define ACE_LACKS_SETSID
#define ACE_LACKS_SETUID
#define ACE_LACKS_SETEUID
#define ACE_LACKS_GETEGID
#define ACE_LACKS_GETGID
#define ACE_LACKS_GETEUID
#define ACE_LACKS_GETUID
#define ACE_LACKS_SETGID
#define ACE_LACKS_GETPGID
#define ACE_LACKS_PIPE
#define ACE_LACKS_STDINT_H
#define ACE_LACKS_INTTYPES_H
#define ACE_LACKS_UNISTD_H
#define ACE_LACKS_SYS_SELECT_H
#define ACE_LACKS_SYS_TIME_H
#define ACE_LACKS_SYS_RESOURCE_H
#define ACE_LACKS_DLFCN_H
#define ACE_LACKS_SYS_UIO_H
#define ACE_LACKS_SYS_IPC_H
#define ACE_LACKS_SYS_SEM_H
#define ACE_LACKS_STROPTS_H
#define ACE_LACKS_SYS_MSG_H
#define ACE_LACKS_WCHAR_H
#define ACE_LACKS_PWD_H
#define ACE_LACKS_SEARCH_H
#define ACE_LACKS_SYS_SHM_H
#define ACE_LACKS_STRINGS_H
#define ACE_LACKS_TERMIOS_H
#define ACE_LACKS_POLL_H
#define ACE_LACKS_WCTYPE_H
// Not sure if these should always be defined.
#define ACE_LACKS_SYS_UN_H
// Some string things
#define ACE_LACKS_WCSCAT
#define ACE_LACKS_WCSCHR
#define ACE_LACKS_WCSCMP
#define ACE_LACKS_WCSCPY
#define ACE_LACKS_WCSCSPN
#define ACE_LACKS_WCSLEN
#define ACE_LACKS_WCSNCAT
#define ACE_LACKS_WCSNCMP
#define ACE_LACKS_WCSNCPY
#define ACE_LACKS_WCSPBRK
#define ACE_LACKS_WCSRCHR
#define ACE_LACKS_WCSSPN
#define ACE_LACKS_WCSSTR
#define ACE_LACKS_WCSTOK
#define ACE_LACKS_TOWLOWER
#define ACE_LACKS_TOWUPPER
#define ACE_LACKS_ITOW
#define ACE_LACKS_WCSICMP
#define ACE_LACKS_WCSNICMP
#define ACE_LACKS_WCSTOD
#define ACE_LACKS_WCSTOL
#define ACE_LACKS_WCSTOUL
#define ACE_LACKS_WCSDUP
#define ACE_LACKS_STRTOULL
#define ACE_LACKS_WCSTOULL
#define ACE_LACKS_SYMLINKS
#define ACE_LACKS_FGETWC
#define ACE_LACKS_FGETWS
#define ACE_LACKS_FPUTWS
#if defined (ACE_HAS_VXWORKS551_PID) || (ACE_HAS_VXWORKS551_PCD) || (ACE_HAS_VXWORKS551_PNE)
# define ACE_HAS_VXWORKS551_MEDUSA
#endif
#if defined (ACE_HAS_VXWORKS551_MEDUSA)
# define ACE_HAS_GETIFADDRS
#endif
// It is possible to enable pthread support with VxWorks, when the user decides
// to use this, we need some more defines
#if defined ACE_HAS_PTHREADS
# define ACE_LACKS_CONDATTR_PSHARED
# define ACE_LACKS_MUTEXATTR_PSHARED
# define ACE_HAS_THREAD_SPECIFIC_STORAGE
# define ACE_HAS_POSIX_SEM
// Include this file, the sys/stat.h file shipped with VxWorks has old types
// and without this include we get a lot of compile errors. A TSR has been filed
// so that hopefully in the future we can zap this include
#include "types/vxTypesOld.h"
#else
# define ACE_HAS_VXTHREADS
# define ACE_LACKS_PTHREAD_H
# define ACE_LACKS_COND_T
// VxWorks has no recursive mutexes. This was set in the past but it doesn't
// work with the pthread support, so only set it for the time being when pthread
// is disabled
# define ACE_HAS_RECURSIVE_MUTEXES
// VxWorks does not have the pthread_mutex_timedlock operation, but there is
// an emulation for this when not using the pthread mapping
#define ACE_HAS_MUTEX_TIMEOUTS
#define ACE_HAS_TSS_EMULATION
#endif
#if !defined (ACE_MT_SAFE)
# define ACE_MT_SAFE 1
#endif
// Needed include to get all VxWorks CPU types
#include "types/vxCpu.h"
#if (CPU == PENTIUM || CPU == PENTIUM2 || CPU == PENTIUM3 || CPU == PENTIUM4)
// If running an Intel Pentium the
// ACE_OS::gethrtime () can use the RDTSC instruction.
# define ACE_HAS_PENTIUM
#endif
# if defined (TOOL) && (TOOL == gnu)
# if defined (CPU) && (CPU == PPC85XX || CPU == PPC604 || CPU == PPC603)
// These PPC's do lack log2
# define ACE_LACKS_LOG2
# endif
# endif
#if !defined (ACE_NEEDS_HUGE_THREAD_STACKSIZE)
# define ACE_NEEDS_HUGE_THREAD_STACKSIZE 65536
#endif /* ACE_NEEDS_HUGE_THREAD_STACKSIZE */
#if !defined (ACE_NTRACE)
# define ACE_NTRACE 1
#endif /* ACE_NTRACE */
// By default, don't include RCS Id strings in object code.
#if !defined (ACE_USE_RCSID)
#define ACE_USE_RCSID 0
#endif /* !ACE_USE_RCSID */
#include /**/ "ace/post.h"
#endif /* ACE_CONFIG_H */

View File

@@ -1,329 +0,0 @@
/* -*- C++ -*- */
// $Id: config-vxworks6.2.h 81850 2008-06-06 08:39:54Z vzykov $
// The following configuration file is designed to work for VxWorks
// 6.2 platforms using one of these compilers:
// 1) The GNU g++ compiler that is shipped with VxWorks 6.2
#ifndef ACE_CONFIG_VXWORKS_6_2_H
#define ACE_CONFIG_VXWORKS_6_2_H
#include /**/ "ace/pre.h"
#if ! defined (VXWORKS)
# define VXWORKS
#endif /* ! VXWORKS */
#if ! defined (ACE_VXWORKS)
# define ACE_VXWORKS 0x620
#endif /* ! ACE_VXWORKS */
#if defined __RTP__
// Fix wrong typedef in unistd.h (unsigned short)
#define _SUSECONDS_T
typedef long suseconds_t;
#endif
#include <unistd.h>
// Fix for including right typedef for pid_t in VxTypes.h (int)
#include <vxWorksCommon.h>
#if ! defined (__ACE_INLINE__)
# define __ACE_INLINE__
#endif /* ! __ACE_INLINE__ */
// Compiler-specific configuration.
#if defined (__GNUG__)
# include "ace/config-g++-common.h"
# define ACE_LACKS_IOSTREAM_FX
# define ACE_LACKS_LINEBUFFERED_STREAMBUF
# if defined (__RTP__) && !defined (_HAS_C9X)
// Workaround for the fact that under RTP the log2 method can't be used
// without this define set, see TSR560446
# if !defined (_C99)
# define _C99
# endif
# endif
#elif defined (__DCPLUSPLUS__) || defined (__DCC__)
// Diab 4.2a or later.
# if !defined (ACE_LACKS_PRAGMA_ONCE)
// We define it with a -D with make depend.
# define ACE_LACKS_PRAGMA_ONCE
# endif /* ! ACE_LACKS_PRAGMA_ONCE */
# define ACE_HAS_STANDARD_CPP_LIBRARY 1
# define ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB 1
# define ACE_TEMPLATES_REQUIRE_SOURCE
#else /* ! __GNUG__ && ! ghs && !__DCC__ */
# ifdef __cplusplus /* Let it slide for C compilers. */
# error unsupported compiler on VxWorks
# endif /* __cplusplus */
#endif /* ! __GNUG__ && ! ghs */
#if !defined __RTP__
# if defined (TOOL) && (TOOL == gnu)
# if defined (CPU) && (CPU == PPC85XX || CPU == PPC604 || CPU == PPC603)
// These PPC's do lack log2 in kernel mode
# define ACE_LACKS_LOG2
# endif
# endif
#endif
// OS-specific configuration
#define ACE_HAS_4_4BSD_SENDMSG_RECVMSG
#define ACE_HAS_NONCONST_GETBY
#define ACE_HAS_NONCONST_SWAB
#define ACE_HAS_NONCONST_READV
#define ACE_LACKS_UNIX_SYSLOG
#define ACE_DEFAULT_MAX_SOCKET_BUFSIZ 32768
#define ACE_DEFAULT_THREAD_KEYS 16
#define ACE_HAS_BROKEN_ACCEPT_ADDR
#define ACE_HAS_NONCONST_SENDMSG
#define ACE_HAS_NONCONST_WRITEV
#define ACE_HAS_CHARPTR_DL
#define ACE_HAS_CLOCK_GETTIME
#define ACE_HAS_CLOCK_SETTIME
#define ACE_HAS_CONSISTENT_SIGNAL_PROTOTYPES
#define ACE_HAS_CPLUSPLUS_HEADERS
#define ACE_HAS_DIRENT
#define ACE_HAS_DLL 0
#define ACE_HAS_HANDLE_SET_OPTIMIZED_FOR_SELECT
#define ACE_HAS_IOCTL_INT_3_PARAM
#define ACE_HAS_MSG
#define ACE_HAS_NONCONST_READV
#define ACE_HAS_NONCONST_SELECT_TIMEVAL
#define ACE_HAS_NONSTATIC_OBJECT_MANAGER
#define ACE_HAS_POSIX_NONBLOCK
#define ACE_HAS_POSIX_TIME
#define ACE_HAS_REENTRANT_FUNCTIONS
#define ACE_HAS_SIGACTION_CONSTP2
#define ACE_HAS_SIGINFO_T
#define ACE_HAS_SIGWAIT
#define ACE_HAS_SIG_ATOMIC_T
#define ACE_HAS_SOCKADDR_IN_SIN_LEN
#define ACE_HAS_SOCKADDR_IN6_SIN6_LEN
#define ACE_HAS_STRERROR
#define ACE_HAS_THREADS
#define ACE_HAS_SYSCTL
#define ACE_LACKS_ALPHASORT
#define ACE_LACKS_EXEC
#define ACE_LACKS_FILELOCKS
#define ACE_LACKS_FORK
#define ACE_LACKS_GETHOSTENT
#define ACE_LACKS_GETSERVBYNAME
#define ACE_LACKS_GETPROTOBYNAME
#define ACE_LACKS_GETPROTOBYNUMBER
#define ACE_LACKS_KEY_T
#define ACE_LACKS_LSTAT
#define ACE_LACKS_MADVISE
#define ACE_LACKS_MALLOC_H
#define ACE_LACKS_MEMORY_H
#define ACE_LACKS_MKFIFO
#define ACE_LACKS_MKTEMP
#define ACE_LACKS_MKSTEMP
#define ACE_LACKS_MMAP
#define ACE_LACKS_MPROTECT
#define ACE_LACKS_MSYNC
#define ACE_LACKS_NETDB_REENTRANT_FUNCTIONS
#define ACE_LACKS_SYS_PARAM_H
#define ACE_LACKS_PWD_FUNCTIONS
#define ACE_LACKS_READDIR_R
#define ACE_LACKS_READLINK
#define ACE_LACKS_REALPATH
#define ACE_LACKS_PIPE
#define ACE_LACKS_RLIMIT
#define ACE_LACKS_RWLOCK_T
#define ACE_LACKS_SBRK
#define ACE_LACKS_SEEKDIR
#define ACE_LACKS_SEMBUF_T
#define ACE_LACKS_SIGINFO_H
#define ACE_LACKS_SI_ADDR
#define ACE_LACKS_SOCKETPAIR
#define ACE_LACKS_STRRECVFD
#define ACE_LACKS_SYSV_SHMEM
#define ACE_LACKS_TELLDIR
#define ACE_LACKS_TEMPNAM
#define ACE_LACKS_TIMESPEC_T
#define ACE_LACKS_TRUNCATE
#define ACE_LACKS_UCONTEXT_H
#define ACE_LACKS_USECONDS_T
#define ACE_LACKS_UMASK
#define ACE_LACKS_STRPTIME
#define ACE_PAGE_SIZE 4096
#define ACE_THR_PRI_FIFO_DEF 101
#define ACE_THR_PRI_OTHER_DEF ACE_THR_PRI_FIFO_DEF
#define ACE_HAS_SIGTIMEDWAIT
#define ACE_HAS_SIGSUSPEND
#if !defined (ACE_VXWORKS_SPARE)
# define ACE_VXWORKS_SPARE spare4
#endif /* ! ACE_VXWORKS_SPARE */
#define ACE_HAS_GETIFADDRS
#define ACE_LACKS_SETEGID
#define ACE_LACKS_SETPGID
#define ACE_LACKS_SETREGID
#define ACE_LACKS_SETREUID
#define ACE_LACKS_SETSID
#define ACE_LACKS_SETUID
#define ACE_LACKS_SETEUID
#define ACE_LACKS_GETEUID
#define ACE_LACKS_GETUID
#define ACE_LACKS_GETPGID
#define ACE_LACKS_GETEGID
#define ACE_LACKS_GETGID
#define ACE_LACKS_SETGID
#define ACE_LACKS_SYS_UIO_H
#define ACE_LACKS_SYS_IPC_H
#define ACE_LACKS_SYS_SEM_H
#define ACE_LACKS_STROPTS_H
#define ACE_LACKS_SYS_MSG_H
#define ACE_LACKS_PWD_H
#define ACE_LACKS_SYS_SHM_H
#define ACE_LACKS_TERMIOS_H
#define ACE_LACKS_POLL_H
#define ACE_LACKS_FCNTL
// Some string things
#define ACE_LACKS_STRCASECMP
#define ACE_LACKS_ITOW
#define ACE_LACKS_WCSDUP
#define ACE_LACKS_WCSICMP
#define ACE_LACKS_WCSNICMP
#define ACE_LACKS_STRTOULL
#define ACE_LACKS_WCSTOULL
#define ACE_HAS_CHARPTR_SOCKOPT
#define ACE_LACKS_SYMLINKS
#if defined __RTP__
// We are building for RTP mode
#if !defined (ACE_AS_STATIC_LIBS)
# define ACE_HAS_SVR4_DYNAMIC_LINKING
#endif
#define ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R
#define ACE_LACKS_REGEX_H
#define ACE_LACKS_PUTENV
#define ACE_HAS_SETENV
#define ACE_HAS_3_PARAM_WCSTOK
#define ACE_HAS_WCHAR
#define ACE_HAS_VFWPRINTF
#define ACE_SIZEOF_WCHAR 2
#else
// We are building for kernel mode
#define ACE_LACKS_INTPTR_T
#define ACE_LACKS_SUSECONDS_T
#define ACE_LACKS_INTTYPES_H
#define ACE_LACKS_STDINT_H
#define ACE_LACKS_UNAME
#define ACE_LACKS_UTSNAME_T
#define ACE_LACKS_RAND_REENTRANT_FUNCTIONS
#define ACE_LACKS_DLFCN_H
#define ACE_LACKS_WAIT
#define ACE_LACKS_WAITPID
#define ACE_LACKS_SYS_TIME_H
#define ACE_LACKS_SYS_SELECT_H
#define ACE_LACKS_STRINGS_H
#define ACE_MKDIR_LACKS_MODE
#define ACE_HAS_SIZET_PTR_ASCTIME_R_AND_CTIME_R
#define ACE_LACKS_SEARCH_H
#define ACE_LACKS_SYSCONF
#define ACE_LACKS_GETPID
#define ACE_LACKS_GETPPID
#define ACE_LACKS_WCHAR_H
#define ACE_LACKS_WCTYPE_H
#define ACE_LACKS_WCSCAT
#define ACE_LACKS_WCSCHR
#define ACE_LACKS_WCSCMP
#define ACE_LACKS_WCSCPY
#define ACE_LACKS_WCSCSPN
#define ACE_LACKS_WCSLEN
#define ACE_LACKS_WCSNCAT
#define ACE_LACKS_WCSNCMP
#define ACE_LACKS_WCSNCPY
#define ACE_LACKS_WCSPBRK
#define ACE_LACKS_WCSRCHR
#define ACE_LACKS_WCSSPN
#define ACE_LACKS_WCSSTR
#define ACE_LACKS_WCSTOK
#define ACE_LACKS_TOWLOWER
#define ACE_LACKS_TOWUPPER
#define ACE_LACKS_WCSTOD
#define ACE_LACKS_WCSTOL
#define ACE_LACKS_WCSTOUL
#define ACE_LACKS_FGETWC
#define ACE_LACKS_FGETWS
#define ACE_LACKS_FPUTWS
#if !defined (ACE_MAIN)
# define ACE_MAIN ace_main
#endif /* ! ACE_MAIN */
#endif
// It is possible to enable pthread support with VxWorks, when the user decides
// to use this, we need some more defines
#if defined ACE_HAS_PTHREADS
# define ACE_HAS_THREAD_SPECIFIC_STORAGE
# define ACE_HAS_POSIX_SEM
# define ACE_LACKS_MUTEXATTR_PSHARED
# define ACE_LACKS_CONDATTR_PSHARED
// Include this file, the sys/stat.h file shipped with VxWorks has old types
// and without this include we get a lot of compile errors. A TSR has been filed
// so that hopefully in the future we can zap this include
#include "types/vxTypesOld.h"
#else
# define ACE_LACKS_PTHREAD_H
# define ACE_HAS_VXTHREADS
# if !defined __RTP__
// Only when building for kernel mode we can use TSS emulation, in rtp mode
// we can't use the WIND_TCB struct anymore
# define ACE_HAS_TSS_EMULATION
# endif
// VxWorks has no recursive mutexes. This was set in the past but it doesn't
// work with the pthread support, so only set it for the time being when pthread
// is disabled
# define ACE_HAS_RECURSIVE_MUTEXES
# define ACE_LACKS_COND_T
# define ACE_HAS_MUTEX_TIMEOUTS
#endif
#if !defined (ACE_MT_SAFE)
# define ACE_MT_SAFE 1
#endif
// Needed include to get all VxWorks CPU types
#include "types/vxCpu.h"
#if (CPU == PENTIUM || CPU == PENTIUM2 || CPU == PENTIUM3 || CPU == PENTIUM4)
// If running an Intel Pentium the
// ACE_OS::gethrtime () can use the RDTSC instruction.
# define ACE_HAS_PENTIUM
#endif
// VxWorks defines the CPU define MAP, undef it to prevent problems with
// application code
#if defined (MAP)
#undef MAP
#endif /* MAP */
#if !defined (ACE_NEEDS_HUGE_THREAD_STACKSIZE)
# define ACE_NEEDS_HUGE_THREAD_STACKSIZE 65536
#endif /* ACE_NEEDS_HUGE_THREAD_STACKSIZE */
#if !defined (ACE_NTRACE)
# define ACE_NTRACE 1
#endif /* ACE_NTRACE */
// By default, don't include RCS Id strings in object code.
#if !defined (ACE_USE_RCSID)
#define ACE_USE_RCSID 0
#endif /* !ACE_USE_RCSID */
#if defined (ACE_HAS_IP_MULTICAST)
# define ACE_LACKS_PERFECT_MULTICAST_FILTERING 1
#endif /* ACE_HAS_IP_MULTICAST */
#include /**/ "ace/post.h"
#endif /* ACE_CONFIG_VXWORKS_6_2_H */

View File

@@ -1,318 +0,0 @@
/* -*- C++ -*- */
// $Id: config-vxworks6.3.h 81850 2008-06-06 08:39:54Z vzykov $
// The following configuration file is designed to work for VxWorks
// 6.3 platforms using one of these compilers:
// 1) The GNU g++ compiler that is shipped with VxWorks 6.3
#ifndef ACE_CONFIG_VXWORKS_6_3_H
#define ACE_CONFIG_VXWORKS_6_3_H
#include /**/ "ace/pre.h"
#if ! defined (VXWORKS)
# define VXWORKS
#endif /* ! VXWORKS */
#if ! defined (ACE_VXWORKS)
# define ACE_VXWORKS 0x630
#endif /* ! ACE_VXWORKS */
#if ! defined (__ACE_INLINE__)
# define __ACE_INLINE__
#endif /* ! __ACE_INLINE__ */
// Compiler-specific configuration.
#if defined (__GNUG__)
# include "ace/config-g++-common.h"
# define ACE_LACKS_IOSTREAM_FX
# define ACE_LACKS_LINEBUFFERED_STREAMBUF
# if defined (__RTP__) && !defined (_HAS_C9X)
// Workaround for the fact that under RTP the log2 method can't be used
// without this define set, see TSR560446
# if !defined (_C99)
# define _C99
# endif
# endif
#elif defined (__DCC__)
# define ACE_HAS_STANDARD_CPP_LIBRARY 1
# define ACE_TEMPLATES_REQUIRE_SOURCE
#else /* ! __GNUG__ && ! ghs && !__DCC__ */
# ifdef __cplusplus /* Let it slide for C compilers. */
# error unsupported compiler on VxWorks
# endif /* __cplusplus */
#endif /* ! __GNUG__ && ! ghs */
#if !defined __RTP__
# if defined (TOOL) && (TOOL == gnu)
# if defined (CPU) && (CPU == PPC85XX || CPU == PPC604 || CPU == PPC603)
// These PPC's do lack log2 in kernel mode
# define ACE_LACKS_LOG2
# endif
# endif
#endif
// OS-specific configuration
#define ACE_HAS_4_4BSD_SENDMSG_RECVMSG
#define ACE_HAS_NONCONST_GETBY
#define ACE_HAS_NONCONST_SWAB
#define ACE_LACKS_UNIX_SYSLOG
#define ACE_DEFAULT_MAX_SOCKET_BUFSIZ 32768
#define ACE_DEFAULT_THREAD_KEYS 16
#define ACE_HAS_BROKEN_ACCEPT_ADDR
#define ACE_HAS_NONCONST_SENDMSG
#define ACE_HAS_NONCONST_WRITEV
#define ACE_HAS_CHARPTR_DL
#define ACE_HAS_CLOCK_GETTIME
#define ACE_HAS_CLOCK_SETTIME
#define ACE_HAS_CONSISTENT_SIGNAL_PROTOTYPES
#define ACE_HAS_CPLUSPLUS_HEADERS
#define ACE_HAS_DIRENT
#define ACE_HAS_DLL 0
#define ACE_HAS_HANDLE_SET_OPTIMIZED_FOR_SELECT
#define ACE_HAS_MSG
#define ACE_HAS_NONCONST_READV
#define ACE_HAS_NONCONST_SELECT_TIMEVAL
#define ACE_HAS_NONSTATIC_OBJECT_MANAGER
#define ACE_HAS_POSIX_NONBLOCK
#define ACE_HAS_POSIX_TIME
#define ACE_HAS_REENTRANT_FUNCTIONS
#define ACE_HAS_SIGACTION_CONSTP2
#define ACE_HAS_SIGINFO_T
#define ACE_HAS_SIGWAIT
#define ACE_HAS_SIG_ATOMIC_T
#define ACE_HAS_SOCKADDR_IN_SIN_LEN
#define ACE_HAS_SOCKADDR_IN6_SIN6_LEN
#define ACE_HAS_STRERROR
#define ACE_HAS_THREADS
#define ACE_HAS_SYSCTL
#define ACE_LACKS_ALPHASORT
#define ACE_LACKS_EXEC
#define ACE_LACKS_FILELOCKS
#define ACE_LACKS_FORK
#define ACE_LACKS_GETHOSTENT
#define ACE_LACKS_GETSERVBYNAME
#define ACE_LACKS_GETPROTOBYNAME
#define ACE_LACKS_GETPROTOBYNUMBER
#define ACE_LACKS_GETIPNODEBYADDR
#define ACE_LACKS_GETIPNODEBYNAME_IPV6
#define ACE_LACKS_LSTAT
#define ACE_LACKS_MADVISE
#define ACE_LACKS_MALLOC_H
#define ACE_LACKS_MEMORY_H
#define ACE_LACKS_MKFIFO
#define ACE_LACKS_MKTEMP
#define ACE_LACKS_MKSTEMP
#define ACE_LACKS_NETDB_REENTRANT_FUNCTIONS
#define ACE_LACKS_SYS_PARAM_H
#define ACE_LACKS_PWD_FUNCTIONS
#define ACE_LACKS_READDIR_R
#define ACE_LACKS_READLINK
#define ACE_LACKS_REALPATH
#define ACE_LACKS_PIPE
#define ACE_LACKS_RLIMIT
#define ACE_LACKS_RWLOCK_T
#define ACE_LACKS_SBRK
#define ACE_LACKS_SEEKDIR
#define ACE_LACKS_SEMBUF_T
#define ACE_LACKS_SIGINFO_H
#define ACE_LACKS_SI_ADDR
#define ACE_LACKS_SOCKETPAIR
#define ACE_LACKS_STRRECVFD
#define ACE_LACKS_SYSV_SHMEM
#define ACE_LACKS_TELLDIR
#define ACE_LACKS_TEMPNAM
#define ACE_LACKS_TIMESPEC_T
#define ACE_LACKS_TRUNCATE
#define ACE_LACKS_UCONTEXT_H
#define ACE_LACKS_USECONDS_T
#define ACE_LACKS_UMASK
#define ACE_LACKS_STRPTIME
#define ACE_PAGE_SIZE 4096
#define ACE_THR_PRI_FIFO_DEF 101
#define ACE_THR_PRI_OTHER_DEF ACE_THR_PRI_FIFO_DEF
#define ACE_HAS_SIGTIMEDWAIT
#define ACE_HAS_SIGSUSPEND
#define ACE_HAS_GETIFADDRS
#define ACE_LACKS_SETEGID
#define ACE_LACKS_SETPGID
#define ACE_LACKS_SETREGID
#define ACE_LACKS_SETREUID
#define ACE_LACKS_SETSID
#define ACE_LACKS_SETUID
#define ACE_LACKS_SETEUID
#define ACE_LACKS_GETEUID
#define ACE_LACKS_GETUID
#define ACE_LACKS_GETPGID
#define ACE_LACKS_GETEGID
#define ACE_LACKS_GETGID
#define ACE_LACKS_SETGID
#define ACE_LACKS_SYS_UIO_H
#define ACE_LACKS_SYS_IPC_H
#define ACE_LACKS_SYS_SEM_H
#define ACE_LACKS_STROPTS_H
#define ACE_LACKS_SYS_MSG_H
#define ACE_LACKS_PWD_H
#define ACE_LACKS_SYS_SHM_H
#define ACE_LACKS_TERMIOS_H
#define ACE_LACKS_POLL_H
#define ACE_LACKS_FCNTL
// Some string things
#define ACE_LACKS_ITOW
#define ACE_LACKS_WCSDUP
#define ACE_LACKS_WCSICMP
#define ACE_LACKS_WCSNICMP
#define ACE_LACKS_STRTOULL
#define ACE_LACKS_WCSTOULL
#define ACE_HAS_CHARPTR_SOCKOPT
#define ACE_LACKS_SYMLINKS
#if defined __RTP__
// We are building for RTP mode
#if !defined (ACE_AS_STATIC_LIBS)
# define ACE_HAS_SVR4_DYNAMIC_LINKING
#endif
#define ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R
#define ACE_LACKS_REGEX_H
#define ACE_LACKS_PUTENV
#define ACE_HAS_SETENV
#define ACE_HAS_3_PARAM_WCSTOK
#define ACE_HAS_WCHAR
#define ACE_HAS_VFWPRINTF
#define ACE_SIZEOF_WCHAR 2
#define ACE_HAS_SHM_OPEN
#if defined (ACE_AS_STATIC_LIBS)
# define ACE_HAS_AIO_CALLS
#endif
#define ACE_LACKS_STRCASECMP
// VxWorks seems to either not define this or define as zero up till now
#if !defined (IOV_MAX) || (IOV_MAX == 0)
#define ACE_IOV_MAX 16
#endif
#else
// We are building for kernel mode
#define ACE_LACKS_SUSECONDS_T
#define ACE_LACKS_INTPTR_T
#define ACE_LACKS_INTTYPES_H
#define ACE_LACKS_STDINT_H
#define ACE_LACKS_UNAME
#define ACE_LACKS_UTSNAME_T
#define ACE_LACKS_RAND_REENTRANT_FUNCTIONS
#define ACE_LACKS_DLFCN_H
#define ACE_LACKS_WAIT
#define ACE_LACKS_WAITPID
#define ACE_LACKS_SYS_TIME_H
#define ACE_LACKS_SYS_SELECT_H
#define ACE_MKDIR_LACKS_MODE
#define ACE_HAS_SIZET_PTR_ASCTIME_R_AND_CTIME_R
#define ACE_LACKS_SEARCH_H
#define ACE_LACKS_SYSCONF
#define ACE_LACKS_GETPID
#define ACE_LACKS_GETPPID
#define ACE_LACKS_WCHAR_H
#define ACE_LACKS_WCTYPE_H
#define ACE_LACKS_WCSCAT
#define ACE_LACKS_WCSCHR
#define ACE_LACKS_WCSCMP
#define ACE_LACKS_WCSCPY
#define ACE_LACKS_WCSCSPN
#define ACE_LACKS_WCSLEN
#define ACE_LACKS_WCSNCAT
#define ACE_LACKS_WCSNCMP
#define ACE_LACKS_WCSNCPY
#define ACE_LACKS_WCSPBRK
#define ACE_LACKS_WCSRCHR
#define ACE_LACKS_WCSSPN
#define ACE_LACKS_WCSSTR
#define ACE_LACKS_WCSTOK
#define ACE_LACKS_TOWLOWER
#define ACE_LACKS_TOWUPPER
#define ACE_LACKS_WCSTOD
#define ACE_LACKS_WCSTOL
#define ACE_LACKS_WCSTOUL
#define ACE_LACKS_FGETWC
#define ACE_LACKS_FGETWS
#define ACE_LACKS_FPUTWS
#define ACE_HAS_IOCTL_INT_3_PARAM
#define ACE_LACKS_MMAP
#define ACE_LACKS_MSYNC
#define ACE_LACKS_MPROTECT
#if !defined (ACE_MAIN)
# define ACE_MAIN ace_main
#endif /* ! ACE_MAIN */
#endif
// It is possible to enable pthread support with VxWorks, when the user decides
// to use this, we need some more defines
#if defined ACE_HAS_PTHREADS
# define ACE_HAS_THREAD_SPECIFIC_STORAGE
# define ACE_HAS_POSIX_SEM
# define ACE_LACKS_MUTEXATTR_PSHARED
# define ACE_LACKS_CONDATTR_PSHARED
// Include this file, the sys/stat.h file shipped with VxWorks has old types
// and without this include we get a lot of compile errors. A TSR has been filed
// so that hopefully in the future we can zap this include
#include "types/vxTypesOld.h"
#else
# define ACE_LACKS_PTHREAD_H
# define ACE_HAS_VXTHREADS
# if !defined __RTP__
// Only when building for kernel mode we can use TSS emulation, in rtp mode
// we can't use the WIND_TCB struct anymore
# define ACE_HAS_TSS_EMULATION
# if !defined (ACE_VXWORKS_SPARE)
# define ACE_VXWORKS_SPARE spare4
# endif /* ! ACE_VXWORKS_SPARE */
# endif
// VxWorks has no recursive mutexes. This was set in the past but it doesn't
// work with the pthread support, so only set it for the time being when pthread
// is disabled
# define ACE_HAS_RECURSIVE_MUTEXES
# define ACE_LACKS_COND_T
# define ACE_HAS_MUTEX_TIMEOUTS
#endif
#if !defined (ACE_MT_SAFE)
# define ACE_MT_SAFE 1
#endif
// Needed include to get all VxWorks CPU types
#include "types/vxCpu.h"
#if defined (CPU) && (CPU == PENTIUM || CPU == PENTIUM2 || CPU == PENTIUM3 || CPU == PENTIUM4)
// If running an Intel Pentium the
// ACE_OS::gethrtime () can use the RDTSC instruction.
# define ACE_HAS_PENTIUM
#endif
// VxWorks defines the CPU define MAP, undef it to prevent problems with
// application code
#if defined (MAP)
#undef MAP
#endif /* MAP */
#if !defined (ACE_NEEDS_HUGE_THREAD_STACKSIZE)
# define ACE_NEEDS_HUGE_THREAD_STACKSIZE 65536
#endif /* ACE_NEEDS_HUGE_THREAD_STACKSIZE */
#if !defined (ACE_NTRACE)
# define ACE_NTRACE 1
#endif /* ACE_NTRACE */
// By default, don't include RCS Id strings in object code.
#if !defined (ACE_USE_RCSID)
#define ACE_USE_RCSID 0
#endif /* !ACE_USE_RCSID */
#if defined (ACE_HAS_IP_MULTICAST)
# define ACE_LACKS_PERFECT_MULTICAST_FILTERING 1
#endif /* ACE_HAS_IP_MULTICAST */
#include /**/ "ace/post.h"
#endif /* ACE_CONFIG_VXWORKS_6_3_H */

View File

@@ -1,100 +0,0 @@
// -*- C++ -*-
// $Id: config-win32-interix.h 80826 2008-03-04 14:51:23Z wotte $
// The following configuration file is designed to work for Interix
// platforms using GNU g++ (Interix == Microsoft's Services for Unix)
#ifndef ACE_CONFIG_WIN32_INTERIX_H
#define ACE_CONFIG_WIN32_INTERIX_H
#include /**/ "ace/pre.h"
#include <arpa/inet.h>
# define ACE_LACKS_SENDMSG
# define ACE_LACKS_RECVMSG
# define ACE_LACKS_STDINT_H
# define ACE_LACKS_INTTYPES_H
# define ACE_LACKS_PRAGMA_ONCE
# define ACE_LACKS_RWLOCK_T
# define ACE_LACKS_GETPGID // Don't have getpgid(), have setpgid() though...
# define ACE_LACKS_UCONTEXT_H
# define ACE_HAS_REENTRANT_FUNCTIONS
# define ACE_LACKS_NETDB_REENTRANT_FUNCTIONS // Don't have gethostbyaddr_r and friends.
# define ACE_HAS_DIRENT
# define ACE_HAS_STDCPP_STL_INCLUDES
# define ACE_HAS_STANDARD_CPP_LIBRARY 1
# define ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB 1
# define ACE_HAS_NONCONST_SELECT_TIMEVAL
# define ACE_HAS_SIGWAIT
# define ACE_HAS_SIGINFO_T
#include "ace/config-g++-common.h"
#define ACE_HAS_NEW_NOTHROW // Need to know 'new's failure semantics.
#if defined (ACE_HAS_THREADS)
#define ACE_HAS_THREADS
#define ACE_HAS_PTHREADS
#define _THREAD_SAFE
#define ACE_MTSAFE 1
#define ACE_MT_SAFE 1
#define ACE_LACKS_PTHREAD_YIELD
#define ACE_HAS_MUTEX_TIMEOUTS
#else
error "You need to enable threads for this Interix port."
#endif /* ACE_HAS_THREADS */
// INTERIX has the following, just an issue with porting for the moment
#define ACE_LACKS_ACCESS
// END INTERIX has the following....
#define ACE_SIZEOF_LONG_DOUBLE 12
#define ACE_PAGE_SIZE 4096
#define ACE_HAS_SYSV_IPC
#define ACE_HAS_SVR4_SIGNAL_T
#define ACE_HAS_CONSISTENT_SIGNAL_PROTOTYPES
#define ACE_HAS_SVR4_DYNAMIC_LINKING
#define ACE_HAS_POSIX_TIME // Supports POSIX timers via struct timespec.
#define ACE_LACKS_TIMESPEC_T // Defines struct timespec but not timespec_t.
#define ACE_LACKS_STRRECVFD
#define ACE_LACKS_SETSCHED
#define ACE_HAS_SOCKADDR_IN_SIN_LEN
#define ACE_HAS_RTLD_LAZY_V
#define ACE_HAS_POSIX_NONBLOCK
#define ACE_HAS_GETRUSAGE
#define ACE_HAS_SIG_ATOMIC_T
#define ACE_HAS_SEMUN
#define ACE_HAS_SSIZE_T
#define ACE_HAS_STRERROR
#define ACE_HAS_SVR4_GETTIMEOFDAY
#define ACE_HAS_UALARM
#define ACE_HAS_TERMIOS
#define ACE_HAS_SIGWAIT
// Turns off the tracing feature.
#if !defined (ACE_NTRACE)
#define ACE_NTRACE 1
#endif /* ACE_NTRACE */
// NOTE: In debugging some of the test apps they would all memory fault in using
// ACE_Errno_Guard. Upon inspection of that code it uses TSS to save ERRNO in
// a TSS pointer. Access to that pointer caused the fault. The work around here
// is to tell ACE we have TSS and use emulation. More investigation is needed to
// determine whether Interix TSS is broken or the correct semantics for usage under
// Interix simply need to be ported.
// To get around the issue ACE_HAS_TSS_EMULATION is defined to use TSS emulation
// however while many test programs that use TSS pass the TSS_Test program fails.
#define ACE_HAS_THREAD_SPECIFIC_STORAGE // We need thread specific storage even though...
#define ACE_HAS_TSS_EMULATION // It would appear to be broken in Interix!
#include /**/ "ace/post.h"
#endif /* ACE_CONFIG_WIN32_INTERIX_H */
/*
The following tests do not run.
Dynamic_Priority_Test.log ACE_HAS_TIMED_MESSAGE_BLOCKS
Enum_Interfaces_Test.log
IOStream_Test.log ACE_IOSTREAM not supported on this platform
*/

View File

@@ -1,154 +0,0 @@
// -*- C++ -*-
//=============================================================================
/**
* @file os_errno.h
*
* system error numbers
*
* $Id: os_errno.h 80826 2008-03-04 14:51:23Z wotte $
*
* @author Don Hinton <dhinton@dresystems.com>
* @author This code was originally in various places including ace/OS.h.
*/
//=============================================================================
#ifndef ACE_OS_INCLUDE_OS_ERRNO_H
#define ACE_OS_INCLUDE_OS_ERRNO_H
#include /**/ "ace/pre.h"
#include "ace/config-lite.h"
#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
#if !defined (ACE_LACKS_ERRNO_H)
# include /**/ <errno.h>
#endif /* !ACE_LACKS_ERRNO_H */
#if defined (ACE_VXWORKS)
// Needed for VxWorks to pickup errnoSet()
#include /**/ <errnoLib.h>
#endif /* ACE_VXWORKS */
// Place all additions (especially function declarations) within extern "C" {}
#ifdef __cplusplus
extern "C"
{
#endif /* __cplusplus */
#if defined (ACE_WIN32)
// error code mapping for windows
# define ETIME ERROR_SEM_TIMEOUT
# define EWOULDBLOCK WSAEWOULDBLOCK
# define EINPROGRESS WSAEINPROGRESS
# define EALREADY WSAEALREADY
# define ENOTSOCK WSAENOTSOCK
# define EDESTADDRREQ WSAEDESTADDRREQ
# define EMSGSIZE WSAEMSGSIZE
# define EPROTOTYPE WSAEPROTOTYPE
# define ENOPROTOOPT WSAENOPROTOOPT
# define EPROTONOSUPPORT WSAEPROTONOSUPPORT
# define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT
# define EOPNOTSUPP WSAEOPNOTSUPP
# define EPFNOSUPPORT WSAEPFNOSUPPORT
# define EAFNOSUPPORT WSAEAFNOSUPPORT
# define EADDRINUSE WSAEADDRINUSE
# define EADDRNOTAVAIL WSAEADDRNOTAVAIL
# define ENETDOWN WSAENETDOWN
# define ENETUNREACH WSAENETUNREACH
# define ENETRESET WSAENETRESET
# define ECONNABORTED WSAECONNABORTED
# define ECONNRESET WSAECONNRESET
# define ENOBUFS WSAENOBUFS
# define EISCONN WSAEISCONN
# define ENOTCONN WSAENOTCONN
# define ESHUTDOWN WSAESHUTDOWN
# define ETOOMANYREFS WSAETOOMANYREFS
# define ETIMEDOUT WSAETIMEDOUT
# define ECONNREFUSED WSAECONNREFUSED
# define ELOOP WSAELOOP
# define EHOSTDOWN WSAEHOSTDOWN
# define EHOSTUNREACH WSAEHOSTUNREACH
# define EPROCLIM WSAEPROCLIM
# define EUSERS WSAEUSERS
# define EDQUOT WSAEDQUOT
# define ESTALE WSAESTALE
# define EREMOTE WSAEREMOTE
// Grrr! ENAMETOOLONG and ENOTEMPTY are already defined by the horrible
// 'standard' library.
// #define ENAMETOOLONG WSAENAMETOOLONG
# define EADDRINUSE WSAEADDRINUSE
// CE needs this...
# if !defined (EPERM)
# define EPERM ERROR_ACCESS_DENIED
# endif
#endif /* ACE_WIN32 */
#if defined (ACE_HAS_H_ERRNO)
void herror (const char *str);
#endif /* ACE_HAS_H_ERRNO */
#if !defined (ACE_WIN32) && defined (ACE_LACKS_T_ERRNO)
extern int t_errno;
#endif /* ACE_WIN32 && ACE_LACKS_T_ERRNO */
#if !defined (ENOSYS)
# define ENOSYS EFAULT /* Operation not supported or unknown error. */
#endif /* !ENOSYS */
#if !defined (ENOTSUP)
# define ENOTSUP ENOSYS /* Operation not supported. */
#endif /* !ENOTSUP */
#if !defined (ESUCCESS)
# define ESUCCESS 0
#endif /* !ESUCCESS */
#if !defined (EIDRM)
# define EIDRM 0
#endif /* !EIDRM */
#if !defined (ENFILE)
# define ENFILE EMFILE /* No more socket descriptors are available. */
#endif /* !ENFILE */
#if !defined (ECOMM)
// Not the same, but ECONNABORTED is provided on NT.
# define ECOMM ECONNABORTED
#endif /* ECOMM */
#if !defined (EDEADLK)
# define EDEADLK 1000 /* Some large number.... */
#endif /* !EDEADLK */
#if !defined (ENXIO) /* Needed in SOCK_Dgram_Mcast */
# define ENXIO 6
#endif /* ENXIO */
#if !defined (ETIMEDOUT) && defined (ETIME)
# define ETIMEDOUT ETIME
#endif /* ETIMEDOUT */
#if !defined (ETIME) && defined (ETIMEDOUT)
# define ETIME ETIMEDOUT
#endif /* ETIMED */
#if !defined (EBUSY)
# define EBUSY ETIME
#endif /* EBUSY */
#if !defined (ECANCELED)
# define ECANCELED 125
#endif /* ECANCELED */
#ifdef __cplusplus
}
#endif /* __cplusplus */
#include /**/ "ace/post.h"
#endif /* ACE_OS_INCLUDE_OS_ERRNO_H */

View File

@@ -1,282 +0,0 @@
/*-------------------------------------------------------------*/
/*--- Public header file for the library. ---*/
/*--- bzlib.h ---*/
/*-------------------------------------------------------------*/
/* ------------------------------------------------------------------
This file is part of bzip2/libbzip2, a program and library for
lossless, block-sorting data compression.
bzip2/libbzip2 version 1.0.5 of 10 December 2007
Copyright (C) 1996-2007 Julian Seward <jseward@bzip.org>
Please read the WARNING, DISCLAIMER and PATENTS sections in the
README file.
This program is released under the terms of the license contained
in the file LICENSE.
------------------------------------------------------------------ */
#ifndef _BZLIB_H
#define _BZLIB_H
#ifdef __cplusplus
extern "C" {
#endif
#define BZ_RUN 0
#define BZ_FLUSH 1
#define BZ_FINISH 2
#define BZ_OK 0
#define BZ_RUN_OK 1
#define BZ_FLUSH_OK 2
#define BZ_FINISH_OK 3
#define BZ_STREAM_END 4
#define BZ_SEQUENCE_ERROR (-1)
#define BZ_PARAM_ERROR (-2)
#define BZ_MEM_ERROR (-3)
#define BZ_DATA_ERROR (-4)
#define BZ_DATA_ERROR_MAGIC (-5)
#define BZ_IO_ERROR (-6)
#define BZ_UNEXPECTED_EOF (-7)
#define BZ_OUTBUFF_FULL (-8)
#define BZ_CONFIG_ERROR (-9)
typedef
struct {
char *next_in;
unsigned int avail_in;
unsigned int total_in_lo32;
unsigned int total_in_hi32;
char *next_out;
unsigned int avail_out;
unsigned int total_out_lo32;
unsigned int total_out_hi32;
void *state;
void *(*bzalloc)(void *,int,int);
void (*bzfree)(void *,void *);
void *opaque;
}
bz_stream;
#ifndef BZ_IMPORT
#define BZ_EXPORT
#endif
#ifndef BZ_NO_STDIO
/* Need a definitition for FILE */
#include <stdio.h>
#endif
#ifdef _WIN32
# include <windows.h>
# ifdef small
/* windows.h define small to char */
# undef small
# endif
# ifdef BZ_EXPORT
# define BZ_API(func) WINAPI func
# define BZ_EXTERN extern
# else
/* import windows dll dynamically */
# define BZ_API(func) (WINAPI * func)
# define BZ_EXTERN
# endif
#else
# define BZ_API(func) func
# define BZ_EXTERN extern
#endif
/*-- Core (low-level) library functions --*/
BZ_EXTERN int BZ_API(BZ2_bzCompressInit) (
bz_stream* strm,
int blockSize100k,
int verbosity,
int workFactor
);
BZ_EXTERN int BZ_API(BZ2_bzCompress) (
bz_stream* strm,
int action
);
BZ_EXTERN int BZ_API(BZ2_bzCompressEnd) (
bz_stream* strm
);
BZ_EXTERN int BZ_API(BZ2_bzDecompressInit) (
bz_stream *strm,
int verbosity,
int small
);
BZ_EXTERN int BZ_API(BZ2_bzDecompress) (
bz_stream* strm
);
BZ_EXTERN int BZ_API(BZ2_bzDecompressEnd) (
bz_stream *strm
);
/*-- High(er) level library functions --*/
#ifndef BZ_NO_STDIO
#define BZ_MAX_UNUSED 5000
typedef void BZFILE;
BZ_EXTERN BZFILE* BZ_API(BZ2_bzReadOpen) (
int* bzerror,
FILE* f,
int verbosity,
int small,
void* unused,
int nUnused
);
BZ_EXTERN void BZ_API(BZ2_bzReadClose) (
int* bzerror,
BZFILE* b
);
BZ_EXTERN void BZ_API(BZ2_bzReadGetUnused) (
int* bzerror,
BZFILE* b,
void** unused,
int* nUnused
);
BZ_EXTERN int BZ_API(BZ2_bzRead) (
int* bzerror,
BZFILE* b,
void* buf,
int len
);
BZ_EXTERN BZFILE* BZ_API(BZ2_bzWriteOpen) (
int* bzerror,
FILE* f,
int blockSize100k,
int verbosity,
int workFactor
);
BZ_EXTERN void BZ_API(BZ2_bzWrite) (
int* bzerror,
BZFILE* b,
void* buf,
int len
);
BZ_EXTERN void BZ_API(BZ2_bzWriteClose) (
int* bzerror,
BZFILE* b,
int abandon,
unsigned int* nbytes_in,
unsigned int* nbytes_out
);
BZ_EXTERN void BZ_API(BZ2_bzWriteClose64) (
int* bzerror,
BZFILE* b,
int abandon,
unsigned int* nbytes_in_lo32,
unsigned int* nbytes_in_hi32,
unsigned int* nbytes_out_lo32,
unsigned int* nbytes_out_hi32
);
#endif
/*-- Utility functions --*/
BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffCompress) (
char* dest,
unsigned int* destLen,
char* source,
unsigned int sourceLen,
int blockSize100k,
int verbosity,
int workFactor
);
BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffDecompress) (
char* dest,
unsigned int* destLen,
char* source,
unsigned int sourceLen,
int small,
int verbosity
);
/*--
Code contributed by Yoshioka Tsuneo (tsuneo@rr.iij4u.or.jp)
to support better zlib compatibility.
This code is not _officially_ part of libbzip2 (yet);
I haven't tested it, documented it, or considered the
threading-safeness of it.
If this code breaks, please contact both Yoshioka and me.
--*/
BZ_EXTERN const char * BZ_API(BZ2_bzlibVersion) (
void
);
#ifndef BZ_NO_STDIO
BZ_EXTERN BZFILE * BZ_API(BZ2_bzopen) (
const char *path,
const char *mode
);
BZ_EXTERN BZFILE * BZ_API(BZ2_bzdopen) (
int fd,
const char *mode
);
BZ_EXTERN int BZ_API(BZ2_bzread) (
BZFILE* b,
void* buf,
int len
);
BZ_EXTERN int BZ_API(BZ2_bzwrite) (
BZFILE* b,
void* buf,
int len
);
BZ_EXTERN int BZ_API(BZ2_bzflush) (
BZFILE* b
);
BZ_EXTERN void BZ_API(BZ2_bzclose) (
BZFILE* b
);
BZ_EXTERN const char * BZ_API(BZ2_bzerror) (
BZFILE *b,
int *errnum
);
#endif
#ifdef __cplusplus
}
#endif
#endif
/*-------------------------------------------------------------*/
/*--- end bzlib.h ---*/
/*-------------------------------------------------------------*/

View File

@@ -1,142 +0,0 @@
/* Copyright (C) 2000 MySQL AB
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; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/* Header for NetWare compatible with MySQL */
#ifndef _config_netware_h
#define _config_netware_h
/* required headers */
#include <unistd.h>
#include <stdio.h>
#include <errno.h>
#include <screen.h>
#include <limits.h>
#include <signal.h>
#include <errno.h>
#include <stdbool.h>
#include <stdlib.h>
#include <sys/types.h>
#include <time.h>
#include <sys/time.h>
#include <pthread.h>
#include <termios.h>
#ifdef __cplusplus
extern "C" {
#endif
/* required adjustments */
#undef HAVE_READDIR_R
#undef HAVE_RWLOCK_INIT
#undef HAVE_SCHED_H
#undef HAVE_SYS_MMAN_H
#undef HAVE_SYNCH_H
#undef HAVE_MMAP
#undef HAVE_RINT
#define HAVE_PTHREAD_ATTR_SETSTACKSIZE 1
#define HAVE_PTHREAD_SIGMASK 1
#define HAVE_PTHREAD_YIELD_ZERO_ARG 1
#define HAVE_BROKEN_REALPATH 1
/* changes made to make use of LibC-June-2004 for building purpose */
#undef HAVE_POSIX_SIGNALS
#undef HAVE_PTHREAD_ATTR_SETSCOPE
#undef HAVE_ALLOC_A
#undef HAVE_FINITE
#undef HAVE_GETPWNAM
#undef HAVE_GETPWUID
#undef HAVE_PTHREAD_SETSCHEDPARAM
#undef HAVE_READLINK
#undef HAVE_STPCPY
/* changes end */
/* no libc crypt() function */
#ifdef HAVE_OPENSSL
#define HAVE_CRYPT 1
#else
#undef HAVE_CRYPT
#endif /* HAVE_OPENSSL */
/* Netware has an ancient zlib */
#undef HAVE_COMPRESS
#define HAVE_COMPRESS
#undef HAVE_ARCHIVE_DB
/* include the old function apis */
#define USE_OLD_FUNCTIONS 1
/* no case sensitivity */
#define FN_NO_CASE_SENCE 1
/* the thread alarm is not used */
#define DONT_USE_THR_ALARM 1
/* signals do not interrupt sockets */
#define SIGNALS_DONT_BREAK_READ 1
/* signal by closing the sockets */
#define SIGNAL_WITH_VIO_CLOSE 1
/* On NetWare, stack grows towards lower address*/
#define STACK_DIRECTION -1
/* On NetWare, we need to set stack size for threads, otherwise default 16K is used */
#define NW_THD_STACKSIZE 65536
/* On NetWare, to fix the problem with the deletion of open files */
#define CANT_DELETE_OPEN_FILES 1
#define FN_LIBCHAR '\\'
#define FN_ROOTDIR "\\"
#define FN_DEVCHAR ':'
/* default directory information */
#define DEFAULT_MYSQL_HOME "sys:/mysql"
#define PACKAGE "mysql"
#define DEFAULT_BASEDIR "sys:/"
#define SHAREDIR "share/"
#define DEFAULT_CHARSET_HOME "sys:/mysql/"
#define DATADIR "data/"
/* 64-bit file system calls */
#define SIZEOF_OFF_T 8
#define off_t off64_t
#define chsize chsize64
#define ftruncate ftruncate64
#define lseek lseek64
#define pread pread64
#define pwrite pwrite64
#define tell tell64
/* do not use the extended time in LibC sys\stat.h */
#define _POSIX_SOURCE
/* Some macros for portability */
#define set_timespec(ABSTIME,SEC) { (ABSTIME).tv_sec=time(NULL)+(SEC); (ABSTIME).tv_nsec=0; }
/* extra protection against CPU Hogs on NetWare */
#define NETWARE_YIELD pthread_yield()
/* Screen mode for help texts */
#define NETWARE_SET_SCREEN_MODE(A) setscreenmode(A)
#ifdef __cplusplus
}
#endif
#endif /* _config_netware_h */

View File

@@ -1,836 +0,0 @@
/* Copyright (C) 2000 MySQL AB & Yuri Dario
All the above parties has a full, independent copyright to
the following code, including the right to use the code in
any manner without any demands from the other parties.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; version 2
of the License.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA */
/* Defines for OS2 to make it compatible for MySQL */
#ifndef __CONFIG_OS2_H__
#define __CONFIG_OS2_H__
#include <os2.h>
#include <math.h>
#include <io.h>
#include <types.h>
/* Define to name of system eg solaris*/
#define SYSTEM_TYPE "IBM OS/2 Warp"
/* Define to machine type name eg sun10 */
#define MACHINE_TYPE "i686"
/* Name of package */
#define PACKAGE "mysql"
/* Version number of package */
#define VERSION MYSQL_SERVER_VERSION
/* Default socket */
#define MYSQL_UNIX_ADDR "\\socket\\MySQL"
#define FN_LIBCHAR '\\'
#define FN_ROOTDIR "\\"
#define MY_NFILE 1024 /* This is only used to save filenames */
#define HAVE_ACCESS
#define DEFAULT_MYSQL_HOME "c:\\mysql"
#define DEFAULT_BASEDIR "C:\\"
#define SHAREDIR "share"
#define DEFAULT_CHARSET_HOME "C:/mysql/"
#define _POSIX_PATH_MAX 255
#define DWORD ULONG
#define O_SHARE 0x1000 /* Open file in sharing mode */
#define FILE_BINARY O_BINARY /* my_fopen in binary mode */
#define S_IROTH S_IREAD /* for my_lib */
#define CANT_DELETE_OPEN_FILES /* saves open files in a list, for delayed delete */
#define O_NONBLOCK 0x10
#define NO_OPEN_3 /* For my_create() */
#define SIGQUIT SIGTERM /* No SIGQUIT */
#define SIGALRM 14 /* Alarm */
#define NO_FCNTL_NONBLOCK
#define EFBIG E2BIG
/*#define ENFILE EMFILE */
/*#define ENAMETOOLONG (EOS2ERR+2) */
/*#define ETIMEDOUT 145 */
/*#define EPIPE 146 */
#define EROFS 147
#define sleep(A) DosSleep((A)*1000)
#define closesocket(A) soclose(A)
#define F_OK 0
#define W_OK 2
#define bzero(x,y) memset((x),'\0',(y))
#define bcopy(x,y,z) memcpy((y),(x),(z))
#define bcmp(x,y,z) memcmp((y),(x),(z))
#define F_RDLCK 4 /* Read lock. */
#define F_WRLCK 2 /* Write lock. */
#define F_UNLCK 0 /* Remove lock. */
#define S_IFMT 0x17000 /* Mask for file type */
#define F_TO_EOF 0L /* Param to lockf() to lock rest of file */
#define HUGE_PTR
#ifdef __cplusplus
extern "C"
#endif
double _cdecl rint( double nr);
DWORD TlsAlloc( void);
BOOL TlsFree( DWORD);
PVOID TlsGetValue( DWORD);
BOOL TlsSetValue( DWORD, PVOID);
/* support for > 2GB file size */
#define SIZEOF_OFF_T 8
#define lseek(A,B,C) _lseek64( A, B, C)
#define tell(A) _lseek64( A, 0, SEEK_CUR)
void* dlopen( char* path, int flag);
char* dlerror( void);
void* dlsym( void* hmod, char* fn);
void dlclose( void* hmod);
/* Some typedefs */
typedef unsigned long long os_off_t;
/* config.h. Generated automatically by configure. */
/* config.h.in. Generated automatically from configure.in by autoheader. */
/* Define if using alloca.c. */
/* #undef C_ALLOCA */
/* Define to empty if the keyword does not work. */
/* #undef const */
/* Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP systems.
This function is required for alloca.c support on those systems. */
/* #undef CRAY_STACKSEG_END */
/* Define if you have alloca, as a function or macro. */
#define HAVE_ALLOCA 1
/* Define if you have <alloca.h> and it should be used (not on Ultrix). */
/* #define HAVE_ALLOCA_H 1 */
/* Define if you don't have vprintf but do have _doprnt. */
/* #undef HAVE_DOPRNT */
/* Define if you have a working `mmap' system call. */
/* #undef HAVE_MMAP */
/* Define if system calls automatically restart after interruption
by a signal. */
/* #undef HAVE_RESTARTABLE_SYSCALLS */
/* Define if your struct stat has st_rdev. */
#define HAVE_ST_RDEV 1
/* Define if you have <sys/wait.h> that is POSIX.1 compatible. */
/* #define HAVE_SYS_WAIT_H 1 */
/* Define if you don't have tm_zone but do have the external array
tzname. */
#define HAVE_TZNAME 1
/* Define if utime(file, NULL) sets file's timestamp to the present. */
#define HAVE_UTIME_NULL 1
/* Define if you have the vprintf function. */
#define HAVE_VPRINTF 1
/* Define as __inline if that's what the C compiler calls it. */
/* #undef inline */
/* Define to `long' if <sys/types.h> doesn't define. */
/* #undef off_t */
/* Define as the return type of signal handlers (int or void). */
#define RETSIGTYPE void
/* Define to `unsigned' if <sys/types.h> doesn't define. */
/* #undef size_t */
/* If using the C implementation of alloca, define if you know the
direction of stack growth for your system; otherwise it will be
automatically deduced at run-time.
STACK_DIRECTION > 0 => grows toward higher addresses
STACK_DIRECTION < 0 => grows toward lower addresses
STACK_DIRECTION = 0 => direction of growth unknown
*/
#define STACK_DIRECTION -1
/* Define if the `S_IS*' macros in <sys/stat.h> do not work properly. */
/* #undef STAT_MACROS_BROKEN */
/* Define if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Define if you can safely include both <sys/time.h> and <time.h>. */
#define TIME_WITH_SYS_TIME 1
/* Define if your <sys/time.h> declares struct tm. */
/* #undef TM_IN_SYS_TIME */
/* Define if your processor stores words with the most significant
byte first (like Motorola and SPARC, unlike Intel and VAX). */
/* #undef WORDS_BIGENDIAN */
/* Version of .frm files */
#define DOT_FRM_VERSION 6
/* READLINE: */
#define FIONREAD_IN_SYS_IOCTL 1
/* READLINE: Define if your system defines TIOCGWINSZ in sys/ioctl.h. */
/* #undef GWINSZ_IN_SYS_IOCTL */
/* Do we have FIONREAD */
#define FIONREAD_IN_SYS_IOCTL 1
/* atomic_add() from <asm/atomic.h> (Linux only) */
/* #undef HAVE_ATOMIC_ADD */
/* atomic_sub() from <asm/atomic.h> (Linux only) */
/* #undef HAVE_ATOMIC_SUB */
/* bool is not defined by all C++ compilators */
#define HAVE_BOOL 1
/* Have berkeley db installed */
/* #define HAVE_BERKELEY_DB 1 */
/* DSB style signals ? */
/* #undef HAVE_BSD_SIGNALS */
/* Can netinet be included */
/* #undef HAVE_BROKEN_NETINET_INCLUDES */
/* READLINE: */
/* #undef HAVE_BSD_SIGNALS */
/* ZLIB and compress: */
#define HAVE_COMPRESS 1
/* Define if we are using OSF1 DEC threads */
/* #undef HAVE_DEC_THREADS */
/* Define if we are using OSF1 DEC threads on 3.2 */
/* #undef HAVE_DEC_3_2_THREADS */
/* fp_except from ieeefp.h */
/* #undef HAVE_FP_EXCEPT */
/* READLINE: */
/* #undef HAVE_GETPW_DECLS */
/* Solaris define gethostbyname_r with 5 arguments. glibc2 defines
this with 6 arguments */
/* #undef HAVE_GETHOSTBYNAME_R_GLIBC2_STYLE */
/* In OSF 4.0f the 3'd argument to gethostname_r is hostent_data * */
/* #undef HAVE_GETHOSTBYNAME_R_RETURN_INT */
/* Define if int8, int16 and int32 types exist */
/* #undef HAVE_INT_8_16_32 */
/* Define if have -lwrap */
/* #undef HAVE_LIBWRAP */
/* Define if we are using Xavier Leroy's LinuxThreads */
/* #undef HAVE_LINUXTHREADS */
/* Do we use user level threads */
/* #undef HAVE_mit_thread */
/* For some non posix threads */
/* #undef HAVE_NONPOSIX_PTHREAD_GETSPECIFIC */
/* For some non posix threads */
/* #undef HAVE_NONPOSIX_PTHREAD_MUTEX_INIT */
/* READLINE: */
#define HAVE_POSIX_SIGNALS 0
/* sigwait with one argument */
/* #undef HAVE_NONPOSIX_SIGWAIT */
/* pthread_attr_setscope */
#define HAVE_PTHREAD_ATTR_SETSCOPE 1
/* POSIX readdir_r */
/* #undef HAVE_READDIR_R */
/* POSIX sigwait */
/* #undef HAVE_SIGWAIT */
/* crypt */
#define HAVE_CRYPT 1
/* Solaris define gethostbyaddr_r with 7 arguments. glibc2 defines
this with 8 arguments */
/* #undef HAVE_SOLARIS_STYLE_GETHOST */
/* Timespec has a ts_sec instead of tv_sev */
#define HAVE_TIMESPEC_TS_SEC 1
/* Have the tzname variable */
#define HAVE_TZNAME 1
/* Define if the system files define uchar */
/* #undef HAVE_UCHAR */
/* Define if the system files define uint */
/* #undef HAVE_UINT */
/* Define if the system files define ulong */
/* #undef HAVE_ULONG */
/* UNIXWARE7 threads are not posix */
/* #undef HAVE_UNIXWARE7_THREADS */
/* new UNIXWARE7 threads that are not yet posix */
/* #undef HAVE_UNIXWARE7_POSIX */
/* READLINE: */
/* #undef HAVE_USG_SIGHOLD */
/* Define if want -lwrap */
/* #undef LIBWRAP */
/* mysql client protocoll version */
#define PROTOCOL_VERSION 10
/* Define if qsort returns void */
#define QSORT_TYPE_IS_VOID 1
/* Define as the return type of qsort (int or void). */
#define RETQSORTTYPE void
/* Define as the base type of the last arg to accept */
#define SOCKET_SIZE_TYPE int
/* Last argument to get/setsockopt */
/* #undef SOCKOPT_OPTLEN_TYPE */
/* #undef SPEED_T_IN_SYS_TYPES */
/* #undef SPRINTF_RETURNS_PTR */
#define SPRINTF_RETURNS_INT 1
/* #undef SPRINTF_RETURNS_GARBAGE */
/* #undef STRUCT_DIRENT_HAS_D_FILENO */
#define STRUCT_DIRENT_HAS_D_INO 1
/* Define if you want to have threaded code. This may be undef on client code */
#define THREAD 1
/* Should be client be thread safe */
/* #undef THREAD_SAFE_CLIENT */
/* READLINE: */
/* #undef TIOCSTAT_IN_SYS_IOCTL */
/* Use multi-byte character routines */
/* #undef USE_MB */
/* #undef USE_MB_IDENT */
/* Use MySQL RAID */
/* #undef USE_RAID */
/* Use strcoll() functions when comparing and sorting. */
/* #undef USE_STRCOLL */
/* READLINE: */
#define VOID_SIGHANDLER 1
/* The number of bytes in a char. */
#define SIZEOF_CHAR 1
/* The number of bytes in a int. */
#define SIZEOF_INT 4
/* The number of bytes in a long. */
#define SIZEOF_LONG 4
/* The number of bytes in a long long. */
#define SIZEOF_LONG_LONG 8
/* Define if you have the alarm function. */
#define HAVE_ALARM 1
/* Define if you have the atod function. */
/* #undef HAVE_ATOD */
/* Define if you have the bcmp function. */
#define HAVE_BCMP 1
/* Define if you have the bfill function. */
/* #undef HAVE_BFILL */
/* Define if you have the bmove function. */
/* #undef HAVE_BMOVE */
/* Define if you have the bzero function. */
#define HAVE_BZERO 1
/* Define if you have the chsize function. */
#define HAVE_CHSIZE 1
/* Define if you have the cuserid function. */
/* #define HAVE_CUSERID 1 */
/* Define if you have the dlerror function. */
#define HAVE_DLERROR 1
/* Define if you have the dlopen function. */
#define HAVE_DLOPEN 1
/* Define if you have the fchmod function. */
/* #undef HAVE_FCHMOD */
/* Define if you have the fcntl function. */
/* #define HAVE_FCNTL 1 */
/* Define if you have the fconvert function. */
/* #undef HAVE_FCONVERT */
/* Define if you have the finite function. */
/* #undef HAVE_FINITE */
/* Define if you have the fpresetsticky function. */
/* #undef HAVE_FPRESETSTICKY */
/* Define if you have the fpsetmask function. */
/* #undef HAVE_FPSETMASK */
/* Define if you have the fseeko function. */
/* #undef HAVE_FSEEKO */
/* Define if you have the ftruncate function. */
/* #define HAVE_FTRUNCATE 1 */
/* Define if you have the getcwd function. */
#define HAVE_GETCWD 1
/* Define if you have the gethostbyaddr_r function. */
/* #undef HAVE_GETHOSTBYADDR_R */
/* Define if you have the gethostbyname_r function. */
/* #undef HAVE_GETHOSTBYNAME_R */
/* Define if you have the getpagesize function. */
#define HAVE_GETPAGESIZE 1
/* Define if you have the getpass function. */
/*#define HAVE_GETPASS 1 */
/* Define if you have the getpassphrase function. */
/* #undef HAVE_GETPASSPHRASE */
/* Define if you have the getpwnam function. */
/* #define HAVE_GETPWNAM 1 */
/* Define if you have the getpwuid function. */
/* #define HAVE_GETPWUID 1 */
/* Define if you have the getrlimit function. */
/* #undef HAVE_GETRLIMIT */
/* Define if you have the getrusage function. */
/* #undef HAVE_GETRUSAGE */
/* Define if you have the getwd function. */
#define HAVE_GETWD 1
/* Define to 1 if you have the `gmtime_r' function. */
#define HAVE_GMTIME_R 1
/* Define if you have the index function. */
#define HAVE_INDEX 1
/* Define if you have the initgroups function. */
/* #undef HAVE_INITGROUPS */
/* Define if you have the localtime_r function. */
#define HAVE_LOCALTIME_R 1
/* Define if you have the locking function. */
/* #undef HAVE_LOCKING */
/* Define if you have the longjmp function. */
#define HAVE_LONGJMP 1
/* Define if you have the lrand48 function. */
/* #undef HAVE_LRAND48 */
/* Define if you have the lstat function. */
/* #undef HAVE_LSTAT */
/* Define if you have the madvise function. */
/* #undef HAVE_MADVISE */
/* Define if you have the memcpy function. */
#define HAVE_MEMCPY 1
/* Define if you have the memmove function. */
#define HAVE_MEMMOVE 1
/* Define if you have the mkstemp function. */
/* #define HAVE_MKSTEMP 1 */
/* Define if you have the mlockall function. */
/* #undef HAVE_MLOCKALL */
/* Define if you have the perror function. */
#define HAVE_PERROR 1
/* Define if you have the poll function. */
/* #undef HAVE_POLL */
/* Define if you have the pread function. */
/* #undef HAVE_PREAD */
/* Define if you have the pthread_attr_create function. */
/* #undef HAVE_PTHREAD_ATTR_CREATE */
/* Define if you have the pthread_attr_setprio function. */
#define HAVE_PTHREAD_ATTR_SETPRIO 1
/* Define if you have the pthread_attr_setschedparam function. */
/* #undef HAVE_PTHREAD_ATTR_SETSCHEDPARAM */
/* Define if you have the pthread_attr_setstacksize function. */
#define HAVE_PTHREAD_ATTR_SETSTACKSIZE 1
/* Define if you have the pthread_condattr_create function. */
/* #undef HAVE_PTHREAD_CONDATTR_CREATE */
/* Define if you have the pthread_getsequence_np function. */
/* #undef HAVE_PTHREAD_GETSEQUENCE_NP */
/* Define if you have the pthread_init function. */
/* #undef HAVE_PTHREAD_INIT */
/* Define if you have the pthread_rwlock_rdlock function. */
/* #undef HAVE_PTHREAD_RWLOCK_RDLOCK */
/* Define if you have the pthread_setprio function. */
#define HAVE_PTHREAD_SETPRIO 1
/* Define if you have the pthread_setprio_np function. */
/* #undef HAVE_PTHREAD_SETPRIO_NP */
/* Define if you have the pthread_setschedparam function. */
/* #undef HAVE_PTHREAD_SETSCHEDPARAM */
/* Define if you have the pthread_sigmask function. */
#define HAVE_PTHREAD_SIGMASK 1
/* Define if you have the putenv function. */
#define HAVE_PUTENV 1
/* Define if you have the readlink function. */
/* #undef HAVE_READLINK */
/* Define if you have the realpath function. */
/* #undef HAVE_REALPATH */
/* Define if you have the rename function. */
#define HAVE_RENAME 1
/* Define if you have the rint function. */
#define HAVE_RINT 1
/* Define if you have the rwlock_init function. */
/* #undef HAVE_RWLOCK_INIT */
/* Define if you have the select function. */
#define HAVE_SELECT 1
/* Define if you have the setenv function. */
/* #undef HAVE_SETENV */
/* Define if you have the setlocale function. */
#define HAVE_SETLOCALE 1
/* Define if you have the setupterm function. */
/* #undef HAVE_SETUPTERM */
/* Define if you have the sighold function. */
/* #undef HAVE_SIGHOLD */
/* Define if you have the sigset function. */
/* #undef HAVE_SIGSET */
/* Define if you have the sigthreadmask function. */
/* #undef HAVE_SIGTHREADMASK */
/* Define if you have the snprintf function. */
/* #define HAVE_SNPRINTF 1 */
/* Define if you have the socket function. */
#define HAVE_SOCKET 1
/* Define if you have the stpcpy function. */
/* #undef HAVE_STPCPY */
/* Define if you have the strcasecmp function. */
/* #undef HAVE_STRCASECMP */
/* Define if you have the strcoll function. */
#define HAVE_STRCOLL 1
/* Define if you have the strerror function. */
#define HAVE_STRERROR 1
/* Define if you have the strnlen function. */
/* #undef HAVE_STRNLEN */
/* Define if you have the strpbrk function. */
#define HAVE_STRPBRK 1
/* Define if you have the strstr function. */
#define HAVE_STRSTR 1
/* Define if you have the strtok_r function. */
/* #undef HAVE_STRTOK_R */
/* Define if you have the strtol function. */
#define HAVE_STRTOL 1
/* Define if you have the strtoul function. */
#define HAVE_STRTOUL 1
/* Define if you have the strtoull function. */
/* #undef HAVE_STRTOULL */
/* Define if you have the tcgetattr function. */
#define HAVE_TCGETATTR 1
/* Define if you have the tell function. */
#define HAVE_TELL 1
/* Define if you have the tempnam function. */
#define HAVE_TEMPNAM 1
/* Define if you have the thr_setconcurrency function. */
/* #undef HAVE_THR_SETCONCURRENCY */
/* Define if you have the vidattr function. */
/* #undef HAVE_VIDATTR */
/* Define if you have the <alloca.h> header file. */
/* #define HAVE_ALLOCA_H 1 */
/* Define if you have the <arpa/inet.h> header file. */
#define HAVE_ARPA_INET_H 1
/* Define if you have the <asm/termbits.h> header file. */
/* #undef HAVE_ASM_TERMBITS_H */
/* Define if you have the <crypt.h> header file. */
#define HAVE_CRYPT_H 1
/* Define if you have the <curses.h> header file. */
/* #define HAVE_CURSES_H 1 */
/* Define if you have the <dirent.h> header file. */
/* #define HAVE_DIRENT_H 1 */
/* Define if you have the <fcntl.h> header file. */
#define HAVE_FCNTL_H 1
/* Define if you have the <float.h> header file. */
#define HAVE_FLOAT_H 1
/* Define if you have the <floatingpoint.h> header file. */
/* #undef HAVE_FLOATINGPOINT_H */
/* Define if you have the <grp.h> header file. */
/* #define HAVE_GRP_H 1 */
/* Define if you have the <ieeefp.h> header file. */
/* #undef HAVE_IEEEFP_H */
/* Define if you have the <limits.h> header file. */
#define HAVE_LIMITS_H 1
/* Define if you have the <locale.h> header file. */
#define HAVE_LOCALE_H 1
/* Define if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
/* Define if you have the <ndir.h> header file. */
/* #undef HAVE_NDIR_H */
/* Define if you have the <netinet/in.h> header file. */
#define HAVE_NETINET_IN_H 1
/* Define if you have the <paths.h> header file. */
/* #undef HAVE_PATHS_H */
/* Define if you have the <pwd.h> header file. */
/* #define HAVE_PWD_H 1 */
/* Define if you have the <sched.h> header file. */
/* #undef HAVE_SCHED_H */
/* Define if you have the <select.h> header file. */
/* #undef HAVE_SELECT_H */
/* Define if you have the <stdarg.h> header file. */
#define HAVE_STDARG_H 1
/* Define if you have the <stddef.h> header file. */
#define HAVE_STDDEF_H 1
/* Define if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1
/* Define if you have the <string.h> header file. */
#define HAVE_STRING_H 1
/* Define if you have the <strings.h> header file. */
/* #define HAVE_STRINGS_H 1 */
/* Define if you have the <synch.h> header file. */
/* #undef HAVE_SYNCH_H */
/* Define if you have the <sys/dir.h> header file. */
/* #define HAVE_SYS_DIR_H 1 */
/* Define if you have the <sys/file.h> header file. */
/* #define HAVE_SYS_FILE_H 1 */
/* Define if you have the <sys/ioctl.h> header file. */
#define HAVE_SYS_IOCTL_H 1
/* Define if you have the <sys/mman.h> header file. */
/* #undef HAVE_SYS_MMAN_H */
/* Define if you have the <sys/ndir.h> header file. */
/* #undef HAVE_SYS_NDIR_H */
/* Define if you have the <sys/pte.h> header file. */
/* #undef HAVE_SYS_PTE_H */
/* Define if you have the <sys/ptem.h> header file. */
/* #undef HAVE_SYS_PTEM_H */
/* Define if you have the <sys/select.h> header file. */
#define HAVE_SYS_SELECT_H 1
/* Define if you have the <sys/socket.h> header file. */
#define HAVE_SYS_SOCKET_H 1
/* Define if you have the <sys/stream.h> header file. */
/* #undef HAVE_SYS_STREAM_H */
/* Define if you have the <sys/timeb.h> header file. */
#define HAVE_SYS_TIMEB_H 1
/* Define if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
/* Define if you have the <sys/un.h> header file. */
#define HAVE_SYS_UN_H 1
/* Define if you have the <sys/utime.h> header file. */
#define HAVE_SYS_UTIME_H 1
/* Define if you have the <sys/vadvise.h> header file. */
/* #undef HAVE_SYS_VADVISE_H */
/* Define if you have the <sys/wait.h> header file. */
/* #define HAVE_SYS_WAIT_H 1 */
/* Define if you have the <term.h> header file. */
/* #undef HAVE_TERM_H */
/* Define if you have the <termbits.h> header file. */
/* #undef HAVE_TERMBITS_H */
/* Define if you have the <termcap.h> header file. */
/* #define HAVE_TERMCAP_H 1 */
/* Define if you have the <termio.h> header file. */
/* /#define HAVE_TERMIO_H 1 */
/* Define if you have the <termios.h> header file. */
/* #define HAVE_TERMIOS_H 1 */
/* Define if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
/* Define if you have the <utime.h> header file. */
#define HAVE_UTIME_H 1
/* Define if you have the <varargs.h> header file. */
#define HAVE_VARARGS_H 1
/* Define if you have the bind library (-lbind). */
/* #undef HAVE_LIBBIND */
/* Define if you have the c_r library (-lc_r). */
/* #undef HAVE_LIBC_R */
/* Define if you have the compat library (-lcompat). */
/* #undef HAVE_LIBCOMPAT */
/* Define if you have the crypt library (-lcrypt). */
#define HAVE_LIBCRYPT 1
/* Define if you have the dl library (-ldl). */
#define HAVE_LIBDL 1
/* Define if you have the gen library (-lgen). */
/* #undef HAVE_LIBGEN */
/* Define if you have the m library (-lm). */
#define HAVE_LIBM 1
/* Define if you have the nsl library (-lnsl). */
/* #undef HAVE_LIBNSL */
/* Define if you have the nsl_r library (-lnsl_r). */
/* #undef HAVE_LIBNSL_R */
/* Define if you have the pthread library (-lpthread). */
/* #undef HAVE_LIBPTHREAD */
/* Define if you have the socket library (-lsocket). */
/* #undef HAVE_LIBSOCKET */
/* Number of bits in a file offset, on hosts where this is settable. */
/* #undef _FILE_OFFSET_BITS */
/* Define to make fseeko etc. visible, on some hosts. */
/* #undef _LARGEFILE_SOURCE */
/* Define for large files, on AIX-style hosts. */
/* #undef _LARGE_FILES */
#endif /* __CONFIG_OS2_H__ */

View File

@@ -1,461 +0,0 @@
/* Copyright (C) 2000 MySQL AB
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; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/* Defines for Win32 to make it compatible for MySQL */
#ifdef __WIN2000__
/* We have to do this define before including windows.h to get the AWE API
functions */
#define _WIN32_WINNT 0x0500
#else
/* Get NT 4.0 functions */
#define _WIN32_WINNT 0x0400
#endif
#if defined(_MSC_VER) && _MSC_VER >= 1400
/* Avoid endless warnings about sprintf() etc. being unsafe. */
#define _CRT_SECURE_NO_DEPRECATE 1
#endif
#include <sys/locking.h>
#include <windows.h>
#include <math.h> /* Because of rint() */
#include <fcntl.h>
#include <io.h>
#include <malloc.h>
#define BIG_TABLES 1
#define HAVE_SMEM 1
#if defined(_WIN64) || defined(WIN64)
#define SYSTEM_TYPE "Win64"
#elif defined(_WIN32) || defined(WIN32)
#define SYSTEM_TYPE "Win32"
#else
#define SYSTEM_TYPE "Windows"
#endif
#if defined(_M_IA64)
#define MACHINE_TYPE "ia64"
#elif defined(_M_IX86)
#define MACHINE_TYPE "ia32"
#elif defined(_M_ALPHA)
#define MACHINE_TYPE "axp"
#else
#define MACHINE_TYPE "unknown" /* Define to machine type name */
#endif
#if !(defined(_WIN64) || defined(WIN64))
#ifndef _WIN32
#define _WIN32 /* Compatible with old source */
#endif
#ifndef __WIN32__
#define __WIN32__
#endif
#endif /* _WIN64 */
#ifndef __WIN__
#define __WIN__ /* To make it easier in VC++ */
#endif
#ifndef MAX_INDEXES
#define MAX_INDEXES 64
#endif
/* File and lock constants */
#define O_SHARE 0x1000 /* Open file in sharing mode */
#ifdef __BORLANDC__
#define F_RDLCK LK_NBLCK /* read lock */
#define F_WRLCK LK_NBRLCK /* write lock */
#define F_UNLCK LK_UNLCK /* remove lock(s) */
#else
#define F_RDLCK _LK_NBLCK /* read lock */
#define F_WRLCK _LK_NBRLCK /* write lock */
#define F_UNLCK _LK_UNLCK /* remove lock(s) */
#endif
#define F_EXCLUSIVE 1 /* We have only exclusive locking */
#define F_TO_EOF (INT_MAX32/2) /* size for lock of all file */
#define F_OK 0 /* parameter to access() */
#define W_OK 2
#define S_IROTH S_IREAD /* for my_lib */
#ifdef __BORLANDC__
#define FILE_BINARY O_BINARY /* my_fopen in binary mode */
#define O_TEMPORARY 0
#define O_SHORT_LIVED 0
#define SH_DENYNO _SH_DENYNO
#else
#define O_BINARY _O_BINARY /* compability with MSDOS */
#define FILE_BINARY _O_BINARY /* my_fopen in binary mode */
#define O_TEMPORARY _O_TEMPORARY
#define O_SHORT_LIVED _O_SHORT_LIVED
#define SH_DENYNO _SH_DENYNO
#endif
#define NO_OPEN_3 /* For my_create() */
#define SIGQUIT SIGTERM /* No SIGQUIT */
#undef _REENTRANT /* Crashes something for win32 */
#undef SAFE_MUTEX /* Can't be used on windows */
#if defined(_MSC_VER) && _MSC_VER >= 1310
#define LL(A) A##ll
#define ULL(A) A##ull
#else
#define LL(A) ((__int64) A)
#define ULL(A) ((unsigned __int64) A)
#endif
#define LONGLONG_MIN LL(0x8000000000000000)
#define LONGLONG_MAX LL(0x7FFFFFFFFFFFFFFF)
#define ULONGLONG_MAX ULL(0xFFFFFFFFFFFFFFFF)
/* Type information */
#if defined(__EMX__) || !defined(HAVE_UINT)
#undef HAVE_UINT
#define HAVE_UINT
typedef unsigned short ushort;
typedef unsigned int uint;
#endif /* defined(__EMX__) || !defined(HAVE_UINT) */
typedef unsigned __int64 ulonglong; /* Microsofts 64 bit types */
typedef __int64 longlong;
#ifndef HAVE_SIGSET_T
typedef int sigset_t;
#endif
#define longlong_defined
/*
off_t should not be __int64 because of conflicts in header files;
Use my_off_t or os_off_t instead
*/
#ifndef HAVE_OFF_T
typedef long off_t;
#endif
typedef __int64 os_off_t;
#ifdef _WIN64
typedef UINT_PTR rf_SetTimer;
#else
#ifndef HAVE_SIZE_T
typedef unsigned int size_t;
#endif
typedef uint rf_SetTimer;
#endif
#define Socket_defined
#define my_socket SOCKET
#define bool BOOL
#define SIGPIPE SIGINT
#define RETQSORTTYPE void
#define QSORT_TYPE_IS_VOID
#define RETSIGTYPE void
#define SOCKET_SIZE_TYPE int
#define my_socket_defined
#define bool_defined
#define byte_defined
#define HUGE_PTR
#define STDCALL __stdcall /* Used by libmysql.dll */
#define isnan(X) _isnan(X)
#define finite(X) _finite(X)
#ifndef UNDEF_THREAD_HACK
#define THREAD
#endif
#define VOID_SIGHANDLER
#define SIZEOF_CHAR 1
#define SIZEOF_LONG 4
#define SIZEOF_LONG_LONG 8
#define SIZEOF_OFF_T 8
#ifdef _WIN64
#define SIZEOF_CHARP 8
#else
#define SIZEOF_CHARP 4
#endif
#define HAVE_BROKEN_NETINET_INCLUDES
#ifdef __NT__
#define HAVE_NAMED_PIPE /* We can only create pipes on NT */
#endif
/* ERROR is defined in wingdi.h */
#undef ERROR
/* We need to close files to break connections on shutdown */
#ifndef SIGNAL_WITH_VIO_CLOSE
#define SIGNAL_WITH_VIO_CLOSE
#endif
/* Use all character sets in MySQL */
#define USE_MB 1
#define USE_MB_IDENT 1
#define USE_STRCOLL 1
/* All windows servers should support .sym files */
#undef USE_SYMDIR
#define USE_SYMDIR
/* If LOAD DATA LOCAL INFILE should be enabled by default */
#define ENABLED_LOCAL_INFILE 1
/* Convert some simple functions to Posix */
#define my_sigset(A,B) signal((A),(B))
#define finite(A) _finite(A)
#define sleep(A) Sleep((A)*1000)
#define popen(A,B) _popen((A),(B))
#define pclose(A) _pclose(A)
#ifndef __BORLANDC__
#define access(A,B) _access(A,B)
#endif
#if !defined(__cplusplus)
#define inline __inline
#endif /* __cplusplus */
inline double rint(double nr)
{
double f = floor(nr);
double c = ceil(nr);
return (((c-nr) >= (nr-f)) ? f :c);
}
#ifdef _WIN64
#define ulonglong2double(A) ((double) (ulonglong) (A))
#define my_off_t2double(A) ((double) (my_off_t) (A))
#else
inline double ulonglong2double(ulonglong value)
{
longlong nr=(longlong) value;
if (nr >= 0)
return (double) nr;
return (18446744073709551616.0 + (double) nr);
}
#define my_off_t2double(A) ulonglong2double(A)
#endif /* _WIN64 */
#if SIZEOF_OFF_T > 4
#define lseek(A,B,C) _lseeki64((A),(longlong) (B),(C))
#define tell(A) _telli64(A)
#endif
#define STACK_DIRECTION -1
/* Optimized store functions for Intel x86 */
#ifndef _WIN64
#define sint2korr(A) (*((int16 *) (A)))
#define sint3korr(A) ((int32) ((((uchar) (A)[2]) & 128) ? \
(((uint32) 255L << 24) | \
(((uint32) (uchar) (A)[2]) << 16) |\
(((uint32) (uchar) (A)[1]) << 8) | \
((uint32) (uchar) (A)[0])) : \
(((uint32) (uchar) (A)[2]) << 16) |\
(((uint32) (uchar) (A)[1]) << 8) | \
((uint32) (uchar) (A)[0])))
#define sint4korr(A) (*((long *) (A)))
#define uint2korr(A) (*((uint16 *) (A)))
/*
ATTENTION !
Please, note, uint3korr reads 4 bytes (not 3) !
It means, that you have to provide enough allocated space !
*/
#define uint3korr(A) (long) (*((unsigned int *) (A)) & 0xFFFFFF)
#define uint4korr(A) (*((unsigned long *) (A)))
#define uint5korr(A) ((ulonglong)(((uint32) ((uchar) (A)[0])) +\
(((uint32) ((uchar) (A)[1])) << 8) +\
(((uint32) ((uchar) (A)[2])) << 16) +\
(((uint32) ((uchar) (A)[3])) << 24)) +\
(((ulonglong) ((uchar) (A)[4])) << 32))
#define uint8korr(A) (*((ulonglong *) (A)))
#define sint8korr(A) (*((longlong *) (A)))
#define int2store(T,A) *((uint16*) (T))= (uint16) (A)
#define int3store(T,A) { *(T)= (uchar) ((A));\
*(T+1)=(uchar) (((uint) (A) >> 8));\
*(T+2)=(uchar) (((A) >> 16)); }
#define int4store(T,A) *((long *) (T))= (long) (A)
#define int5store(T,A) { *(T)= (uchar)((A));\
*((T)+1)=(uchar) (((A) >> 8));\
*((T)+2)=(uchar) (((A) >> 16));\
*((T)+3)=(uchar) (((A) >> 24)); \
*((T)+4)=(uchar) (((A) >> 32)); }
#define int8store(T,A) *((ulonglong *) (T))= (ulonglong) (A)
#define doubleget(V,M) do { *((long *) &V) = *((long*) M); \
*(((long *) &V)+1) = *(((long*) M)+1); } while(0)
#define doublestore(T,V) do { *((long *) T) = *((long*) &V); \
*(((long *) T)+1) = *(((long*) &V)+1); } while(0)
#define float4get(V,M) { *((long *) &(V)) = *((long*) (M)); }
#define floatstore(T,V) memcpy((byte*)(T), (byte*)(&V), sizeof(float))
#define floatget(V,M) memcpy((byte*)(&V), (byte*)(M), sizeof(float))
#define float8get(V,M) doubleget((V),(M))
#define float4store(V,M) memcpy((byte*) V,(byte*) (&M),sizeof(float))
#define float8store(V,M) doublestore((V),(M))
#endif /* _WIN64 */
#define HAVE_PERROR
#define HAVE_VFPRINT
#define HAVE_RENAME /* Have rename() as function */
#define HAVE_BINARY_STREAMS /* Have "b" flag in streams */
#define HAVE_LONG_JMP /* Have long jump function */
#define HAVE_LOCKING /* have locking() call */
#define HAVE_ERRNO_AS_DEFINE /* errno is a define */
#define HAVE_STDLIB /* everything is include in this file */
#define HAVE_MEMCPY
#define HAVE_MEMMOVE
#define HAVE_GETCWD
#define HAVE_TELL
#define HAVE_TZNAME
#define HAVE_PUTENV
#define HAVE_SELECT
#define HAVE_SETLOCALE
#define HAVE_SOCKET /* Giangi */
#define HAVE_FLOAT_H
#define HAVE_LIMITS_H
#define HAVE_STDDEF_H
#define HAVE_RINT /* defined in this file */
#define NO_FCNTL_NONBLOCK /* No FCNTL */
#define HAVE_ALLOCA
#define HAVE_STRPBRK
#define HAVE_STRSTR
#define HAVE_COMPRESS
#define HAVE_CREATESEMAPHORE
#define HAVE_ISNAN
#define HAVE_FINITE
#define HAVE_QUERY_CACHE
#define SPRINTF_RETURNS_INT
#define HAVE_SETFILEPOINTER
#define HAVE_VIO_READ_BUFF
#define HAVE_STRNLEN
#ifndef __NT__
#undef FILE_SHARE_DELETE
#define FILE_SHARE_DELETE 0 /* Not implemented on Win 98/ME */
#endif
#ifdef NOT_USED
#define HAVE_SNPRINTF /* Gave link error */
#define _snprintf snprintf
#endif
#ifdef _MSC_VER
#define HAVE_LDIV /* The optimizer breaks in zortech for ldiv */
#define HAVE_ANSI_INCLUDE
#define HAVE_SYS_UTIME_H
#define HAVE_STRTOUL
#endif
#define my_reinterpret_cast(A) reinterpret_cast <A>
#define my_const_cast(A) const_cast<A>
/* MYSQL OPTIONS */
#ifdef _CUSTOMCONFIG_
#include <custom_conf.h>
#else
#define DEFAULT_MYSQL_HOME "c:\\mysql"
#define DATADIR "c:\\mysql\\data"
#define PACKAGE "mysql"
#define DEFAULT_BASEDIR "C:\\"
#define SHAREDIR "share"
#define DEFAULT_CHARSET_HOME "C:/mysql/"
#endif
#ifndef DEFAULT_HOME_ENV
#define DEFAULT_HOME_ENV MYSQL_HOME
#endif
#ifndef DEFAULT_GROUP_SUFFIX_ENV
#define DEFAULT_GROUP_SUFFIX_ENV MYSQL_GROUP_SUFFIX
#endif
/* File name handling */
#define FN_LIBCHAR '\\'
#define FN_ROOTDIR "\\"
#define FN_DEVCHAR ':'
#define FN_NETWORK_DRIVES /* Uses \\ to indicate network drives */
#define FN_NO_CASE_SENCE /* Files are not case-sensitive */
#define OS_FILE_LIMIT 2048
#define DO_NOT_REMOVE_THREAD_WRAPPERS
#define thread_safe_increment(V,L) InterlockedIncrement((long*) &(V))
#define thread_safe_decrement(V,L) InterlockedDecrement((long*) &(V))
/* The following is only used for statistics, so it should be good enough */
#ifdef __NT__ /* This should also work on Win98 but .. */
#define thread_safe_add(V,C,L) InterlockedExchangeAdd((long*) &(V),(C))
#define thread_safe_sub(V,C,L) InterlockedExchangeAdd((long*) &(V),-(long) (C))
#define statistic_add(V,C,L) thread_safe_add((V),(C),(L))
#else
#define thread_safe_add(V,C,L) \
pthread_mutex_lock((L)); (V)+=(C); pthread_mutex_unlock((L));
#define thread_safe_sub(V,C,L) \
pthread_mutex_lock((L)); (V)-=(C); pthread_mutex_unlock((L));
#define statistic_add(V,C,L) (V)+=(C)
#endif
#define statistic_increment(V,L) thread_safe_increment((V),(L))
#define statistic_decrement(V,L) thread_safe_decrement((V),(L))
#define shared_memory_buffer_length 16000
#define default_shared_memory_base_name "MYSQL"
#define MYSQL_DEFAULT_CHARSET_NAME "latin1"
#define MYSQL_DEFAULT_COLLATION_NAME "latin1_swedish_ci"
#define HAVE_SPATIAL 1
#define HAVE_RTREE_KEYS 1
#define HAVE_OPENSSL 1
#define HAVE_YASSL 1
/* Define charsets you want */
/* #undef HAVE_CHARSET_armscii8 */
/* #undef HAVE_CHARSET_ascii */
#define HAVE_CHARSET_big5 1
#define HAVE_CHARSET_cp1250 1
/* #undef HAVE_CHARSET_cp1251 */
/* #undef HAVE_CHARSET_cp1256 */
/* #undef HAVE_CHARSET_cp1257 */
/* #undef HAVE_CHARSET_cp850 */
/* #undef HAVE_CHARSET_cp852 */
/* #undef HAVE_CHARSET_cp866 */
#define HAVE_CHARSET_cp932 1
/* #undef HAVE_CHARSET_dec8 */
#define HAVE_CHARSET_eucjpms 1
#define HAVE_CHARSET_euckr 1
#define HAVE_CHARSET_gb2312 1
#define HAVE_CHARSET_gbk 1
/* #undef HAVE_CHARSET_greek */
/* #undef HAVE_CHARSET_hebrew */
/* #undef HAVE_CHARSET_hp8 */
/* #undef HAVE_CHARSET_keybcs2 */
/* #undef HAVE_CHARSET_koi8r */
/* #undef HAVE_CHARSET_koi8u */
#define HAVE_CHARSET_latin1 1
#define HAVE_CHARSET_latin2 1
/* #undef HAVE_CHARSET_latin5 */
/* #undef HAVE_CHARSET_latin7 */
/* #undef HAVE_CHARSET_macce */
/* #undef HAVE_CHARSET_macroman */
#define HAVE_CHARSET_sjis 1
/* #undef HAVE_CHARSET_swe7 */
#define HAVE_CHARSET_tis620 1
#define HAVE_CHARSET_ucs2 1
#define HAVE_CHARSET_ujis 1
#define HAVE_CHARSET_utf8 1
#define HAVE_UCA_COLLATIONS 1

View File

@@ -1,267 +0,0 @@
/* Copyright (C) 2000 MySQL AB
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; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/* There may be prolems include all of theese. Try to test in
configure with ones are needed? */
/* This is needed for the definitions of strchr... on solaris */
#ifndef _m_string_h
#define _m_string_h
#ifndef __USE_GNU
#define __USE_GNU /* We want to use stpcpy */
#endif
#if defined(HAVE_STRINGS_H)
#include <strings.h>
#endif
#if defined(HAVE_STRING_H)
#include <string.h>
#endif
/* need by my_vsnprintf */
#include <stdarg.h>
/* Correct some things for UNIXWARE7 */
#ifdef HAVE_UNIXWARE7_THREADS
#undef HAVE_STRINGS_H
#undef HAVE_MEMORY_H
#define HAVE_MEMCPY
#ifndef HAVE_MEMMOVE
#define HAVE_MEMMOVE
#endif
#undef HAVE_BCMP
#undef bcopy
#undef bcmp
#undef bzero
#endif /* HAVE_UNIXWARE7_THREADS */
#ifdef _AIX
#undef HAVE_BCMP
#endif
/* This is needed for the definitions of bzero... on solaris */
#if defined(HAVE_STRINGS_H) && !defined(HAVE_mit_thread)
#include <strings.h>
#endif
/* This is needed for the definitions of memcpy... on solaris */
#if defined(HAVE_MEMORY_H) && !defined(__cplusplus)
#include <memory.h>
#endif
#if !defined(HAVE_MEMCPY) && !defined(HAVE_MEMMOVE)
# define memcpy(d, s, n) bcopy ((s), (d), (n))
# define memset(A,C,B) bfill((A),(B),(C))
# define memmove(d, s, n) bmove ((d), (s), (n))
#elif defined(HAVE_MEMMOVE)
# define bmove(d, s, n) memmove((d), (s), (n))
#else
# define memmove(d, s, n) bmove((d), (s), (n)) /* our bmove */
#endif
/* Unixware 7 */
#if !defined(HAVE_BFILL)
# define bfill(A,B,C) memset((A),(C),(B))
# define bmove_align(A,B,C) memcpy((A),(B),(C))
#endif
#if !defined(HAVE_BCMP)
# define bcopy(s, d, n) memcpy((d), (s), (n))
# define bcmp(A,B,C) memcmp((A),(B),(C))
# define bzero(A,B) memset((A),0,(B))
# define bmove_align(A,B,C) memcpy((A),(B),(C))
#endif
#if defined(__cplusplus) && !defined(OS2)
extern "C" {
#endif
/*
my_str_malloc() and my_str_free() are assigned to implementations in
strings/alloc.c, but can be overridden in the calling program.
*/
extern void *(*my_str_malloc)(size_t);
extern void (*my_str_free)(void *);
#if defined(HAVE_STPCPY) && !defined(HAVE_mit_thread)
#define strmov(A,B) stpcpy((A),(B))
#ifndef stpcpy
extern char *stpcpy(char *, const char *); /* For AIX with gcc 2.95.3 */
#endif
#endif
/* Declared in int2str() */
extern char NEAR _dig_vec_upper[];
extern char NEAR _dig_vec_lower[];
/* Defined in strtod.c */
extern const double log_10[309];
#ifdef BAD_STRING_COMPILER
#define strmov(A,B) (memccpy(A,B,0,INT_MAX)-1)
#else
#define strmov_overlapp(A,B) strmov(A,B)
#define strmake_overlapp(A,B,C) strmake(A,B,C)
#endif
#ifdef BAD_MEMCPY /* Problem with gcc on Alpha */
#define memcpy_fixed(A,B,C) bmove((A),(B),(C))
#else
#define memcpy_fixed(A,B,C) memcpy((A),(B),(C))
#endif
#ifdef MSDOS
#undef bmove_align
#define bmove512(A,B,C) bmove_align(A,B,C)
extern void bmove_align(gptr dst,const gptr src,uint len);
#endif
#if (!defined(USE_BMOVE512) || defined(HAVE_purify)) && !defined(bmove512)
#define bmove512(A,B,C) memcpy(A,B,C)
#endif
/* Prototypes for string functions */
#if !defined(bfill) && !defined(HAVE_BFILL)
extern void bfill(gptr dst,uint len,pchar fill);
#endif
#if !defined(bzero) && !defined(HAVE_BZERO)
extern void bzero(gptr dst,uint len);
#endif
#if !defined(bcmp) && !defined(HAVE_BCMP)
extern int bcmp(const char *s1,const char *s2,uint len);
#endif
#ifdef HAVE_purify
extern int my_bcmp(const char *s1,const char *s2,uint len);
#undef bcmp
#define bcmp(A,B,C) my_bcmp((A),(B),(C))
#endif
#ifndef bmove512
extern void bmove512(gptr dst,const gptr src,uint len);
#endif
#if !defined(HAVE_BMOVE) && !defined(bmove)
extern void bmove(char *dst, const char *src,uint len);
#endif
extern void bmove_upp(char *dst,const char *src,uint len);
extern void bchange(char *dst,uint old_len,const char *src,
uint new_len,uint tot_len);
extern void strappend(char *s,uint len,pchar fill);
extern char *strend(const char *s);
extern char *strcend(const char *, pchar);
extern char *strfield(char *src,int fields,int chars,int blanks,
int tabch);
extern char *strfill(my_string s,uint len,pchar fill);
extern uint strinstr(const char *str,const char *search);
extern uint r_strinstr(reg1 my_string str,int from, reg4 my_string search);
extern char *strkey(char *dst,char *head,char *tail,char *flags);
extern char *strmake(char *dst,const char *src,uint length);
#ifndef strmake_overlapp
extern char *strmake_overlapp(char *dst,const char *src, uint length);
#endif
#ifndef strmov
extern char *strmov(char *dst,const char *src);
#endif
extern char *strnmov(char *dst,const char *src,uint n);
extern char *strsuff(const char *src,const char *suffix);
extern char *strcont(const char *src,const char *set);
extern char *strxcat _VARARGS((char *dst,const char *src, ...));
extern char *strxmov _VARARGS((char *dst,const char *src, ...));
extern char *strxcpy _VARARGS((char *dst,const char *src, ...));
extern char *strxncat _VARARGS((char *dst,uint len, const char *src, ...));
extern char *strxnmov _VARARGS((char *dst,uint len, const char *src, ...));
extern char *strxncpy _VARARGS((char *dst,uint len, const char *src, ...));
/* Prototypes of normal stringfunctions (with may ours) */
#ifdef WANT_STRING_PROTOTYPES
extern char *strcat(char *, const char *);
extern char *strchr(const char *, pchar);
extern char *strrchr(const char *, pchar);
extern char *strcpy(char *, const char *);
extern int strcmp(const char *, const char *);
#ifndef __GNUC__
extern size_t strlen(const char *);
#endif
#endif
#ifndef HAVE_STRNLEN
extern uint strnlen(const char *s, uint n);
#endif
#if !defined(__cplusplus)
#ifndef HAVE_STRPBRK
extern char *strpbrk(const char *, const char *);
#endif
#ifndef HAVE_STRSTR
extern char *strstr(const char *, const char *);
#endif
#endif
extern int is_prefix(const char *, const char *);
/* Conversion routines */
double my_strtod(const char *str, char **end, int *error);
double my_atof(const char *nptr);
extern char *llstr(longlong value,char *buff);
extern char *ullstr(longlong value,char *buff);
#ifndef HAVE_STRTOUL
extern long strtol(const char *str, char **ptr, int base);
extern ulong strtoul(const char *str, char **ptr, int base);
#endif
extern char *int2str(long val, char *dst, int radix, int upcase);
extern char *int10_to_str(long val,char *dst,int radix);
extern char *str2int(const char *src,int radix,long lower,long upper,
long *val);
longlong my_strtoll10(const char *nptr, char **endptr, int *error);
#if SIZEOF_LONG == SIZEOF_LONG_LONG
#define longlong2str(A,B,C) int2str((A),(B),(C),1)
#define longlong10_to_str(A,B,C) int10_to_str((A),(B),(C))
#undef strtoll
#define strtoll(A,B,C) strtol((A),(B),(C))
#define strtoull(A,B,C) strtoul((A),(B),(C))
#ifndef HAVE_STRTOULL
#define HAVE_STRTOULL
#endif
#ifndef HAVE_STRTOLL
#define HAVE_STRTOLL
#endif
#else
#ifdef HAVE_LONG_LONG
extern char *longlong2str(longlong val,char *dst,int radix);
extern char *longlong10_to_str(longlong val,char *dst,int radix);
#if (!defined(HAVE_STRTOULL) || defined(HAVE_mit_thread)) || defined(NO_STRTOLL_PROTO)
extern longlong strtoll(const char *str, char **ptr, int base);
extern ulonglong strtoull(const char *str, char **ptr, int base);
#endif
#endif
#endif
/* my_vsnprintf.c */
extern int my_vsnprintf( char *str, size_t n,
const char *format, va_list ap );
extern int my_snprintf(char *to, size_t n, const char *fmt, ...)
ATTRIBUTE_FORMAT(printf, 3, 4);
#if defined(__cplusplus) && !defined(OS2)
}
#endif
#endif

View File

@@ -1,108 +0,0 @@
/* Copyright (C) 2000 MySQL AB
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; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#ifndef _dbug_h
#define _dbug_h
#ifdef __cplusplus
extern "C" {
#endif
#if !defined(DBUG_OFF) && !defined(_lint)
extern int _db_on_,_no_db_;
extern FILE *_db_fp_;
extern char *_db_process_;
extern int _db_keyword_(const char *keyword);
extern int _db_strict_keyword_(const char *keyword);
extern void _db_setjmp_(void);
extern void _db_longjmp_(void);
extern void _db_push_(const char *control);
extern void _db_pop_(void);
extern void _db_enter_(const char *_func_,const char *_file_,uint _line_,
const char **_sfunc_,const char **_sfile_,
uint *_slevel_, char ***);
extern void _db_return_(uint _line_,const char **_sfunc_,const char **_sfile_,
uint *_slevel_);
extern void _db_pargs_(uint _line_,const char *keyword);
extern void _db_doprnt_ _VARARGS((const char *format,...))
ATTRIBUTE_FORMAT(printf, 1, 2);
extern void _db_dump_(uint _line_,const char *keyword,const char *memory,
uint length);
extern void _db_output_(uint flag);
extern void _db_end_(void);
extern void _db_lock_file(void);
extern void _db_unlock_file(void);
#define DBUG_ENTER(a) const char *_db_func_, *_db_file_; uint _db_level_; \
char **_db_framep_; \
_db_enter_ (a,__FILE__,__LINE__,&_db_func_,&_db_file_,&_db_level_, \
&_db_framep_)
#define DBUG_LEAVE \
(_db_return_ (__LINE__, &_db_func_, &_db_file_, &_db_level_))
#define DBUG_RETURN(a1) {DBUG_LEAVE; return(a1);}
#define DBUG_VOID_RETURN {DBUG_LEAVE; return;}
#define DBUG_EXECUTE(keyword,a1) \
{if (_db_on_) {if (_db_keyword_ (keyword)) { a1 }}}
#define DBUG_PRINT(keyword,arglist) \
{if (_db_on_) {_db_pargs_(__LINE__,keyword); _db_doprnt_ arglist;}}
#define DBUG_PUSH(a1) _db_push_ (a1)
#define DBUG_POP() _db_pop_ ()
#define DBUG_PROCESS(a1) (_db_process_ = a1)
#define DBUG_FILE (_db_fp_)
#define DBUG_SETJMP(a1) (_db_setjmp_ (), setjmp (a1))
#define DBUG_LONGJMP(a1,a2) (_db_longjmp_ (), longjmp (a1, a2))
#define DBUG_DUMP(keyword,a1,a2)\
{if (_db_on_) {_db_dump_(__LINE__,keyword,a1,a2);}}
#define DBUG_IN_USE (_db_fp_ && _db_fp_ != stderr)
#define DEBUGGER_OFF _no_db_=1;_db_on_=0;
#define DEBUGGER_ON _no_db_=0
#define DBUG_END() _db_end_ ()
#define DBUG_LOCK_FILE { _db_lock_file(); }
#define DBUG_UNLOCK_FILE { _db_unlock_file(); }
#define DBUG_OUTPUT(A) { _db_output_(A); }
#define DBUG_ASSERT(A) assert(A)
#define DBUG_EXECUTE_IF(keyword,a1) \
{if (_db_on_) {if (_db_strict_keyword_ (keyword)) { a1 }}}
#define IF_DBUG(A) A
#else /* No debugger */
#define DBUG_ENTER(a1)
#define DBUG_RETURN(a1) return(a1)
#define DBUG_VOID_RETURN return
#define DBUG_EXECUTE(keyword,a1) {}
#define DBUG_EXECUTE_IF(keyword,a1) {}
#define DBUG_PRINT(keyword,arglist) {}
#define DBUG_PUSH(a1) {}
#define DBUG_POP() {}
#define DBUG_PROCESS(a1) {}
#define DBUG_FILE (stderr)
#define DBUG_SETJMP setjmp
#define DBUG_LONGJMP longjmp
#define DBUG_DUMP(keyword,a1,a2) {}
#define DBUG_IN_USE 0
#define DEBUGGER_OFF
#define DEBUGGER_ON
#define DBUG_END()
#define DBUG_LOCK_FILE
#define DBUG_UNLOCK_FILE
#define DBUG_OUTPUT(A)
#define DBUG_ASSERT(A) {}
#define DBUG_LEAVE
#define IF_DBUG(A)
#endif
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -1,31 +0,0 @@
/* Copyright Abandoned 1996, 1999, 2001 MySQL AB
This file is public domain and comes with NO WARRANTY of any kind */
/* Version numbers for protocol & mysqld */
#ifndef _mysql_version_h
#define _mysql_version_h
#ifdef _CUSTOMCONFIG_
#include <custom_conf.h>
#else
#define PROTOCOL_VERSION 10
#define MYSQL_SERVER_VERSION "5.0.56"
#define MYSQL_BASE_VERSION "mysqld-5.0"
#define MYSQL_SERVER_SUFFIX_DEF "-nt"
#define FRM_VER 6
#define MYSQL_VERSION_ID 50056
#define MYSQL_PORT 3306
#define MYSQL_PORT_DEFAULT 0
#define MYSQL_UNIX_ADDR "/tmp/mysql.sock"
#define MYSQL_CONFIG_NAME "my"
#define MYSQL_COMPILATION_COMMENT "From Sources"
/* mysqld compile time options */
#endif /* _CUSTOMCONFIG_ */
#ifndef LICENSE
#define LICENSE GPL
#endif /* LICENSE */
#endif /* _mysql_version_h */

View File

@@ -1,159 +0,0 @@
/* Copyright (C) 2000 MySQL AB
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; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/* Parser needs these defines always, even if USE_RAID is not defined */
#define RAID_TYPE_0 1 /* Striping */
#define RAID_TYPE_x 2 /* Some new modes */
#define RAID_TYPE_y 3
#define RAID_DEFAULT_CHUNKS 4
#define RAID_DEFAULT_CHUNKSIZE 256*1024 /* 256kB */
C_MODE_START
#define my_raid_type(raid_type) raid_type_string[(int)(raid_type)]
extern const char *raid_type_string[];
C_MODE_END
#ifdef DONT_USE_RAID
#undef USE_RAID
#endif
#if defined(USE_RAID)
#include "my_dir.h"
/* Trap all occurences of my_...() in source and use our wrapper around this function */
#ifdef MAP_TO_USE_RAID
#define my_read(A,B,C,D) my_raid_read(A,B,C,D)
#define my_write(A,B,C,D) my_raid_write(A,B,C,D)
#define my_pwrite(A,B,C,D,E) my_raid_pwrite(A,B,C,D,E)
#define my_pread(A,B,C,D,E) my_raid_pread(A,B,C,D,E)
#define my_chsize(A,B,C,D) my_raid_chsize(A,B,C,D)
#define my_close(A,B) my_raid_close(A,B)
#define my_tell(A,B) my_raid_tell(A,B)
#define my_seek(A,B,C,D) my_raid_seek(A,B,C,D)
#define my_lock(A,B,C,D,E) my_raid_lock(A,B,C,D,E)
#define my_fstat(A,B,C) my_raid_fstat(A,B,C)
#endif /* MAP_TO_USE_RAID */
#ifdef __cplusplus
extern "C" {
#endif
void init_raid(void);
void end_raid(void);
bool is_raid(File fd);
File my_raid_create(const char *FileName, int CreateFlags, int access_flags,
uint raid_type, uint raid_chunks, ulong raid_chunksize,
myf MyFlags);
File my_raid_open(const char *FileName, int Flags,
uint raid_type, uint raid_chunks, ulong raid_chunksize,
myf MyFlags);
int my_raid_rename(const char *from, const char *to, uint raid_chunks,
myf MyFlags);
int my_raid_delete(const char *from, uint raid_chunks, myf MyFlags);
int my_raid_redel(const char *old_name, const char *new_name,
uint raid_chunks, myf MyFlags);
my_off_t my_raid_seek(File fd, my_off_t pos, int whence, myf MyFlags);
my_off_t my_raid_tell(File fd, myf MyFlags);
uint my_raid_write(File,const byte *Buffer, uint Count, myf MyFlags);
uint my_raid_read(File Filedes, byte *Buffer, uint Count, myf MyFlags);
uint my_raid_pread(File Filedes, byte *Buffer, uint Count, my_off_t offset,
myf MyFlags);
uint my_raid_pwrite(int Filedes, const byte *Buffer, uint Count,
my_off_t offset, myf MyFlags);
int my_raid_lock(File,int locktype, my_off_t start, my_off_t length,
myf MyFlags);
int my_raid_chsize(File fd, my_off_t newlength, int filler, myf MyFlags);
int my_raid_close(File, myf MyFlags);
int my_raid_fstat(int Filedes, struct stat *buf, myf MyFlags);
#ifdef __cplusplus
}
#ifdef USE_PRAGMA_INTERFACE
#pragma interface /* gcc class implementation */
#endif
class RaidName {
public:
RaidName(const char *FileName);
~RaidName();
bool IsRaid();
int Rename(const char * from, const char * to, myf MyFlags);
private:
uint _raid_type; /* RAID_TYPE_0 or RAID_TYPE_1 or RAID_TYPE_5 */
uint _raid_chunks; /* 1..n */
ulong _raid_chunksize; /* 1..n in bytes */
};
class RaidFd {
public:
RaidFd(uint raid_type, uint raid_chunks , ulong raid_chunksize);
~RaidFd();
File Create(const char *FileName, int CreateFlags, int access_flags,
myf MyFlags);
File Open(const char *FileName, int Flags, myf MyFlags);
my_off_t Seek(my_off_t pos,int whence,myf MyFlags);
my_off_t Tell(myf MyFlags);
int Write(const byte *Buffer, uint Count, myf MyFlags);
int Read(const byte *Buffer, uint Count, myf MyFlags);
int Lock(int locktype, my_off_t start, my_off_t length, myf MyFlags);
int Chsize(File fd, my_off_t newlength, int filler, myf MyFlags);
int Fstat(int fd, MY_STAT *stat_area, myf MyFlags );
int Close(myf MyFlags);
static bool IsRaid(File fd);
static DYNAMIC_ARRAY _raid_map; /* Map of RaidFD* */
private:
uint _raid_type; /* RAID_TYPE_0 or RAID_TYPE_1 or RAID_TYPE_5 */
uint _raid_chunks; /* 1..n */
ulong _raid_chunksize; /* 1..n in bytes */
ulong _total_block; /* We are operating with block no x (can be 0..many). */
uint _this_block; /* can be 0.._raid_chunks */
uint _remaining_bytes; /* Maximum bytes that can be written in this block */
my_off_t _position;
my_off_t _size; /* Cached file size for faster seek(SEEK_END) */
File _fd;
File *_fd_vector; /* Array of File */
off_t *_seek_vector; /* Array of cached seek positions */
inline void Calculate()
{
DBUG_ENTER("RaidFd::_Calculate");
DBUG_PRINT("info",("_position: %lu _raid_chunksize: %lu _size: %lu",
(ulong) _position, _raid_chunksize, (ulong) _size));
_total_block = (ulong) (_position / _raid_chunksize);
_this_block = _total_block % _raid_chunks; /* can be 0.._raid_chunks */
_remaining_bytes = (uint) (_raid_chunksize -
(_position - _total_block * _raid_chunksize));
DBUG_PRINT("info",
("_total_block: %lu this_block: %d _remaining_bytes: %d",
_total_block, _this_block, _remaining_bytes));
DBUG_VOID_RETURN;
}
};
#endif /* __cplusplus */
#endif /* USE_RAID */

View File

@@ -1,77 +0,0 @@
/** \file Base64.h
** \date 2004-02-13
** \author grymse@alhem.net
**/
/*
Copyright (C) 2004-2007 Anders Hedstrom
This library is made available under the terms of the GNU GPL.
If you would like to use this library in a closed-source application,
a separate license agreement is available. For information about
the closed-source license agreement for the C++ sockets library,
please visit http://www.alhem.net/Sockets/license.html and/or
email license@alhem.net.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETS_Base64_H
#define _SOCKETS_Base64_H
#include "sockets-config.h"
#ifdef _MSC_VER
#pragma warning(disable:4514)
#endif
#include <stdio.h>
#include <string>
#ifdef SOCKETS_NAMESPACE
namespace SOCKETS_NAMESPACE {
#endif
/** \defgroup util Utilities */
/** Base64 encode/decode.
\ingroup util */
class Base64
{
public:
Base64();
void encode(FILE *, std::string& , bool add_crlf = true);
void encode(const std::string&, std::string& , bool add_crlf = true);
void encode(const char *, size_t, std::string& , bool add_crlf = true);
void encode(const unsigned char *, size_t, std::string& , bool add_crlf = true);
void decode(const std::string&, std::string& );
void decode(const std::string&, unsigned char *, size_t&);
size_t decode_length(const std::string& );
private:
Base64(const Base64& ) {}
Base64& operator=(const Base64& ) { return *this; }
static const char *bstr;
static const char rstr[128];
};
#ifdef SOCKETS_NAMESPACE
}
#endif
#endif // _SOCKETS_Base64_H

View File

@@ -1,55 +0,0 @@
/**
** \file Exception.h
** \date 2007-09-28
** \author grymse@alhem.net
**/
/*
Copyright (C) 2007 Anders Hedstrom
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _Sockets_Exception_H
#define _Sockets_Exception_H
#include <string>
#ifdef SOCKETS_NAMESPACE
namespace SOCKETS_NAMESPACE {
#endif
class Exception
{
public:
Exception(const std::string& description);
virtual ~Exception() {}
virtual const std::string ToString() const;
Exception(const Exception& ) {} // copy constructor
Exception& operator=(const Exception& ) { return *this; } // assignment operator
private:
std::string m_description;
};
#ifdef SOCKETS_NAMESPACE
} // namespace SOCKETS_NAMESPACE {
#endif
#endif // _Sockets_Exception_H

View File

@@ -1,82 +0,0 @@
/** \file File.h
** \date 2005-04-25
** \author grymse@alhem.net
**/
/*
Copyright (C) 2004-2007 Anders Hedstrom
This library is made available under the terms of the GNU GPL.
If you would like to use this library in a closed-source application,
a separate license agreement is available. For information about
the closed-source license agreement for the C++ sockets library,
please visit http://www.alhem.net/Sockets/license.html and/or
email license@alhem.net.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETS_File_H
#define _SOCKETS_File_H
#include "sockets-config.h"
#include "IFile.h"
#include <stdio.h>
#ifdef SOCKETS_NAMESPACE
namespace SOCKETS_NAMESPACE {
#endif
/** IFile implementation of a disk file.
\ingroup file */
class File : public IFile
{
public:
File();
~File();
bool fopen(const std::string&, const std::string&);
void fclose();
size_t fread(char *, size_t, size_t) const;
size_t fwrite(const char *, size_t, size_t);
char *fgets(char *, int) const;
void fprintf(const char *format, ...);
off_t size() const;
bool eof() const;
void reset_read() const;
void reset_write();
private:
File(const File& ) {} // copy constructor
File& operator=(const File& ) { return *this; } // assignment operator
std::string m_path;
std::string m_mode;
FILE *m_fil;
mutable long m_rptr;
long m_wptr;
};
#ifdef SOCKETS_NAMESPACE
}
#endif
#endif // _SOCKETS_File_H

View File

@@ -1,71 +0,0 @@
/** \file IFile.h
** \date 2005-04-25
** \author grymse@alhem.net
**/
/*
Copyright (C) 2004-2007 Anders Hedstrom
This library is made available under the terms of the GNU GPL.
If you would like to use this library in a closed-source application,
a separate license agreement is available. For information about
the closed-source license agreement for the C++ sockets library,
please visit http://www.alhem.net/Sockets/license.html and/or
email license@alhem.net.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETS_IFile_H
#define _SOCKETS_IFile_H
#include "sockets-config.h"
#include <string>
#ifdef SOCKETS_NAMESPACE
namespace SOCKETS_NAMESPACE {
#endif
/** \defgroup file File handling */
/** Pure virtual file I/O interface.
\ingroup file */
class IFile
{
public:
virtual ~IFile() {}
virtual bool fopen(const std::string&, const std::string&) = 0;
virtual void fclose() = 0;
virtual size_t fread(char *, size_t, size_t) const = 0;
virtual size_t fwrite(const char *, size_t, size_t) = 0;
virtual char *fgets(char *, int) const = 0;
virtual void fprintf(const char *format, ...) = 0;
virtual off_t size() const = 0;
virtual bool eof() const = 0;
virtual void reset_read() const = 0;
virtual void reset_write() = 0;
};
#ifdef SOCKETS_NAMESPACE
}
#endif
#endif // _SOCKETS_IFile_H

View File

@@ -1,231 +0,0 @@
/** \file ISocketHandler.h
** \date 2004-02-13
** \author grymse@alhem.net
**/
/*
Copyright (C) 2004-2007 Anders Hedstrom
This library is made available under the terms of the GNU GPL.
If you would like to use this library in a closed-source application,
a separate license agreement is available. For information about
the closed-source license agreement for the C++ sockets library,
please visit http://www.alhem.net/Sockets/license.html and/or
email license@alhem.net.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETS_ISocketHandler_H
#define _SOCKETS_ISocketHandler_H
#include "sockets-config.h"
#include <list>
#include "socket_include.h"
#include "Socket.h"
#include "StdLog.h"
#ifdef SOCKETS_NAMESPACE
namespace SOCKETS_NAMESPACE {
#endif
typedef enum {
LIST_CALLONCONNECT = 0,
#ifdef ENABLE_DETACH
LIST_DETACH,
#endif
LIST_TIMEOUT,
LIST_RETRY,
LIST_CLOSE
} list_t;
class SocketAddress;
class Mutex;
/** Socket container class, event generator.
\ingroup basic */
class ISocketHandler
{
friend class Socket;
public:
/** Connection pool class for internal use by the ISocketHandler.
\ingroup internal */
#ifdef ENABLE_POOL
class PoolSocket : public Socket
{
public:
PoolSocket(ISocketHandler& h,Socket *src) : Socket(h) {
CopyConnection( src );
SetIsClient();
}
void OnRead() {
Handler().LogError(this, "OnRead", 0, "data on hibernating socket", LOG_LEVEL_FATAL);
SetCloseAndDelete();
}
void OnOptions(int,int,int,SOCKET) {}
};
#endif
public:
virtual ~ISocketHandler() {}
/** Get mutex reference for threadsafe operations. */
virtual Mutex& GetMutex() const = 0;
/** Register StdLog object for error callback.
\param log Pointer to log class */
virtual void RegStdLog(StdLog *log) = 0;
/** Log error to log class for print out / storage. */
virtual void LogError(Socket *p,const std::string& user_text,int err,const std::string& sys_err,loglevel_t t = LOG_LEVEL_WARNING) = 0;
// -------------------------------------------------------------------------
// Socket stuff
// -------------------------------------------------------------------------
/** Add socket instance to socket map. Removal is always automatic. */
virtual void Add(Socket *) = 0;
private:
/** Remove socket from socket map, used by Socket class. */
virtual void Remove(Socket *) = 0;
public:
/** Get status of read/write/exception file descriptor set for a socket. */
virtual void Get(SOCKET s,bool& r,bool& w,bool& e) = 0;
/** Set read/write/exception file descriptor sets (fd_set). */
virtual void Set(SOCKET s,bool bRead,bool bWrite,bool bException = true) = 0;
/** Wait for events, generate callbacks. */
virtual int Select(long sec,long usec) = 0;
/** This method will not return until an event has been detected. */
virtual int Select() = 0;
/** Wait for events, generate callbacks. */
virtual int Select(struct timeval *tsel) = 0;
/** Check that a socket really is handled by this socket handler. */
virtual bool Valid(Socket *) = 0;
/** Return number of sockets handled by this handler. */
virtual size_t GetCount() = 0;
/** Override and return false to deny all incoming connections.
\param p ListenSocket class pointer (use GetPort to identify which one) */
virtual bool OkToAccept(Socket *p) = 0;
/** Called by Socket when a socket changes state. */
virtual void AddList(SOCKET s,list_t which_one,bool add) = 0;
// -------------------------------------------------------------------------
// Connection pool
// -------------------------------------------------------------------------
#ifdef ENABLE_POOL
/** Find available open connection (used by connection pool). */
virtual ISocketHandler::PoolSocket *FindConnection(int type,const std::string& protocol,SocketAddress&) = 0;
/** Enable connection pool (by default disabled). */
virtual void EnablePool(bool = true) = 0;
/** Check pool status.
\return true if connection pool is enabled */
virtual bool PoolEnabled() = 0;
#endif // ENABLE_POOL
// -------------------------------------------------------------------------
// Socks4
// -------------------------------------------------------------------------
#ifdef ENABLE_SOCKS4
/** Set socks4 server ip that all new tcp sockets should use. */
virtual void SetSocks4Host(ipaddr_t) = 0;
/** Set socks4 server hostname that all new tcp sockets should use. */
virtual void SetSocks4Host(const std::string& ) = 0;
/** Set socks4 server port number that all new tcp sockets should use. */
virtual void SetSocks4Port(port_t) = 0;
/** Set optional socks4 userid. */
virtual void SetSocks4Userid(const std::string& ) = 0;
/** If connection to socks4 server fails, immediately try direct connection to final host. */
virtual void SetSocks4TryDirect(bool = true) = 0;
/** Get socks4 server ip.
\return socks4 server ip */
virtual ipaddr_t GetSocks4Host() = 0;
/** Get socks4 port number.
\return socks4 port number */
virtual port_t GetSocks4Port() = 0;
/** Get socks4 userid (optional).
\return socks4 userid */
virtual const std::string& GetSocks4Userid() = 0;
/** Check status of socks4 try direct flag.
\return true if direct connection should be tried if connection to socks4 server fails */
virtual bool Socks4TryDirect() = 0;
#endif // ENABLE_SOCKS4
// -------------------------------------------------------------------------
// DNS resolve server
// -------------------------------------------------------------------------
#ifdef ENABLE_RESOLVER
/** Enable asynchronous DNS.
\param port Listen port of asynchronous dns server */
virtual void EnableResolver(port_t = 16667) = 0;
/** Check resolver status.
\return true if resolver is enabled */
virtual bool ResolverEnabled() = 0;
/** Queue a dns request.
\param host Hostname to be resolved
\param port Port number will be echoed in Socket::OnResolved callback */
virtual int Resolve(Socket *,const std::string& host,port_t port) = 0;
#ifdef ENABLE_IPV6
virtual int Resolve6(Socket *,const std::string& host,port_t port) = 0;
#endif
/** Do a reverse dns lookup. */
virtual int Resolve(Socket *,ipaddr_t a) = 0;
#ifdef ENABLE_IPV6
virtual int Resolve(Socket *,in6_addr& a) = 0;
#endif
/** Get listen port of asynchronous dns server. */
virtual port_t GetResolverPort() = 0;
/** Resolver thread ready for queries. */
virtual bool ResolverReady() = 0;
/** Returns true if socket waiting for a resolve event. */
virtual bool Resolving(Socket *) = 0;
#endif // ENABLE_RESOLVER
#ifdef ENABLE_TRIGGERS
/** Fetch unique trigger id. */
virtual int TriggerID(Socket *src) = 0;
/** Subscribe socket to trigger id. */
virtual bool Subscribe(int id, Socket *dst) = 0;
/** Unsubscribe socket from trigger id. */
virtual bool Unsubscribe(int id, Socket *dst) = 0;
/** Execute OnTrigger for subscribed sockets.
\param id Trigger ID
\param data Data passed from source to destination
\param erase Empty trigger id source and destination maps if 'true',
Leave them in place if 'false' - if a trigger should be called many times */
virtual void Trigger(int id, Socket::TriggerData& data, bool erase = true) = 0;
#endif // ENABLE_TRIGGERS
#ifdef ENABLE_DETACH
/** Indicates that the handler runs under SocketThread. */
virtual void SetSlave(bool x = true) = 0;
/** Indicates that the handler runs under SocketThread. */
virtual bool IsSlave() = 0;
#endif // ENABLE_DETACH
};
#ifdef SOCKETS_NAMESPACE
}
#endif
#endif // _SOCKETS_ISocketHandler_H

View File

@@ -1,95 +0,0 @@
/**
** \file Ipv4Address.h
** \date 2006-09-21
** \author grymse@alhem.net
**/
/*
Copyright (C) 2007 Anders Hedstrom
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETS_Ipv4Address_H
#define _SOCKETS_Ipv4Address_H
#include "sockets-config.h"
#include "SocketAddress.h"
#ifdef SOCKETS_NAMESPACE
namespace SOCKETS_NAMESPACE {
#endif
/* Ipv4 address implementation.
\ingroup basic */
class Ipv4Address : public SocketAddress
{
public:
/** Create empty Ipv4 address structure.
\param port Port number */
Ipv4Address(port_t port = 0);
/** Create Ipv4 address structure.
\param a Socket address in network byte order (as returned by Utility::u2ip)
\param port Port number in host byte order */
Ipv4Address(ipaddr_t a,port_t port);
/** Create Ipv4 address structure.
\param a Socket address in network byte order
\param port Port number in host byte order */
Ipv4Address(struct in_addr& a,port_t port);
/** Create Ipv4 address structure.
\param host Hostname to be resolved
\param port Port number in host byte order */
Ipv4Address(const std::string& host,port_t port);
Ipv4Address(struct sockaddr_in&);
~Ipv4Address();
// SocketAddress implementation
operator struct sockaddr *();
operator socklen_t();
bool operator==(SocketAddress&);
void SetPort(port_t port);
port_t GetPort();
void SetAddress(struct sockaddr *sa);
int GetFamily();
bool IsValid();
std::auto_ptr<SocketAddress> GetCopy();
/** Convert address struct to text. */
std::string Convert(bool include_port = false);
std::string Reverse();
/** Resolve hostname. */
static bool Resolve(const std::string& hostname,struct in_addr& a);
/** Reverse resolve (IP to hostname). */
static bool Reverse(struct in_addr& a,std::string& name);
/** Convert address struct to text. */
static std::string Convert(struct in_addr& a);
private:
Ipv4Address(const Ipv4Address& ) {} // copy constructor
Ipv4Address& operator=(const Ipv4Address& ) { return *this; } // assignment operator
struct sockaddr_in m_addr;
bool m_valid;
};
#ifdef SOCKETS_NAMESPACE
} // namespace SOCKETS_NAMESPACE {
#endif
#endif // _SOCKETS_Ipv4Address_H

View File

@@ -1,105 +0,0 @@
/**
** \file Ipv6Address.h
** \date 2006-09-21
** \author grymse@alhem.net
**/
/*
Copyright (C) 2007 Anders Hedstrom
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETS_Ipv6Address_H
#define _SOCKETS_Ipv6Address_H
#include "sockets-config.h"
#ifdef ENABLE_IPV6
#include "SocketAddress.h"
#ifdef IPPROTO_IPV6
#if defined( _WIN32) && !defined(__CYGWIN__)
typedef unsigned __int32 uint32_t;
#endif
#ifdef SOCKETS_NAMESPACE
namespace SOCKETS_NAMESPACE {
#endif
/** Ipv6 address implementation.
\ingroup basic */
class Ipv6Address : public SocketAddress
{
public:
/** Create empty Ipv6 address structure.
\param port Port number */
Ipv6Address(port_t port = 0);
/** Create Ipv6 address structure.
\param a Socket address in network byte order
\param port Port number in host byte order */
Ipv6Address(struct in6_addr& a,port_t port);
/** Create Ipv6 address structure.
\param host Hostname to be resolved
\param port Port number in host byte order */
Ipv6Address(const std::string& host,port_t port);
Ipv6Address(struct sockaddr_in6&);
~Ipv6Address();
// SocketAddress implementation
operator struct sockaddr *();
operator socklen_t();
bool operator==(SocketAddress&);
void SetPort(port_t port);
port_t GetPort();
void SetAddress(struct sockaddr *sa);
int GetFamily();
bool IsValid();
std::auto_ptr<SocketAddress> GetCopy();
/** Convert address struct to text. */
std::string Convert(bool include_port = false);
std::string Reverse();
/** Resolve hostname. */
static bool Resolve(const std::string& hostname,struct in6_addr& a);
/** Reverse resolve (IP to hostname). */
static bool Reverse(struct in6_addr& a,std::string& name);
/** Convert address struct to text. */
static std::string Convert(struct in6_addr& a,bool mixed = false);
void SetFlowinfo(uint32_t);
uint32_t GetFlowinfo();
#ifndef _WIN32
void SetScopeId(uint32_t);
uint32_t GetScopeId();
#endif
private:
Ipv6Address(const Ipv6Address& ) {} // copy constructor
Ipv6Address& operator=(const Ipv6Address& ) { return *this; } // assignment operator
struct sockaddr_in6 m_addr;
bool m_valid;
};
#ifdef SOCKETS_NAMESPACE
} // namespace SOCKETS_NAMESPACE {
#endif
#endif // IPPROTO_IPV6
#endif // ENABLE_IPV6
#endif // _SOCKETS_Ipv6Address_H

View File

@@ -1,418 +0,0 @@
/** \file ListenSocket.h
** \date 2004-02-13
** \author grymse@alhem.net
**/
/*
Copyright (C) 2004-2007 Anders Hedstrom
This library is made available under the terms of the GNU GPL.
If you would like to use this library in a closed-source application,
a separate license agreement is available. For information about
the closed-source license agreement for the C++ sockets library,
please visit http://www.alhem.net/Sockets/license.html and/or
email license@alhem.net.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETS_ListenSocket_H
#define _SOCKETS_ListenSocket_H
#include "sockets-config.h"
#ifdef _WIN32
#include <stdlib.h>
#else
#include <errno.h>
#endif
#include "ISocketHandler.h"
#include "Socket.h"
#include "Utility.h"
#include "SctpSocket.h"
#include "Ipv4Address.h"
#include "Ipv6Address.h"
#ifdef ENABLE_EXCEPTIONS
#include "Exception.h"
#endif
#ifdef SOCKETS_NAMESPACE
namespace SOCKETS_NAMESPACE {
#endif
/** Binds incoming port number to new Socket class X.
\ingroup basic */
template <class X>
class ListenSocket : public Socket
{
public:
/** Constructor.
\param h ISocketHandler reference
\param use_creator Optional use of creator (default true) */
ListenSocket(ISocketHandler& h,bool use_creator = true) : Socket(h), m_depth(0), m_creator(NULL)
,m_bHasCreate(false)
{
if (use_creator)
{
m_creator = new X(h);
Socket *tmp = m_creator -> Create();
if (tmp && dynamic_cast<X *>(tmp))
{
m_bHasCreate = true;
}
if (tmp)
{
delete tmp;
}
}
}
~ListenSocket() {
if (m_creator)
{
delete m_creator;
}
}
/** Close file descriptor. */
int Close() {
if (GetSocket() != INVALID_SOCKET)
{
closesocket(GetSocket());
}
return 0;
}
/** Bind and listen to any interface.
\param port Port (0 is random)
\param depth Listen queue depth */
int Bind(port_t port,int depth = 20) {
#ifdef ENABLE_IPV6
#ifdef IPPROTO_IPV6
if (IsIpv6())
{
Ipv6Address ad(port);
return Bind(ad, depth);
}
else
#endif
#endif
{
Ipv4Address ad(port);
return Bind(ad, depth);
}
}
int Bind(SocketAddress& ad,int depth) {
#ifdef USE_SCTP
if (dynamic_cast<SctpSocket *>(m_creator))
{
return Bind(ad, "sctp", depth);
}
#endif
return Bind(ad, "tcp", depth);
}
/** Bind and listen to any interface, with optional protocol.
\param port Port (0 is random)
\param protocol Network protocol
\param depth Listen queue depth */
int Bind(port_t port,const std::string& protocol,int depth = 20) {
#ifdef ENABLE_IPV6
#ifdef IPPROTO_IPV6
if (IsIpv6())
{
Ipv6Address ad(port);
return Bind(ad, protocol, depth);
}
else
#endif
#endif
{
Ipv4Address ad(port);
return Bind(ad, protocol, depth);
}
}
/** Bind and listen to specific interface.
\param intf Interface hostname
\param port Port (0 is random)
\param depth Listen queue depth */
int Bind(const std::string& intf,port_t port,int depth = 20) {
#ifdef ENABLE_IPV6
#ifdef IPPROTO_IPV6
if (IsIpv6())
{
Ipv6Address ad(intf, port);
if (ad.IsValid())
{
return Bind(ad, depth);
}
Handler().LogError(this, "Bind", 0, "name resolution of interface name failed", LOG_LEVEL_FATAL);
return -1;
}
else
#endif
#endif
{
Ipv4Address ad(intf, port);
if (ad.IsValid())
{
return Bind(ad, depth);
}
Handler().LogError(this, "Bind", 0, "name resolution of interface name failed", LOG_LEVEL_FATAL);
return -1;
}
}
/** Bind and listen to specific interface.
\param intf Interface hostname
\param port Port (0 is random)
\param protocol Network protocol
\param depth Listen queue depth */
int Bind(const std::string& intf,port_t port,const std::string& protocol,int depth = 20) {
#ifdef ENABLE_IPV6
#ifdef IPPROTO_IPV6
if (IsIpv6())
{
Ipv6Address ad(intf, port);
if (ad.IsValid())
{
return Bind(ad, protocol, depth);
}
Handler().LogError(this, "Bind", 0, "name resolution of interface name failed", LOG_LEVEL_FATAL);
return -1;
}
else
#endif
#endif
{
Ipv4Address ad(intf, port);
if (ad.IsValid())
{
return Bind(ad, protocol, depth);
}
Handler().LogError(this, "Bind", 0, "name resolution of interface name failed", LOG_LEVEL_FATAL);
return -1;
}
}
/** Bind and listen to ipv4 interface.
\param a Ipv4 interface address
\param port Port (0 is random)
\param depth Listen queue depth */
int Bind(ipaddr_t a,port_t port,int depth = 20) {
Ipv4Address ad(a, port);
#ifdef USE_SCTP
if (dynamic_cast<SctpSocket *>(m_creator))
{
return Bind(ad, "sctp", depth);
}
#endif
return Bind(ad, "tcp", depth);
}
/** Bind and listen to ipv4 interface.
\param a Ipv4 interface address
\param port Port (0 is random)
\param protocol Network protocol
\param depth Listen queue depth */
int Bind(ipaddr_t a,port_t port,const std::string& protocol,int depth) {
Ipv4Address ad(a, port);
return Bind(ad, protocol, depth);
}
#ifdef ENABLE_IPV6
#ifdef IPPROTO_IPV6
/** Bind and listen to ipv6 interface.
\param a Ipv6 interface address
\param port Port (0 is random)
\param depth Listen queue depth */
int Bind(in6_addr a,port_t port,int depth = 20) {
Ipv6Address ad(a, port);
#ifdef USE_SCTP
if (dynamic_cast<SctpSocket *>(m_creator))
{
return Bind(ad, "sctp", depth);
}
#endif
return Bind(ad, "tcp", depth);
}
/** Bind and listen to ipv6 interface.
\param a Ipv6 interface address
\param port Port (0 is random)
\param protocol Network protocol
\param depth Listen queue depth */
int Bind(in6_addr a,port_t port,const std::string& protocol,int depth) {
Ipv6Address ad(a, port);
return Bind(ad, protocol, depth);
}
#endif
#endif
/** Bind and listen to network interface.
\param ad Interface address
\param protocol Network protocol
\param depth Listen queue depth */
int Bind(SocketAddress& ad,const std::string& protocol,int depth) {
SOCKET s;
if ( (s = CreateSocket(ad.GetFamily(), SOCK_STREAM, protocol)) == INVALID_SOCKET)
{
return -1;
}
if (bind(s, ad, ad) == -1)
{
Handler().LogError(this, "bind", Errno, StrError(Errno), LOG_LEVEL_FATAL);
closesocket(s);
#ifdef ENABLE_EXCEPTIONS
throw Exception("bind() failed for port " + Utility::l2string(ad.GetPort()) + ": " + StrError(Errno));
#endif
return -1;
}
if (listen(s, depth) == -1)
{
Handler().LogError(this, "listen", Errno, StrError(Errno), LOG_LEVEL_FATAL);
closesocket(s);
#ifdef ENABLE_EXCEPTIONS
throw Exception("listen() failed for port " + Utility::l2string(ad.GetPort()) + ": " + StrError(Errno));
#endif
return -1;
}
m_depth = depth;
Attach(s);
return 0;
}
/** Return assigned port number. */
port_t GetPort()
{
return GetSockPort();
}
/** Return listen queue depth. */
int GetDepth()
{
return m_depth;
}
/** OnRead on a ListenSocket receives an incoming connection. */
void OnRead()
{
struct sockaddr sa;
socklen_t sa_len = sizeof(struct sockaddr);
SOCKET a_s = accept(GetSocket(), &sa, &sa_len);
if (a_s == INVALID_SOCKET)
{
Handler().LogError(this, "accept", Errno, StrError(Errno), LOG_LEVEL_ERROR);
return;
}
if (!Handler().OkToAccept(this))
{
Handler().LogError(this, "accept", -1, "Not OK to accept", LOG_LEVEL_WARNING);
closesocket(a_s);
return;
}
if (Handler().GetCount() >= FD_SETSIZE)
{
Handler().LogError(this, "accept", (int)Handler().GetCount(), "ISocketHandler fd_set limit reached", LOG_LEVEL_FATAL);
closesocket(a_s);
return;
}
Socket *tmp = m_bHasCreate ? m_creator -> Create() : new X(Handler());
#ifdef ENABLE_IPV6
tmp -> SetIpv6( IsIpv6() );
#endif
tmp -> SetParent(this);
tmp -> Attach(a_s);
tmp -> SetNonblocking(true);
{
#ifdef ENABLE_IPV6
#ifdef IPPROTO_IPV6
if (sa_len == sizeof(struct sockaddr_in6))
{
struct sockaddr_in6 *p = (struct sockaddr_in6 *)&sa;
if (p -> sin6_family == AF_INET6)
{
Ipv6Address ad(p -> sin6_addr,ntohs(p -> sin6_port));
ad.SetFlowinfo(p -> sin6_flowinfo);
#ifndef _WIN32
ad.SetScopeId(p -> sin6_scope_id);
#endif
tmp -> SetRemoteAddress(ad);
}
}
#endif
#endif
if (sa_len == sizeof(struct sockaddr_in))
{
struct sockaddr_in *p = (struct sockaddr_in *)&sa;
if (p -> sin_family == AF_INET)
{
Ipv4Address ad(p -> sin_addr,ntohs(p -> sin_port));
tmp -> SetRemoteAddress(ad);
}
}
}
tmp -> SetConnected(true);
tmp -> Init();
tmp -> SetDeleteByHandler(true);
Handler().Add(tmp);
#ifdef HAVE_OPENSSL
if (tmp -> IsSSL()) // SSL Enabled socket
{
// %! OnSSLAccept calls SSLNegotiate that can finish in this one call.
// %! If that happens and negotiation fails, the 'tmp' instance is
// %! still added to the list of active sockets in the sockethandler.
// %! See bugfix for this in SocketHandler::Select - don't Set rwx
// %! flags if CloseAndDelete() flag is true.
// %! An even better fugbix (see TcpSocket::OnSSLAccept) now avoids
// %! the Add problem altogether, so ignore the above.
// %! (OnSSLAccept does no longer call SSLNegotiate().)
tmp -> OnSSLAccept();
}
else
#endif
{
tmp -> OnAccept();
}
}
/** Please don't use this method.
"accept()" is handled automatically in the OnRead() method. */
virtual SOCKET Accept(SOCKET socket, struct sockaddr *saptr, socklen_t *lenptr)
{
return accept(socket, saptr, lenptr);
}
bool HasCreator() { return m_bHasCreate; }
void OnOptions(int,int,int,SOCKET) {
SetSoReuseaddr(true);
}
protected:
ListenSocket(const ListenSocket& s) : Socket(s) {}
private:
ListenSocket& operator=(const ListenSocket& ) { return *this; }
int m_depth;
X *m_creator;
bool m_bHasCreate;
};
#ifdef SOCKETS_NAMESPACE
}
#endif
#endif // _SOCKETS_ListenSocket_H

View File

@@ -1,58 +0,0 @@
/** \file Lock.h
** \date 2005-08-22
** \author grymse@alhem.net
**/
/*
Copyright (C) 2005,2007 Anders Hedstrom
This library is made available under the terms of the GNU GPL.
If you would like to use this library in a closed-source application,
a separate license agreement is available. For information about
the closed-source license agreement for the C++ sockets library,
please visit http://www.alhem.net/Sockets/license.html and/or
email license@alhem.net.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETS_Lock_H
#define _SOCKETS_Lock_H
#include "sockets-config.h"
#ifdef SOCKETS_NAMESPACE
namespace SOCKETS_NAMESPACE {
#endif
class Mutex;
/** Mutex encapsulation class.
\ingroup threading */
class Lock
{
public:
Lock(Mutex&);
~Lock();
private:
Mutex& m_mutex;
};
#ifdef SOCKETS_NAMESPACE
}
#endif
#endif // _SOCKETS_Lock_H

View File

@@ -1,68 +0,0 @@
/** \file Mutex.h
** \date 2004-10-30
** \author grymse@alhem.net
**/
/*
Copyright (C) 2004-2007 Anders Hedstrom
This library is made available under the terms of the GNU GPL.
If you would like to use this library in a closed-source application,
a separate license agreement is available. For information about
the closed-source license agreement for the C++ sockets library,
please visit http://www.alhem.net/Sockets/license.html and/or
email license@alhem.net.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETS_Mutex_H
#define _SOCKETS_Mutex_H
#include "sockets-config.h"
#ifndef _WIN32
#include <pthread.h>
#else
#include <windows.h>
#endif
#ifdef SOCKETS_NAMESPACE
namespace SOCKETS_NAMESPACE {
#endif
/** Mutex container class, used by Lock.
\ingroup threading */
class Mutex
{
friend class Lock;
public:
Mutex();
~Mutex();
void Lock();
void Unlock();
private:
#ifdef _WIN32
HANDLE m_mutex;
#else
pthread_mutex_t m_mutex;
#endif
};
#ifdef SOCKETS_NAMESPACE
}
#endif
#endif // _SOCKETS_Mutex_H

View File

@@ -1,100 +0,0 @@
/** \file Parse.h - parse a string
**
** Written: 1999-Feb-10 grymse@alhem.net
**/
/*
Copyright (C) 1999-2007 Anders Hedstrom
This library is made available under the terms of the GNU GPL.
If you would like to use this library in a closed-source application,
a separate license agreement is available. For information about
the closed-source license agreement for the C++ sockets library,
please visit http://www.alhem.net/Sockets/license.html and/or
email license@alhem.net.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETS_Parse_H
#define _SOCKETS_Parse_H
#include "sockets-config.h"
#ifdef _MSC_VER
#pragma warning(disable:4514)
#endif
#include <string>
#ifdef SOCKETS_NAMESPACE
namespace SOCKETS_NAMESPACE {
#endif
/***************************************************/
/* interface of class Parse */
/** Splits a string whatever way you want.
\ingroup util */
class Parse
{
public:
Parse();
Parse(const std::string&);
Parse(const std::string&,const std::string&);
Parse(const std::string&,const std::string&,short);
~Parse();
short issplit(const char);
void getsplit();
void getsplit(std::string&);
std::string getword();
void getword(std::string&);
void getword(std::string&,std::string&,int);
std::string getrest();
void getrest(std::string&);
long getvalue();
void setbreak(const char);
int getwordlen();
int getrestlen();
void enablebreak(const char c) {
pa_enable = c;
}
void disablebreak(const char c) {
pa_disable = c;
}
void getline();
void getline(std::string&);
size_t getptr() { return pa_the_ptr; }
void EnableQuote(bool b) { pa_quote = b; }
private:
std::string pa_the_str;
std::string pa_splits;
std::string pa_ord;
size_t pa_the_ptr;
char pa_breakchar;
char pa_enable;
char pa_disable;
short pa_nospace;
bool pa_quote;
};
#ifdef SOCKETS_NAMESPACE
}
#endif
#endif // _SOCKETS_Parse_H

View File

@@ -1,72 +0,0 @@
/** \file ResolvServer.h
** \date 2005-03-24
** \author grymse@alhem.net
**/
/*
Copyright (C) 2004-2007 Anders Hedstrom
This library is made available under the terms of the GNU GPL.
If you would like to use this library in a closed-source application,
a separate license agreement is available. For information about
the closed-source license agreement for the C++ sockets library,
please visit http://www.alhem.net/Sockets/license.html and/or
email license@alhem.net.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETS_ResolvServer_H
#define _SOCKETS_ResolvServer_H
#include "sockets-config.h"
#ifdef ENABLE_RESOLVER
#include "socket_include.h"
#include "Thread.h"
#ifdef SOCKETS_NAMESPACE
namespace SOCKETS_NAMESPACE {
#endif
/** \defgroup async Asynchronous DNS */
/** Async DNS resolver thread.
\ingroup async */
class ResolvServer : public Thread
{
public:
ResolvServer(port_t);
~ResolvServer();
void Run();
void Quit();
bool Ready();
private:
ResolvServer(const ResolvServer& ) {} // copy constructor
ResolvServer& operator=(const ResolvServer& ) { return *this; } // assignment operator
bool m_quit;
port_t m_port;
bool m_ready;
};
#ifdef SOCKETS_NAMESPACE
}
#endif
#endif // ENABLE_RESOLVER
#endif // _SOCKETS_ResolvServer_H

View File

@@ -1,105 +0,0 @@
/** \file ResolvSocket.h
** \date 2005-03-24
** \author grymse@alhem.net
**/
/*
Copyright (C) 2004-2007 Anders Hedstrom
This library is made available under the terms of the GNU GPL.
If you would like to use this library in a closed-source application,
a separate license agreement is available. For information about
the closed-source license agreement for the C++ sockets library,
please visit http://www.alhem.net/Sockets/license.html and/or
email license@alhem.net.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETS_ResolvSocket_H
#define _SOCKETS_ResolvSocket_H
#include "sockets-config.h"
#ifdef ENABLE_RESOLVER
#include "TcpSocket.h"
#include <map>
#ifdef SOCKETS_NAMESPACE
namespace SOCKETS_NAMESPACE {
#endif
class Mutex;
/** Async DNS resolver socket.
\ingroup async */
class ResolvSocket : public TcpSocket
{
typedef std::map<std::string, /* type */
std::map<std::string, std::string> > cache_t; /* host, result */
typedef std::map<std::string, /* type */
std::map<std::string, time_t> > timeout_t; /* host, time */
public:
ResolvSocket(ISocketHandler&);
ResolvSocket(ISocketHandler&, Socket *parent, const std::string& host, port_t port, bool ipv6 = false);
ResolvSocket(ISocketHandler&, Socket *parent, ipaddr_t);
#ifdef ENABLE_IPV6
ResolvSocket(ISocketHandler&, Socket *parent, in6_addr&);
#endif
~ResolvSocket();
void OnAccept() { m_bServer = true; }
void OnLine(const std::string& line);
void OnDetached();
void OnDelete();
void SetId(int x) { m_resolv_id = x; }
int GetId() { return m_resolv_id; }
void OnConnect();
#ifdef ENABLE_IPV6
void SetResolveIpv6(bool x = true) { m_resolve_ipv6 = x; }
#endif
private:
ResolvSocket(const ResolvSocket& s) : TcpSocket(s) {} // copy constructor
ResolvSocket& operator=(const ResolvSocket& ) { return *this; } // assignment operator
std::string m_query;
std::string m_data;
bool m_bServer;
Socket *m_parent;
int m_resolv_id;
std::string m_resolv_host;
port_t m_resolv_port;
ipaddr_t m_resolv_address;
#ifdef ENABLE_IPV6
bool m_resolve_ipv6;
in6_addr m_resolv_address6;
#endif
static cache_t m_cache;
static timeout_t m_cache_to;
static Mutex m_cache_mutex;
bool m_cached;
};
#ifdef SOCKETS_NAMESPACE
}
#endif
#endif // ENABLE_RESOLVER
#endif // _SOCKETS_ResolvSocket_H

View File

@@ -1,108 +0,0 @@
/**
** \file SctpSocket.h
** \date 2006-09-04
** \author grymse@alhem.net
**/
/*
Copyright (C) 2007 Anders Hedstrom
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETS_SctpSocket_H
#define _SOCKETS_SctpSocket_H
#include "sockets-config.h"
#include "StreamSocket.h"
#ifdef USE_SCTP
#include <netinet/sctp.h>
#ifdef SOCKETS_NAMESPACE
namespace SOCKETS_NAMESPACE {
#endif
#define SCTP_BUFSIZE_READ 16400
class SocketAddress;
class SctpSocket : public StreamSocket
{
public:
/** SctpSocket constructor.
\param h Owner
\param type SCTP_STREAM or SCTP_SEQPACKET */
SctpSocket(ISocketHandler& h,int type);
~SctpSocket();
/** bind() */
int Bind(const std::string&,port_t);
int Bind(SocketAddress&);
/** sctp_bindx() */
int AddAddress(const std::string&,port_t);
int AddAddress(SocketAddress&);
/** sctp_bindx() */
int RemoveAddress(const std::string&,port_t);
int RemoveAddress(SocketAddress&);
/** connect() */
int Open(const std::string&,port_t);
int Open(SocketAddress&);
/** Connect timeout callback. */
void OnConnectTimeout();
#ifdef _WIN32
/** Connection failed reported as exception on win32 */
void OnException();
#endif
#ifndef SOLARIS
/** sctp_connectx() */
int AddConnection(const std::string&,port_t);
int AddConnection(SocketAddress&);
#endif
/** Get peer addresses of an association. */
int getpaddrs(sctp_assoc_t id,std::list<std::string>&);
/** Get all bound addresses of an association. */
int getladdrs(sctp_assoc_t id,std::list<std::string>&);
/** sctp_peeloff */
int PeelOff(sctp_assoc_t id);
/** recvmsg callback */
virtual void OnReceiveMessage(const char *buf,size_t sz,struct sockaddr *sa,socklen_t sa_len,struct sctp_sndrcvinfo *sinfo,int msg_flags) = 0;
void OnOptions(int,int,int,SOCKET) {}
virtual int Protocol();
protected:
SctpSocket(const SctpSocket& s) : StreamSocket(s) {}
void OnRead();
void OnWrite();
private:
SctpSocket& operator=(const SctpSocket& s) { return *this; }
int m_type; ///< SCTP_STREAM or SCTP_SEQPACKET
char *m_buf; ///< Temporary receive buffer
};
#ifdef SOCKETS_NAMESPACE
} // namespace SOCKETS_NAMESPACE
#endif
#endif // USE_SCTP
#endif // _SOCKETS_SctpSocket_H

View File

@@ -1,735 +0,0 @@
/** \file Socket.h
** \date 2004-02-13
** \author grymse@alhem.net
**/
/*
Copyright (C) 2004-2007 Anders Hedstrom
This software is made available under the terms of the GNU GPL.
If you would like to use this library in a closed-source application,
a separate license agreement is available. For information about
the closed-source license agreement for the C++ sockets library,
please visit http://www.alhem.net/Sockets/license.html and/or
email license@alhem.net.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETS_Socket_H
#define _SOCKETS_Socket_H
#include "sockets-config.h"
#include <string>
#include <vector>
#include <list>
#ifdef HAVE_OPENSSL
#include <openssl/ssl.h>
#endif
#include "socket_include.h"
#include <time.h>
#include "SocketAddress.h"
#include "Thread.h"
#ifdef SOCKETS_NAMESPACE
namespace SOCKETS_NAMESPACE {
#endif
class ISocketHandler;
class SocketAddress;
class IFile;
/** \defgroup basic Basic sockets */
/** Socket base class.
\ingroup basic */
class Socket
{
friend class ISocketHandler;
#ifdef ENABLE_DETACH
/** Detached socket run thread.
\ingroup internal */
class SocketThread : public Thread
{
public:
SocketThread(Socket *p);
~SocketThread();
void Run();
private:
Socket *GetSocket() const { return m_socket; }
SocketThread(const SocketThread& s) : m_socket(s.GetSocket()) {}
SocketThread& operator=(const SocketThread& ) { return *this; }
Socket *m_socket;
};
#endif // ENABLE_DETACH
#ifdef ENABLE_TRIGGERS
public:
/** Data pass class from source to destination. */
class TriggerData
{
public:
TriggerData() : m_src(NULL) {}
virtual ~TriggerData() {}
Socket *GetSource() const { return m_src; }
void SetSource(Socket *x) { m_src = x; }
private:
Socket *m_src;
};
#endif // ENABLE_TRIGGERS
/** Socket mode flags. */
/*
enum {
// Socket
SOCK_DEL = 0x01, ///< Delete by handler flag
SOCK_CLOSE = 0x02, ///< Close and delete flag
SOCK_DISABLE_READ = 0x04, ///< Disable checking for read events
SOCK_CONNECTED = 0x08, ///< Socket is connected (tcp/udp)
SOCK_ERASED_BY_HANDLER = 0x10, ///< Set by handler before delete
// HAVE_OPENSSL
SOCK_ENABLE_SSL = 0x20, ///< Enable SSL for this TcpSocket
SOCK_SSL = 0x40, ///< ssl negotiation mode (TcpSocket)
SOCK_SSL_SERVER = 0x80, ///< True if this is an incoming ssl TcpSocket connection
// ENABLE_IPV6
SOCK_IPV6 = 0x0100, ///< This is an ipv6 socket if this one is true
// ENABLE_POOL
SOCK_CLIENT = 0x0200, ///< only client connections are pooled
SOCK_RETAIN = 0x0400, ///< keep connection on close
SOCK_LOST = 0x0800, ///< connection lost
// ENABLE_SOCKS4
SOCK_SOCKS4 = 0x1000, ///< socks4 negotiation mode (TcpSocket)
// ENABLE_DETACH
SOCK_DETACH = 0x2000, ///< Socket ordered to detach flag
SOCK_DETACHED = 0x4000, ///< Socket has been detached
// StreamSocket
STREAMSOCK_CONNECTING = 0x8000, ///< Flag indicating connection in progress
STREAMSOCK_FLUSH_BEFORE_CLOSE = 0x010000L, ///< Send all data before closing (default true)
STREAMSOCK_CALL_ON_CONNECT = 0x020000L, ///< OnConnect will be called next ISocketHandler cycle if true
STREAMSOCK_RETRY_CONNECT = 0x040000L, ///< Try another connection attempt next ISocketHandler cycle
STREAMSOCK_LINE_PROTOCOL = 0x080000L, ///< Line protocol mode flag
};
*/
public:
/** "Default" constructor */
Socket(ISocketHandler&);
virtual ~Socket();
/** Socket class instantiation method. Used when a "non-standard" constructor
* needs to be used for the socket class. Note: the socket class still needs
* the "default" constructor with one ISocketHandler& as input parameter.
*/
virtual Socket *Create() { return NULL; }
/** Returns reference to sockethandler that owns the socket.
If the socket is detached, this is a reference to the slave sockethandler.
*/
ISocketHandler& Handler() const;
/** Returns reference to sockethandler that owns the socket.
This one always returns the reference to the original sockethandler,
even if the socket is detached.
*/
ISocketHandler& MasterHandler() const;
/** Called by ListenSocket after accept but before socket is added to handler.
* CTcpSocket uses this to create its ICrypt member variable.
* The ICrypt member variable is created by a virtual method, therefore
* it can't be called directly from the CTcpSocket constructor.
* Also used to determine if incoming HTTP connection is normal (port 80)
* or ssl (port 443).
*/
virtual void Init();
/** Create a socket file descriptor.
\param af Address family AF_INET / AF_INET6 / ...
\param type SOCK_STREAM / SOCK_DGRAM / ...
\param protocol "tcp" / "udp" / ... */
SOCKET CreateSocket(int af,int type,const std::string& protocol = "");
/** Assign this socket a file descriptor created
by a call to socket() or otherwise. */
void Attach(SOCKET s);
/** Return file descriptor assigned to this socket. */
SOCKET GetSocket();
/** Close connection immediately - internal use.
\sa SetCloseAndDelete */
virtual int Close();
/** Add file descriptor to sockethandler fd_set's. */
void Set(bool bRead,bool bWrite,bool bException = true);
/** Returns true when socket file descriptor is valid
and socket is not about to be closed. */
virtual bool Ready();
/** Returns pointer to ListenSocket that created this instance
* on an incoming connection. */
Socket *GetParent();
/** Used by ListenSocket to set parent pointer of newly created
* socket instance. */
void SetParent(Socket *);
/** Get listening port from ListenSocket<>. */
virtual port_t GetPort();
/** Set socket non-block operation. */
bool SetNonblocking(bool);
/** Set socket non-block operation. */
bool SetNonblocking(bool, SOCKET);
/** Total lifetime of instance. */
time_t Uptime();
/** Set address/port of last connect() call. */
void SetClientRemoteAddress(SocketAddress&);
/** Get address/port of last connect() call. */
std::auto_ptr<SocketAddress> GetClientRemoteAddress();
/** Common interface for SendBuf used by Tcp and Udp sockets. */
virtual void SendBuf(const char *,size_t,int = 0);
/** Common interface for Send used by Tcp and Udp sockets. */
virtual void Send(const std::string&,int = 0);
/** Outgoing traffic counter. */
virtual uint64_t GetBytesSent(bool clear = false);
/** Incoming traffic counter. */
virtual uint64_t GetBytesReceived(bool clear = false);
// LIST_TIMEOUT
/** Enable timeout control. 0=disable timeout check. */
void SetTimeout(time_t secs);
/** Check timeout. \return true if time limit reached */
bool Timeout(time_t tnow);
/** Used by ListenSocket. ipv4 and ipv6 */
void SetRemoteAddress(SocketAddress&);
/** \name Event callbacks */
//@{
/** Called when there is something to be read from the file descriptor. */
virtual void OnRead();
/** Called when there is room for another write on the file descriptor. */
virtual void OnWrite();
/** Called on socket exception. */
virtual void OnException();
/** Called before a socket class is deleted by the ISocketHandler. */
virtual void OnDelete();
/** Called when a connection has completed. */
virtual void OnConnect();
/** Called when an incoming connection has been completed. */
virtual void OnAccept();
/** Called when a complete line has been read and the socket is in
* line protocol mode. */
virtual void OnLine(const std::string& );
/** Called on connect timeout (5s). */
virtual void OnConnectFailed();
/** Called when a client socket is created, to set socket options.
\param family AF_INET, AF_INET6, etc
\param type SOCK_STREAM, SOCK_DGRAM, etc
\param protocol Protocol number (tcp, udp, sctp, etc)
\param s Socket file descriptor
*/
virtual void OnOptions(int family,int type,int protocol,SOCKET s) = 0;
/** Connection retry callback - return false to abort connection attempts */
virtual bool OnConnectRetry();
#ifdef ENABLE_RECONNECT
/** a reconnect has been made */
virtual void OnReconnect();
#endif
/** TcpSocket: When a disconnect has been detected (recv/SSL_read returns 0 bytes). */
virtual void OnDisconnect();
/** Timeout callback. */
virtual void OnTimeout();
/** Connection timeout. */
virtual void OnConnectTimeout();
//@}
/** \name Socket mode flags, set/reset */
//@{
/** Set delete by handler true when you want the sockethandler to
delete the socket instance after use. */
void SetDeleteByHandler(bool = true);
/** Check delete by handler flag.
\return true if this instance should be deleted by the sockethandler */
bool DeleteByHandler();
// LIST_CLOSE - conditional event queue
/** Set close and delete to terminate the connection. */
void SetCloseAndDelete(bool = true);
/** Check close and delete flag.
\return true if this socket should be closed and the instance removed */
bool CloseAndDelete();
/** Return number of seconds since socket was ordered to close. \sa SetCloseAndDelete */
time_t TimeSinceClose();
/** Ignore read events for an output only socket. */
void DisableRead(bool x = true);
/** Check ignore read events flag.
\return true if read events should be ignored */
bool IsDisableRead();
/** Set connected status. */
void SetConnected(bool = true);
/** Check connected status.
\return true if connected */
bool IsConnected();
/** Connection lost - error while reading/writing from a socket - TcpSocket only. */
void SetLost();
/** Check connection lost status flag, used by TcpSocket only.
\return true if there was an error while r/w causing the socket to close */
bool Lost();
/** Set flag indicating the socket is being actively deleted by the sockethandler. */
void SetErasedByHandler(bool x = true);
/** Get value of flag indicating socket is deleted by sockethandler. */
bool ErasedByHandler();
//@}
/** \name Information about remote connection */
//@{
/** Returns address of remote end. */
std::auto_ptr<SocketAddress> GetRemoteSocketAddress();
/** Returns address of remote end: ipv4. */
ipaddr_t GetRemoteIP4();
#ifdef ENABLE_IPV6
/** Returns address of remote end: ipv6. */
#ifdef IPPROTO_IPV6
struct in6_addr GetRemoteIP6();
#endif
#endif
/** Returns remote port number: ipv4 and ipv6. */
port_t GetRemotePort();
/** Returns remote ip as string? ipv4 and ipv6. */
std::string GetRemoteAddress();
/** ipv4 and ipv6(not implemented) */
std::string GetRemoteHostname();
//@}
/** Returns local port number for bound socket file descriptor. */
port_t GetSockPort();
/** Returns local ipv4 address for bound socket file descriptor. */
ipaddr_t GetSockIP4();
/** Returns local ipv4 address as text for bound socket file descriptor. */
std::string GetSockAddress();
#ifdef ENABLE_IPV6
#ifdef IPPROTO_IPV6
/** Returns local ipv6 address for bound socket file descriptor. */
struct in6_addr GetSockIP6();
/** Returns local ipv6 address as text for bound socket file descriptor. */
std::string GetSockAddress6();
#endif
#endif
// --------------------------------------------------------------------------
/** @name IP options
When an ip or socket option is available on all of the operating systems
I'm testing on (linux 2.4.x, _win32, macosx, solaris9 intel) they are not
checked with an #ifdef below.
This might cause a compile error on other operating systems. */
// --------------------------------------------------------------------------
// IP options
//@{
bool SetIpOptions(const void *p, socklen_t len);
bool SetIpTOS(unsigned char tos);
unsigned char IpTOS();
bool SetIpTTL(int ttl);
int IpTTL();
bool SetIpHdrincl(bool x = true);
bool SetIpMulticastTTL(int);
int IpMulticastTTL();
bool SetMulticastLoop(bool x = true);
bool IpAddMembership(struct ip_mreq&);
bool IpDropMembership(struct ip_mreq&);
#ifdef IP_PKTINFO
bool SetIpPktinfo(bool x = true);
#endif
#ifdef IP_RECVTOS
bool SetIpRecvTOS(bool x = true);
#endif
#ifdef IP_RECVTTL
bool SetIpRecvTTL(bool x = true);
#endif
#ifdef IP_RECVOPTS
bool SetIpRecvopts(bool x = true);
#endif
#ifdef IP_RETOPTS
bool SetIpRetopts(bool x = true);
#endif
#ifdef IP_RECVERR
bool SetIpRecverr(bool x = true);
#endif
#ifdef IP_MTU_DISCOVER
bool SetIpMtudiscover(bool x = true);
#endif
#ifdef IP_MTU
int IpMtu();
#endif
#ifdef IP_ROUTER_ALERT
bool SetIpRouterAlert(bool x = true);
#endif
#ifdef LINUX
bool IpAddMembership(struct ip_mreqn&);
#endif
#ifdef LINUX
bool IpDropMembership(struct ip_mreqn&);
#endif
//@}
// SOCKET options
/** @name Socket Options */
//@{
bool SoAcceptconn();
bool SetSoBroadcast(bool x = true);
bool SetSoDebug(bool x = true);
int SoError();
bool SetSoDontroute(bool x = true);
bool SetSoLinger(int onoff, int linger);
bool SetSoOobinline(bool x = true);
bool SetSoRcvlowat(int);
bool SetSoSndlowat(int);
bool SetSoRcvtimeo(struct timeval&);
bool SetSoSndtimeo(struct timeval&);
bool SetSoRcvbuf(int);
int SoRcvbuf();
bool SetSoSndbuf(int);
int SoSndbuf();
int SoType();
bool SetSoReuseaddr(bool x = true);
bool SetSoKeepalive(bool x = true);
#ifdef SO_BSDCOMPAT
bool SetSoBsdcompat(bool x = true);
#endif
#ifdef SO_BINDTODEVICE
bool SetSoBindtodevice(const std::string& intf);
#endif
#ifdef SO_PASSCRED
bool SetSoPasscred(bool x = true);
#endif
#ifdef SO_PEERCRED
bool SoPeercred(struct ucred& );
#endif
#ifdef SO_PRIORITY
bool SetSoPriority(int);
#endif
#ifdef SO_RCVBUFFORCE
bool SetSoRcvbufforce(int);
#endif
#ifdef SO_SNDBUFFORCE
bool SetSoSndbufforce(int);
#endif
#ifdef SO_TIMESTAMP
bool SetSoTimestamp(bool x = true);
#endif
#ifdef SO_NOSIGPIPE
bool SetSoNosigpipe(bool x = true);
#endif
//@}
// TCP options in TcpSocket.h/TcpSocket.cpp
#ifdef HAVE_OPENSSL
/** @name SSL Support */
//@{
/** SSL client/server support - internal use. \sa TcpSocket */
virtual void OnSSLConnect();
/** SSL client/server support - internal use. \sa TcpSocket */
virtual void OnSSLAccept();
/** SSL negotiation failed for client connect. */
virtual void OnSSLConnectFailed();
/** SSL negotiation failed for server accept. */
virtual void OnSSLAcceptFailed();
/** new SSL support */
virtual bool SSLNegotiate();
/** Check if SSL is Enabled for this TcpSocket.
\return true if this is a TcpSocket with SSL enabled */
bool IsSSL();
/** Enable SSL operation for a TcpSocket. */
void EnableSSL(bool x = true);
/** Still negotiating ssl connection.
\return true if ssl negotiating is still in progress */
bool IsSSLNegotiate();
/** Set flag indicating ssl handshaking still in progress. */
void SetSSLNegotiate(bool x = true);
/** OnAccept called with SSL Enabled.
\return true if this is a TcpSocket with an incoming SSL connection */
bool IsSSLServer();
/** Set flag indicating that this is a TcpSocket with incoming SSL connection. */
void SetSSLServer(bool x = true);
/** SSL; Get pointer to ssl context structure. */
virtual SSL_CTX *GetSslContext() { return NULL; }
/** SSL; Get pointer to ssl structure. */
virtual SSL *GetSsl() { return NULL; }
//@}
#endif // HAVE_OPENSSL
#ifdef ENABLE_IPV6
/** Enable ipv6 for this socket. */
void SetIpv6(bool x = true);
/** Check ipv6 socket.
\return true if this is an ipv6 socket */
bool IsIpv6();
#endif
#ifdef ENABLE_POOL
/** @name Connection Pool */
//@{
/** Client = connecting TcpSocket. */
void SetIsClient();
/** Socket type from socket() call. */
void SetSocketType(int x);
/** Socket type from socket() call. */
int GetSocketType();
/** Protocol type from socket() call. */
void SetSocketProtocol(const std::string& x);
/** Protocol type from socket() call. */
const std::string& GetSocketProtocol();
/** Instruct a client socket to stay open in the connection pool after use.
If you have connected to a server using tcp, you can call SetRetain
to leave the connection open after your socket instance has been deleted.
The next connection you make to the same server will reuse the already
opened connection, if it is still available.
*/
void SetRetain();
/** Check retain flag.
\return true if the socket should be moved to connection pool after use */
bool Retain();
/** Copy connection parameters from sock. */
void CopyConnection(Socket *sock);
//@}
#endif // ENABLE_POOL
#ifdef ENABLE_SOCKS4
/** \name Socks4 support */
//@{
/** Socks4 client support internal use. \sa TcpSocket */
virtual void OnSocks4Connect();
/** Socks4 client support internal use. \sa TcpSocket */
virtual void OnSocks4ConnectFailed();
/** Socks4 client support internal use. \sa TcpSocket */
virtual bool OnSocks4Read();
/** Called when the last write caused the tcp output buffer to
* become empty. */
/** socket still in socks4 negotiation mode */
bool Socks4();
/** Set flag indicating Socks4 handshaking in progress */
void SetSocks4(bool x = true);
/** Set socks4 server host address to use */
void SetSocks4Host(ipaddr_t a);
/** Set socks4 server hostname to use. */
void SetSocks4Host(const std::string& );
/** Socks4 server port to use. */
void SetSocks4Port(port_t p);
/** Provide a socks4 userid if required by the socks4 server. */
void SetSocks4Userid(const std::string& x);
/** Get the ip address of socks4 server to use.
\return socks4 server host address */
ipaddr_t GetSocks4Host();
/** Get the socks4 server port to use.
\return socks4 server port */
port_t GetSocks4Port();
/** Get socks4 userid.
\return Socks4 userid */
const std::string& GetSocks4Userid();
//@}
#endif // ENABLE_SOCKS4
#ifdef ENABLE_RESOLVER
/** \name Asynchronous Resolver */
//@{
/** Request an asynchronous dns resolution.
\param host hostname to be resolved
\param port port number passed along for the ride
\return Resolve ID */
int Resolve(const std::string& host,port_t port = 0);
#ifdef ENABLE_IPV6
int Resolve6(const std::string& host, port_t port = 0);
#endif
/** Callback returning a resolved address.
\param id Resolve ID from Resolve call
\param a resolved ip address
\param port port number passed to Resolve */
virtual void OnResolved(int id,ipaddr_t a,port_t port);
#ifdef ENABLE_IPV6
virtual void OnResolved(int id,in6_addr& a,port_t port);
#endif
/** Request asynchronous reverse dns lookup.
\param a in_addr to be translated */
int Resolve(ipaddr_t a);
#ifdef ENABLE_IPV6
int Resolve(in6_addr& a);
#endif
/** Callback returning reverse resolve results.
\param id Resolve ID
\param name Resolved hostname */
virtual void OnReverseResolved(int id,const std::string& name);
/** Callback indicating failed dns lookup.
\param id Resolve ID */
virtual void OnResolveFailed(int id);
//@}
#endif // ENABLE_RESOLVER
#ifdef ENABLE_DETACH
/** \name Thread Support */
//@{
/** Callback fires when a new socket thread has started and this
socket is ready for operation again.
\sa ResolvSocket */
virtual void OnDetached();
// LIST_DETACH
/** Internal use. */
void SetDetach(bool x = true);
/** Check detach flag.
\return true if the socket should detach to its own thread */
bool IsDetach();
/** Internal use. */
void SetDetached(bool x = true);
/** Check detached flag.
\return true if the socket runs in its own thread. */
const bool IsDetached() const;
/** Order this socket to start its own thread and call OnDetached
when ready for operation. */
bool Detach();
/** Store the slave sockethandler pointer. */
void SetSlaveHandler(ISocketHandler *);
/** Create new thread for this socket to run detached in. */
void DetachSocket();
//@}
#endif // ENABLE_DETACH
/** Write traffic to an IFile. Socket will not delete this object. */
void SetTrafficMonitor(IFile *p) { m_traffic_monitor = p; }
#ifdef ENABLE_TRIGGERS
/** \name Triggers */
//@{
/** Subscribe to trigger id. */
void Subscribe(int id);
/** Unsubscribe from trigger id. */
void Unsubscribe(int id);
/** Trigger callback, with data passed from source to destination. */
virtual void OnTrigger(int id, const TriggerData& data);
/** Trigger cancelled because source has been deleted (as in delete). */
virtual void OnCancelled(int id);
//@}
#endif
protected:
/** default constructor not available */
Socket() : m_handler(m_handler) {}
/** copy constructor not available */
Socket(const Socket& s) : m_handler(s.m_handler) {}
/** assignment operator not available. */
Socket& operator=(const Socket& ) { return *this; }
/** All traffic will be written to this IFile, if set. */
IFile *GetTrafficMonitor() { return m_traffic_monitor; }
// unsigned long m_flags; ///< boolean flags, replacing old 'bool' members
private:
ISocketHandler& m_handler; ///< Reference of ISocketHandler in control of this socket
SOCKET m_socket; ///< File descriptor
bool m_bDel; ///< Delete by handler flag
bool m_bClose; ///< Close and delete flag
time_t m_tCreate; ///< Time in seconds when this socket was created
Socket *m_parent; ///< Pointer to ListenSocket class, valid for incoming sockets
bool m_b_disable_read; ///< Disable checking for read events
bool m_connected; ///< Socket is connected (tcp/udp)
bool m_b_erased_by_handler; ///< Set by handler before delete
time_t m_tClose; ///< Time in seconds when ordered to close
std::auto_ptr<SocketAddress> m_client_remote_address; ///< Address of last connect()
std::auto_ptr<SocketAddress> m_remote_address; ///< Remote end address
IFile *m_traffic_monitor;
time_t m_timeout_start; ///< Set by SetTimeout
time_t m_timeout_limit; ///< Defined by SetTimeout
bool m_bLost; ///< connection lost
#ifdef _WIN32
static WSAInitializer m_winsock_init; ///< Winsock initialization singleton class
#endif
#ifdef HAVE_OPENSSL
bool m_b_enable_ssl; ///< Enable SSL for this TcpSocket
bool m_b_ssl; ///< ssl negotiation mode (TcpSocket)
bool m_b_ssl_server; ///< True if this is an incoming ssl TcpSocket connection
#endif
#ifdef ENABLE_IPV6
bool m_ipv6; ///< This is an ipv6 socket if this one is true
#endif
#ifdef ENABLE_POOL
int m_socket_type; ///< Type of socket, from socket() call
std::string m_socket_protocol; ///< Protocol, from socket() call
bool m_bClient; ///< only client connections are pooled
bool m_bRetain; ///< keep connection on close
#endif
#ifdef ENABLE_SOCKS4
bool m_bSocks4; ///< socks4 negotiation mode (TcpSocket)
ipaddr_t m_socks4_host; ///< socks4 server address
port_t m_socks4_port; ///< socks4 server port number
std::string m_socks4_userid; ///< socks4 server usedid
#endif
#ifdef ENABLE_DETACH
bool m_detach; ///< Socket ordered to detach flag
bool m_detached; ///< Socket has been detached
SocketThread *m_pThread; ///< Detach socket thread class pointer
ISocketHandler *m_slave_handler; ///< Actual sockethandler while detached
#endif
};
#ifdef SOCKETS_NAMESPACE
}
#endif
#endif // _SOCKETS_Socket_H

View File

@@ -1,93 +0,0 @@
/**
** \file SocketAddress.h
** \date 2006-09-21
** \author grymse@alhem.net
**/
/*
Copyright (C) 2007 Anders Hedstrom
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETS_SocketAddress_H
#define _SOCKETS_SocketAddress_H
#include "sockets-config.h"
#include <string>
#include <memory>
#include "socket_include.h"
#ifdef SOCKETS_NAMESPACE
namespace SOCKETS_NAMESPACE {
#endif
/**
This class and its subclasses is intended to be used as replacement
for the internal data type 'ipaddr_t' and various implementations of
IPv6 addressing found throughout the library.
'ipaddr_t' is an IPv4 address in network byte order.
'port_t' is the portnumber in host byte order.
'struct in6_addr' is an IPv6 address.
'struct in_addr' is an IPv4 address.
\ingroup basic
*/
class SocketAddress
{
public:
virtual ~SocketAddress() {}
/** Get a pointer to the address struct. */
virtual operator struct sockaddr *() = 0;
/** Get length of address struct. */
virtual operator socklen_t() = 0;
/** Compare two addresses. */
virtual bool operator==(SocketAddress&) = 0;
/** Set port number.
\param port Port number in host byte order */
virtual void SetPort(port_t port) = 0;
/** Get port number.
\return Port number in host byte order. */
virtual port_t GetPort() = 0;
/** Set socket address.
\param sa Pointer to either 'struct sockaddr_in' or 'struct sockaddr_in6'. */
virtual void SetAddress(struct sockaddr *sa) = 0;
/** Convert address to text. */
virtual std::string Convert(bool include_port) = 0;
/** Reverse lookup of address. */
virtual std::string Reverse() = 0;
/** Get address family. */
virtual int GetFamily() = 0;
/** Address structure is valid. */
virtual bool IsValid() = 0;
/** Get a copy of this SocketAddress object. */
virtual std::auto_ptr<SocketAddress> GetCopy() = 0;
};
#ifdef SOCKETS_NAMESPACE
} // namespace SOCKETS_NAMESPACE {
#endif
#endif // _SOCKETS_SocketAddress_H

View File

@@ -1,265 +0,0 @@
/** \file SocketHandler.h
** \date 2004-02-13
** \author grymse@alhem.net
**/
/*
Copyright (C) 2004-2007 Anders Hedstrom
This library is made available under the terms of the GNU GPL.
If you would like to use this library in a closed-source application,
a separate license agreement is available. For information about
the closed-source license agreement for the C++ sockets library,
please visit http://www.alhem.net/Sockets/license.html and/or
email license@alhem.net.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETS_SocketHandler_H
#define _SOCKETS_SocketHandler_H
#include "sockets-config.h"
#include <map>
#include <list>
#include "socket_include.h"
#include "ISocketHandler.h"
#ifdef SOCKETS_NAMESPACE
namespace SOCKETS_NAMESPACE {
#endif
class Socket;
#ifdef ENABLE_RESOLVER
class ResolvServer;
#endif
class Mutex;
/** Socket container class, event generator.
\ingroup basic */
class SocketHandler : public ISocketHandler
{
protected:
/** Map type for holding file descriptors/socket object pointers. */
typedef std::map<SOCKET,Socket *> socket_m;
public:
/** SocketHandler constructor.
\param log Optional log class pointer */
SocketHandler(StdLog *log = NULL);
/** SocketHandler threadsafe constructor.
\param mutex Externally declared mutex variable
\param log Optional log class pointer */
SocketHandler(Mutex& mutex,StdLog *log = NULL);
~SocketHandler();
/** Get mutex reference for threadsafe operations. */
Mutex& GetMutex() const;
/** Register StdLog object for error callback.
\param log Pointer to log class */
void RegStdLog(StdLog *log);
/** Log error to log class for print out / storage. */
void LogError(Socket *p,const std::string& user_text,int err,const std::string& sys_err,loglevel_t t = LOG_LEVEL_WARNING);
/** Add socket instance to socket map. Removal is always automatic. */
void Add(Socket *);
/** Get status of read/write/exception file descriptor set for a socket. */
void Get(SOCKET s,bool& r,bool& w,bool& e);
/** Set read/write/exception file descriptor sets (fd_set). */
void Set(SOCKET s,bool bRead,bool bWrite,bool bException = true);
/** Wait for events, generate callbacks. */
int Select(long sec,long usec);
/** This method will not return until an event has been detected. */
int Select();
/** Wait for events, generate callbacks. */
int Select(struct timeval *tsel);
/** Check that a socket really is handled by this socket handler. */
bool Valid(Socket *);
/** Return number of sockets handled by this handler. */
size_t GetCount();
/** Override and return false to deny all incoming connections.
\param p ListenSocket class pointer (use GetPort to identify which one) */
bool OkToAccept(Socket *p);
/** Called by Socket when a socket changes state. */
void AddList(SOCKET s,list_t which_one,bool add);
// Connection pool
#ifdef ENABLE_POOL
/** Find available open connection (used by connection pool). */
ISocketHandler::PoolSocket *FindConnection(int type,const std::string& protocol,SocketAddress&);
/** Enable connection pool (by default disabled). */
void EnablePool(bool x = true);
/** Check pool status.
\return true if connection pool is enabled */
bool PoolEnabled();
#endif // ENABLE_POOL
// Socks4
#ifdef ENABLE_SOCKS4
/** Set socks4 server ip that all new tcp sockets should use. */
void SetSocks4Host(ipaddr_t);
/** Set socks4 server hostname that all new tcp sockets should use. */
void SetSocks4Host(const std::string& );
/** Set socks4 server port number that all new tcp sockets should use. */
void SetSocks4Port(port_t);
/** Set optional socks4 userid. */
void SetSocks4Userid(const std::string& );
/** If connection to socks4 server fails, immediately try direct connection to final host. */
void SetSocks4TryDirect(bool x = true);
/** Get socks4 server ip.
\return socks4 server ip */
ipaddr_t GetSocks4Host();
/** Get socks4 port number.
\return socks4 port number */
port_t GetSocks4Port();
/** Get socks4 userid (optional).
\return socks4 userid */
const std::string& GetSocks4Userid();
/** Check status of socks4 try direct flag.
\return true if direct connection should be tried if connection to socks4 server fails */
bool Socks4TryDirect();
#endif // ENABLE_SOCKS4
// DNS resolve server
#ifdef ENABLE_RESOLVER
/** Enable asynchronous DNS.
\param port Listen port of asynchronous dns server */
void EnableResolver(port_t port = 16667);
/** Check resolver status.
\return true if resolver is enabled */
bool ResolverEnabled();
/** Queue a dns request.
\param host Hostname to be resolved
\param port Port number will be echoed in Socket::OnResolved callback */
int Resolve(Socket *,const std::string& host,port_t port);
#ifdef ENABLE_IPV6
int Resolve6(Socket *,const std::string& host,port_t port);
#endif
/** Do a reverse dns lookup. */
int Resolve(Socket *,ipaddr_t a);
#ifdef ENABLE_IPV6
int Resolve(Socket *,in6_addr& a);
#endif
/** Get listen port of asynchronous dns server. */
port_t GetResolverPort();
/** Resolver thread ready for queries. */
bool ResolverReady();
/** Returns true if the socket is waiting for a resolve event. */
bool Resolving(Socket *);
#endif // ENABLE_RESOLVER
#ifdef ENABLE_TRIGGERS
/** Fetch unique trigger id. */
int TriggerID(Socket *src);
/** Subscribe socket to trigger id. */
bool Subscribe(int id, Socket *dst);
/** Unsubscribe socket from trigger id. */
bool Unsubscribe(int id, Socket *dst);
/** Execute OnTrigger for subscribed sockets.
\param id Trigger ID
\param data Data passed from source to destination
\param erase Empty trigger id source and destination maps if 'true',
Leave them in place if 'false' - if a trigger should be called many times */
void Trigger(int id, Socket::TriggerData& data, bool erase = true);
#endif // ENABLE_TRIGGERS
#ifdef ENABLE_DETACH
/** Indicates that the handler runs under SocketThread. */
void SetSlave(bool x = true);
/** Indicates that the handler runs under SocketThread. */
bool IsSlave();
#endif
/** Sanity check of those accursed lists. */
void CheckSanity();
protected:
socket_m m_sockets; ///< Active sockets map
socket_m m_add; ///< Sockets to be added to sockets map
std::list<Socket *> m_delete; ///< Sockets to be deleted (failed when Add)
protected:
StdLog *m_stdlog; ///< Registered log class, or NULL
Mutex& m_mutex; ///< Thread safety mutex
bool m_b_use_mutex; ///< Mutex correctly initialized
private:
void CheckList(socket_v&,const std::string&); ///< Used by CheckSanity
/** Remove socket from socket map, used by Socket class. */
void Remove(Socket *);
SOCKET m_maxsock; ///< Highest file descriptor + 1 in active sockets list
fd_set m_rfds; ///< file descriptor set monitored for read events
fd_set m_wfds; ///< file descriptor set monitored for write events
fd_set m_efds; ///< file descriptor set monitored for exceptions
int m_preverror; ///< debug select() error
int m_errcnt; ///< debug select() error
time_t m_tlast; ///< timeout control
// state lists
socket_v m_fds; ///< Active file descriptor list
socket_v m_fds_erase; ///< File descriptors that are to be erased from m_sockets
socket_v m_fds_callonconnect; ///< checklist CallOnConnect
#ifdef ENABLE_DETACH
socket_v m_fds_detach; ///< checklist Detach
#endif
socket_v m_fds_timeout; ///< checklist timeout
socket_v m_fds_retry; ///< checklist retry client connect
socket_v m_fds_close; ///< checklist close and delete
#ifdef ENABLE_SOCKS4
ipaddr_t m_socks4_host; ///< Socks4 server host ip
port_t m_socks4_port; ///< Socks4 server port number
std::string m_socks4_userid; ///< Socks4 userid
bool m_bTryDirect; ///< Try direct connection if socks4 server fails
#endif
#ifdef ENABLE_RESOLVER
int m_resolv_id; ///< Resolver id counter
ResolvServer *m_resolver; ///< Resolver thread pointer
port_t m_resolver_port; ///< Resolver listen port
std::map<Socket *, bool> m_resolve_q; ///< resolve queue
#endif
#ifdef ENABLE_POOL
bool m_b_enable_pool; ///< Connection pool enabled if true
#endif
#ifdef ENABLE_TRIGGERS
int m_next_trigger_id; ///< Unique trigger id counter
std::map<int, Socket *> m_trigger_src; ///< mapping trigger id to source socket
std::map<int, std::map<Socket *, bool> > m_trigger_dst; ///< mapping trigger id to destination sockets
#endif
#ifdef ENABLE_DETACH
bool m_slave; ///< Indicates that this is a ISocketHandler run in SocketThread
#endif
};
#ifdef SOCKETS_NAMESPACE
}
#endif
#endif // _SOCKETS_SocketHandler_H

View File

@@ -1,73 +0,0 @@
/** \file StdLog.h
** \date 2004-06-01
** \author grymse@alhem.net
**/
/*
Copyright (C) 2004-2007 Anders Hedstrom
This library is made available under the terms of the GNU GPL.
If you would like to use this library in a closed-source application,
a separate license agreement is available. For information about
the closed-source license agreement for the C++ sockets library,
please visit http://www.alhem.net/Sockets/license.html and/or
email license@alhem.net.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETS_StdLog_H
#define _SOCKETS_StdLog_H
#include "sockets-config.h"
#include <string>
#ifdef SOCKETS_NAMESPACE
namespace SOCKETS_NAMESPACE {
#endif
/** error level enum. */
typedef enum
{
LOG_LEVEL_WARNING = 0,
LOG_LEVEL_ERROR,
LOG_LEVEL_FATAL,
LOG_LEVEL_INFO
} loglevel_t;
class ISocketHandler;
class Socket;
/** \defgroup logging Log help classes */
/** Log class interface.
\ingroup logging */
class StdLog
{
public:
virtual ~StdLog() {}
virtual void error(ISocketHandler *,Socket *,
const std::string& user_text,
int err,
const std::string& sys_err,
loglevel_t = LOG_LEVEL_WARNING) = 0;
};
#ifdef SOCKETS_NAMESPACE
}
#endif
#endif // _SOCKETS_StdLog_H

View File

@@ -1,55 +0,0 @@
/** \file StdoutLog.h
** \date 2004-06-01
** \author grymse@alhem.net
**/
/*
Copyright (C) 2004-2007 Anders Hedstrom
This library is made available under the terms of the GNU GPL.
If you would like to use this library in a closed-source application,
a separate license agreement is available. For information about
the closed-source license agreement for the C++ sockets library,
please visit http://www.alhem.net/Sockets/license.html and/or
email license@alhem.net.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETS_StdoutLog_H
#define _SOCKETS_StdoutLog_H
#include "sockets-config.h"
#include "StdLog.h"
#ifdef SOCKETS_NAMESPACE
namespace SOCKETS_NAMESPACE {
#endif
/** StdLog implementation, logs to stdout.
\ingroup logging */
class StdoutLog : public StdLog
{
public:
void error(ISocketHandler *,Socket *,const std::string& call,int err,const std::string& sys_err,loglevel_t);
};
#ifdef SOCKETS_NAMESPACE
}
#endif
#endif // _SOCKETS_StdoutLog_H

View File

@@ -1,124 +0,0 @@
#ifndef _StreamSocket_H
#define _StreamSocket_H
#include "Socket.h"
#ifdef SOCKETS_NAMESPACE
namespace SOCKETS_NAMESPACE {
#endif
/** SOCK_STREAM Socket base class.
\ingroup basic */
class StreamSocket : public Socket
{
public:
StreamSocket(ISocketHandler& );
~StreamSocket();
/** Socket should Check Connect on next write event from select(). */
void SetConnecting(bool = true);
/** Check connecting flag.
\return true if the socket is still trying to connect */
bool Connecting();
/** Returns true when socket file descriptor is valid,
socket connection is established, and socket is not about to
be closed. */
bool Ready();
/** Set timeout to use for connection attempt.
\param x Timeout in seconds */
void SetConnectTimeout(int x);
/** Return number of seconds to wait for a connection.
\return Connection timeout (seconds) */
int GetConnectTimeout();
/** Set flush before close to make a tcp socket completely empty its
output buffer before closing the connection. */
void SetFlushBeforeClose(bool = true);
/** Check flush before status.
\return true if the socket should send all data before closing */
bool GetFlushBeforeClose();
/** Define number of connection retries (tcp only).
n = 0 - no retry
n > 0 - number of retries
n = -1 - unlimited retries */
void SetConnectionRetry(int n);
/** Get number of maximum connection retries (tcp only). */
int GetConnectionRetry();
/** Increase number of actual connection retries (tcp only). */
void IncreaseConnectionRetries();
/** Get number of actual connection retries (tcp only). */
int GetConnectionRetries();
/** Reset actual connection retries (tcp only). */
void ResetConnectionRetries();
// LIST_CALLONCONNECT
/** Instruct socket to call OnConnect callback next sockethandler cycle. */
void SetCallOnConnect(bool x = true);
/** Check call on connect flag.
\return true if OnConnect() should be called a.s.a.p */
bool CallOnConnect();
// LIST_RETRY
/** Set flag to initiate a connection attempt after a connection timeout. */
void SetRetryClientConnect(bool x = true);
/** Check if a connection attempt should be made.
\return true when another attempt should be made */
bool RetryClientConnect();
/** Called after OnRead if socket is in line protocol mode.
\sa SetLineProtocol */
/** Enable the OnLine callback. Do not create your own OnRead
* callback when using this. */
virtual void SetLineProtocol(bool = true);
/** Check line protocol mode.
\return true if socket is in line protocol mode */
bool LineProtocol();
/** Set shutdown status. */
void SetShutdown(int);
/** Get shutdown status. */
int GetShutdown();
/** Returns IPPROTO_TCP or IPPROTO_SCTP */
virtual int Protocol() = 0;
protected:
StreamSocket(const StreamSocket& ) {} // copy constructor
private:
StreamSocket& operator=(const StreamSocket& ) { return *this; } // assignment operator
bool m_bConnecting; ///< Flag indicating connection in progress
int m_connect_timeout; ///< Connection timeout (seconds)
bool m_flush_before_close; ///< Send all data before closing (default true)
int m_connection_retry; ///< Maximum connection retries (tcp)
int m_retries; ///< Actual number of connection retries (tcp)
bool m_call_on_connect; ///< OnConnect will be called next ISocketHandler cycle if true
bool m_b_retry_connect; ///< Try another connection attempt next ISocketHandler cycle
bool m_line_protocol; ///< Line protocol mode flag
int m_shutdown; ///< Shutdown status
};
#ifdef SOCKETS_NAMESPACE
} // namespace SOCKETS_NAMESPACE {
#endif
#endif // _StreamSocket_H

View File

@@ -1,356 +0,0 @@
/** \file TcpSocket.h
** \date 2004-02-13
** \author grymse@alhem.net
**/
/*
Copyright (C) 2004-2007 Anders Hedstrom
This library is made available under the terms of the GNU GPL.
If you would like to use this library in a closed-source application,
a separate license agreement is available. For information about
the closed-source license agreement for the C++ sockets library,
please visit http://www.alhem.net/Sockets/license.html and/or
email license@alhem.net.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETS_TcpSocket_H
#define _SOCKETS_TcpSocket_H
#include "sockets-config.h"
#include "StreamSocket.h"
#ifdef HAVE_OPENSSL
#include <openssl/ssl.h>
#include "SSLInitializer.h"
#endif
#include <string.h>
#define TCP_BUFSIZE_READ 16400
#define TCP_OUTPUT_CAPACITY 1024000
#ifdef SOCKETS_NAMESPACE
namespace SOCKETS_NAMESPACE {
#endif
class SocketAddress;
/** Socket implementation for TCP.
\ingroup basic */
class TcpSocket : public StreamSocket
{
/** \defgroup internal Internal utility */
protected:
/** Buffer class containing one read/write circular buffer.
\ingroup internal */
class CircularBuffer
{
public:
CircularBuffer(size_t size);
~CircularBuffer();
/** append l bytes from p to buffer */
bool Write(const char *p,size_t l);
/** copy l bytes from buffer to dest */
bool Read(char *dest,size_t l);
/** copy l bytes from buffer to dest, dont touch buffer pointers */
bool SoftRead(char *dest, size_t l);
/** skip l bytes from buffer */
bool Remove(size_t l);
/** read l bytes from buffer, returns as string. */
std::string ReadString(size_t l);
/** total buffer length */
size_t GetLength();
/** pointer to circular buffer beginning */
const char *GetStart();
/** return number of bytes from circular buffer beginning to buffer physical end */
size_t GetL();
/** return free space in buffer, number of bytes until buffer overrun */
size_t Space();
/** return total number of bytes written to this buffer, ever */
unsigned long ByteCounter(bool clear = false);
private:
CircularBuffer(const CircularBuffer& /*s*/) {}
CircularBuffer& operator=(const CircularBuffer& ) { return *this; }
char *buf;
size_t m_max;
size_t m_q;
size_t m_b;
size_t m_t;
unsigned long m_count;
};
/** Output buffer struct.
\ingroup internal */
struct OUTPUT {
OUTPUT() : _b(0), _t(0), _q(0) {}
OUTPUT(const char *buf, size_t len) : _b(0), _t(len), _q(len) {
memcpy(_buf, buf, len);
}
size_t Space() {
return TCP_OUTPUT_CAPACITY - _t;
}
void Add(const char *buf, size_t len) {
memcpy(_buf + _t, buf, len);
_t += len;
_q += len;
}
size_t Remove(size_t len) {
_b += len;
_q -= len;
return _q;
}
const char *Buf() {
return _buf + _b;
}
size_t Len() {
return _q;
}
size_t _b;
size_t _t;
size_t _q;
char _buf[TCP_OUTPUT_CAPACITY];
};
typedef std::list<OUTPUT *> output_l;
public:
/** Constructor with standard values on input/output buffers. */
TcpSocket(ISocketHandler& );
/** Constructor with custom values for i/o buffer.
\param h ISocketHandler reference
\param isize Input buffer size
\param osize Output buffer size */
TcpSocket(ISocketHandler& h,size_t isize,size_t osize);
~TcpSocket();
/** Open a connection to a remote server.
If you want your socket to connect to a server,
always call Open before Add'ing a socket to the sockethandler.
If not, the connection attempt will not be monitored by the
socket handler...
\param ip IP address
\param port Port number
\param skip_socks Do not use socks4 even if configured */
bool Open(ipaddr_t ip,port_t port,bool skip_socks = false);
#ifdef ENABLE_IPV6
#ifdef IPPROTO_IPV6
/** Open connection.
\param ip Ipv6 address
\param port Port number
\param skip_socks Do not use socks4 even if configured */
bool Open(in6_addr ip,port_t port,bool skip_socks = false);
#endif
#endif
bool Open(SocketAddress&,bool skip_socks = false);
bool Open(SocketAddress&,SocketAddress& bind_address,bool skip_socks = false);
/** Open connection.
\param host Hostname
\param port Port number */
bool Open(const std::string &host,port_t port);
/** Connect timeout callback. */
void OnConnectTimeout();
#ifdef _WIN32
/** Connection failed reported as exception on win32 */
void OnException();
#endif
/** Close file descriptor - internal use only.
\sa SetCloseAndDelete */
int Close();
/** Send a string.
\param s String to send
\param f Dummy flags -- not used */
void Send(const std::string &s,int f = 0);
/** Send string using printf formatting. */
void Sendf(const char *format, ...);
/** Send buffer of bytes.
\param buf Buffer pointer
\param len Length of data
\param f Dummy flags -- not used */
void SendBuf(const char *buf,size_t len,int f = 0);
/** This callback is executed after a successful read from the socket.
\param buf Pointer to the data
\param len Length of the data */
virtual void OnRawData(const char *buf,size_t len);
/** Called when output buffer has been sent.
Note: Will only be called IF the output buffer has been used.
Send's that was successful without needing the output buffer
will not generate a call to this method. */
virtual void OnWriteComplete();
/** Number of bytes in input buffer. */
size_t GetInputLength();
/** Number of bytes in output buffer. */
size_t GetOutputLength();
/** Callback fires when a socket in line protocol has read one full line.
\param line Line read */
void OnLine(const std::string& line);
/** Get counter of number of bytes received. */
uint64_t GetBytesReceived(bool clear = false);
/** Get counter of number of bytes sent. */
uint64_t GetBytesSent(bool clear = false);
/** Socks4 specific callback. */
void OnSocks4Connect();
/** Socks4 specific callback. */
void OnSocks4ConnectFailed();
/** Socks4 specific callback.
\return 'need_more' */
bool OnSocks4Read();
#ifdef ENABLE_RESOLVER
/** Callback executed when resolver thread has finished a resolve request. */
void OnResolved(int id,ipaddr_t a,port_t port);
#ifdef ENABLE_IPV6
void OnResolved(int id,in6_addr& a,port_t port);
#endif
#endif
#ifdef HAVE_OPENSSL
/** Callback for 'New' ssl support - replaces SSLSocket. Internal use. */
void OnSSLConnect();
/** Callback for 'New' ssl support - replaces SSLSocket. Internal use. */
void OnSSLAccept();
/** This method must be implemented to initialize
the ssl context for an outgoing connection. */
virtual void InitSSLClient();
/** This method must be implemented to initialize
the ssl context for an incoming connection. */
virtual void InitSSLServer();
#endif
#ifdef ENABLE_RECONNECT
/** Flag that says a broken connection will try to reconnect. */
void SetReconnect(bool = true);
/** Check reconnect on lost connection flag status. */
bool Reconnect();
/** Flag to determine if a reconnect is in progress. */
void SetIsReconnect(bool x = true);
/** Socket is reconnecting. */
bool IsReconnect();
#endif
void DisableInputBuffer(bool = true);
void OnOptions(int,int,int,SOCKET);
void SetLineProtocol(bool = true);
// TCP options
bool SetTcpNodelay(bool = true);
virtual int Protocol();
/** Trigger limit for callback OnTransferLimit. */
void SetTransferLimit(size_t sz);
/** This callback fires when the output buffer drops below the value
set by SetTransferLimit. Default: 0 (disabled). */
virtual void OnTransferLimit();
protected:
TcpSocket(const TcpSocket& );
void OnRead();
void OnRead( char *buf, size_t n );
void OnWrite();
#ifdef HAVE_OPENSSL
/** SSL; Initialize ssl context for a client socket.
\param meth_in SSL method */
void InitializeContext(const std::string& context, SSL_METHOD *meth_in = NULL);
/** SSL; Initialize ssl context for a server socket.
\param keyfile Combined private key/certificate file
\param password Password for private key
\param meth_in SSL method */
void InitializeContext(const std::string& context, const std::string& keyfile, const std::string& password, SSL_METHOD *meth_in = NULL);
/** SSL; Initialize ssl context for a server socket.
\param certfile Separate certificate file
\param keyfile Combined private key/certificate file
\param password Password for private key
\param meth_in SSL method */
void InitializeContext(const std::string& context, const std::string& certfile, const std::string& keyfile, const std::string& password, SSL_METHOD *meth_in = NULL);
/** SSL; Password callback method. */
static int SSL_password_cb(char *buf,int num,int rwflag,void *userdata);
/** SSL; Get pointer to ssl context structure. */
virtual SSL_CTX *GetSslContext();
/** SSL; Get pointer to ssl structure. */
virtual SSL *GetSsl();
/** ssl; still negotiating connection. */
bool SSLNegotiate();
/** SSL; Get ssl password. */
const std::string& GetPassword();
#endif
CircularBuffer ibuf; ///< Circular input buffer
private:
TcpSocket& operator=(const TcpSocket& ) { return *this; }
/** the actual send() */
int TryWrite(const char *buf, size_t len);
/** add data to output buffer top */
void Buffer(const char *buf, size_t len);
//
bool m_b_input_buffer_disabled;
uint64_t m_bytes_sent;
uint64_t m_bytes_received;
bool m_skip_c; ///< Skip second char of CRLF or LFCR sequence in OnRead
char m_c; ///< First char in CRLF or LFCR sequence
std::string m_line; ///< Current line in line protocol mode
#ifdef SOCKETS_DYNAMIC_TEMP
char *m_buf; ///< temporary read buffer
#endif
output_l m_obuf; ///< output buffer
OUTPUT *m_obuf_top; ///< output buffer on top
size_t m_transfer_limit;
size_t m_output_length;
#ifdef HAVE_OPENSSL
static SSLInitializer m_ssl_init;
SSL_CTX *m_ssl_ctx; ///< ssl context
SSL *m_ssl; ///< ssl 'socket'
BIO *m_sbio; ///< ssl bio
std::string m_password; ///< ssl password
#endif
#ifdef ENABLE_SOCKS4
int m_socks4_state; ///< socks4 support
char m_socks4_vn; ///< socks4 support, temporary variable
char m_socks4_cd; ///< socks4 support, temporary variable
unsigned short m_socks4_dstport; ///< socks4 support
unsigned long m_socks4_dstip; ///< socks4 support
#endif
#ifdef ENABLE_RESOLVER
int m_resolver_id; ///< Resolver id (if any) for current Open call
#endif
#ifdef ENABLE_RECONNECT
bool m_b_reconnect; ///< Reconnect on lost connection flag
bool m_b_is_reconnect; ///< Trying to reconnect
#endif
};
#ifdef SOCKETS_NAMESPACE
}
#endif
#endif // _SOCKETS_TcpSocket_H

View File

@@ -1,100 +0,0 @@
/** \file Thread.h
** \date 2004-10-30
** \author grymse@alhem.net
**/
/*
Copyright (C) 2004-2007 Anders Hedstrom
This library is made available under the terms of the GNU GPL.
If you would like to use this library in a closed-source application,
a separate license agreement is available. For information about
the closed-source license agreement for the C++ sockets library,
please visit http://www.alhem.net/Sockets/license.html and/or
email license@alhem.net.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETS_Thread_H
#define _SOCKETS_Thread_H
#include "sockets-config.h"
#ifdef SOCKETS_NAMESPACE
namespace SOCKETS_NAMESPACE {
#endif
#ifdef _WIN32
// to be
//typedef DWORD threadfunc_t;
//typedef LPVOID threadparam_t;
//#define STDPREFIX WINAPI
typedef unsigned threadfunc_t;
typedef void * threadparam_t;
#define STDPREFIX __stdcall
#else
#include <pthread.h>
typedef void * threadfunc_t;
typedef void * threadparam_t;
#define STDPREFIX
#endif
/** \defgroup threading Threading */
/** Thread base class.
The Thread class is used by the resolver (ResolvServer) and running a detached socket (SocketThread).
When you know some processing will take a long time and will freeze up a socket, there is always the
possibility to call Detach() on that socket before starting the processing.
When the OnDetached() callback is later called the processing can continue, now in its own thread.
\ingroup threading */
class Thread
{
public:
Thread(bool release = true);
virtual ~Thread();
static threadfunc_t STDPREFIX StartThread(threadparam_t);
virtual void Run() = 0;
bool IsRunning();
void SetRunning(bool x);
bool IsReleased();
void SetRelease(bool x);
bool DeleteOnExit();
void SetDeleteOnExit(bool x = true);
bool IsDestructor();
private:
Thread(const Thread& ) {}
Thread& operator=(const Thread& ) { return *this; }
#ifdef _WIN32
HANDLE m_thread;
unsigned m_dwThreadId;
#else
pthread_t m_thread;
#endif
bool m_running;
bool m_release;
bool m_b_delete_on_exit;
bool m_b_destructor;
};
#ifdef SOCKETS_NAMESPACE
}
#endif
#endif // _SOCKETS_Thread_H

View File

@@ -1,215 +0,0 @@
/** \file UdpSocket.h
** \date 2004-02-13
** \author grymse@alhem.net
**/
/*
Copyright (C) 2004-2007 Anders Hedstrom
This library is made available under the terms of the GNU GPL.
If you would like to use this library in a closed-source application,
a separate license agreement is available. For information about
the closed-source license agreement for the C++ sockets library,
please visit http://www.alhem.net/Sockets/license.html and/or
email license@alhem.net.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETS_UdpSocket_H
#define _SOCKETS_UdpSocket_H
#include "sockets-config.h"
#include "Socket.h"
#ifdef SOCKETS_NAMESPACE
namespace SOCKETS_NAMESPACE {
#endif
/** Socket implementation for UDP.
\ingroup basic */
class UdpSocket : public Socket
{
public:
/** Constructor.
\param h ISocketHandler reference
\param ibufsz Maximum size of receive message (extra bytes will be truncated)
\param ipv6 'true' if this is an ipv6 socket */
UdpSocket(ISocketHandler& h,int ibufsz = 16384,bool ipv6 = false, int retries = 0);
~UdpSocket();
/** Called when incoming data has been received.
\param buf Pointer to data
\param len Length of data
\param sa Pointer to sockaddr struct of sender
\param sa_len Length of sockaddr struct */
virtual void OnRawData(const char *buf,size_t len,struct sockaddr *sa,socklen_t sa_len);
/** Called when incoming data has been received and read timestamp is enabled.
\param buf Pointer to data
\param len Length of data
\param sa Pointer to sockaddr struct of sender
\param sa_len Length of sockaddr struct
\param ts Timestamp from message */
virtual void OnRawData(const char *buf,size_t len,struct sockaddr *sa,socklen_t sa_len,struct timeval *ts);
/** To receive incoming data, call Bind to setup an incoming port.
\param port Incoming port number
\param range Port range to try if ports already in use
\return 0 if bind succeeded */
int Bind(port_t& port,int range = 1);
/** To receive data on a specific interface:port, use this.
\param intf Interface ip/hostname
\param port Port number
\param range Port range
\return 0 if bind succeeded */
int Bind(const std::string& intf,port_t& port,int range = 1);
/** To receive data on a specific interface:port, use this.
\param a Ip address
\param port Port number
\param range Port range
\return 0 if bind succeeded */
int Bind(ipaddr_t a,port_t& port,int range = 1);
#ifdef ENABLE_IPV6
#ifdef IPPROTO_IPV6
/** To receive data on a specific interface:port, use this.
\param a Ipv6 address
\param port Port number
\param range Port range
\return 0 if bind succeeded */
int Bind(in6_addr a,port_t& port,int range = 1);
#endif
#endif
/** To receive data on a specific interface:port, use this.
\param ad Socket address
\param range Port range
\return 0 if bind succeeded */
int Bind(SocketAddress& ad,int range = 1);
/** Define remote host.
\param l Address of remote host
\param port Port of remote host
\return true if successful */
bool Open(ipaddr_t l,port_t port);
/** Define remote host.
\param host Hostname
\param port Port number
\return true if successful */
bool Open(const std::string& host,port_t port);
#ifdef ENABLE_IPV6
#ifdef IPPROTO_IPV6
/** Define remote host.
\param a Address of remote host, ipv6
\param port Port of remote host
\return true if successful */
bool Open(struct in6_addr& a,port_t port);
#endif
#endif
/** Define remote host.
\param ad Socket address
\return true if successful */
bool Open(SocketAddress& ad);
/** Send to specified host */
void SendToBuf(const std::string& ,port_t,const char *data,int len,int flags = 0);
/** Send to specified address */
void SendToBuf(ipaddr_t,port_t,const char *data,int len,int flags = 0);
#ifdef ENABLE_IPV6
#ifdef IPPROTO_IPV6
/** Send to specified ipv6 address */
void SendToBuf(in6_addr,port_t,const char *data,int len,int flags = 0);
#endif
#endif
/** Send to specified socket address */
void SendToBuf(SocketAddress& ad,const char *data,int len,int flags = 0);
/** Send string to specified host */
void SendTo(const std::string&,port_t,const std::string&,int flags = 0);
/** Send string to specified address */
void SendTo(ipaddr_t,port_t,const std::string&,int flags = 0);
#ifdef ENABLE_IPV6
#ifdef IPPROTO_IPV6
/** Send string to specified ipv6 address */
void SendTo(in6_addr,port_t,const std::string&,int flags = 0);
#endif
#endif
/** Send string to specified socket address */
void SendTo(SocketAddress& ad,const std::string&,int flags = 0);
/** Send to connected address */
void SendBuf(const char *data,size_t,int flags = 0);
/** Send string to connected address. */
void Send(const std::string& ,int flags = 0);
/** Set broadcast */
void SetBroadcast(bool b = true);
/** Check broadcast flag.
\return true broadcast is enabled. */
bool IsBroadcast();
/** multicast */
void SetMulticastTTL(int ttl = 1);
int GetMulticastTTL();
void SetMulticastLoop(bool = true);
bool IsMulticastLoop();
void AddMulticastMembership(const std::string& group,const std::string& intf = "0.0.0.0",int if_index = 0);
void DropMulticastMembership(const std::string& group,const std::string& intf = "0.0.0.0",int if_index = 0);
#ifdef ENABLE_IPV6
#ifdef IPPROTO_IPV6
/** multicast, ipv6 only */
void SetMulticastHops(int = -1);
/** multicast, ipv6 only */
int GetMulticastHops();
#endif
#endif
/** Returns true if Bind succeeded. */
bool IsBound();
/** Return Bind port number */
port_t GetPort();
void OnOptions(int,int,int,SOCKET) {}
int GetLastSizeWritten();
/** Also read timestamp information from incoming message */
void SetTimestamp(bool = true);
protected:
UdpSocket(const UdpSocket& s) : Socket(s) {}
void OnRead();
#if defined(LINUX) || defined(MACOSX)
/** This method emulates socket recvfrom, but uses messages so we can get the timestamp */
int ReadTS(char *ioBuf, int inBufSize, struct sockaddr *from, socklen_t fromlen, struct timeval *ts);
#endif
private:
UdpSocket& operator=(const UdpSocket& ) { return *this; }
/** create before using sendto methods */
void CreateConnection();
char *m_ibuf; ///< Input buffer
int m_ibufsz; ///< Size of input buffer
bool m_bind_ok; ///< Bind completed successfully
port_t m_port; ///< Bind port number
int m_last_size_written;
int m_retries;
bool m_b_read_ts;
};
#ifdef SOCKETS_NAMESPACE
}
#endif
#endif // _SOCKETS_UdpSocket_H

View File

@@ -1,186 +0,0 @@
/** \file Utility.h
** \date 2004-02-13
** \author grymse@alhem.net
**/
/*
Copyright (C) 2004-2007 Anders Hedstrom
This library is made available under the terms of the GNU GPL.
If you would like to use this library in a closed-source application,
a separate license agreement is available. For information about
the closed-source license agreement for the C++ sockets library,
please visit http://www.alhem.net/Sockets/license.html and/or
email license@alhem.net.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETS_Utility_H
#define _SOCKETS_Utility_H
#include "sockets-config.h"
#include <ctype.h>
#include <string.h>
#include <memory>
#include "socket_include.h"
#include <map>
#include <string>
#ifdef SOCKETS_NAMESPACE
namespace SOCKETS_NAMESPACE {
#endif
#define TWIST_LEN 624
class SocketAddress;
/** Conversion utilities.
\ingroup util */
class Utility
{
/**
The Mersenne Twister
http://www.math.keio.ac.jp/~matumoto/emt.html
*/
class Rng {
public:
Rng(unsigned long seed);
unsigned long Get();
private:
int m_value;
unsigned long m_tmp[TWIST_LEN];
};
class ncmap_compare {
public:
bool operator()(const std::string& x, const std::string& y) const {
return strcasecmp(x.c_str(), y.c_str()) < 0;
}
};
public:
template<typename Y> class ncmap : public std::map<std::string, Y, ncmap_compare> {
public:
ncmap() {}
};
public:
static std::string base64(const std::string& str_in);
static std::string base64d(const std::string& str_in);
static std::string l2string(long l);
static std::string bigint2string(uint64_t l);
static uint64_t atoi64(const std::string& str);
static unsigned int hex2unsigned(const std::string& str);
static std::string rfc1738_encode(const std::string& src);
static std::string rfc1738_decode(const std::string& src);
/** Checks whether a string is a valid ipv4/ipv6 ip number. */
static bool isipv4(const std::string&);
/** Checks whether a string is a valid ipv4/ipv6 ip number. */
static bool isipv6(const std::string&);
/** Hostname to ip resolution ipv4, not asynchronous. */
static bool u2ip(const std::string&, ipaddr_t&);
static bool u2ip(const std::string&, struct sockaddr_in& sa, int ai_flags = 0);
#ifdef ENABLE_IPV6
#ifdef IPPROTO_IPV6
/** Hostname to ip resolution ipv6, not asynchronous. */
static bool u2ip(const std::string&, struct in6_addr&);
static bool u2ip(const std::string&, struct sockaddr_in6& sa, int ai_flags = 0);
#endif
#endif
/** Reverse lookup of address to hostname */
static bool reverse(struct sockaddr *sa, socklen_t sa_len, std::string&, int flags = 0);
static bool reverse(struct sockaddr *sa, socklen_t sa_len, std::string& hostname, std::string& service, int flags = 0);
static bool u2service(const std::string& name, int& service, int ai_flags = 0);
/** Convert binary ip address to string: ipv4. */
static void l2ip(const ipaddr_t,std::string& );
static void l2ip(const in_addr&,std::string& );
#ifdef ENABLE_IPV6
#ifdef IPPROTO_IPV6
/** Convert binary ip address to string: ipv6. */
static void l2ip(const struct in6_addr&,std::string& ,bool mixed = false);
/** ipv6 address compare. */
static int in6_addr_compare(in6_addr,in6_addr);
#endif
#endif
/** ResolveLocal (hostname) - call once before calling any GetLocal method. */
static void ResolveLocal();
/** Returns local hostname, ResolveLocal must be called once before using.
\sa ResolveLocal */
static const std::string& GetLocalHostname();
/** Returns local ip, ResolveLocal must be called once before using.
\sa ResolveLocal */
static ipaddr_t GetLocalIP();
/** Returns local ip number as string.
\sa ResolveLocal */
static const std::string& GetLocalAddress();
#ifdef ENABLE_IPV6
#ifdef IPPROTO_IPV6
/** Returns local ipv6 ip.
\sa ResolveLocal */
static const struct in6_addr& GetLocalIP6();
/** Returns local ipv6 address.
\sa ResolveLocal */
static const std::string& GetLocalAddress6();
#endif
#endif
/** Set environment variable.
\param var Name of variable to set
\param value Value */
static void SetEnv(const std::string& var,const std::string& value);
/** Convert sockaddr struct to human readable string.
\param sa Ptr to sockaddr struct */
static std::string Sa2String(struct sockaddr *sa);
/** Get current time in sec/microseconds. */
static void GetTime(struct timeval *);
static std::auto_ptr<SocketAddress> CreateAddress(struct sockaddr *,socklen_t);
static unsigned long ThreadID();
static std::string ToLower(const std::string& str);
static std::string ToUpper(const std::string& str);
static std::string ToString(double d);
/** Returns a random 32-bit integer */
static unsigned long Rnd();
private:
static std::string m_host; ///< local hostname
static ipaddr_t m_ip; ///< local ip address
static std::string m_addr; ///< local ip address in string format
#ifdef ENABLE_IPV6
#ifdef IPPROTO_IPV6
static struct in6_addr m_local_ip6; ///< local ipv6 address
#endif
static std::string m_local_addr6; ///< local ipv6 address in string format
#endif
static bool m_local_resolved; ///< ResolveLocal has been called if true
};
#ifdef SOCKETS_NAMESPACE
}
#endif
#endif // _SOCKETS_Utility_H

View File

@@ -1,290 +0,0 @@
/** \file socket_include.h
** \date 2005-04-12
** \author grymse@alhem.net
**/
/*
Copyright (C) 2004-2007 Anders Hedstrom
This library is made available under the terms of the GNU GPL.
If you would like to use this library in a closed-source application,
a separate license agreement is available. For information about
the closed-source license agreement for the C++ sockets library,
please visit http://www.alhem.net/Sockets/license.html and/or
email license@alhem.net.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETS_socket_include_H
#define _SOCKETS_socket_include_H
#include "sockets-config.h"
#ifdef _MSC_VER
#pragma warning(disable:4514)
#endif
// common defines affecting library and applications using library
/* Define SOCKETS_DYNAMIC_TEMP to use dynamically allocated buffers
in read operations - helps on ECOS */
#define SOCKETS_DYNAMIC_TEMP
// platform specific stuff
#if (defined(__unix__) || defined(unix)) && !defined(USG)
#include <sys/param.h>
#endif
#include <list>
// int64
#ifdef _WIN32
typedef unsigned __int64 uint64_t;
#else
#include <stdlib.h>
#ifdef SOLARIS
# include <sys/types.h>
#else
# include <stdint.h>
#endif
#endif
#ifndef _WIN32
// ----------------------------------------
// common unix includes / defines
#include <unistd.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
//#include <netdb.h>
// all typedefs in this file will be declared outside the sockets namespace,
// because some os's will already have one or more of the type defined.
typedef int SOCKET;
#define Errno errno
#define StrError strerror
#ifdef SOCKETS_NAMESPACE
namespace SOCKETS_NAMESPACE {
#endif
// WIN32 adapt
#define closesocket close
#define INVALID_SOCKET -1
#define SOCKET_ERROR -1
#ifndef INADDR_NONE
#define INADDR_NONE ((unsigned long) -1)
#endif // INADDR_NONE
#ifdef SOCKETS_NAMESPACE
}
#endif
#endif // !_WIN32
// ----------------------------------------
// Generic
#ifndef SOL_IP
#define SOL_IP IPPROTO_IP
#endif
// ----------------------------------------
// OS specific adaptions
#ifdef SOLARIS
// ----------------------------------------
// Solaris
typedef unsigned short port_t;
#ifdef SOCKETS_NAMESPACE
namespace SOCKETS_NAMESPACE {
#endif
// no defs
#ifdef SOCKETS_NAMESPACE
}
#endif
#define s6_addr16 _S6_un._S6_u8
#define MSG_NOSIGNAL 0
#elif defined __FreeBSD__
// ----------------------------------------
// FreeBSD
# if __FreeBSD_version >= 400014
# define s6_addr16 __u6_addr.__u6_addr16
# if !defined(MSG_NOSIGNAL)
# define MSG_NOSIGNAL 0
# endif
# include <netinet/in.h>
typedef in_addr_t ipaddr_t;
typedef in_port_t port_t;
#ifdef SOCKETS_NAMESPACE
namespace SOCKETS_NAMESPACE {
#endif
// no defs
#ifdef SOCKETS_NAMESPACE
}
#endif
# define IPV6_ADD_MEMBERSHIP IPV6_JOIN_GROUP
# define IPV6_DROP_MEMBERSHIP IPV6_LEAVE_GROUP
# else
# error FreeBSD versions prior to 400014 does not support ipv6
# endif
#elif defined (__NetBSD__) || defined (__OpenBSD__)
# if !defined(MSG_NOSIGNAL)
# define MSG_NOSIGNAL 0
# endif
# include <netinet/in.h>
typedef in_addr_t ipaddr_t;
typedef in_port_t port_t;
#elif defined MACOSX
// ----------------------------------------
// Mac OS X
#include <string.h>
#ifdef __DARWIN_UNIX03
typedef unsigned short port_t;
#else
#include <mach/port.h>
#endif // __DARWIN_UNIX03
typedef unsigned long ipaddr_t;
#ifdef SOCKETS_NAMESPACE
namespace SOCKETS_NAMESPACE {
#endif
// no defs
#ifdef SOCKETS_NAMESPACE
}
#endif
#define s6_addr16 __u6_addr.__u6_addr16
#define MSG_NOSIGNAL 0 // oops - thanks Derek
#define IPV6_ADD_MEMBERSHIP IPV6_JOIN_GROUP
#define IPV6_DROP_MEMBERSHIP IPV6_LEAVE_GROUP
#elif defined _WIN32
// ----------------------------------------
// Win32
#ifdef _MSC_VER
#pragma comment(lib, "wsock32.lib")
#endif
#define strcasecmp _stricmp
typedef unsigned long ipaddr_t;
typedef unsigned short port_t;
typedef int socklen_t;
#ifdef SOCKETS_NAMESPACE
namespace SOCKETS_NAMESPACE {
#endif
// no defs
#ifdef SOCKETS_NAMESPACE
}
#endif
// 1.8.6: define FD_SETSIZE to something bigger than 64 if there are a lot of
// simultaneous connections (must be done before including winsock.h)
#define FD_SETSIZE 1024
// windows 2000 with ipv6 preview installed:
// http://msdn.microsoft.com/downloads/sdks/platform/tpipv6.asp
// see the FAQ on how to install
#define WIN32_LEAN_AND_MEAN
#include <winsock2.h>
#include <ws2tcpip.h>
#if _MSC_VER < 1200
#ifndef __CYGWIN__
#ifdef ENABLE_IPV6
#include <tpipv6.h> // For IPv6 Tech Preview.
#endif
#endif
#endif // _MSC_VER < 1200
#define MSG_NOSIGNAL 0
//#define SHUT_RDWR 2
#define SHUT_WR 1
#define Errno WSAGetLastError()
const char *StrError(int x);
#ifdef SOCKETS_NAMESPACE
namespace SOCKETS_NAMESPACE {
#endif
// class WSAInitializer is a part of the Socket class (on win32)
// as a static instance - so whenever an application uses a Socket,
// winsock is initialized
class WSAInitializer // Winsock Initializer
{
public:
WSAInitializer() {
if (WSAStartup(0x101,&m_wsadata))
{
exit(-1);
}
}
~WSAInitializer() {
WSACleanup();
}
private:
WSADATA m_wsadata;
};
#ifdef SOCKETS_NAMESPACE
}
#endif
#else
// ----------------------------------------
// LINUX
typedef unsigned long ipaddr_t;
typedef unsigned short port_t;
#ifdef SOCKETS_NAMESPACE
namespace SOCKETS_NAMESPACE {
#endif
// no defs
#ifdef SOCKETS_NAMESPACE
}
#endif
#endif
#ifdef SOCKETS_NAMESPACE
namespace SOCKETS_NAMESPACE {
#endif
/** List type containing file descriptors. */
typedef std::list<SOCKET> socket_v;
#ifdef SOCKETS_NAMESPACE
}
#endif
// getaddrinfo / getnameinfo replacements
#ifdef NO_GETADDRINFO
#ifndef AI_NUMERICHOST
#define AI_NUMERICHOST 1
#endif
#ifndef NI_NUMERICHOST
#define NI_NUMERICHOST 1
#endif
#endif
#endif // _SOCKETS_socket_include_H

View File

@@ -1,90 +0,0 @@
/**
** \file sockets-config.h
** \date 2007-04-14
** \author grymse@alhem.net
**/
/*
Copyright (C) 2007 Anders Hedstrom
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SOCKETS_CONFIG_H
#define _SOCKETS_CONFIG_H
#ifndef _RUN_DP
/* First undefine symbols if already defined. */
#undef HAVE_OPENSSL
#undef ENABLE_IPV6
#undef USE_SCTP
#undef NO_GETADDRINFO
#undef ENABLE_POOL
#undef ENABLE_SOCKS4
#undef ENABLE_RESOLVER
#undef ENABLE_RECONNECT
#undef ENABLE_DETACH
#undef ENABLE_TRIGGERS
#undef ENABLE_EXCEPTIONS
#endif // _RUN_DP
// define MACOSX for internal socket library checks
#if defined(__APPLE__) && defined(__MACH__) && !defined(MACOSX)
#define MACOSX
#endif
/* OpenSSL support. */
//#define HAVE_OPENSSL
/* Ipv6 support. */
//#define ENABLE_IPV6
/* SCTP support. */
//#define USE_SCTP
/* Define NO_GETADDRINFO if your operating system does not support
the "getaddrinfo" and "getnameinfo" function calls. */
#define NO_GETADDRINFO
/* Connection pool support. */
#define ENABLE_POOL
/* Socks4 client support. */
//#define ENABLE_SOCKS4
/* Asynchronous resolver. */
#define ENABLE_RESOLVER
/* Enable TCP reconnect on lost connection.
Socket::OnReconnect
Socket::OnDisconnect
*/
#define ENABLE_RECONNECT
/* Enable socket thread detach functionality. */
#define ENABLE_DETACH
/* Enable socket to socket triggers. Not yet in use. */
//#define ENABLE_TRIGGERS
/* Enabled exceptions. */
//#define ENABLE_EXCEPTIONS
/* Resolver uses the detach function so either enable both or disable both. */
#ifndef ENABLE_DETACH
#undef ENABLE_RESOLVER
#endif
#endif // _SOCKETS_CONFIG_H

View File

@@ -1,9 +0,0 @@
utf8 cpp library
Release 2.1
This is a minor feature release - added the function peek_next.
Changes from version 2.o
- Implemented feature request [ 1770746 ] "Provide a const version of next() (some sort of a peek() )
Files included in the release: utf8.h, core.h, checked.h, unchecked.h, utf8cpp.html, ReleaseNotes

File diff suppressed because it is too large Load Diff

View File

@@ -1,105 +0,0 @@
////////////////////////////////////////////////////////////////////////////////
// $Id: vld.h,v 1.27 2006/11/12 18:09:20 dmouldin Exp $
//
// Visual Leak Detector (Version 1.9d) - Import Library Header
// Copyright (c) 2006 Dan Moulding
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library 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
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
// See COPYING.txt for the full terms of the GNU Lesser General Public License.
//
////////////////////////////////////////////////////////////////////////////////
//#pragma once
#ifndef _VLD_H_
#define _VLD_H_
#ifdef _DEBUG
#pragma comment(lib, "vld.lib")
// Force a symbolic reference to the global VisualLeakDetector class object from
// the DLL. This enusres that the DLL is loaded and linked with the program,
// even if no code otherwise imports any of the DLL's exports.
#pragma comment(linker, "/include:__imp_?vld@@3VVisualLeakDetector@@A")
////////////////////////////////////////////////////////////////////////////////
//
// Visual Leak Detector APIs
//
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
// VLDDisable - Disables Visual Leak Detector's memory leak detection at
// runtime. If memory leak detection is already disabled, then calling this
// function has no effect.
//
// Note: In multithreaded programs, this function operates on a per-thread
// basis. In other words, if you call this function from one thread, then
// memory leak detection is only disabled for that thread. If memory leak
// detection is enabled for other threads, then it will remain enabled for
// those other threads. It was designed to work this way to insulate you,
// the programmer, from having to ensure thread synchronization when calling
// VLDEnable() and VLDDisable(). Without this, calling these two functions
// unsychronized could result in unpredictable and unintended behavior.
// But this also means that if you want to disable memory leak detection
// process-wide, then you need to call this function from every thread in
// the process.
//
// Return Value:
//
// None.
//
__declspec(dllimport) void VLDDisable ();
// VLDEnable - Enables Visual Leak Detector's memory leak detection at runtime.
// If memory leak detection is already enabled, which it is by default, then
// calling this function has no effect.
//
// Note: In multithreaded programs, this function operates on a per-thread
// basis. In other words, if you call this function from one thread, then
// memory leak detection is only enabled for that thread. If memory leak
// detection is disabled for other threads, then it will remain disabled for
// those other threads. It was designed to work this way to insulate you,
// the programmer, from having to ensure thread synchronization when calling
// VLDEnable() and VLDDisable(). Without this, calling these two functions
// unsychronized could result in unpredictable and unintended behavior.
// But this also means that if you want to enable memory leak detection
// process-wide, then you need to call this function from every thread in
// the process.
//
// Return Value:
//
// None.
//
__declspec(dllimport) void VLDEnable ();
#ifdef __cplusplus
}
#endif // __cplusplus
#else // !_DEBUG
#define VLDEnable()
#define VLDDisable()
#endif // _DEBUG
#endif // _VLD_H_

View File

@@ -1,333 +0,0 @@
/* zconf.h -- configuration of the zlib compression library
* Copyright (C) 1995-2005 Jean-loup Gailly.
* For conditions of distribution and use, see copyright notice in zlib.h
*/
/* @(#) $Id$ */
#ifndef ZCONF_H
#define ZCONF_H
/*
* If you *really* need a unique prefix for all types and library functions,
* compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.
*/
#ifdef Z_PREFIX
# define deflateInit_ z_deflateInit_
# define deflate z_deflate
# define deflateEnd z_deflateEnd
# define inflateInit_ z_inflateInit_
# define inflate z_inflate
# define inflateEnd z_inflateEnd
# define deflateInit2_ z_deflateInit2_
# define deflateSetDictionary z_deflateSetDictionary
# define deflateCopy z_deflateCopy
# define deflateReset z_deflateReset
# define deflateParams z_deflateParams
# define deflateBound z_deflateBound
# define deflatePrime z_deflatePrime
# define inflateInit2_ z_inflateInit2_
# define inflateSetDictionary z_inflateSetDictionary
# define inflateSync z_inflateSync
# define inflateSyncPoint z_inflateSyncPoint
# define inflateCopy z_inflateCopy
# define inflateReset z_inflateReset
# define inflateBack z_inflateBack
# define inflateBackEnd z_inflateBackEnd
# define compress z_compress
# define compress2 z_compress2
# define compressBound z_compressBound
# define uncompress z_uncompress
# define adler32 z_adler32
# define crc32 z_crc32
# define get_crc_table z_get_crc_table
# define zError z_zError
# define alloc_func z_alloc_func
# define free_func z_free_func
# define in_func z_in_func
# define out_func z_out_func
# define Byte z_Byte
# define uInt z_uInt
# define uLong z_uLong
# define Bytef z_Bytef
# define charf z_charf
# define intf z_intf
# define uIntf z_uIntf
# define uLongf z_uLongf
# define voidpf z_voidpf
# define voidp z_voidp
#endif
#if defined(__MSDOS__) && !defined(MSDOS)
# define MSDOS
#endif
#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2)
# define OS2
#endif
#if defined(_WINDOWS) && !defined(WINDOWS)
# define WINDOWS
#endif
#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__)
# ifndef WIN32
# define WIN32
# endif
#endif
#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32)
# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__)
# ifndef SYS16BIT
# define SYS16BIT
# endif
# endif
#endif
/*
* Compile with -DMAXSEG_64K if the alloc function cannot allocate more
* than 64k bytes at a time (needed on systems with 16-bit int).
*/
#ifdef SYS16BIT
# define MAXSEG_64K
#endif
#ifdef MSDOS
# define UNALIGNED_OK
#endif
#ifdef __STDC_VERSION__
# ifndef STDC
# define STDC
# endif
# if __STDC_VERSION__ >= 199901L
# ifndef STDC99
# define STDC99
# endif
# endif
#endif
#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus))
# define STDC
#endif
#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__))
# define STDC
#endif
#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32))
# define STDC
#endif
#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__))
# define STDC
#endif
#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */
# define STDC
#endif
#ifndef STDC
# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */
# define const /* note: need a more gentle solution here */
# endif
#endif
/* Some Mac compilers merge all .h files incorrectly: */
#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__)
# define NO_DUMMY_DECL
#endif
/* Maximum value for memLevel in deflateInit2 */
#ifndef MAX_MEM_LEVEL
# ifdef MAXSEG_64K
# define MAX_MEM_LEVEL 8
# else
# define MAX_MEM_LEVEL 9
# endif
#endif
/* Maximum value for windowBits in deflateInit2 and inflateInit2.
* WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files
* created by gzip. (Files created by minigzip can still be extracted by
* gzip.)
*/
#ifndef MAX_WBITS
# define MAX_WBITS 15 /* 32K LZ77 window */
#endif
/* The memory requirements for deflate are (in bytes):
(1 << (windowBits+2)) + (1 << (memLevel+9))
that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values)
plus a few kilobytes for small objects. For example, if you want to reduce
the default memory requirements from 256K to 128K, compile with
make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"
Of course this will generally degrade compression (there's no free lunch).
The memory requirements for inflate are (in bytes) 1 << windowBits
that is, 32K for windowBits=15 (default value) plus a few kilobytes
for small objects.
*/
/* Type declarations */
#ifndef OF /* function prototypes */
# ifdef STDC
# define OF(args) args
# else
# define OF(args) ()
# endif
#endif
/* The following definitions for FAR are needed only for MSDOS mixed
* model programming (small or medium model with some far allocations).
* This was tested only with MSC; for other MSDOS compilers you may have
* to define NO_MEMCPY in zutil.h. If you don't need the mixed model,
* just define FAR to be empty.
*/
#ifdef SYS16BIT
# if defined(M_I86SM) || defined(M_I86MM)
/* MSC small or medium model */
# define SMALL_MEDIUM
# ifdef _MSC_VER
# define FAR _far
# else
# define FAR far
# endif
# endif
# if (defined(__SMALL__) || defined(__MEDIUM__))
/* Turbo C small or medium model */
# define SMALL_MEDIUM
# ifdef __BORLANDC__
# define FAR _far
# else
# define FAR far
# endif
# endif
#endif
#if defined(WINDOWS) || defined(WIN32)
/* If building or using zlib as a DLL, define ZLIB_DLL.
* This is not mandatory, but it offers a little performance increase.
*/
# ifdef ZLIB_DLL
# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500))
# ifdef ZLIB_INTERNAL
# define ZEXTERN extern __declspec(dllexport)
# else
# define ZEXTERN extern __declspec(dllimport)
# endif
# endif
# endif /* ZLIB_DLL */
/* If building or using zlib with the WINAPI/WINAPIV calling convention,
* define ZLIB_WINAPI.
* Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI.
*/
# ifdef ZLIB_WINAPI
# ifdef FAR
# undef FAR
# endif
# include <windows.h>
/* No need for _export, use ZLIB.DEF instead. */
/* For complete Windows compatibility, use WINAPI, not __stdcall. */
# define ZEXPORT WINAPI
# ifdef WIN32
# define ZEXPORTVA WINAPIV
# else
# define ZEXPORTVA FAR CDECL
# endif
# endif
#endif
#if defined (__BEOS__)
# ifdef ZLIB_DLL
# ifdef ZLIB_INTERNAL
# define ZEXPORT __declspec(dllexport)
# define ZEXPORTVA __declspec(dllexport)
# else
# define ZEXPORT __declspec(dllimport)
# define ZEXPORTVA __declspec(dllimport)
# endif
# endif
#endif
#ifndef ZEXTERN
# define ZEXTERN extern
#endif
#ifndef ZEXPORT
# define ZEXPORT
#endif
#ifndef ZEXPORTVA
# define ZEXPORTVA
#endif
#ifndef FAR
# define FAR
#endif
#if !defined(__MACTYPES__)
typedef unsigned char Byte; /* 8 bits */
#endif
typedef unsigned int uInt; /* 16 bits or more */
typedef unsigned long uLong; /* 32 bits or more */
#ifdef SMALL_MEDIUM
/* Borland C/C++ and some old MSC versions ignore FAR inside typedef */
# define Bytef Byte FAR
#else
typedef Byte FAR Bytef;
#endif
typedef char FAR charf;
typedef int FAR intf;
typedef uInt FAR uIntf;
typedef uLong FAR uLongf;
#ifdef STDC
typedef void const *voidpc;
typedef void FAR *voidpf;
typedef void *voidp;
#else
typedef Byte const *voidpc;
typedef Byte FAR *voidpf;
typedef Byte *voidp;
#endif
#if 0 /* HAVE_UNISTD_H -- this line is updated by ./configure */
# include <sys/types.h> /* for off_t */
# include <unistd.h> /* for SEEK_* and off_t */
# ifdef VMS
# include <unixio.h> /* for off_t */
# endif
# define z_off_t off_t
#endif
#ifndef SEEK_SET
# define SEEK_SET 0 /* Seek from beginning of file. */
# define SEEK_CUR 1 /* Seek from current position. */
# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */
#endif
#ifndef z_off_t
# define z_off_t long
#endif
#if defined(__OS400__)
# define NO_vsnprintf
#endif
#if defined(__MVS__)
# define NO_vsnprintf
# ifdef FAR
# undef FAR
# endif
#endif
/* MVS linker does not support external names larger than 8 bytes */
#if defined(__MVS__)
# pragma map(deflateInit_,"DEIN")
# pragma map(deflateInit2_,"DEIN2")
# pragma map(deflateEnd,"DEEND")
# pragma map(deflateBound,"DEBND")
# pragma map(inflateInit_,"ININ")
# pragma map(inflateInit2_,"ININ2")
# pragma map(inflateEnd,"INEND")
# pragma map(inflateSync,"INSY")
# pragma map(inflateSetDictionary,"INSEDI")
# pragma map(compressBound,"CMBND")
# pragma map(inflate_table,"INTABL")
# pragma map(inflate_fast,"INFA")
# pragma map(inflate_copyright,"INCOPY")
#endif
#endif /* ZCONF_H */

File diff suppressed because it is too large Load Diff

View File

@@ -1,9 +0,0 @@
add_subdirectory(g3dlite)
if (NOT MACOSX)
add_subdirectory(jmalloc)
endif(NOT MACOSX)
add_subdirectory(sockets)
add_subdirectory(zlib)
########### install files ###############

View File

@@ -1,192 +0,0 @@
// $Id: Cleanup.cpp 80826 2008-03-04 14:51:23Z wotte $
#include "ace/Cleanup.h"
ACE_RCSID (ace,
Cleanup,
"$Id: Cleanup.cpp 80826 2008-03-04 14:51:23Z wotte $")
#if !defined (ACE_HAS_INLINED_OSCALLS)
# include "ace/Cleanup.inl"
#endif /* ACE_HAS_INLINED_OSCALLS */
#include "ace/OS_Memory.h"
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
void
ACE_Cleanup::cleanup (void *)
{
delete this;
}
ACE_Cleanup::~ACE_Cleanup (void)
{
}
/*****************************************************************************/
extern "C" void
ACE_CLEANUP_DESTROYER_NAME (ACE_Cleanup *object, void *param)
{
object->cleanup (param);
}
/*****************************************************************************/
ACE_Cleanup_Info::ACE_Cleanup_Info (void)
: object_ (0),
cleanup_hook_ (0),
param_ (0)
{
}
bool
ACE_Cleanup_Info::operator== (const ACE_Cleanup_Info &o) const
{
return o.object_ == this->object_
&& o.cleanup_hook_ == this->cleanup_hook_
&& o.param_ == this->param_;
}
bool
ACE_Cleanup_Info::operator!= (const ACE_Cleanup_Info &o) const
{
return !(*this == o);
}
/*****************************************************************************/
/**
* @class ACE_Cleanup_Info_Node
*
* @brief For maintaining a list of ACE_Cleanup_Info items.
*
* For internal use by ACE_Object_Manager.
*/
class ACE_Cleanup_Info_Node
{
public:
ACE_Cleanup_Info_Node (void);
ACE_Cleanup_Info_Node (const ACE_Cleanup_Info &new_info,
ACE_Cleanup_Info_Node *next);
~ACE_Cleanup_Info_Node (void);
ACE_Cleanup_Info_Node *insert (const ACE_Cleanup_Info &);
private:
ACE_Cleanup_Info cleanup_info_;
ACE_Cleanup_Info_Node *next_;
friend class ACE_OS_Exit_Info;
};
ACE_Cleanup_Info_Node::ACE_Cleanup_Info_Node (void)
: cleanup_info_ (),
next_ (0)
{
}
ACE_Cleanup_Info_Node::ACE_Cleanup_Info_Node (const ACE_Cleanup_Info &new_info,
ACE_Cleanup_Info_Node *next)
: cleanup_info_ (new_info),
next_ (next)
{
}
ACE_Cleanup_Info_Node::~ACE_Cleanup_Info_Node (void)
{
delete next_;
}
ACE_Cleanup_Info_Node *
ACE_Cleanup_Info_Node::insert (const ACE_Cleanup_Info &new_info)
{
ACE_Cleanup_Info_Node *new_node = 0;
ACE_NEW_RETURN (new_node,
ACE_Cleanup_Info_Node (new_info, this),
0);
return new_node;
}
/*****************************************************************************/
ACE_OS_Exit_Info::ACE_OS_Exit_Info (void)
{
ACE_NEW (registered_objects_, ACE_Cleanup_Info_Node);
}
ACE_OS_Exit_Info::~ACE_OS_Exit_Info (void)
{
delete registered_objects_;
registered_objects_ = 0;
}
int
ACE_OS_Exit_Info::at_exit_i (void *object,
ACE_CLEANUP_FUNC cleanup_hook,
void *param)
{
ACE_Cleanup_Info new_info;
new_info.object_ = object;
new_info.cleanup_hook_ = cleanup_hook;
new_info.param_ = param;
// Return -1 and sets errno if unable to allocate storage. Enqueue
// at the head and dequeue from the head to get LIFO ordering.
ACE_Cleanup_Info_Node *new_node = 0;
if ((new_node = registered_objects_->insert (new_info)) == 0)
return -1;
else
{
registered_objects_ = new_node;
return 0;
}
}
int
ACE_OS_Exit_Info::find (void *object)
{
// Check for already in queue, and return 1 if so.
for (ACE_Cleanup_Info_Node *iter = registered_objects_;
iter && iter->next_ != 0;
iter = iter->next_)
{
if (iter->cleanup_info_.object_ == object)
{
// The object has already been registered.
return 1;
}
}
return 0;
}
void
ACE_OS_Exit_Info::call_hooks (void)
{
// Call all registered cleanup hooks, in reverse order of
// registration.
for (ACE_Cleanup_Info_Node *iter = registered_objects_;
iter && iter->next_ != 0;
iter = iter->next_)
{
ACE_Cleanup_Info &info = iter->cleanup_info_;
if (info.cleanup_hook_ == reinterpret_cast<ACE_CLEANUP_FUNC> (
ACE_CLEANUP_DESTROYER_NAME))
// The object is an ACE_Cleanup.
ACE_CLEANUP_DESTROYER_NAME (
reinterpret_cast<ACE_Cleanup *> (info.object_),
info.param_);
else if (info.object_ == &ace_exit_hook_marker)
// The hook is an ACE_EXIT_HOOK.
(* reinterpret_cast<ACE_EXIT_HOOK> (info.cleanup_hook_)) ();
else
(*info.cleanup_hook_) (info.object_, info.param_);
}
}
ACE_END_VERSIONED_NAMESPACE_DECL

View File

@@ -1,564 +0,0 @@
// $Id: String_Base.cpp 81138 2008-03-28 09:18:15Z johnnyw $
#ifndef ACE_STRING_BASE_CPP
#define ACE_STRING_BASE_CPP
#include "ace/ACE.h"
#include "ace/Malloc_Base.h"
#include "ace/String_Base.h"
#include "ace/Auto_Ptr.h"
#include "ace/OS_NS_string.h"
#include <algorithm> // For std::swap<>
#if !defined (__ACE_INLINE__)
#include "ace/String_Base.inl"
#endif /* __ACE_INLINE__ */
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_ALLOC_HOOK_DEFINE(ACE_String_Base)
template <class CHAR>
CHAR ACE_String_Base<CHAR>::NULL_String_ = 0;
// Default constructor.
template <class CHAR>
ACE_String_Base<CHAR>::ACE_String_Base (ACE_Allocator *the_allocator)
: allocator_ (the_allocator ? the_allocator : ACE_Allocator::instance ()),
len_ (0),
buf_len_ (0),
rep_ (&ACE_String_Base<CHAR>::NULL_String_),
release_ (false)
{
ACE_TRACE ("ACE_String_Base<CHAR>::ACE_String_Base");
}
// Constructor that actually copies memory.
template <class CHAR>
ACE_String_Base<CHAR>::ACE_String_Base (const CHAR *s,
ACE_Allocator *the_allocator,
bool release)
: allocator_ (the_allocator ? the_allocator : ACE_Allocator::instance ()),
len_ (0),
buf_len_ (0),
rep_ (0),
release_ (false)
{
ACE_TRACE ("ACE_String_Base<CHAR>::ACE_String_Base");
this->set (s, release);
}
template <class CHAR>
ACE_String_Base<CHAR>::ACE_String_Base (CHAR c,
ACE_Allocator *the_allocator)
: allocator_ (the_allocator ? the_allocator : ACE_Allocator::instance ()),
len_ (0),
buf_len_ (0),
rep_ (0),
release_ (false)
{
ACE_TRACE ("ACE_String_Base<CHAR>::ACE_String_Base");
this->set (&c, 1, true);
}
// Constructor that actually copies memory.
template <class CHAR>
ACE_String_Base<CHAR>::ACE_String_Base (
const CHAR *s,
typename ACE_String_Base<CHAR>::size_type len,
ACE_Allocator *the_allocator,
bool release)
: allocator_ (the_allocator ? the_allocator : ACE_Allocator::instance ()),
len_ (0),
buf_len_ (0),
rep_ (0),
release_ (false)
{
ACE_TRACE ("ACE_String_Base<CHAR>::ACE_String_Base");
this->set (s, len, release);
}
// Copy constructor.
template <class CHAR>
ACE_String_Base<CHAR>::ACE_String_Base (const ACE_String_Base<CHAR> &s)
: allocator_ (s.allocator_ ? s.allocator_ : ACE_Allocator::instance ()),
len_ (0),
buf_len_ (0),
rep_ (0),
release_ (false)
{
ACE_TRACE ("ACE_String_Base<CHAR>::ACE_String_Base");
this->set (s.rep_, s.len_, true);
}
template <class CHAR>
ACE_String_Base<CHAR>::ACE_String_Base (
typename ACE_String_Base<CHAR>::size_type len,
CHAR c,
ACE_Allocator *the_allocator)
: allocator_ (the_allocator ? the_allocator : ACE_Allocator::instance ()),
len_ (0),
buf_len_ (0),
rep_ (0),
release_ (false)
{
ACE_TRACE ("ACE_String_Base<CHAR>::ACE_String_Base");
this->resize (len, c);
}
template <class CHAR>
ACE_String_Base<CHAR>::~ACE_String_Base (void)
{
ACE_TRACE ("ACE_String_Base<CHAR>::~ACE_String_Base");
if (this->buf_len_ != 0 && this->release_)
this->allocator_->free (this->rep_);
}
// this method might benefit from a little restructuring.
template <class CHAR> void
ACE_String_Base<CHAR>::set (const CHAR *s,
typename ACE_String_Base<CHAR>::size_type len,
bool release)
{
// Case 1. Going from memory to more memory
size_type new_buf_len = len + 1;
if (s != 0 && len != 0 && release && this->buf_len_ < new_buf_len)
{
CHAR *temp = 0;
ACE_ALLOCATOR (temp,
(CHAR *) this->allocator_->malloc (new_buf_len * sizeof (CHAR)));
if (this->buf_len_ != 0 && this->release_)
this->allocator_->free (this->rep_);
this->rep_ = temp;
this->buf_len_ = new_buf_len;
this->release_ = true;
this->len_ = len;
ACE_OS::memcpy (this->rep_, s, len * sizeof (CHAR));
this->rep_[len] = 0;
}
else // Case 2. No memory allocation is necessary.
{
// Free memory if necessary and figure out future ownership
if (!release || s == 0 || len == 0)
{
if (this->buf_len_ != 0 && this->release_)
{
this->allocator_->free (this->rep_);
this->release_ = false;
}
}
// Populate data.
if (s == 0 || len == 0)
{
this->buf_len_ = 0;
this->len_ = 0;
this->rep_ = &ACE_String_Base<CHAR>::NULL_String_;
this->release_ = false;
}
else if (!release) // Note: No guarantee that rep_ is null terminated.
{
this->buf_len_ = len;
this->len_ = len;
this->rep_ = const_cast <CHAR *> (s);
this->release_ = false;
}
else
{
ACE_OS::memcpy (this->rep_, s, len * sizeof (CHAR));
this->rep_[len] = 0;
this->len_ = len;
}
}
}
// Return substring.
template <class CHAR> ACE_String_Base<CHAR>
ACE_String_Base<CHAR>::substring (
typename ACE_String_Base<CHAR>::size_type offset,
typename ACE_String_Base<CHAR>::size_type length) const
{
ACE_String_Base<CHAR> nill;
size_type count = length;
// case 1. empty string
if (this->len_ == 0)
return nill;
// case 2. start pos past our end
if (offset >= this->len_)
return nill;
// No length == empty string.
else if (length == 0)
return nill;
// Get all remaining bytes.
else if (length == npos || count > (this->len_ - offset))
count = this->len_ - offset;
return ACE_String_Base<CHAR> (&this->rep_[offset], count, this->allocator_);
}
template <class CHAR> ACE_String_Base<CHAR> &
ACE_String_Base<CHAR>::append (const CHAR* s,
typename ACE_String_Base<CHAR>::size_type slen)
{
ACE_TRACE ("ACE_String_Base<CHAR>::append(const CHAR*, size_type)");
if (slen > 0 && slen != npos)
{
// case 1. No memory allocation needed.
if (this->buf_len_ >= this->len_ + slen + 1)
{
// Copy in data from new string.
ACE_OS::memcpy (this->rep_ + this->len_, s, slen * sizeof (CHAR));
}
else // case 2. Memory reallocation is needed
{
const size_type new_buf_len =
ace_max(this->len_ + slen + 1, this->buf_len_ + this->buf_len_ / 2);
CHAR *t = 0;
ACE_ALLOCATOR_RETURN (t,
(CHAR *) this->allocator_->malloc (new_buf_len * sizeof (CHAR)), *this);
// Copy memory from old string into new string.
ACE_OS::memcpy (t, this->rep_, this->len_ * sizeof (CHAR));
ACE_OS::memcpy (t + this->len_, s, slen * sizeof (CHAR));
if (this->buf_len_ != 0 && this->release_)
this->allocator_->free (this->rep_);
this->release_ = true;
this->rep_ = t;
this->buf_len_ = new_buf_len;
}
this->len_ += slen;
this->rep_[this->len_] = 0;
}
return *this;
}
template <class CHAR> u_long
ACE_String_Base<CHAR>::hash (void) const
{
return
ACE::hash_pjw (reinterpret_cast<char *> (
const_cast<CHAR *> (this->rep_)),
this->len_ * sizeof (CHAR));
}
template <class CHAR> void
ACE_String_Base<CHAR>::resize (typename ACE_String_Base<CHAR>::size_type len,
CHAR c)
{
ACE_TRACE ("ACE_String_Base<CHAR>::resize");
fast_resize(len);
ACE_OS::memset (this->rep_, c, this->buf_len_ * sizeof (CHAR));
}
template <class CHAR> void
ACE_String_Base<CHAR>::fast_resize (size_t len)
{
ACE_TRACE ("ACE_String_Base<CHAR>::fast_resize");
// Only reallocate if we don't have enough space...
if (this->buf_len_ <= len)
{
if (this->buf_len_ != 0 && this->release_)
this->allocator_->free (this->rep_);
this->rep_ = static_cast<CHAR*>
(this->allocator_->malloc ((len + 1) * sizeof (CHAR)));
this->buf_len_ = len + 1;
this->release_ = true;
}
this->len_ = 0;
if (len > 0)
this->rep_[0] = 0;
}
template <class CHAR> void
ACE_String_Base<CHAR>::clear (bool release)
{
// This can't use set(), because that would free memory if release=false
if (release)
{
if (this->buf_len_ != 0 && this->release_)
this->allocator_->free (this->rep_);
this->rep_ = &ACE_String_Base<CHAR>::NULL_String_;
this->len_ = 0;
this->buf_len_ = 0;
this->release_ = false;
}
else
{
this->fast_clear ();
}
}
// Assignment operator (does copy memory).
template <class CHAR> ACE_String_Base<CHAR> &
ACE_String_Base<CHAR>::operator= (const CHAR *s)
{
ACE_TRACE ("ACE_String_Base<CHAR>::operator=");
if (s != 0)
this->set (s, true);
return *this;
}
// Assignment operator (does copy memory).
template <class CHAR> ACE_String_Base<CHAR> &
ACE_String_Base<CHAR>::operator= (const ACE_String_Base<CHAR> &s)
{
ACE_TRACE ("ACE_String_Base<CHAR>::operator=");
// Check for self-assignment.
if (this != &s)
{
this->set (s.rep_, s.len_, true);
}
return *this;
}
template <class CHAR> void
ACE_String_Base<CHAR>::set (const CHAR *s, bool release)
{
size_t length = 0;
if (s != 0)
length = ACE_OS::strlen (s);
this->set (s, length, release);
}
template <class CHAR> void
ACE_String_Base<CHAR>::fast_clear (void)
{
this->len_ = 0;
if (this->release_)
{
// String retains the original buffer.
if (this->rep_ != &ACE_String_Base<CHAR>::NULL_String_)
this->rep_[0] = 0;
}
else
{
// External buffer: string relinquishes control of it.
this->buf_len_ = 0;
this->rep_ = &ACE_String_Base<CHAR>::NULL_String_;
}
}
// Get a copy of the underlying representation.
template <class CHAR> CHAR *
ACE_String_Base<CHAR>::rep (void) const
{
ACE_TRACE ("ACE_String_Base<CHAR>::rep");
CHAR *new_string;
ACE_NEW_RETURN (new_string, CHAR[this->len_ + 1], 0);
ACE_OS::strsncpy (new_string, this->rep_, this->len_+1);
return new_string;
}
template <class CHAR> int
ACE_String_Base<CHAR>::compare (const ACE_String_Base<CHAR> &s) const
{
ACE_TRACE ("ACE_String_Base<CHAR>::compare");
if (this->rep_ == s.rep_)
return 0;
// Pick smaller of the two lengths and perform the comparison.
size_type smaller_length = ace_min (this->len_, s.len_);
int result = ACE_OS::memcmp (this->rep_,
s.rep_,
smaller_length * sizeof (CHAR));
if (!result)
result = static_cast<int> (this->len_ - s.len_);
return result;
}
// Comparison operator.
template <class CHAR> bool
ACE_String_Base<CHAR>::operator== (const ACE_String_Base<CHAR> &s) const
{
return this->len_ == s.len_ &&
ACE_OS::memcmp (this->rep_,
s.rep_,
this->len_ * sizeof (CHAR)) == 0;
}
template <class CHAR> bool
ACE_String_Base<CHAR>::operator== (const CHAR *s) const
{
size_t len = ACE_OS::strlen (s);
return this->len_ == len &&
ACE_OS::memcmp (this->rep_,
s,
len * sizeof (CHAR)) == 0;
}
template <class CHAR> typename ACE_String_Base<CHAR>::size_type
ACE_String_Base<CHAR>::find (
const CHAR *s,
typename ACE_String_Base<CHAR>::size_type pos) const
{
CHAR *substr = this->rep_ + pos;
size_t len = ACE_OS::strlen (s);
CHAR *pointer = ACE_OS::strnstr (substr, s, len);
if (pointer == 0)
return ACE_String_Base<CHAR>::npos;
else
return pointer - this->rep_;
}
template <class CHAR> typename ACE_String_Base<CHAR>::size_type
ACE_String_Base<CHAR>::find (
CHAR c,
typename ACE_String_Base<CHAR>::size_type pos) const
{
CHAR *substr = this->rep_ + pos;
CHAR *pointer = ACE_OS::strnchr (substr, c, this->len_ - pos);
if (pointer == 0)
return ACE_String_Base<CHAR>::npos;
else
return pointer - this->rep_;
}
template <class CHAR> typename ACE_String_Base<CHAR>::size_type
ACE_String_Base<CHAR>::rfind (
CHAR c,
typename ACE_String_Base<CHAR>::size_type pos) const
{
if (pos == npos || pos > this->len_)
pos = this->len_;
// Do not change to prefix operator! Proper operation of this loop
// depends on postfix decrement behavior.
for (size_type i = pos; i-- != 0; )
if (this->rep_[i] == c)
return i;
return ACE_String_Base<CHAR>::npos;
}
template <class CHAR> void
ACE_String_Base<CHAR>::swap (ACE_String_Base<CHAR> & str)
{
std::swap (this->allocator_ , str.allocator_);
std::swap (this->len_ , str.len_);
std::swap (this->buf_len_ , str.buf_len_);
std::swap (this->rep_ , str.rep_);
std::swap (this->release_ , str.release_);
}
// ----------------------------------------------
template <class CHAR> ACE_String_Base<CHAR>
operator+ (const ACE_String_Base<CHAR> &s, const ACE_String_Base<CHAR> &t)
{
ACE_String_Base<CHAR> temp (s.length () + t.length ());
temp += s;
temp += t;
return temp;
}
template <class CHAR> ACE_String_Base<CHAR>
operator+ (const CHAR *s, const ACE_String_Base<CHAR> &t)
{
size_t slen = 0;
if (s != 0)
slen = ACE_OS::strlen (s);
ACE_String_Base<CHAR> temp (slen + t.length ());
if (slen > 0)
temp.append (s, slen);
temp += t;
return temp;
}
template <class CHAR> ACE_String_Base<CHAR>
operator+ (const ACE_String_Base<CHAR> &s, const CHAR *t)
{
size_t tlen = 0;
if (t != 0)
tlen = ACE_OS::strlen (t);
ACE_String_Base<CHAR> temp (s.length () + tlen);
temp += s;
if (tlen > 0)
temp.append (t, tlen);
return temp;
}
template <class CHAR> ACE_String_Base<CHAR>
operator + (const ACE_String_Base<CHAR> &t,
const CHAR c)
{
ACE_String_Base<CHAR> temp (t.length () + 1);
temp += t;
temp += c;
return temp;
}
template <class CHAR> ACE_String_Base<CHAR>
operator + (const CHAR c,
const ACE_String_Base<CHAR> &t)
{
ACE_String_Base<CHAR> temp (t.length () + 1);
temp += c;
temp += t;
return temp;
}
template <class CHAR>
ACE_String_Base<CHAR> &
ACE_String_Base<CHAR>::operator+= (const CHAR* s)
{
size_t slen = 0;
if (s != 0)
slen = ACE_OS::strlen (s);
return this->append (s, slen);
}
template <class CHAR>
ACE_String_Base<CHAR> &
ACE_String_Base<CHAR>::operator+= (const ACE_String_Base<CHAR> &s)
{
ACE_TRACE ("ACE_String_Base<CHAR>::operator+=(const ACE_String_Base<CHAR> &)");
return this->append (s.rep_, s.len_);
}
template <class CHAR>
ACE_String_Base<CHAR> &
ACE_String_Base<CHAR>::operator+= (const CHAR c)
{
ACE_TRACE ("ACE_String_Base<CHAR>::operator+=(const CHAR)");
const size_type slen = 1;
return this->append (&c, slen);
}
ACE_END_VERSIONED_NAMESPACE_DECL
#endif /* ACE_STRING_BASE_CPP */

View File

@@ -1,263 +0,0 @@
#include "ace/Time_Value.h"
ACE_RCSID (ace,
Time_Value,
"$Id: Time_Value.cpp 80826 2008-03-04 14:51:23Z wotte $")
#if !defined (__ACE_INLINE__)
#include "ace/Time_Value.inl"
#endif /* __ACE_INLINE__ */
#include "ace/Numeric_Limits.h"
#include "ace/If_Then_Else.h"
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
// Static constant representing `zero-time'.
// Note: this object requires static construction.
const ACE_Time_Value ACE_Time_Value::zero;
// Constant for maximum time representable. Note that this time
// is not intended for use with select () or other calls that may
// have *their own* implementation-specific maximum time representations.
// Its primary use is in time computations such as those used by the
// dynamic subpriority strategies in the ACE_Dynamic_Message_Queue class.
// Note: this object requires static construction.
const ACE_Time_Value ACE_Time_Value::max_time (
ACE_Numeric_Limits<time_t>::max (),
ACE_ONE_SECOND_IN_USECS - 1);
ACE_ALLOC_HOOK_DEFINE (ACE_Time_Value)
// Increment microseconds (the only reason this is here is to allow
// the use of ACE_Atomic_Op with ACE_Time_Value).
ACE_Time_Value
ACE_Time_Value::operator ++ (int)
{
// ACE_OS_TRACE ("ACE_Time_Value::operator ++ (int)");
ACE_Time_Value tv (*this);
++*this;
return tv;
}
ACE_Time_Value &
ACE_Time_Value::operator ++ (void)
{
// ACE_OS_TRACE ("ACE_Time_Value::operator ++ (void)");
this->usec (this->usec () + 1);
this->normalize ();
return *this;
}
// Decrement microseconds (the only reason this is here is / to allow
// the use of ACE_Atomic_Op with ACE_Time_Value).
ACE_Time_Value
ACE_Time_Value::operator -- (int)
{
// ACE_OS_TRACE ("ACE_Time_Value::operator -- (int)");
ACE_Time_Value tv (*this);
--*this;
return tv;
}
ACE_Time_Value &
ACE_Time_Value::operator -- (void)
{
// ACE_OS_TRACE ("ACE_Time_Value::operator -- (void)");
this->usec (this->usec () - 1);
this->normalize ();
return *this;
}
#if defined (ACE_WIN32)
// Static constant to remove time skew between FILETIME and POSIX
// time. POSIX and Win32 use different epochs (Jan. 1, 1970 v.s.
// Jan. 1, 1601). The following constant defines the difference
// in 100ns ticks.
//
// In the beginning (Jan. 1, 1601), there was no time and no computer.
// And Bill said: "Let there be time," and there was time....
# if defined (ACE_LACKS_LONGLONG_T)
const ACE_U_LongLong ACE_Time_Value::FILETIME_to_timval_skew =
ACE_U_LongLong (0xd53e8000, 0x19db1de);
# else
const DWORDLONG ACE_Time_Value::FILETIME_to_timval_skew =
ACE_INT64_LITERAL (0x19db1ded53e8000);
# endif
// Initializes the ACE_Time_Value object from a Win32 FILETIME
ACE_Time_Value::ACE_Time_Value (const FILETIME &file_time)
{
// // ACE_OS_TRACE ("ACE_Time_Value::ACE_Time_Value");
this->set (file_time);
}
void ACE_Time_Value::set (const FILETIME &file_time)
{
// Initializes the ACE_Time_Value object from a Win32 FILETIME
#if defined (ACE_LACKS_LONGLONG_T)
ACE_U_LongLong LL_100ns(file_time.dwLowDateTime, file_time.dwHighDateTime);
LL_100ns -= ACE_Time_Value::FILETIME_to_timval_skew;
// Convert 100ns units to seconds;
this->tv_.tv_sec = (long) (LL_100ns / ((double) (10000 * 1000)));
// Convert remainder to microseconds;
this->tv_.tv_usec = (suseconds_t)((LL_100ns % ((ACE_UINT32)(10000 * 1000))) / 10);
#else
// Don't use a struct initializer, gcc don't like it.
ULARGE_INTEGER _100ns;
_100ns.LowPart = file_time.dwLowDateTime;
_100ns.HighPart = file_time.dwHighDateTime;
_100ns.QuadPart -= ACE_Time_Value::FILETIME_to_timval_skew;
// Convert 100ns units to seconds;
this->tv_.tv_sec = (long) (_100ns.QuadPart / (10000 * 1000));
// Convert remainder to microseconds;
this->tv_.tv_usec = (suseconds_t) ((_100ns.QuadPart % (10000 * 1000)) / 10);
#endif // ACE_LACKS_LONGLONG_T
this->normalize ();
}
// Returns the value of the object as a Win32 FILETIME.
ACE_Time_Value::operator FILETIME () const
{
FILETIME file_time;
// ACE_OS_TRACE ("ACE_Time_Value::operator FILETIME");
#if defined (ACE_LACKS_LONGLONG_T)
ACE_U_LongLong LL_sec(this->tv_.tv_sec);
ACE_U_LongLong LL_usec(this->tv_.tv_usec);
ACE_U_LongLong LL_100ns = LL_sec * (ACE_UINT32)(10000 * 1000) +
LL_usec * (ACE_UINT32)10 +
ACE_Time_Value::FILETIME_to_timval_skew;
file_time.dwLowDateTime = LL_100ns.lo();
file_time.dwHighDateTime = LL_100ns.hi();
#else
ULARGE_INTEGER _100ns;
_100ns.QuadPart = (((DWORDLONG) this->tv_.tv_sec * (10000 * 1000) +
this->tv_.tv_usec * 10) +
ACE_Time_Value::FILETIME_to_timval_skew);
file_time.dwLowDateTime = _100ns.LowPart;
file_time.dwHighDateTime = _100ns.HighPart;
#endif //ACE_LACKS_LONGLONG_T
return file_time;
}
#endif /* ACE_WIN32 */
void
ACE_Time_Value::dump (void) const
{
#if defined (ACE_HAS_DUMP)
// ACE_OS_TRACE ("ACE_Time_Value::dump");
#if 0
ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\ntv_sec_ = %d"), this->tv_.tv_sec));
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\ntv_usec_ = %d\n"), this->tv_.tv_usec));
ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
#endif /* 0 */
#endif /* ACE_HAS_DUMP */
}
void
ACE_Time_Value::normalize (void)
{
// // ACE_OS_TRACE ("ACE_Time_Value::normalize");
// From Hans Rohnert...
if (this->tv_.tv_usec >= ACE_ONE_SECOND_IN_USECS)
{
/*! \todo This loop needs some optimization.
*/
do
{
++this->tv_.tv_sec;
this->tv_.tv_usec -= ACE_ONE_SECOND_IN_USECS;
}
while (this->tv_.tv_usec >= ACE_ONE_SECOND_IN_USECS);
}
else if (this->tv_.tv_usec <= -ACE_ONE_SECOND_IN_USECS)
{
/*! \todo This loop needs some optimization.
*/
do
{
--this->tv_.tv_sec;
this->tv_.tv_usec += ACE_ONE_SECOND_IN_USECS;
}
while (this->tv_.tv_usec <= -ACE_ONE_SECOND_IN_USECS);
}
if (this->tv_.tv_sec >= 1 && this->tv_.tv_usec < 0)
{
--this->tv_.tv_sec;
this->tv_.tv_usec += ACE_ONE_SECOND_IN_USECS;
}
// tv_sec in qnxnto is unsigned
#if !defined ( __QNXNTO__)
else if (this->tv_.tv_sec < 0 && this->tv_.tv_usec > 0)
{
++this->tv_.tv_sec;
this->tv_.tv_usec -= ACE_ONE_SECOND_IN_USECS;
}
#endif /* __QNXNTO__ */
}
ACE_Time_Value &
ACE_Time_Value::operator *= (double d)
{
// The floating type to be used in the computations. It should be
// large enough to hold a time_t. We actually want a floating type
// with enough digits in its mantissa to hold a time_t without
// losing precision. For example, if FLT_RADIX is 2 and
// LDBL_MANT_DIG is 64, a long double has a 64 bit wide mantissa,
// which would be sufficient to hold a 64 bit time_t value without
// losing precision.
//
// For now we'll simply go with long double if it is larger than
// time_t. We're hosed if long double isn't large enough.
typedef ACE::If_Then_Else<(sizeof (double) > sizeof (time_t)),
double,
long double>::result_type float_type;
float_type time_total =
(this->sec ()
+ static_cast<float_type> (this->usec ()) / ACE_ONE_SECOND_IN_USECS) * d;
// shall we saturate the result?
static const float_type max_int =
ACE_Numeric_Limits<time_t>::max () + 0.999999;
static const float_type min_int =
ACE_Numeric_Limits<time_t>::min () - 0.999999;
if (time_total > max_int)
time_total = max_int;
if (time_total < min_int)
time_total = min_int;
const time_t time_sec = static_cast<time_t> (time_total);
time_total -= time_sec;
time_total *= ACE_ONE_SECOND_IN_USECS;
suseconds_t time_usec = static_cast<suseconds_t> (time_total);
// round up the result to save the last usec
if (time_usec > 0 && (time_total - time_usec) >= 0.5)
++time_usec;
else if (time_usec < 0 && (time_total - time_usec) <= -0.5)
--time_usec;
this->set (time_sec, time_usec);
return *this;
}
ACE_END_VERSIONED_NAMESPACE_DECL

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,282 +0,0 @@
/*-------------------------------------------------------------*/
/*--- Public header file for the library. ---*/
/*--- bzlib.h ---*/
/*-------------------------------------------------------------*/
/* ------------------------------------------------------------------
This file is part of bzip2/libbzip2, a program and library for
lossless, block-sorting data compression.
bzip2/libbzip2 version 1.0.5 of 10 December 2007
Copyright (C) 1996-2007 Julian Seward <jseward@bzip.org>
Please read the WARNING, DISCLAIMER and PATENTS sections in the
README file.
This program is released under the terms of the license contained
in the file LICENSE.
------------------------------------------------------------------ */
#ifndef _BZLIB_H
#define _BZLIB_H
#ifdef __cplusplus
extern "C" {
#endif
#define BZ_RUN 0
#define BZ_FLUSH 1
#define BZ_FINISH 2
#define BZ_OK 0
#define BZ_RUN_OK 1
#define BZ_FLUSH_OK 2
#define BZ_FINISH_OK 3
#define BZ_STREAM_END 4
#define BZ_SEQUENCE_ERROR (-1)
#define BZ_PARAM_ERROR (-2)
#define BZ_MEM_ERROR (-3)
#define BZ_DATA_ERROR (-4)
#define BZ_DATA_ERROR_MAGIC (-5)
#define BZ_IO_ERROR (-6)
#define BZ_UNEXPECTED_EOF (-7)
#define BZ_OUTBUFF_FULL (-8)
#define BZ_CONFIG_ERROR (-9)
typedef
struct {
char *next_in;
unsigned int avail_in;
unsigned int total_in_lo32;
unsigned int total_in_hi32;
char *next_out;
unsigned int avail_out;
unsigned int total_out_lo32;
unsigned int total_out_hi32;
void *state;
void *(*bzalloc)(void *,int,int);
void (*bzfree)(void *,void *);
void *opaque;
}
bz_stream;
#ifndef BZ_IMPORT
#define BZ_EXPORT
#endif
#ifndef BZ_NO_STDIO
/* Need a definitition for FILE */
#include <stdio.h>
#endif
#ifdef _WIN32
# include <windows.h>
# ifdef small
/* windows.h define small to char */
# undef small
# endif
# ifdef BZ_EXPORT
# define BZ_API(func) WINAPI func
# define BZ_EXTERN extern
# else
/* import windows dll dynamically */
# define BZ_API(func) (WINAPI * func)
# define BZ_EXTERN
# endif
#else
# define BZ_API(func) func
# define BZ_EXTERN extern
#endif
/*-- Core (low-level) library functions --*/
BZ_EXTERN int BZ_API(BZ2_bzCompressInit) (
bz_stream* strm,
int blockSize100k,
int verbosity,
int workFactor
);
BZ_EXTERN int BZ_API(BZ2_bzCompress) (
bz_stream* strm,
int action
);
BZ_EXTERN int BZ_API(BZ2_bzCompressEnd) (
bz_stream* strm
);
BZ_EXTERN int BZ_API(BZ2_bzDecompressInit) (
bz_stream *strm,
int verbosity,
int small
);
BZ_EXTERN int BZ_API(BZ2_bzDecompress) (
bz_stream* strm
);
BZ_EXTERN int BZ_API(BZ2_bzDecompressEnd) (
bz_stream *strm
);
/*-- High(er) level library functions --*/
#ifndef BZ_NO_STDIO
#define BZ_MAX_UNUSED 5000
typedef void BZFILE;
BZ_EXTERN BZFILE* BZ_API(BZ2_bzReadOpen) (
int* bzerror,
FILE* f,
int verbosity,
int small,
void* unused,
int nUnused
);
BZ_EXTERN void BZ_API(BZ2_bzReadClose) (
int* bzerror,
BZFILE* b
);
BZ_EXTERN void BZ_API(BZ2_bzReadGetUnused) (
int* bzerror,
BZFILE* b,
void** unused,
int* nUnused
);
BZ_EXTERN int BZ_API(BZ2_bzRead) (
int* bzerror,
BZFILE* b,
void* buf,
int len
);
BZ_EXTERN BZFILE* BZ_API(BZ2_bzWriteOpen) (
int* bzerror,
FILE* f,
int blockSize100k,
int verbosity,
int workFactor
);
BZ_EXTERN void BZ_API(BZ2_bzWrite) (
int* bzerror,
BZFILE* b,
void* buf,
int len
);
BZ_EXTERN void BZ_API(BZ2_bzWriteClose) (
int* bzerror,
BZFILE* b,
int abandon,
unsigned int* nbytes_in,
unsigned int* nbytes_out
);
BZ_EXTERN void BZ_API(BZ2_bzWriteClose64) (
int* bzerror,
BZFILE* b,
int abandon,
unsigned int* nbytes_in_lo32,
unsigned int* nbytes_in_hi32,
unsigned int* nbytes_out_lo32,
unsigned int* nbytes_out_hi32
);
#endif
/*-- Utility functions --*/
BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffCompress) (
char* dest,
unsigned int* destLen,
char* source,
unsigned int sourceLen,
int blockSize100k,
int verbosity,
int workFactor
);
BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffDecompress) (
char* dest,
unsigned int* destLen,
char* source,
unsigned int sourceLen,
int small,
int verbosity
);
/*--
Code contributed by Yoshioka Tsuneo (tsuneo@rr.iij4u.or.jp)
to support better zlib compatibility.
This code is not _officially_ part of libbzip2 (yet);
I haven't tested it, documented it, or considered the
threading-safeness of it.
If this code breaks, please contact both Yoshioka and me.
--*/
BZ_EXTERN const char * BZ_API(BZ2_bzlibVersion) (
void
);
#ifndef BZ_NO_STDIO
BZ_EXTERN BZFILE * BZ_API(BZ2_bzopen) (
const char *path,
const char *mode
);
BZ_EXTERN BZFILE * BZ_API(BZ2_bzdopen) (
int fd,
const char *mode
);
BZ_EXTERN int BZ_API(BZ2_bzread) (
BZFILE* b,
void* buf,
int len
);
BZ_EXTERN int BZ_API(BZ2_bzwrite) (
BZFILE* b,
void* buf,
int len
);
BZ_EXTERN int BZ_API(BZ2_bzflush) (
BZFILE* b
);
BZ_EXTERN void BZ_API(BZ2_bzclose) (
BZFILE* b
);
BZ_EXTERN const char * BZ_API(BZ2_bzerror) (
BZFILE *b,
int *errnum
);
#endif
#ifdef __cplusplus
}
#endif
#endif
/*-------------------------------------------------------------*/
/*--- end bzlib.h ---*/
/*-------------------------------------------------------------*/

View File

@@ -1,509 +0,0 @@
/*-------------------------------------------------------------*/
/*--- Private header file for the library. ---*/
/*--- bzlib_private.h ---*/
/*-------------------------------------------------------------*/
/* ------------------------------------------------------------------
This file is part of bzip2/libbzip2, a program and library for
lossless, block-sorting data compression.
bzip2/libbzip2 version 1.0.5 of 10 December 2007
Copyright (C) 1996-2007 Julian Seward <jseward@bzip.org>
Please read the WARNING, DISCLAIMER and PATENTS sections in the
README file.
This program is released under the terms of the license contained
in the file LICENSE.
------------------------------------------------------------------ */
#ifndef _BZLIB_PRIVATE_H
#define _BZLIB_PRIVATE_H
#include <stdlib.h>
#ifndef BZ_NO_STDIO
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#endif
#include "bzlib.h"
/*-- General stuff. --*/
#define BZ_VERSION "1.0.5, 10-Dec-2007"
typedef char Char;
typedef unsigned char Bool;
typedef unsigned char UChar;
typedef int Int32;
typedef unsigned int UInt32;
typedef short Int16;
typedef unsigned short UInt16;
#define True ((Bool)1)
#define False ((Bool)0)
#ifndef __GNUC__
#define __inline__ /* */
#endif
#ifndef BZ_NO_STDIO
extern void BZ2_bz__AssertH__fail ( int errcode );
#define AssertH(cond,errcode) \
{ if (!(cond)) BZ2_bz__AssertH__fail ( errcode ); }
#if BZ_DEBUG
#define AssertD(cond,msg) \
{ if (!(cond)) { \
fprintf ( stderr, \
"\n\nlibbzip2(debug build): internal error\n\t%s\n", msg );\
exit(1); \
}}
#else
#define AssertD(cond,msg) /* */
#endif
#define VPrintf0(zf) \
fprintf(stderr,zf)
#define VPrintf1(zf,za1) \
fprintf(stderr,zf,za1)
#define VPrintf2(zf,za1,za2) \
fprintf(stderr,zf,za1,za2)
#define VPrintf3(zf,za1,za2,za3) \
fprintf(stderr,zf,za1,za2,za3)
#define VPrintf4(zf,za1,za2,za3,za4) \
fprintf(stderr,zf,za1,za2,za3,za4)
#define VPrintf5(zf,za1,za2,za3,za4,za5) \
fprintf(stderr,zf,za1,za2,za3,za4,za5)
#else
extern void bz_internal_error ( int errcode );
#define AssertH(cond,errcode) \
{ if (!(cond)) bz_internal_error ( errcode ); }
#define AssertD(cond,msg) do { } while (0)
#define VPrintf0(zf) do { } while (0)
#define VPrintf1(zf,za1) do { } while (0)
#define VPrintf2(zf,za1,za2) do { } while (0)
#define VPrintf3(zf,za1,za2,za3) do { } while (0)
#define VPrintf4(zf,za1,za2,za3,za4) do { } while (0)
#define VPrintf5(zf,za1,za2,za3,za4,za5) do { } while (0)
#endif
#define BZALLOC(nnn) (strm->bzalloc)(strm->opaque,(nnn),1)
#define BZFREE(ppp) (strm->bzfree)(strm->opaque,(ppp))
/*-- Header bytes. --*/
#define BZ_HDR_B 0x42 /* 'B' */
#define BZ_HDR_Z 0x5a /* 'Z' */
#define BZ_HDR_h 0x68 /* 'h' */
#define BZ_HDR_0 0x30 /* '0' */
/*-- Constants for the back end. --*/
#define BZ_MAX_ALPHA_SIZE 258
#define BZ_MAX_CODE_LEN 23
#define BZ_RUNA 0
#define BZ_RUNB 1
#define BZ_N_GROUPS 6
#define BZ_G_SIZE 50
#define BZ_N_ITERS 4
#define BZ_MAX_SELECTORS (2 + (900000 / BZ_G_SIZE))
/*-- Stuff for randomising repetitive blocks. --*/
extern Int32 BZ2_rNums[512];
#define BZ_RAND_DECLS \
Int32 rNToGo; \
Int32 rTPos \
#define BZ_RAND_INIT_MASK \
s->rNToGo = 0; \
s->rTPos = 0 \
#define BZ_RAND_MASK ((s->rNToGo == 1) ? 1 : 0)
#define BZ_RAND_UPD_MASK \
if (s->rNToGo == 0) { \
s->rNToGo = BZ2_rNums[s->rTPos]; \
s->rTPos++; \
if (s->rTPos == 512) s->rTPos = 0; \
} \
s->rNToGo--;
/*-- Stuff for doing CRCs. --*/
extern UInt32 BZ2_crc32Table[256];
#define BZ_INITIALISE_CRC(crcVar) \
{ \
crcVar = 0xffffffffL; \
}
#define BZ_FINALISE_CRC(crcVar) \
{ \
crcVar = ~(crcVar); \
}
#define BZ_UPDATE_CRC(crcVar,cha) \
{ \
crcVar = (crcVar << 8) ^ \
BZ2_crc32Table[(crcVar >> 24) ^ \
((UChar)cha)]; \
}
/*-- States and modes for compression. --*/
#define BZ_M_IDLE 1
#define BZ_M_RUNNING 2
#define BZ_M_FLUSHING 3
#define BZ_M_FINISHING 4
#define BZ_S_OUTPUT 1
#define BZ_S_INPUT 2
#define BZ_N_RADIX 2
#define BZ_N_QSORT 12
#define BZ_N_SHELL 18
#define BZ_N_OVERSHOOT (BZ_N_RADIX + BZ_N_QSORT + BZ_N_SHELL + 2)
/*-- Structure holding all the compression-side stuff. --*/
typedef
struct {
/* pointer back to the struct bz_stream */
bz_stream* strm;
/* mode this stream is in, and whether inputting */
/* or outputting data */
Int32 mode;
Int32 state;
/* remembers avail_in when flush/finish requested */
UInt32 avail_in_expect;
/* for doing the block sorting */
UInt32* arr1;
UInt32* arr2;
UInt32* ftab;
Int32 origPtr;
/* aliases for arr1 and arr2 */
UInt32* ptr;
UChar* block;
UInt16* mtfv;
UChar* zbits;
/* for deciding when to use the fallback sorting algorithm */
Int32 workFactor;
/* run-length-encoding of the input */
UInt32 state_in_ch;
Int32 state_in_len;
BZ_RAND_DECLS;
/* input and output limits and current posns */
Int32 nblock;
Int32 nblockMAX;
Int32 numZ;
Int32 state_out_pos;
/* map of bytes used in block */
Int32 nInUse;
Bool inUse[256];
UChar unseqToSeq[256];
/* the buffer for bit stream creation */
UInt32 bsBuff;
Int32 bsLive;
/* block and combined CRCs */
UInt32 blockCRC;
UInt32 combinedCRC;
/* misc administratium */
Int32 verbosity;
Int32 blockNo;
Int32 blockSize100k;
/* stuff for coding the MTF values */
Int32 nMTF;
Int32 mtfFreq [BZ_MAX_ALPHA_SIZE];
UChar selector [BZ_MAX_SELECTORS];
UChar selectorMtf[BZ_MAX_SELECTORS];
UChar len [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
Int32 code [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
Int32 rfreq [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
/* second dimension: only 3 needed; 4 makes index calculations faster */
UInt32 len_pack[BZ_MAX_ALPHA_SIZE][4];
}
EState;
/*-- externs for compression. --*/
extern void
BZ2_blockSort ( EState* );
extern void
BZ2_compressBlock ( EState*, Bool );
extern void
BZ2_bsInitWrite ( EState* );
extern void
BZ2_hbAssignCodes ( Int32*, UChar*, Int32, Int32, Int32 );
extern void
BZ2_hbMakeCodeLengths ( UChar*, Int32*, Int32, Int32 );
/*-- states for decompression. --*/
#define BZ_X_IDLE 1
#define BZ_X_OUTPUT 2
#define BZ_X_MAGIC_1 10
#define BZ_X_MAGIC_2 11
#define BZ_X_MAGIC_3 12
#define BZ_X_MAGIC_4 13
#define BZ_X_BLKHDR_1 14
#define BZ_X_BLKHDR_2 15
#define BZ_X_BLKHDR_3 16
#define BZ_X_BLKHDR_4 17
#define BZ_X_BLKHDR_5 18
#define BZ_X_BLKHDR_6 19
#define BZ_X_BCRC_1 20
#define BZ_X_BCRC_2 21
#define BZ_X_BCRC_3 22
#define BZ_X_BCRC_4 23
#define BZ_X_RANDBIT 24
#define BZ_X_ORIGPTR_1 25
#define BZ_X_ORIGPTR_2 26
#define BZ_X_ORIGPTR_3 27
#define BZ_X_MAPPING_1 28
#define BZ_X_MAPPING_2 29
#define BZ_X_SELECTOR_1 30
#define BZ_X_SELECTOR_2 31
#define BZ_X_SELECTOR_3 32
#define BZ_X_CODING_1 33
#define BZ_X_CODING_2 34
#define BZ_X_CODING_3 35
#define BZ_X_MTF_1 36
#define BZ_X_MTF_2 37
#define BZ_X_MTF_3 38
#define BZ_X_MTF_4 39
#define BZ_X_MTF_5 40
#define BZ_X_MTF_6 41
#define BZ_X_ENDHDR_2 42
#define BZ_X_ENDHDR_3 43
#define BZ_X_ENDHDR_4 44
#define BZ_X_ENDHDR_5 45
#define BZ_X_ENDHDR_6 46
#define BZ_X_CCRC_1 47
#define BZ_X_CCRC_2 48
#define BZ_X_CCRC_3 49
#define BZ_X_CCRC_4 50
/*-- Constants for the fast MTF decoder. --*/
#define MTFA_SIZE 4096
#define MTFL_SIZE 16
/*-- Structure holding all the decompression-side stuff. --*/
typedef
struct {
/* pointer back to the struct bz_stream */
bz_stream* strm;
/* state indicator for this stream */
Int32 state;
/* for doing the final run-length decoding */
UChar state_out_ch;
Int32 state_out_len;
Bool blockRandomised;
BZ_RAND_DECLS;
/* the buffer for bit stream reading */
UInt32 bsBuff;
Int32 bsLive;
/* misc administratium */
Int32 blockSize100k;
Bool smallDecompress;
Int32 currBlockNo;
Int32 verbosity;
/* for undoing the Burrows-Wheeler transform */
Int32 origPtr;
UInt32 tPos;
Int32 k0;
Int32 unzftab[256];
Int32 nblock_used;
Int32 cftab[257];
Int32 cftabCopy[257];
/* for undoing the Burrows-Wheeler transform (FAST) */
UInt32 *tt;
/* for undoing the Burrows-Wheeler transform (SMALL) */
UInt16 *ll16;
UChar *ll4;
/* stored and calculated CRCs */
UInt32 storedBlockCRC;
UInt32 storedCombinedCRC;
UInt32 calculatedBlockCRC;
UInt32 calculatedCombinedCRC;
/* map of bytes used in block */
Int32 nInUse;
Bool inUse[256];
Bool inUse16[16];
UChar seqToUnseq[256];
/* for decoding the MTF values */
UChar mtfa [MTFA_SIZE];
Int32 mtfbase[256 / MTFL_SIZE];
UChar selector [BZ_MAX_SELECTORS];
UChar selectorMtf[BZ_MAX_SELECTORS];
UChar len [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
Int32 limit [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
Int32 base [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
Int32 perm [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
Int32 minLens[BZ_N_GROUPS];
/* save area for scalars in the main decompress code */
Int32 save_i;
Int32 save_j;
Int32 save_t;
Int32 save_alphaSize;
Int32 save_nGroups;
Int32 save_nSelectors;
Int32 save_EOB;
Int32 save_groupNo;
Int32 save_groupPos;
Int32 save_nextSym;
Int32 save_nblockMAX;
Int32 save_nblock;
Int32 save_es;
Int32 save_N;
Int32 save_curr;
Int32 save_zt;
Int32 save_zn;
Int32 save_zvec;
Int32 save_zj;
Int32 save_gSel;
Int32 save_gMinlen;
Int32* save_gLimit;
Int32* save_gBase;
Int32* save_gPerm;
}
DState;
/*-- Macros for decompression. --*/
#define BZ_GET_FAST(cccc) \
/* c_tPos is unsigned, hence test < 0 is pointless. */ \
if (s->tPos >= (UInt32)100000 * (UInt32)s->blockSize100k) return True; \
s->tPos = s->tt[s->tPos]; \
cccc = (UChar)(s->tPos & 0xff); \
s->tPos >>= 8;
#define BZ_GET_FAST_C(cccc) \
/* c_tPos is unsigned, hence test < 0 is pointless. */ \
if (c_tPos >= (UInt32)100000 * (UInt32)ro_blockSize100k) return True; \
c_tPos = c_tt[c_tPos]; \
cccc = (UChar)(c_tPos & 0xff); \
c_tPos >>= 8;
#define SET_LL4(i,n) \
{ if (((i) & 0x1) == 0) \
s->ll4[(i) >> 1] = (s->ll4[(i) >> 1] & 0xf0) | (n); else \
s->ll4[(i) >> 1] = (s->ll4[(i) >> 1] & 0x0f) | ((n) << 4); \
}
#define GET_LL4(i) \
((((UInt32)(s->ll4[(i) >> 1])) >> (((i) << 2) & 0x4)) & 0xF)
#define SET_LL(i,n) \
{ s->ll16[i] = (UInt16)(n & 0x0000ffff); \
SET_LL4(i, n >> 16); \
}
#define GET_LL(i) \
(((UInt32)s->ll16[i]) | (GET_LL4(i) << 16))
#define BZ_GET_SMALL(cccc) \
/* c_tPos is unsigned, hence test < 0 is pointless. */ \
if (s->tPos >= (UInt32)100000 * (UInt32)s->blockSize100k) return True; \
cccc = BZ2_indexIntoF ( s->tPos, s->cftab ); \
s->tPos = GET_LL(s->tPos);
/*-- externs for decompression. --*/
extern Int32
BZ2_indexIntoF ( Int32, Int32* );
extern Int32
BZ2_decompress ( DState* );
extern void
BZ2_hbCreateDecodeTables ( Int32*, Int32*, Int32*, UChar*,
Int32, Int32, Int32 );
#endif
/*-- BZ_NO_STDIO seems to make NULL disappear on some platforms. --*/
#ifdef BZ_NO_STDIO
#ifndef NULL
#define NULL 0
#endif
#endif
/*-------------------------------------------------------------*/
/*--- end bzlib_private.h ---*/
/*-------------------------------------------------------------*/

View File

@@ -1,672 +0,0 @@
/*-------------------------------------------------------------*/
/*--- Compression machinery (not incl block sorting) ---*/
/*--- compress.c ---*/
/*-------------------------------------------------------------*/
/* ------------------------------------------------------------------
This file is part of bzip2/libbzip2, a program and library for
lossless, block-sorting data compression.
bzip2/libbzip2 version 1.0.5 of 10 December 2007
Copyright (C) 1996-2007 Julian Seward <jseward@bzip.org>
Please read the WARNING, DISCLAIMER and PATENTS sections in the
README file.
This program is released under the terms of the license contained
in the file LICENSE.
------------------------------------------------------------------ */
/* CHANGES
0.9.0 -- original version.
0.9.0a/b -- no changes in this file.
0.9.0c -- changed setting of nGroups in sendMTFValues()
so as to do a bit better on small files
*/
#include "bzlib_private.h"
/*---------------------------------------------------*/
/*--- Bit stream I/O ---*/
/*---------------------------------------------------*/
/*---------------------------------------------------*/
void BZ2_bsInitWrite ( EState* s )
{
s->bsLive = 0;
s->bsBuff = 0;
}
/*---------------------------------------------------*/
static
void bsFinishWrite ( EState* s )
{
while (s->bsLive > 0) {
s->zbits[s->numZ] = (UChar)(s->bsBuff >> 24);
s->numZ++;
s->bsBuff <<= 8;
s->bsLive -= 8;
}
}
/*---------------------------------------------------*/
#define bsNEEDW(nz) \
{ \
while (s->bsLive >= 8) { \
s->zbits[s->numZ] \
= (UChar)(s->bsBuff >> 24); \
s->numZ++; \
s->bsBuff <<= 8; \
s->bsLive -= 8; \
} \
}
/*---------------------------------------------------*/
static
__inline__
void bsW ( EState* s, Int32 n, UInt32 v )
{
bsNEEDW ( n );
s->bsBuff |= (v << (32 - s->bsLive - n));
s->bsLive += n;
}
/*---------------------------------------------------*/
static
void bsPutUInt32 ( EState* s, UInt32 u )
{
bsW ( s, 8, (u >> 24) & 0xffL );
bsW ( s, 8, (u >> 16) & 0xffL );
bsW ( s, 8, (u >> 8) & 0xffL );
bsW ( s, 8, u & 0xffL );
}
/*---------------------------------------------------*/
static
void bsPutUChar ( EState* s, UChar c )
{
bsW( s, 8, (UInt32)c );
}
/*---------------------------------------------------*/
/*--- The back end proper ---*/
/*---------------------------------------------------*/
/*---------------------------------------------------*/
static
void makeMaps_e ( EState* s )
{
Int32 i;
s->nInUse = 0;
for (i = 0; i < 256; i++)
if (s->inUse[i]) {
s->unseqToSeq[i] = s->nInUse;
s->nInUse++;
}
}
/*---------------------------------------------------*/
static
void generateMTFValues ( EState* s )
{
UChar yy[256];
Int32 i, j;
Int32 zPend;
Int32 wr;
Int32 EOB;
/*
After sorting (eg, here),
s->arr1 [ 0 .. s->nblock-1 ] holds sorted order,
and
((UChar*)s->arr2) [ 0 .. s->nblock-1 ]
holds the original block data.
The first thing to do is generate the MTF values,
and put them in
((UInt16*)s->arr1) [ 0 .. s->nblock-1 ].
Because there are strictly fewer or equal MTF values
than block values, ptr values in this area are overwritten
with MTF values only when they are no longer needed.
The final compressed bitstream is generated into the
area starting at
(UChar*) (&((UChar*)s->arr2)[s->nblock])
These storage aliases are set up in bzCompressInit(),
except for the last one, which is arranged in
compressBlock().
*/
UInt32* ptr = s->ptr;
UChar* block = s->block;
UInt16* mtfv = s->mtfv;
makeMaps_e ( s );
EOB = s->nInUse+1;
for (i = 0; i <= EOB; i++) s->mtfFreq[i] = 0;
wr = 0;
zPend = 0;
for (i = 0; i < s->nInUse; i++) yy[i] = (UChar) i;
for (i = 0; i < s->nblock; i++) {
UChar ll_i;
AssertD ( wr <= i, "generateMTFValues(1)" );
j = ptr[i]-1; if (j < 0) j += s->nblock;
ll_i = s->unseqToSeq[block[j]];
AssertD ( ll_i < s->nInUse, "generateMTFValues(2a)" );
if (yy[0] == ll_i) {
zPend++;
} else {
if (zPend > 0) {
zPend--;
while (True) {
if (zPend & 1) {
mtfv[wr] = BZ_RUNB; wr++;
s->mtfFreq[BZ_RUNB]++;
} else {
mtfv[wr] = BZ_RUNA; wr++;
s->mtfFreq[BZ_RUNA]++;
}
if (zPend < 2) break;
zPend = (zPend - 2) / 2;
};
zPend = 0;
}
{
register UChar rtmp;
register UChar* ryy_j;
register UChar rll_i;
rtmp = yy[1];
yy[1] = yy[0];
ryy_j = &(yy[1]);
rll_i = ll_i;
while ( rll_i != rtmp ) {
register UChar rtmp2;
ryy_j++;
rtmp2 = rtmp;
rtmp = *ryy_j;
*ryy_j = rtmp2;
};
yy[0] = rtmp;
j = ryy_j - &(yy[0]);
mtfv[wr] = j+1; wr++; s->mtfFreq[j+1]++;
}
}
}
if (zPend > 0) {
zPend--;
while (True) {
if (zPend & 1) {
mtfv[wr] = BZ_RUNB; wr++;
s->mtfFreq[BZ_RUNB]++;
} else {
mtfv[wr] = BZ_RUNA; wr++;
s->mtfFreq[BZ_RUNA]++;
}
if (zPend < 2) break;
zPend = (zPend - 2) / 2;
};
zPend = 0;
}
mtfv[wr] = EOB; wr++; s->mtfFreq[EOB]++;
s->nMTF = wr;
}
/*---------------------------------------------------*/
#define BZ_LESSER_ICOST 0
#define BZ_GREATER_ICOST 15
static
void sendMTFValues ( EState* s )
{
Int32 v, t, i, j, gs, ge, totc, bt, bc, iter;
Int32 nSelectors, alphaSize, minLen, maxLen, selCtr;
Int32 nGroups, nBytes;
/*--
UChar len [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
is a global since the decoder also needs it.
Int32 code[BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
Int32 rfreq[BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
are also globals only used in this proc.
Made global to keep stack frame size small.
--*/
UInt16 cost[BZ_N_GROUPS];
Int32 fave[BZ_N_GROUPS];
UInt16* mtfv = s->mtfv;
if (s->verbosity >= 3)
VPrintf3( " %d in block, %d after MTF & 1-2 coding, "
"%d+2 syms in use\n",
s->nblock, s->nMTF, s->nInUse );
alphaSize = s->nInUse+2;
for (t = 0; t < BZ_N_GROUPS; t++)
for (v = 0; v < alphaSize; v++)
s->len[t][v] = BZ_GREATER_ICOST;
/*--- Decide how many coding tables to use ---*/
AssertH ( s->nMTF > 0, 3001 );
if (s->nMTF < 200) nGroups = 2; else
if (s->nMTF < 600) nGroups = 3; else
if (s->nMTF < 1200) nGroups = 4; else
if (s->nMTF < 2400) nGroups = 5; else
nGroups = 6;
/*--- Generate an initial set of coding tables ---*/
{
Int32 nPart, remF, tFreq, aFreq;
nPart = nGroups;
remF = s->nMTF;
gs = 0;
while (nPart > 0) {
tFreq = remF / nPart;
ge = gs-1;
aFreq = 0;
while (aFreq < tFreq && ge < alphaSize-1) {
ge++;
aFreq += s->mtfFreq[ge];
}
if (ge > gs
&& nPart != nGroups && nPart != 1
&& ((nGroups-nPart) % 2 == 1)) {
aFreq -= s->mtfFreq[ge];
ge--;
}
if (s->verbosity >= 3)
VPrintf5( " initial group %d, [%d .. %d], "
"has %d syms (%4.1f%%)\n",
nPart, gs, ge, aFreq,
(100.0 * (float)aFreq) / (float)(s->nMTF) );
for (v = 0; v < alphaSize; v++)
if (v >= gs && v <= ge)
s->len[nPart-1][v] = BZ_LESSER_ICOST; else
s->len[nPart-1][v] = BZ_GREATER_ICOST;
nPart--;
gs = ge+1;
remF -= aFreq;
}
}
/*---
Iterate up to BZ_N_ITERS times to improve the tables.
---*/
for (iter = 0; iter < BZ_N_ITERS; iter++) {
for (t = 0; t < nGroups; t++) fave[t] = 0;
for (t = 0; t < nGroups; t++)
for (v = 0; v < alphaSize; v++)
s->rfreq[t][v] = 0;
/*---
Set up an auxiliary length table which is used to fast-track
the common case (nGroups == 6).
---*/
if (nGroups == 6) {
for (v = 0; v < alphaSize; v++) {
s->len_pack[v][0] = (s->len[1][v] << 16) | s->len[0][v];
s->len_pack[v][1] = (s->len[3][v] << 16) | s->len[2][v];
s->len_pack[v][2] = (s->len[5][v] << 16) | s->len[4][v];
}
}
nSelectors = 0;
totc = 0;
gs = 0;
while (True) {
/*--- Set group start & end marks. --*/
if (gs >= s->nMTF) break;
ge = gs + BZ_G_SIZE - 1;
if (ge >= s->nMTF) ge = s->nMTF-1;
/*--
Calculate the cost of this group as coded
by each of the coding tables.
--*/
for (t = 0; t < nGroups; t++) cost[t] = 0;
if (nGroups == 6 && 50 == ge-gs+1) {
/*--- fast track the common case ---*/
register UInt32 cost01, cost23, cost45;
register UInt16 icv;
cost01 = cost23 = cost45 = 0;
# define BZ_ITER(nn) \
icv = mtfv[gs+(nn)]; \
cost01 += s->len_pack[icv][0]; \
cost23 += s->len_pack[icv][1]; \
cost45 += s->len_pack[icv][2]; \
BZ_ITER(0); BZ_ITER(1); BZ_ITER(2); BZ_ITER(3); BZ_ITER(4);
BZ_ITER(5); BZ_ITER(6); BZ_ITER(7); BZ_ITER(8); BZ_ITER(9);
BZ_ITER(10); BZ_ITER(11); BZ_ITER(12); BZ_ITER(13); BZ_ITER(14);
BZ_ITER(15); BZ_ITER(16); BZ_ITER(17); BZ_ITER(18); BZ_ITER(19);
BZ_ITER(20); BZ_ITER(21); BZ_ITER(22); BZ_ITER(23); BZ_ITER(24);
BZ_ITER(25); BZ_ITER(26); BZ_ITER(27); BZ_ITER(28); BZ_ITER(29);
BZ_ITER(30); BZ_ITER(31); BZ_ITER(32); BZ_ITER(33); BZ_ITER(34);
BZ_ITER(35); BZ_ITER(36); BZ_ITER(37); BZ_ITER(38); BZ_ITER(39);
BZ_ITER(40); BZ_ITER(41); BZ_ITER(42); BZ_ITER(43); BZ_ITER(44);
BZ_ITER(45); BZ_ITER(46); BZ_ITER(47); BZ_ITER(48); BZ_ITER(49);
# undef BZ_ITER
cost[0] = cost01 & 0xffff; cost[1] = cost01 >> 16;
cost[2] = cost23 & 0xffff; cost[3] = cost23 >> 16;
cost[4] = cost45 & 0xffff; cost[5] = cost45 >> 16;
} else {
/*--- slow version which correctly handles all situations ---*/
for (i = gs; i <= ge; i++) {
UInt16 icv = mtfv[i];
for (t = 0; t < nGroups; t++) cost[t] += s->len[t][icv];
}
}
/*--
Find the coding table which is best for this group,
and record its identity in the selector table.
--*/
bc = 999999999; bt = -1;
for (t = 0; t < nGroups; t++)
if (cost[t] < bc) { bc = cost[t]; bt = t; };
totc += bc;
fave[bt]++;
s->selector[nSelectors] = bt;
nSelectors++;
/*--
Increment the symbol frequencies for the selected table.
--*/
if (nGroups == 6 && 50 == ge-gs+1) {
/*--- fast track the common case ---*/
# define BZ_ITUR(nn) s->rfreq[bt][ mtfv[gs+(nn)] ]++
BZ_ITUR(0); BZ_ITUR(1); BZ_ITUR(2); BZ_ITUR(3); BZ_ITUR(4);
BZ_ITUR(5); BZ_ITUR(6); BZ_ITUR(7); BZ_ITUR(8); BZ_ITUR(9);
BZ_ITUR(10); BZ_ITUR(11); BZ_ITUR(12); BZ_ITUR(13); BZ_ITUR(14);
BZ_ITUR(15); BZ_ITUR(16); BZ_ITUR(17); BZ_ITUR(18); BZ_ITUR(19);
BZ_ITUR(20); BZ_ITUR(21); BZ_ITUR(22); BZ_ITUR(23); BZ_ITUR(24);
BZ_ITUR(25); BZ_ITUR(26); BZ_ITUR(27); BZ_ITUR(28); BZ_ITUR(29);
BZ_ITUR(30); BZ_ITUR(31); BZ_ITUR(32); BZ_ITUR(33); BZ_ITUR(34);
BZ_ITUR(35); BZ_ITUR(36); BZ_ITUR(37); BZ_ITUR(38); BZ_ITUR(39);
BZ_ITUR(40); BZ_ITUR(41); BZ_ITUR(42); BZ_ITUR(43); BZ_ITUR(44);
BZ_ITUR(45); BZ_ITUR(46); BZ_ITUR(47); BZ_ITUR(48); BZ_ITUR(49);
# undef BZ_ITUR
} else {
/*--- slow version which correctly handles all situations ---*/
for (i = gs; i <= ge; i++)
s->rfreq[bt][ mtfv[i] ]++;
}
gs = ge+1;
}
if (s->verbosity >= 3) {
VPrintf2 ( " pass %d: size is %d, grp uses are ",
iter+1, totc/8 );
for (t = 0; t < nGroups; t++)
VPrintf1 ( "%d ", fave[t] );
VPrintf0 ( "\n" );
}
/*--
Recompute the tables based on the accumulated frequencies.
--*/
/* maxLen was changed from 20 to 17 in bzip2-1.0.3. See
comment in huffman.c for details. */
for (t = 0; t < nGroups; t++)
BZ2_hbMakeCodeLengths ( &(s->len[t][0]), &(s->rfreq[t][0]),
alphaSize, 17 /*20*/ );
}
AssertH( nGroups < 8, 3002 );
AssertH( nSelectors < 32768 &&
nSelectors <= (2 + (900000 / BZ_G_SIZE)),
3003 );
/*--- Compute MTF values for the selectors. ---*/
{
UChar pos[BZ_N_GROUPS], ll_i, tmp2, tmp;
for (i = 0; i < nGroups; i++) pos[i] = i;
for (i = 0; i < nSelectors; i++) {
ll_i = s->selector[i];
j = 0;
tmp = pos[j];
while ( ll_i != tmp ) {
j++;
tmp2 = tmp;
tmp = pos[j];
pos[j] = tmp2;
};
pos[0] = tmp;
s->selectorMtf[i] = j;
}
};
/*--- Assign actual codes for the tables. --*/
for (t = 0; t < nGroups; t++) {
minLen = 32;
maxLen = 0;
for (i = 0; i < alphaSize; i++) {
if (s->len[t][i] > maxLen) maxLen = s->len[t][i];
if (s->len[t][i] < minLen) minLen = s->len[t][i];
}
AssertH ( !(maxLen > 17 /*20*/ ), 3004 );
AssertH ( !(minLen < 1), 3005 );
BZ2_hbAssignCodes ( &(s->code[t][0]), &(s->len[t][0]),
minLen, maxLen, alphaSize );
}
/*--- Transmit the mapping table. ---*/
{
Bool inUse16[16];
for (i = 0; i < 16; i++) {
inUse16[i] = False;
for (j = 0; j < 16; j++)
if (s->inUse[i * 16 + j]) inUse16[i] = True;
}
nBytes = s->numZ;
for (i = 0; i < 16; i++)
if (inUse16[i]) bsW(s,1,1); else bsW(s,1,0);
for (i = 0; i < 16; i++)
if (inUse16[i])
for (j = 0; j < 16; j++) {
if (s->inUse[i * 16 + j]) bsW(s,1,1); else bsW(s,1,0);
}
if (s->verbosity >= 3)
VPrintf1( " bytes: mapping %d, ", s->numZ-nBytes );
}
/*--- Now the selectors. ---*/
nBytes = s->numZ;
bsW ( s, 3, nGroups );
bsW ( s, 15, nSelectors );
for (i = 0; i < nSelectors; i++) {
for (j = 0; j < s->selectorMtf[i]; j++) bsW(s,1,1);
bsW(s,1,0);
}
if (s->verbosity >= 3)
VPrintf1( "selectors %d, ", s->numZ-nBytes );
/*--- Now the coding tables. ---*/
nBytes = s->numZ;
for (t = 0; t < nGroups; t++) {
Int32 curr = s->len[t][0];
bsW ( s, 5, curr );
for (i = 0; i < alphaSize; i++) {
while (curr < s->len[t][i]) { bsW(s,2,2); curr++; /* 10 */ };
while (curr > s->len[t][i]) { bsW(s,2,3); curr--; /* 11 */ };
bsW ( s, 1, 0 );
}
}
if (s->verbosity >= 3)
VPrintf1 ( "code lengths %d, ", s->numZ-nBytes );
/*--- And finally, the block data proper ---*/
nBytes = s->numZ;
selCtr = 0;
gs = 0;
while (True) {
if (gs >= s->nMTF) break;
ge = gs + BZ_G_SIZE - 1;
if (ge >= s->nMTF) ge = s->nMTF-1;
AssertH ( s->selector[selCtr] < nGroups, 3006 );
if (nGroups == 6 && 50 == ge-gs+1) {
/*--- fast track the common case ---*/
UInt16 mtfv_i;
UChar* s_len_sel_selCtr
= &(s->len[s->selector[selCtr]][0]);
Int32* s_code_sel_selCtr
= &(s->code[s->selector[selCtr]][0]);
# define BZ_ITAH(nn) \
mtfv_i = mtfv[gs+(nn)]; \
bsW ( s, \
s_len_sel_selCtr[mtfv_i], \
s_code_sel_selCtr[mtfv_i] )
BZ_ITAH(0); BZ_ITAH(1); BZ_ITAH(2); BZ_ITAH(3); BZ_ITAH(4);
BZ_ITAH(5); BZ_ITAH(6); BZ_ITAH(7); BZ_ITAH(8); BZ_ITAH(9);
BZ_ITAH(10); BZ_ITAH(11); BZ_ITAH(12); BZ_ITAH(13); BZ_ITAH(14);
BZ_ITAH(15); BZ_ITAH(16); BZ_ITAH(17); BZ_ITAH(18); BZ_ITAH(19);
BZ_ITAH(20); BZ_ITAH(21); BZ_ITAH(22); BZ_ITAH(23); BZ_ITAH(24);
BZ_ITAH(25); BZ_ITAH(26); BZ_ITAH(27); BZ_ITAH(28); BZ_ITAH(29);
BZ_ITAH(30); BZ_ITAH(31); BZ_ITAH(32); BZ_ITAH(33); BZ_ITAH(34);
BZ_ITAH(35); BZ_ITAH(36); BZ_ITAH(37); BZ_ITAH(38); BZ_ITAH(39);
BZ_ITAH(40); BZ_ITAH(41); BZ_ITAH(42); BZ_ITAH(43); BZ_ITAH(44);
BZ_ITAH(45); BZ_ITAH(46); BZ_ITAH(47); BZ_ITAH(48); BZ_ITAH(49);
# undef BZ_ITAH
} else {
/*--- slow version which correctly handles all situations ---*/
for (i = gs; i <= ge; i++) {
bsW ( s,
s->len [s->selector[selCtr]] [mtfv[i]],
s->code [s->selector[selCtr]] [mtfv[i]] );
}
}
gs = ge+1;
selCtr++;
}
AssertH( selCtr == nSelectors, 3007 );
if (s->verbosity >= 3)
VPrintf1( "codes %d\n", s->numZ-nBytes );
}
/*---------------------------------------------------*/
void BZ2_compressBlock ( EState* s, Bool is_last_block )
{
if (s->nblock > 0) {
BZ_FINALISE_CRC ( s->blockCRC );
s->combinedCRC = (s->combinedCRC << 1) | (s->combinedCRC >> 31);
s->combinedCRC ^= s->blockCRC;
if (s->blockNo > 1) s->numZ = 0;
if (s->verbosity >= 2)
VPrintf4( " block %d: crc = 0x%08x, "
"combined CRC = 0x%08x, size = %d\n",
s->blockNo, s->blockCRC, s->combinedCRC, s->nblock );
BZ2_blockSort ( s );
}
s->zbits = (UChar*) (&((UChar*)s->arr2)[s->nblock]);
/*-- If this is the first block, create the stream header. --*/
if (s->blockNo == 1) {
BZ2_bsInitWrite ( s );
bsPutUChar ( s, BZ_HDR_B );
bsPutUChar ( s, BZ_HDR_Z );
bsPutUChar ( s, BZ_HDR_h );
bsPutUChar ( s, (UChar)(BZ_HDR_0 + s->blockSize100k) );
}
if (s->nblock > 0) {
bsPutUChar ( s, 0x31 ); bsPutUChar ( s, 0x41 );
bsPutUChar ( s, 0x59 ); bsPutUChar ( s, 0x26 );
bsPutUChar ( s, 0x53 ); bsPutUChar ( s, 0x59 );
/*-- Now the block's CRC, so it is in a known place. --*/
bsPutUInt32 ( s, s->blockCRC );
/*--
Now a single bit indicating (non-)randomisation.
As of version 0.9.5, we use a better sorting algorithm
which makes randomisation unnecessary. So always set
the randomised bit to 'no'. Of course, the decoder
still needs to be able to handle randomised blocks
so as to maintain backwards compatibility with
older versions of bzip2.
--*/
bsW(s,1,0);
bsW ( s, 24, s->origPtr );
generateMTFValues ( s );
sendMTFValues ( s );
}
/*-- If this is the last block, add the stream trailer. --*/
if (is_last_block) {
bsPutUChar ( s, 0x17 ); bsPutUChar ( s, 0x72 );
bsPutUChar ( s, 0x45 ); bsPutUChar ( s, 0x38 );
bsPutUChar ( s, 0x50 ); bsPutUChar ( s, 0x90 );
bsPutUInt32 ( s, s->combinedCRC );
if (s->verbosity >= 2)
VPrintf1( " final combined CRC = 0x%08x\n ", s->combinedCRC );
bsFinishWrite ( s );
}
}
/*-------------------------------------------------------------*/
/*--- end compress.c ---*/
/*-------------------------------------------------------------*/

View File

@@ -1,104 +0,0 @@
/*-------------------------------------------------------------*/
/*--- Table for doing CRCs ---*/
/*--- crctable.c ---*/
/*-------------------------------------------------------------*/
/* ------------------------------------------------------------------
This file is part of bzip2/libbzip2, a program and library for
lossless, block-sorting data compression.
bzip2/libbzip2 version 1.0.5 of 10 December 2007
Copyright (C) 1996-2007 Julian Seward <jseward@bzip.org>
Please read the WARNING, DISCLAIMER and PATENTS sections in the
README file.
This program is released under the terms of the license contained
in the file LICENSE.
------------------------------------------------------------------ */
#include "bzlib_private.h"
/*--
I think this is an implementation of the AUTODIN-II,
Ethernet & FDDI 32-bit CRC standard. Vaguely derived
from code by Rob Warnock, in Section 51 of the
comp.compression FAQ.
--*/
UInt32 BZ2_crc32Table[256] = {
/*-- Ugly, innit? --*/
0x00000000L, 0x04c11db7L, 0x09823b6eL, 0x0d4326d9L,
0x130476dcL, 0x17c56b6bL, 0x1a864db2L, 0x1e475005L,
0x2608edb8L, 0x22c9f00fL, 0x2f8ad6d6L, 0x2b4bcb61L,
0x350c9b64L, 0x31cd86d3L, 0x3c8ea00aL, 0x384fbdbdL,
0x4c11db70L, 0x48d0c6c7L, 0x4593e01eL, 0x4152fda9L,
0x5f15adacL, 0x5bd4b01bL, 0x569796c2L, 0x52568b75L,
0x6a1936c8L, 0x6ed82b7fL, 0x639b0da6L, 0x675a1011L,
0x791d4014L, 0x7ddc5da3L, 0x709f7b7aL, 0x745e66cdL,
0x9823b6e0L, 0x9ce2ab57L, 0x91a18d8eL, 0x95609039L,
0x8b27c03cL, 0x8fe6dd8bL, 0x82a5fb52L, 0x8664e6e5L,
0xbe2b5b58L, 0xbaea46efL, 0xb7a96036L, 0xb3687d81L,
0xad2f2d84L, 0xa9ee3033L, 0xa4ad16eaL, 0xa06c0b5dL,
0xd4326d90L, 0xd0f37027L, 0xddb056feL, 0xd9714b49L,
0xc7361b4cL, 0xc3f706fbL, 0xceb42022L, 0xca753d95L,
0xf23a8028L, 0xf6fb9d9fL, 0xfbb8bb46L, 0xff79a6f1L,
0xe13ef6f4L, 0xe5ffeb43L, 0xe8bccd9aL, 0xec7dd02dL,
0x34867077L, 0x30476dc0L, 0x3d044b19L, 0x39c556aeL,
0x278206abL, 0x23431b1cL, 0x2e003dc5L, 0x2ac12072L,
0x128e9dcfL, 0x164f8078L, 0x1b0ca6a1L, 0x1fcdbb16L,
0x018aeb13L, 0x054bf6a4L, 0x0808d07dL, 0x0cc9cdcaL,
0x7897ab07L, 0x7c56b6b0L, 0x71159069L, 0x75d48ddeL,
0x6b93dddbL, 0x6f52c06cL, 0x6211e6b5L, 0x66d0fb02L,
0x5e9f46bfL, 0x5a5e5b08L, 0x571d7dd1L, 0x53dc6066L,
0x4d9b3063L, 0x495a2dd4L, 0x44190b0dL, 0x40d816baL,
0xaca5c697L, 0xa864db20L, 0xa527fdf9L, 0xa1e6e04eL,
0xbfa1b04bL, 0xbb60adfcL, 0xb6238b25L, 0xb2e29692L,
0x8aad2b2fL, 0x8e6c3698L, 0x832f1041L, 0x87ee0df6L,
0x99a95df3L, 0x9d684044L, 0x902b669dL, 0x94ea7b2aL,
0xe0b41de7L, 0xe4750050L, 0xe9362689L, 0xedf73b3eL,
0xf3b06b3bL, 0xf771768cL, 0xfa325055L, 0xfef34de2L,
0xc6bcf05fL, 0xc27dede8L, 0xcf3ecb31L, 0xcbffd686L,
0xd5b88683L, 0xd1799b34L, 0xdc3abdedL, 0xd8fba05aL,
0x690ce0eeL, 0x6dcdfd59L, 0x608edb80L, 0x644fc637L,
0x7a089632L, 0x7ec98b85L, 0x738aad5cL, 0x774bb0ebL,
0x4f040d56L, 0x4bc510e1L, 0x46863638L, 0x42472b8fL,
0x5c007b8aL, 0x58c1663dL, 0x558240e4L, 0x51435d53L,
0x251d3b9eL, 0x21dc2629L, 0x2c9f00f0L, 0x285e1d47L,
0x36194d42L, 0x32d850f5L, 0x3f9b762cL, 0x3b5a6b9bL,
0x0315d626L, 0x07d4cb91L, 0x0a97ed48L, 0x0e56f0ffL,
0x1011a0faL, 0x14d0bd4dL, 0x19939b94L, 0x1d528623L,
0xf12f560eL, 0xf5ee4bb9L, 0xf8ad6d60L, 0xfc6c70d7L,
0xe22b20d2L, 0xe6ea3d65L, 0xeba91bbcL, 0xef68060bL,
0xd727bbb6L, 0xd3e6a601L, 0xdea580d8L, 0xda649d6fL,
0xc423cd6aL, 0xc0e2d0ddL, 0xcda1f604L, 0xc960ebb3L,
0xbd3e8d7eL, 0xb9ff90c9L, 0xb4bcb610L, 0xb07daba7L,
0xae3afba2L, 0xaafbe615L, 0xa7b8c0ccL, 0xa379dd7bL,
0x9b3660c6L, 0x9ff77d71L, 0x92b45ba8L, 0x9675461fL,
0x8832161aL, 0x8cf30badL, 0x81b02d74L, 0x857130c3L,
0x5d8a9099L, 0x594b8d2eL, 0x5408abf7L, 0x50c9b640L,
0x4e8ee645L, 0x4a4ffbf2L, 0x470cdd2bL, 0x43cdc09cL,
0x7b827d21L, 0x7f436096L, 0x7200464fL, 0x76c15bf8L,
0x68860bfdL, 0x6c47164aL, 0x61043093L, 0x65c52d24L,
0x119b4be9L, 0x155a565eL, 0x18197087L, 0x1cd86d30L,
0x029f3d35L, 0x065e2082L, 0x0b1d065bL, 0x0fdc1becL,
0x3793a651L, 0x3352bbe6L, 0x3e119d3fL, 0x3ad08088L,
0x2497d08dL, 0x2056cd3aL, 0x2d15ebe3L, 0x29d4f654L,
0xc5a92679L, 0xc1683bceL, 0xcc2b1d17L, 0xc8ea00a0L,
0xd6ad50a5L, 0xd26c4d12L, 0xdf2f6bcbL, 0xdbee767cL,
0xe3a1cbc1L, 0xe760d676L, 0xea23f0afL, 0xeee2ed18L,
0xf0a5bd1dL, 0xf464a0aaL, 0xf9278673L, 0xfde69bc4L,
0x89b8fd09L, 0x8d79e0beL, 0x803ac667L, 0x84fbdbd0L,
0x9abc8bd5L, 0x9e7d9662L, 0x933eb0bbL, 0x97ffad0cL,
0xafb010b1L, 0xab710d06L, 0xa6322bdfL, 0xa2f33668L,
0xbcb4666dL, 0xb8757bdaL, 0xb5365d03L, 0xb1f740b4L
};
/*-------------------------------------------------------------*/
/*--- end crctable.c ---*/
/*-------------------------------------------------------------*/

View File

@@ -1,626 +0,0 @@
/*-------------------------------------------------------------*/
/*--- Decompression machinery ---*/
/*--- decompress.c ---*/
/*-------------------------------------------------------------*/
/* ------------------------------------------------------------------
This file is part of bzip2/libbzip2, a program and library for
lossless, block-sorting data compression.
bzip2/libbzip2 version 1.0.5 of 10 December 2007
Copyright (C) 1996-2007 Julian Seward <jseward@bzip.org>
Please read the WARNING, DISCLAIMER and PATENTS sections in the
README file.
This program is released under the terms of the license contained
in the file LICENSE.
------------------------------------------------------------------ */
#include "bzlib_private.h"
/*---------------------------------------------------*/
static
void makeMaps_d ( DState* s )
{
Int32 i;
s->nInUse = 0;
for (i = 0; i < 256; i++)
if (s->inUse[i]) {
s->seqToUnseq[s->nInUse] = i;
s->nInUse++;
}
}
/*---------------------------------------------------*/
#define RETURN(rrr) \
{ retVal = rrr; goto save_state_and_return; };
#define GET_BITS(lll,vvv,nnn) \
case lll: s->state = lll; \
while (True) { \
if (s->bsLive >= nnn) { \
UInt32 v; \
v = (s->bsBuff >> \
(s->bsLive-nnn)) & ((1 << nnn)-1); \
s->bsLive -= nnn; \
vvv = v; \
break; \
} \
if (s->strm->avail_in == 0) RETURN(BZ_OK); \
s->bsBuff \
= (s->bsBuff << 8) | \
((UInt32) \
(*((UChar*)(s->strm->next_in)))); \
s->bsLive += 8; \
s->strm->next_in++; \
s->strm->avail_in--; \
s->strm->total_in_lo32++; \
if (s->strm->total_in_lo32 == 0) \
s->strm->total_in_hi32++; \
}
#define GET_UCHAR(lll,uuu) \
GET_BITS(lll,uuu,8)
#define GET_BIT(lll,uuu) \
GET_BITS(lll,uuu,1)
/*---------------------------------------------------*/
#define GET_MTF_VAL(label1,label2,lval) \
{ \
if (groupPos == 0) { \
groupNo++; \
if (groupNo >= nSelectors) \
RETURN(BZ_DATA_ERROR); \
groupPos = BZ_G_SIZE; \
gSel = s->selector[groupNo]; \
gMinlen = s->minLens[gSel]; \
gLimit = &(s->limit[gSel][0]); \
gPerm = &(s->perm[gSel][0]); \
gBase = &(s->base[gSel][0]); \
} \
groupPos--; \
zn = gMinlen; \
GET_BITS(label1, zvec, zn); \
while (1) { \
if (zn > 20 /* the longest code */) \
RETURN(BZ_DATA_ERROR); \
if (zvec <= gLimit[zn]) break; \
zn++; \
GET_BIT(label2, zj); \
zvec = (zvec << 1) | zj; \
}; \
if (zvec - gBase[zn] < 0 \
|| zvec - gBase[zn] >= BZ_MAX_ALPHA_SIZE) \
RETURN(BZ_DATA_ERROR); \
lval = gPerm[zvec - gBase[zn]]; \
}
/*---------------------------------------------------*/
Int32 BZ2_decompress ( DState* s )
{
UChar uc;
Int32 retVal;
Int32 minLen, maxLen;
bz_stream* strm = s->strm;
/* stuff that needs to be saved/restored */
Int32 i;
Int32 j;
Int32 t;
Int32 alphaSize;
Int32 nGroups;
Int32 nSelectors;
Int32 EOB;
Int32 groupNo;
Int32 groupPos;
Int32 nextSym;
Int32 nblockMAX;
Int32 nblock;
Int32 es;
Int32 N;
Int32 curr;
Int32 zt;
Int32 zn;
Int32 zvec;
Int32 zj;
Int32 gSel;
Int32 gMinlen;
Int32* gLimit;
Int32* gBase;
Int32* gPerm;
if (s->state == BZ_X_MAGIC_1) {
/*initialise the save area*/
s->save_i = 0;
s->save_j = 0;
s->save_t = 0;
s->save_alphaSize = 0;
s->save_nGroups = 0;
s->save_nSelectors = 0;
s->save_EOB = 0;
s->save_groupNo = 0;
s->save_groupPos = 0;
s->save_nextSym = 0;
s->save_nblockMAX = 0;
s->save_nblock = 0;
s->save_es = 0;
s->save_N = 0;
s->save_curr = 0;
s->save_zt = 0;
s->save_zn = 0;
s->save_zvec = 0;
s->save_zj = 0;
s->save_gSel = 0;
s->save_gMinlen = 0;
s->save_gLimit = NULL;
s->save_gBase = NULL;
s->save_gPerm = NULL;
}
/*restore from the save area*/
i = s->save_i;
j = s->save_j;
t = s->save_t;
alphaSize = s->save_alphaSize;
nGroups = s->save_nGroups;
nSelectors = s->save_nSelectors;
EOB = s->save_EOB;
groupNo = s->save_groupNo;
groupPos = s->save_groupPos;
nextSym = s->save_nextSym;
nblockMAX = s->save_nblockMAX;
nblock = s->save_nblock;
es = s->save_es;
N = s->save_N;
curr = s->save_curr;
zt = s->save_zt;
zn = s->save_zn;
zvec = s->save_zvec;
zj = s->save_zj;
gSel = s->save_gSel;
gMinlen = s->save_gMinlen;
gLimit = s->save_gLimit;
gBase = s->save_gBase;
gPerm = s->save_gPerm;
retVal = BZ_OK;
switch (s->state) {
GET_UCHAR(BZ_X_MAGIC_1, uc);
if (uc != BZ_HDR_B) RETURN(BZ_DATA_ERROR_MAGIC);
GET_UCHAR(BZ_X_MAGIC_2, uc);
if (uc != BZ_HDR_Z) RETURN(BZ_DATA_ERROR_MAGIC);
GET_UCHAR(BZ_X_MAGIC_3, uc)
if (uc != BZ_HDR_h) RETURN(BZ_DATA_ERROR_MAGIC);
GET_BITS(BZ_X_MAGIC_4, s->blockSize100k, 8)
if (s->blockSize100k < (BZ_HDR_0 + 1) ||
s->blockSize100k > (BZ_HDR_0 + 9)) RETURN(BZ_DATA_ERROR_MAGIC);
s->blockSize100k -= BZ_HDR_0;
if (s->smallDecompress) {
s->ll16 = BZALLOC( s->blockSize100k * 100000 * sizeof(UInt16) );
s->ll4 = BZALLOC(
((1 + s->blockSize100k * 100000) >> 1) * sizeof(UChar)
);
if (s->ll16 == NULL || s->ll4 == NULL) RETURN(BZ_MEM_ERROR);
} else {
s->tt = BZALLOC( s->blockSize100k * 100000 * sizeof(Int32) );
if (s->tt == NULL) RETURN(BZ_MEM_ERROR);
}
GET_UCHAR(BZ_X_BLKHDR_1, uc);
if (uc == 0x17) goto endhdr_2;
if (uc != 0x31) RETURN(BZ_DATA_ERROR);
GET_UCHAR(BZ_X_BLKHDR_2, uc);
if (uc != 0x41) RETURN(BZ_DATA_ERROR);
GET_UCHAR(BZ_X_BLKHDR_3, uc);
if (uc != 0x59) RETURN(BZ_DATA_ERROR);
GET_UCHAR(BZ_X_BLKHDR_4, uc);
if (uc != 0x26) RETURN(BZ_DATA_ERROR);
GET_UCHAR(BZ_X_BLKHDR_5, uc);
if (uc != 0x53) RETURN(BZ_DATA_ERROR);
GET_UCHAR(BZ_X_BLKHDR_6, uc);
if (uc != 0x59) RETURN(BZ_DATA_ERROR);
s->currBlockNo++;
if (s->verbosity >= 2)
VPrintf1 ( "\n [%d: huff+mtf ", s->currBlockNo );
s->storedBlockCRC = 0;
GET_UCHAR(BZ_X_BCRC_1, uc);
s->storedBlockCRC = (s->storedBlockCRC << 8) | ((UInt32)uc);
GET_UCHAR(BZ_X_BCRC_2, uc);
s->storedBlockCRC = (s->storedBlockCRC << 8) | ((UInt32)uc);
GET_UCHAR(BZ_X_BCRC_3, uc);
s->storedBlockCRC = (s->storedBlockCRC << 8) | ((UInt32)uc);
GET_UCHAR(BZ_X_BCRC_4, uc);
s->storedBlockCRC = (s->storedBlockCRC << 8) | ((UInt32)uc);
GET_BITS(BZ_X_RANDBIT, s->blockRandomised, 1);
s->origPtr = 0;
GET_UCHAR(BZ_X_ORIGPTR_1, uc);
s->origPtr = (s->origPtr << 8) | ((Int32)uc);
GET_UCHAR(BZ_X_ORIGPTR_2, uc);
s->origPtr = (s->origPtr << 8) | ((Int32)uc);
GET_UCHAR(BZ_X_ORIGPTR_3, uc);
s->origPtr = (s->origPtr << 8) | ((Int32)uc);
if (s->origPtr < 0)
RETURN(BZ_DATA_ERROR);
if (s->origPtr > 10 + 100000*s->blockSize100k)
RETURN(BZ_DATA_ERROR);
/*--- Receive the mapping table ---*/
for (i = 0; i < 16; i++) {
GET_BIT(BZ_X_MAPPING_1, uc);
if (uc == 1)
s->inUse16[i] = True; else
s->inUse16[i] = False;
}
for (i = 0; i < 256; i++) s->inUse[i] = False;
for (i = 0; i < 16; i++)
if (s->inUse16[i])
for (j = 0; j < 16; j++) {
GET_BIT(BZ_X_MAPPING_2, uc);
if (uc == 1) s->inUse[i * 16 + j] = True;
}
makeMaps_d ( s );
if (s->nInUse == 0) RETURN(BZ_DATA_ERROR);
alphaSize = s->nInUse+2;
/*--- Now the selectors ---*/
GET_BITS(BZ_X_SELECTOR_1, nGroups, 3);
if (nGroups < 2 || nGroups > 6) RETURN(BZ_DATA_ERROR);
GET_BITS(BZ_X_SELECTOR_2, nSelectors, 15);
if (nSelectors < 1) RETURN(BZ_DATA_ERROR);
for (i = 0; i < nSelectors; i++) {
j = 0;
while (True) {
GET_BIT(BZ_X_SELECTOR_3, uc);
if (uc == 0) break;
j++;
if (j >= nGroups) RETURN(BZ_DATA_ERROR);
}
s->selectorMtf[i] = j;
}
/*--- Undo the MTF values for the selectors. ---*/
{
UChar pos[BZ_N_GROUPS], tmp, v;
for (v = 0; v < nGroups; v++) pos[v] = v;
for (i = 0; i < nSelectors; i++) {
v = s->selectorMtf[i];
tmp = pos[v];
while (v > 0) { pos[v] = pos[v-1]; v--; }
pos[0] = tmp;
s->selector[i] = tmp;
}
}
/*--- Now the coding tables ---*/
for (t = 0; t < nGroups; t++) {
GET_BITS(BZ_X_CODING_1, curr, 5);
for (i = 0; i < alphaSize; i++) {
while (True) {
if (curr < 1 || curr > 20) RETURN(BZ_DATA_ERROR);
GET_BIT(BZ_X_CODING_2, uc);
if (uc == 0) break;
GET_BIT(BZ_X_CODING_3, uc);
if (uc == 0) curr++; else curr--;
}
s->len[t][i] = curr;
}
}
/*--- Create the Huffman decoding tables ---*/
for (t = 0; t < nGroups; t++) {
minLen = 32;
maxLen = 0;
for (i = 0; i < alphaSize; i++) {
if (s->len[t][i] > maxLen) maxLen = s->len[t][i];
if (s->len[t][i] < minLen) minLen = s->len[t][i];
}
BZ2_hbCreateDecodeTables (
&(s->limit[t][0]),
&(s->base[t][0]),
&(s->perm[t][0]),
&(s->len[t][0]),
minLen, maxLen, alphaSize
);
s->minLens[t] = minLen;
}
/*--- Now the MTF values ---*/
EOB = s->nInUse+1;
nblockMAX = 100000 * s->blockSize100k;
groupNo = -1;
groupPos = 0;
for (i = 0; i <= 255; i++) s->unzftab[i] = 0;
/*-- MTF init --*/
{
Int32 ii, jj, kk;
kk = MTFA_SIZE-1;
for (ii = 256 / MTFL_SIZE - 1; ii >= 0; ii--) {
for (jj = MTFL_SIZE-1; jj >= 0; jj--) {
s->mtfa[kk] = (UChar)(ii * MTFL_SIZE + jj);
kk--;
}
s->mtfbase[ii] = kk + 1;
}
}
/*-- end MTF init --*/
nblock = 0;
GET_MTF_VAL(BZ_X_MTF_1, BZ_X_MTF_2, nextSym);
while (True) {
if (nextSym == EOB) break;
if (nextSym == BZ_RUNA || nextSym == BZ_RUNB) {
es = -1;
N = 1;
do {
if (nextSym == BZ_RUNA) es = es + (0+1) * N; else
if (nextSym == BZ_RUNB) es = es + (1+1) * N;
N = N * 2;
GET_MTF_VAL(BZ_X_MTF_3, BZ_X_MTF_4, nextSym);
}
while (nextSym == BZ_RUNA || nextSym == BZ_RUNB);
es++;
uc = s->seqToUnseq[ s->mtfa[s->mtfbase[0]] ];
s->unzftab[uc] += es;
if (s->smallDecompress)
while (es > 0) {
if (nblock >= nblockMAX) RETURN(BZ_DATA_ERROR);
s->ll16[nblock] = (UInt16)uc;
nblock++;
es--;
}
else
while (es > 0) {
if (nblock >= nblockMAX) RETURN(BZ_DATA_ERROR);
s->tt[nblock] = (UInt32)uc;
nblock++;
es--;
};
continue;
} else {
if (nblock >= nblockMAX) RETURN(BZ_DATA_ERROR);
/*-- uc = MTF ( nextSym-1 ) --*/
{
Int32 ii, jj, kk, pp, lno, off;
UInt32 nn;
nn = (UInt32)(nextSym - 1);
if (nn < MTFL_SIZE) {
/* avoid general-case expense */
pp = s->mtfbase[0];
uc = s->mtfa[pp+nn];
while (nn > 3) {
Int32 z = pp+nn;
s->mtfa[(z) ] = s->mtfa[(z)-1];
s->mtfa[(z)-1] = s->mtfa[(z)-2];
s->mtfa[(z)-2] = s->mtfa[(z)-3];
s->mtfa[(z)-3] = s->mtfa[(z)-4];
nn -= 4;
}
while (nn > 0) {
s->mtfa[(pp+nn)] = s->mtfa[(pp+nn)-1]; nn--;
};
s->mtfa[pp] = uc;
} else {
/* general case */
lno = nn / MTFL_SIZE;
off = nn % MTFL_SIZE;
pp = s->mtfbase[lno] + off;
uc = s->mtfa[pp];
while (pp > s->mtfbase[lno]) {
s->mtfa[pp] = s->mtfa[pp-1]; pp--;
};
s->mtfbase[lno]++;
while (lno > 0) {
s->mtfbase[lno]--;
s->mtfa[s->mtfbase[lno]]
= s->mtfa[s->mtfbase[lno-1] + MTFL_SIZE - 1];
lno--;
}
s->mtfbase[0]--;
s->mtfa[s->mtfbase[0]] = uc;
if (s->mtfbase[0] == 0) {
kk = MTFA_SIZE-1;
for (ii = 256 / MTFL_SIZE-1; ii >= 0; ii--) {
for (jj = MTFL_SIZE-1; jj >= 0; jj--) {
s->mtfa[kk] = s->mtfa[s->mtfbase[ii] + jj];
kk--;
}
s->mtfbase[ii] = kk + 1;
}
}
}
}
/*-- end uc = MTF ( nextSym-1 ) --*/
s->unzftab[s->seqToUnseq[uc]]++;
if (s->smallDecompress)
s->ll16[nblock] = (UInt16)(s->seqToUnseq[uc]); else
s->tt[nblock] = (UInt32)(s->seqToUnseq[uc]);
nblock++;
GET_MTF_VAL(BZ_X_MTF_5, BZ_X_MTF_6, nextSym);
continue;
}
}
/* Now we know what nblock is, we can do a better sanity
check on s->origPtr.
*/
if (s->origPtr < 0 || s->origPtr >= nblock)
RETURN(BZ_DATA_ERROR);
/*-- Set up cftab to facilitate generation of T^(-1) --*/
s->cftab[0] = 0;
for (i = 1; i <= 256; i++) s->cftab[i] = s->unzftab[i-1];
for (i = 1; i <= 256; i++) s->cftab[i] += s->cftab[i-1];
for (i = 0; i <= 256; i++) {
if (s->cftab[i] < 0 || s->cftab[i] > nblock) {
/* s->cftab[i] can legitimately be == nblock */
RETURN(BZ_DATA_ERROR);
}
}
s->state_out_len = 0;
s->state_out_ch = 0;
BZ_INITIALISE_CRC ( s->calculatedBlockCRC );
s->state = BZ_X_OUTPUT;
if (s->verbosity >= 2) VPrintf0 ( "rt+rld" );
if (s->smallDecompress) {
/*-- Make a copy of cftab, used in generation of T --*/
for (i = 0; i <= 256; i++) s->cftabCopy[i] = s->cftab[i];
/*-- compute the T vector --*/
for (i = 0; i < nblock; i++) {
uc = (UChar)(s->ll16[i]);
SET_LL(i, s->cftabCopy[uc]);
s->cftabCopy[uc]++;
}
/*-- Compute T^(-1) by pointer reversal on T --*/
i = s->origPtr;
j = GET_LL(i);
do {
Int32 tmp = GET_LL(j);
SET_LL(j, i);
i = j;
j = tmp;
}
while (i != s->origPtr);
s->tPos = s->origPtr;
s->nblock_used = 0;
if (s->blockRandomised) {
BZ_RAND_INIT_MASK;
BZ_GET_SMALL(s->k0); s->nblock_used++;
BZ_RAND_UPD_MASK; s->k0 ^= BZ_RAND_MASK;
} else {
BZ_GET_SMALL(s->k0); s->nblock_used++;
}
} else {
/*-- compute the T^(-1) vector --*/
for (i = 0; i < nblock; i++) {
uc = (UChar)(s->tt[i] & 0xff);
s->tt[s->cftab[uc]] |= (i << 8);
s->cftab[uc]++;
}
s->tPos = s->tt[s->origPtr] >> 8;
s->nblock_used = 0;
if (s->blockRandomised) {
BZ_RAND_INIT_MASK;
BZ_GET_FAST(s->k0); s->nblock_used++;
BZ_RAND_UPD_MASK; s->k0 ^= BZ_RAND_MASK;
} else {
BZ_GET_FAST(s->k0); s->nblock_used++;
}
}
RETURN(BZ_OK);
endhdr_2:
GET_UCHAR(BZ_X_ENDHDR_2, uc);
if (uc != 0x72) RETURN(BZ_DATA_ERROR);
GET_UCHAR(BZ_X_ENDHDR_3, uc);
if (uc != 0x45) RETURN(BZ_DATA_ERROR);
GET_UCHAR(BZ_X_ENDHDR_4, uc);
if (uc != 0x38) RETURN(BZ_DATA_ERROR);
GET_UCHAR(BZ_X_ENDHDR_5, uc);
if (uc != 0x50) RETURN(BZ_DATA_ERROR);
GET_UCHAR(BZ_X_ENDHDR_6, uc);
if (uc != 0x90) RETURN(BZ_DATA_ERROR);
s->storedCombinedCRC = 0;
GET_UCHAR(BZ_X_CCRC_1, uc);
s->storedCombinedCRC = (s->storedCombinedCRC << 8) | ((UInt32)uc);
GET_UCHAR(BZ_X_CCRC_2, uc);
s->storedCombinedCRC = (s->storedCombinedCRC << 8) | ((UInt32)uc);
GET_UCHAR(BZ_X_CCRC_3, uc);
s->storedCombinedCRC = (s->storedCombinedCRC << 8) | ((UInt32)uc);
GET_UCHAR(BZ_X_CCRC_4, uc);
s->storedCombinedCRC = (s->storedCombinedCRC << 8) | ((UInt32)uc);
s->state = BZ_X_IDLE;
RETURN(BZ_STREAM_END);
default: AssertH ( False, 4001 );
}
AssertH ( False, 4002 );
save_state_and_return:
s->save_i = i;
s->save_j = j;
s->save_t = t;
s->save_alphaSize = alphaSize;
s->save_nGroups = nGroups;
s->save_nSelectors = nSelectors;
s->save_EOB = EOB;
s->save_groupNo = groupNo;
s->save_groupPos = groupPos;
s->save_nextSym = nextSym;
s->save_nblockMAX = nblockMAX;
s->save_nblock = nblock;
s->save_es = es;
s->save_N = N;
s->save_curr = curr;
s->save_zt = zt;
s->save_zn = zn;
s->save_zvec = zvec;
s->save_zj = zj;
s->save_gSel = gSel;
s->save_gMinlen = gMinlen;
s->save_gLimit = gLimit;
s->save_gBase = gBase;
s->save_gPerm = gPerm;
return retVal;
}
/*-------------------------------------------------------------*/
/*--- end decompress.c ---*/
/*-------------------------------------------------------------*/

View File

@@ -1,205 +0,0 @@
/*-------------------------------------------------------------*/
/*--- Huffman coding low-level stuff ---*/
/*--- huffman.c ---*/
/*-------------------------------------------------------------*/
/* ------------------------------------------------------------------
This file is part of bzip2/libbzip2, a program and library for
lossless, block-sorting data compression.
bzip2/libbzip2 version 1.0.5 of 10 December 2007
Copyright (C) 1996-2007 Julian Seward <jseward@bzip.org>
Please read the WARNING, DISCLAIMER and PATENTS sections in the
README file.
This program is released under the terms of the license contained
in the file LICENSE.
------------------------------------------------------------------ */
#include "bzlib_private.h"
/*---------------------------------------------------*/
#define WEIGHTOF(zz0) ((zz0) & 0xffffff00)
#define DEPTHOF(zz1) ((zz1) & 0x000000ff)
#define MYMAX(zz2,zz3) ((zz2) > (zz3) ? (zz2) : (zz3))
#define ADDWEIGHTS(zw1,zw2) \
(WEIGHTOF(zw1)+WEIGHTOF(zw2)) | \
(1 + MYMAX(DEPTHOF(zw1),DEPTHOF(zw2)))
#define UPHEAP(z) \
{ \
Int32 zz, tmp; \
zz = z; tmp = heap[zz]; \
while (weight[tmp] < weight[heap[zz >> 1]]) { \
heap[zz] = heap[zz >> 1]; \
zz >>= 1; \
} \
heap[zz] = tmp; \
}
#define DOWNHEAP(z) \
{ \
Int32 zz, yy, tmp; \
zz = z; tmp = heap[zz]; \
while (True) { \
yy = zz << 1; \
if (yy > nHeap) break; \
if (yy < nHeap && \
weight[heap[yy+1]] < weight[heap[yy]]) \
yy++; \
if (weight[tmp] < weight[heap[yy]]) break; \
heap[zz] = heap[yy]; \
zz = yy; \
} \
heap[zz] = tmp; \
}
/*---------------------------------------------------*/
void BZ2_hbMakeCodeLengths ( UChar *len,
Int32 *freq,
Int32 alphaSize,
Int32 maxLen )
{
/*--
Nodes and heap entries run from 1. Entry 0
for both the heap and nodes is a sentinel.
--*/
Int32 nNodes, nHeap, n1, n2, i, j, k;
Bool tooLong;
Int32 heap [ BZ_MAX_ALPHA_SIZE + 2 ];
Int32 weight [ BZ_MAX_ALPHA_SIZE * 2 ];
Int32 parent [ BZ_MAX_ALPHA_SIZE * 2 ];
for (i = 0; i < alphaSize; i++)
weight[i+1] = (freq[i] == 0 ? 1 : freq[i]) << 8;
while (True) {
nNodes = alphaSize;
nHeap = 0;
heap[0] = 0;
weight[0] = 0;
parent[0] = -2;
for (i = 1; i <= alphaSize; i++) {
parent[i] = -1;
nHeap++;
heap[nHeap] = i;
UPHEAP(nHeap);
}
AssertH( nHeap < (BZ_MAX_ALPHA_SIZE+2), 2001 );
while (nHeap > 1) {
n1 = heap[1]; heap[1] = heap[nHeap]; nHeap--; DOWNHEAP(1);
n2 = heap[1]; heap[1] = heap[nHeap]; nHeap--; DOWNHEAP(1);
nNodes++;
parent[n1] = parent[n2] = nNodes;
weight[nNodes] = ADDWEIGHTS(weight[n1], weight[n2]);
parent[nNodes] = -1;
nHeap++;
heap[nHeap] = nNodes;
UPHEAP(nHeap);
}
AssertH( nNodes < (BZ_MAX_ALPHA_SIZE * 2), 2002 );
tooLong = False;
for (i = 1; i <= alphaSize; i++) {
j = 0;
k = i;
while (parent[k] >= 0) { k = parent[k]; j++; }
len[i-1] = j;
if (j > maxLen) tooLong = True;
}
if (! tooLong) break;
/* 17 Oct 04: keep-going condition for the following loop used
to be 'i < alphaSize', which missed the last element,
theoretically leading to the possibility of the compressor
looping. However, this count-scaling step is only needed if
one of the generated Huffman code words is longer than
maxLen, which up to and including version 1.0.2 was 20 bits,
which is extremely unlikely. In version 1.0.3 maxLen was
changed to 17 bits, which has minimal effect on compression
ratio, but does mean this scaling step is used from time to
time, enough to verify that it works.
This means that bzip2-1.0.3 and later will only produce
Huffman codes with a maximum length of 17 bits. However, in
order to preserve backwards compatibility with bitstreams
produced by versions pre-1.0.3, the decompressor must still
handle lengths of up to 20. */
for (i = 1; i <= alphaSize; i++) {
j = weight[i] >> 8;
j = 1 + (j / 2);
weight[i] = j << 8;
}
}
}
/*---------------------------------------------------*/
void BZ2_hbAssignCodes ( Int32 *code,
UChar *length,
Int32 minLen,
Int32 maxLen,
Int32 alphaSize )
{
Int32 n, vec, i;
vec = 0;
for (n = minLen; n <= maxLen; n++) {
for (i = 0; i < alphaSize; i++)
if (length[i] == n) { code[i] = vec; vec++; };
vec <<= 1;
}
}
/*---------------------------------------------------*/
void BZ2_hbCreateDecodeTables ( Int32 *limit,
Int32 *base,
Int32 *perm,
UChar *length,
Int32 minLen,
Int32 maxLen,
Int32 alphaSize )
{
Int32 pp, i, j, vec;
pp = 0;
for (i = minLen; i <= maxLen; i++)
for (j = 0; j < alphaSize; j++)
if (length[j] == i) { perm[pp] = j; pp++; };
for (i = 0; i < BZ_MAX_CODE_LEN; i++) base[i] = 0;
for (i = 0; i < alphaSize; i++) base[length[i]+1]++;
for (i = 1; i < BZ_MAX_CODE_LEN; i++) base[i] += base[i-1];
for (i = 0; i < BZ_MAX_CODE_LEN; i++) limit[i] = 0;
vec = 0;
for (i = minLen; i <= maxLen; i++) {
vec += (base[i+1] - base[i]);
limit[i] = vec-1;
vec <<= 1;
}
for (i = minLen + 1; i <= maxLen; i++)
base[i] = ((limit[i-1] + 1) << 1) - base[i];
}
/*-------------------------------------------------------------*/
/*--- end huffman.c ---*/
/*-------------------------------------------------------------*/

View File

@@ -1,84 +0,0 @@
/*-------------------------------------------------------------*/
/*--- Table for randomising repetitive blocks ---*/
/*--- randtable.c ---*/
/*-------------------------------------------------------------*/
/* ------------------------------------------------------------------
This file is part of bzip2/libbzip2, a program and library for
lossless, block-sorting data compression.
bzip2/libbzip2 version 1.0.5 of 10 December 2007
Copyright (C) 1996-2007 Julian Seward <jseward@bzip.org>
Please read the WARNING, DISCLAIMER and PATENTS sections in the
README file.
This program is released under the terms of the license contained
in the file LICENSE.
------------------------------------------------------------------ */
#include "bzlib_private.h"
/*---------------------------------------------*/
Int32 BZ2_rNums[512] = {
619, 720, 127, 481, 931, 816, 813, 233, 566, 247,
985, 724, 205, 454, 863, 491, 741, 242, 949, 214,
733, 859, 335, 708, 621, 574, 73, 654, 730, 472,
419, 436, 278, 496, 867, 210, 399, 680, 480, 51,
878, 465, 811, 169, 869, 675, 611, 697, 867, 561,
862, 687, 507, 283, 482, 129, 807, 591, 733, 623,
150, 238, 59, 379, 684, 877, 625, 169, 643, 105,
170, 607, 520, 932, 727, 476, 693, 425, 174, 647,
73, 122, 335, 530, 442, 853, 695, 249, 445, 515,
909, 545, 703, 919, 874, 474, 882, 500, 594, 612,
641, 801, 220, 162, 819, 984, 589, 513, 495, 799,
161, 604, 958, 533, 221, 400, 386, 867, 600, 782,
382, 596, 414, 171, 516, 375, 682, 485, 911, 276,
98, 553, 163, 354, 666, 933, 424, 341, 533, 870,
227, 730, 475, 186, 263, 647, 537, 686, 600, 224,
469, 68, 770, 919, 190, 373, 294, 822, 808, 206,
184, 943, 795, 384, 383, 461, 404, 758, 839, 887,
715, 67, 618, 276, 204, 918, 873, 777, 604, 560,
951, 160, 578, 722, 79, 804, 96, 409, 713, 940,
652, 934, 970, 447, 318, 353, 859, 672, 112, 785,
645, 863, 803, 350, 139, 93, 354, 99, 820, 908,
609, 772, 154, 274, 580, 184, 79, 626, 630, 742,
653, 282, 762, 623, 680, 81, 927, 626, 789, 125,
411, 521, 938, 300, 821, 78, 343, 175, 128, 250,
170, 774, 972, 275, 999, 639, 495, 78, 352, 126,
857, 956, 358, 619, 580, 124, 737, 594, 701, 612,
669, 112, 134, 694, 363, 992, 809, 743, 168, 974,
944, 375, 748, 52, 600, 747, 642, 182, 862, 81,
344, 805, 988, 739, 511, 655, 814, 334, 249, 515,
897, 955, 664, 981, 649, 113, 974, 459, 893, 228,
433, 837, 553, 268, 926, 240, 102, 654, 459, 51,
686, 754, 806, 760, 493, 403, 415, 394, 687, 700,
946, 670, 656, 610, 738, 392, 760, 799, 887, 653,
978, 321, 576, 617, 626, 502, 894, 679, 243, 440,
680, 879, 194, 572, 640, 724, 926, 56, 204, 700,
707, 151, 457, 449, 797, 195, 791, 558, 945, 679,
297, 59, 87, 824, 713, 663, 412, 693, 342, 606,
134, 108, 571, 364, 631, 212, 174, 643, 304, 329,
343, 97, 430, 751, 497, 314, 983, 374, 822, 928,
140, 206, 73, 263, 980, 736, 876, 478, 430, 305,
170, 514, 364, 692, 829, 82, 855, 953, 676, 246,
369, 970, 294, 750, 807, 827, 150, 790, 288, 923,
804, 378, 215, 828, 592, 281, 565, 555, 710, 82,
896, 831, 547, 261, 524, 462, 293, 465, 502, 56,
661, 821, 976, 991, 658, 869, 905, 758, 745, 193,
768, 550, 608, 933, 378, 286, 215, 979, 792, 961,
61, 688, 793, 644, 986, 403, 106, 366, 905, 644,
372, 567, 466, 434, 645, 210, 389, 550, 919, 135,
780, 773, 635, 389, 707, 100, 626, 958, 165, 504,
920, 176, 193, 713, 857, 265, 203, 50, 668, 108,
645, 990, 626, 197, 510, 357, 358, 850, 858, 364,
936, 638
};
/*-------------------------------------------------------------*/
/*--- end randtable.c ---*/
/*-------------------------------------------------------------*/

File diff suppressed because it is too large Load Diff

View File

@@ -1,87 +0,0 @@
/**
@file AreaMemoryManager.cpp
@maintainer Morgan McGuire, http://graphics.cs.williams.edu
@created 2009-01-20
@edited 2009-01-20
Copyright 2000-2009, Morgan McGuire.
All rights reserved.
*/
#include "G3D/AreaMemoryManager.h"
#include "G3D/System.h"
namespace G3D {
AreaMemoryManager::Buffer::Buffer(size_t size) : m_size(size), m_used(0) {
// Allocate space for a lot of buffers.
m_first = (uint8*)::malloc(m_size);
}
AreaMemoryManager::Buffer::~Buffer() {
::free(m_first);
}
void* AreaMemoryManager::Buffer::alloc(size_t s) {
if (s + m_used > m_size) {
return NULL;
} else {
void* old = m_first + m_used;
m_used += s;
return old;
}
}
bool AreaMemoryManager::isThreadsafe() const {
return false;
}
AreaMemoryManager::Ref AreaMemoryManager::create(size_t sizeHint) {
return new AreaMemoryManager(sizeHint);
}
AreaMemoryManager::AreaMemoryManager(size_t sizeHint) : m_sizeHint(sizeHint) {
debugAssert(sizeHint > 0);
}
AreaMemoryManager::~AreaMemoryManager() {
deallocateAll();
}
size_t AreaMemoryManager::bytesAllocated() const {
return m_sizeHint * m_bufferArray.size();
}
void* AreaMemoryManager::alloc(size_t s) {
void* n = (m_bufferArray.size() > 0) ? m_bufferArray.last()->alloc(s) : NULL;
if (n == NULL) {
// This buffer is full
m_bufferArray.append(new Buffer(max(s, m_sizeHint)));
return m_bufferArray.last()->alloc(s);
} else {
return n;
}
}
void AreaMemoryManager::free(void* x) {
// Intentionally empty; we block deallocate
}
void AreaMemoryManager::deallocateAll() {
m_bufferArray.deleteAll();
m_bufferArray.clear();
}
}

View File

@@ -1,113 +0,0 @@
/**
@file Box.cpp
Box class
@maintainer Morgan McGuire, http://graphics.cs.williams.edu
@created 2001-06-02
@edited 2008-12-27
*/
#include "G3D/Box2D.h"
#include "G3D/CoordinateFrame.h"
#include "G3D/Rect2D.h"
namespace G3D {
bool Box2D::overlaps1Way(const Box2D& other) const {
for (int a = 0; a < 2; ++a) {
float t = other.m_corner[0].dot(m_axisin[a]);
// Find the extent of box 2 on m_axisin a
float tMin = t;
float tMax = t;
for (int c = 1; c < 4; ++c) {
t = other.m_corner[c].dot(m_axisin[a]);
if (t < tMin) {
tMin = t;
} else if (t > tMax) {
tMax = t;
}
}
// We have to subtract off the origin
// See if [tMin, tMax] intersects [0, 1]
if ((tMin > 1 + origin[a]) || (tMax < origin[a])) {
// There was no intersection along this dimension;
// the boxes cannot possibly overlap.
return false;
}
}
// There was no dimension along which there is no intersection.
// Therefore the boxes overlap.
return true;
}
void Box2D::computeAxes() {
m_axis[0] = m_corner[1] - m_corner[0];
m_axis[1] = m_corner[3] - m_corner[0];
// Make the length of each m_axisin = 1/edge length so we know any
// dot product must be less than 1 to fall within the edge.
float len[2];
for (int a = 0; a < 2; ++a) {
float lenSq = m_axis[a].squaredLength();
m_axisin[a] = m_axis[a] / lenSq;
origin[a] = m_corner[0].dot(m_axisin[a]);
len[a] = sqrt(lenSq);
m_axis[a] /= len[a];
}
// w * h
m_area = len[0] * len[1];
m_center = (m_corner[0] + m_corner[2]) * 0.5f;
}
Box2D::Box2D(const Vector2& center, float w, float h, float angle) {
Vector2 X( cos(angle), sin(angle));
Vector2 Y(-sin(angle), cos(angle));
X *= w / 2;
Y *= h / 2;
m_corner[0] = center - X - Y;
m_corner[1] = center + X - Y;
m_corner[2] = center + X + Y;
m_corner[3] = center - X + Y;
computeAxes();
}
Box2D::Box2D(const AABox2D& b) {
for (int i = 0; i < 4; ++i) {
m_corner[i] = b.corner(i);
}
computeAxes();
}
Box2D::Box2D(const Vector2& min, const Vector2& max) {
*this = Box2D(Rect2D::xyxy(min, max));
}
Box2D::Box2D(const CFrame& frame, Box2D& b) {
for (int i = 0; i < 4; ++i) {
m_corner[i] = frame.pointToWorldSpace(Vector3(b.corner(i), 0)).xy();
}
computeAxes();
}
} // G3D

View File

@@ -1,43 +0,0 @@
/**
\file BumpMapPreprocess.cpp
\maintainer Morgan McGuire, http://graphics.cs.williams.edu
\created 2010-01-28
\edited 2010-01-28
Copyright 2000-2010, Morgan McGuire.
All rights reserved.
*/
#include "G3D/BumpMapPreprocess.h"
#include "G3D/Any.h"
#include "G3D/stringutils.h"
namespace G3D {
BumpMapPreprocess::BumpMapPreprocess(const Any& any) {
*this = BumpMapPreprocess();
for (Any::AnyTable::Iterator it = any.table().begin(); it.hasMore(); ++it) {
const std::string& key = toLower(it->key);
if (key == "lowpassfilter") {
lowPassFilter = it->value;
} else if (key == "zextentpixels") {
zExtentPixels = it->value;
} else if (key == "scalezbynz") {
scaleZByNz = it->value;
} else {
any.verify(false, "Illegal key: " + it->key);
}
}
}
BumpMapPreprocess::operator Any() const {
Any any(Any::TABLE, "BumpMapPreprocess");
any["lowPassFilter"] = lowPassFilter;
any["zExtentPixels"] = zExtentPixels;
any["scaleZByNz"] = scaleZByNz;
return any;
}
}

View File

@@ -1,53 +0,0 @@
########### next target ###############
SET(g3dlite_STAT_SRCS
AABox.cpp
Box.cpp
Crypto.cpp
format.cpp
Matrix3.cpp
Plane.cpp
System.cpp
Triangle.cpp
Vector3.cpp
Vector4.cpp
debugAssert.cpp
fileutils.cpp
g3dmath.cpp
g3dfnmatch.cpp
prompt.cpp
stringutils.cpp
Any.cpp
BinaryFormat.cpp
BinaryInput.cpp
BinaryOutput.cpp
Capsule.cpp
CollisionDetection.cpp
CoordinateFrame.cpp
Cylinder.cpp
Line.cpp
LineSegment.cpp
Log.cpp
Matrix4.cpp
MemoryManager.cpp
Quat.cpp
Random.cpp
Ray.cpp
ReferenceCount.cpp
Sphere.cpp
TextInput.cpp
TextOutput.cpp
UprightFrame.cpp
Vector2.cpp
)
include_directories(
${CMAKE_SOURCE_DIR}/dep/include
${CMAKE_SOURCE_DIR}/dep/include/g3dlite
)
add_library(g3dlite STATIC ${g3dlite_STAT_SRCS})
########### install files ###############

View File

@@ -1,58 +0,0 @@
/**
@file Color1.cpp
Color class.
@author Morgan McGuire, http://graphics.cs.williams.edu
@created 2007-01-30
@edited 2009-03-27
*/
#include "G3D/platform.h"
#include "G3D/Color1.h"
#include "G3D/Color1uint8.h"
#include "G3D/BinaryInput.h"
#include "G3D/BinaryOutput.h"
#include "G3D/Color3.h"
namespace G3D {
const Color1& Color1::one() {
static const Color1 x(1.0f);
return x;
}
const Color1& Color1::zero() {
const static Color1 x(0.0f);
return x;
}
Color1::Color1(BinaryInput& bi) {
deserialize(bi);
}
Color3 Color1::rgb() const {
return Color3(value, value, value);
}
void Color1::deserialize(BinaryInput& bi) {
value = bi.readFloat32();
}
void Color1::serialize(BinaryOutput& bo) const {
bo.writeFloat32(value);
}
Color1::Color1(const class Color1uint8& other) {
value = other.value / 255.0f;
}
} // namespace G3D

View File

@@ -1,38 +0,0 @@
/**
@file Color1uint8.cpp
@author Morgan McGuire, http://graphics.cs.williams.edu
@created 2007-01-30
@edited 2007-01-30
*/
#include "G3D/platform.h"
#include "G3D/g3dmath.h"
#include "G3D/Color1uint8.h"
#include "G3D/Color1.h"
#include "G3D/BinaryInput.h"
#include "G3D/BinaryOutput.h"
namespace G3D {
Color1uint8::Color1uint8(const class Color1& c) : value(iClamp(iFloor(c.value * 256), 0, 255)) {
}
Color1uint8::Color1uint8(class BinaryInput& bi) {
deserialize(bi);
}
void Color1uint8::serialize(class BinaryOutput& bo) const {
bo.writeUInt8(value);
}
void Color1uint8::deserialize(class BinaryInput& bi) {
value = bi.readUInt8();
}
}

View File

@@ -1,384 +0,0 @@
/**
@file Color3.cpp
Color class.
@author Morgan McGuire, http://graphics.cs.williams.edu
@created 2001-06-02
@edited 2010-01-28
*/
#include "G3D/platform.h"
#include <stdlib.h>
#include "G3D/Color3.h"
#include "G3D/Vector3.h"
#include "G3D/format.h"
#include "G3D/BinaryInput.h"
#include "G3D/BinaryOutput.h"
#include "G3D/Color3uint8.h"
#include "G3D/Any.h"
#include "G3D/stringutils.h"
namespace G3D {
Color3::Color3(const Any& any) {
*this = Color3::zero();
any.verifyName("Color3");
std::string name = toLower(any.name());
switch (any.type()) {
case Any::TABLE:
for (Any::AnyTable::Iterator it = any.table().begin(); it.hasMore(); ++it) {
const std::string& key = toLower(it->key);
if (key == "r") {
r = it->value;
} else if (key == "g") {
g = it->value;
} else if (key == "b") {
b = it->value;
} else {
any.verify(false, "Illegal key: " + it->key);
}
}
break;
case Any::ARRAY:
if (name == "color3") {
any.verifySize(3);
r = any[0];
g = any[1];
b = any[2];
} else if (name == "color3::one") {
any.verifySize(0);
*this = one();
} else if (name == "color3::zero") {
any.verifySize(0);
*this = zero();
} else if (name == "color3::fromargb") {
*this = Color3::fromARGB((int)any[0].number());
} else {
any.verify(false, "Expected Color3 constructor");
}
break;
default:
any.verify(false, "Bad Color3 constructor");
}
}
Color3::operator Any() const {
Any a(Any::ARRAY, "Color3");
a.append(r, g, b);
return a;
}
Color3 Color3::ansiMap(uint32 i) {
static const Color3 map[] =
{Color3::black(), Color3::red() * 0.75f, Color3::green() * 0.75f, Color3::yellow() * 0.75f,
Color3::blue() * 0.75f, Color3::purple() * 0.75f, Color3::cyan() * 0.75f, Color3::white() * 0.75f,
Color3::white() * 0.90f, Color3::red(), Color3::green(), Color3::yellow(), Color3::blue(),
Color3::purple(), Color3::cyan(), Color3::white()};
return map[i & 15];
}
Color3 Color3::pastelMap(uint32 i) {
uint32 x = Crypto::crc32(&i, sizeof(uint32));
// Create fairly bright, saturated colors
Vector3 v(((x >> 22) & 1023) / 1023.0f,
(((x >> 11) & 2047) / 2047.0f) * 0.5f + 0.25f,
((x & 2047) / 2047.0f) * 0.75f + 0.25f);
return Color3::fromHSV(v);
}
const Color3& Color3::red() {
static Color3 c(1.0f, 0.0f, 0.0f);
return c;
}
const Color3& Color3::green() {
static Color3 c(0.0f, 1.0f, 0.0f);
return c;
}
const Color3& Color3::blue() {
static Color3 c(0.0f, 0.0f, 1.0f);
return c;
}
const Color3& Color3::purple() {
static Color3 c(0.7f, 0.0f, 1.0f);
return c;
}
const Color3& Color3::cyan() {
static Color3 c(0.0f, 0.7f, 1.0f);
return c;
}
const Color3& Color3::yellow() {
static Color3 c(1.0f, 1.0f, 0.0f);
return c;
}
const Color3& Color3::brown() {
static Color3 c(0.5f, 0.5f, 0.0f);
return c;
}
const Color3& Color3::orange() {
static Color3 c(1.0f, 0.5f, 0.0f);
return c;
}
const Color3& Color3::black() {
static Color3 c(0.0f, 0.0f, 0.0f);
return c;
}
const Color3& Color3::zero() {
static Color3 c(0.0f, 0.0f, 0.0f);
return c;
}
const Color3& Color3::one() {
static Color3 c(1.0f, 1.0f, 1.0f);
return c;
}
const Color3& Color3::gray() {
static Color3 c(0.7f, 0.7f, 0.7f);
return c;
}
const Color3& Color3::white() {
static Color3 c(1, 1, 1);
return c;
}
bool Color3::isFinite() const {
return G3D::isFinite(r) && G3D::isFinite(g) && G3D::isFinite(b);
}
Color3::Color3(BinaryInput& bi) {
deserialize(bi);
}
void Color3::deserialize(BinaryInput& bi) {
r = bi.readFloat32();
g = bi.readFloat32();
b = bi.readFloat32();
}
void Color3::serialize(BinaryOutput& bo) const {
bo.writeFloat32(r);
bo.writeFloat32(g);
bo.writeFloat32(b);
}
const Color3& Color3::wheelRandom() {
static const Color3 colorArray[8] =
{Color3::blue(), Color3::red(), Color3::green(),
Color3::orange(), Color3::yellow(),
Color3::cyan(), Color3::purple(), Color3::brown()};
return colorArray[iRandom(0, 7)];
}
size_t Color3::hashCode() const {
unsigned int rhash = (*(int*)(void*)(&r));
unsigned int ghash = (*(int*)(void*)(&g));
unsigned int bhash = (*(int*)(void*)(&b));
return rhash + (ghash * 37) + (bhash * 101);
}
Color3::Color3(const Vector3& v) {
r = v.x;
g = v.y;
b = v.z;
}
Color3::Color3(const class Color3uint8& other) {
r = other.r / 255.0f;
g = other.g / 255.0f;
b = other.b / 255.0f;
}
Color3 Color3::fromARGB(uint32 x) {
return Color3((float)((x >> 16) & 0xFF), (float)((x >> 8) & 0xFF), (float)(x & 0xFF)) / 255.0f;
}
//----------------------------------------------------------------------------
Color3 Color3::random() {
return Color3(uniformRandom(),
uniformRandom(),
uniformRandom()).direction();
}
//----------------------------------------------------------------------------
Color3& Color3::operator/= (float fScalar) {
if (fScalar != 0.0f) {
float fInvScalar = 1.0f / fScalar;
r *= fInvScalar;
g *= fInvScalar;
b *= fInvScalar;
} else {
r = (float)G3D::finf();
g = (float)G3D::finf();
b = (float)G3D::finf();
}
return *this;
}
//----------------------------------------------------------------------------
float Color3::unitize (float fTolerance) {
float fLength = length();
if ( fLength > fTolerance ) {
float fInvLength = 1.0f / fLength;
r *= fInvLength;
g *= fInvLength;
b *= fInvLength;
} else {
fLength = 0.0f;
}
return fLength;
}
//----------------------------------------------------------------------------
Color3 Color3::fromHSV(const Vector3& _hsv) {
debugAssertM((_hsv.x <= 1.0f && _hsv.x >= 0.0f)
&& (_hsv.y <= 1.0f && _hsv.y >= 0.0f)
&& ( _hsv.z <= 1.0f && _hsv.z >= 0.0f), "H,S,V must be between [0,1]");
const int i = iMin(5, G3D::iFloor(6.0 * _hsv.x));
const float f = 6.0f * _hsv.x - i;
const float m = _hsv.z * (1.0f - (_hsv.y));
const float n = _hsv.z * (1.0f - (_hsv.y * f));
const float k = _hsv.z * (1.0f - (_hsv.y * (1 - f)));
switch(i) {
case 0:
return Color3(_hsv.z, k, m);
case 1:
return Color3(n, _hsv.z, m);
case 2:
return Color3(m, _hsv.z, k);
case 3:
return Color3(m, n, _hsv.z);
case 4:
return Color3(k, m, _hsv.z);
case 5:
return Color3(_hsv.z, m, n);
default:
debugAssertM(false, "fell through switch..");
}
return Color3::black();
}
Vector3 Color3::toHSV(const Color3& _rgb) {
debugAssertM((_rgb.r <= 1.0f && _rgb.r >= 0.0f)
&& (_rgb.g <= 1.0f && _rgb.g >= 0.0f)
&& (_rgb.b <= 1.0f && _rgb.b >= 0.0f), "R,G,B must be between [0,1]");
Vector3 hsv = Vector3::zero();
hsv.z = G3D::max(G3D::max(_rgb.r, _rgb.g), _rgb.b);
if (G3D::fuzzyEq(hsv.z, 0.0f)) {
return hsv;
}
const float x = G3D::min(G3D::min(_rgb.r, _rgb.g), _rgb.b);
hsv.y = (hsv.z - x) / hsv.z;
if (G3D::fuzzyEq(hsv.y, 0.0f)) {
return hsv;
}
Vector3 rgbN;
rgbN.x = (hsv.z - _rgb.r) / (hsv.z - x);
rgbN.y = (hsv.z - _rgb.g) / (hsv.z - x);
rgbN.z = (hsv.z - _rgb.b) / (hsv.z - x);
if (_rgb.r == hsv.z) { // note from the max we know that it exactly equals one of the three.
hsv.x = (_rgb.g == x)? 5.0f + rgbN.z : 1.0f - rgbN.y;
} else if (_rgb.g == hsv.z) {
hsv.x = (_rgb.b == x)? 1.0f + rgbN.x : 3.0f - rgbN.z;
} else {
hsv.x = (_rgb.r == x)? 3.0f + rgbN.y : 5.0f - rgbN.x;
}
hsv.x /= 6.0f;
return hsv;
}
Color3 Color3::jetColorMap(const float& val) {
debugAssertM(val <= 1.0f && val >= 0.0f , "value should be in [0,1]");
//truncated triangles where sides have slope 4
Color3 jet;
jet.r = G3D::min(4.0f * val - 1.5f,-4.0f * val + 4.5f) ;
jet.g = G3D::min(4.0f * val - 0.5f,-4.0f * val + 3.5f) ;
jet.b = G3D::min(4.0f * val + 0.5f,-4.0f * val + 2.5f) ;
jet.r = G3D::clamp(jet.r, 0.0f, 1.0f);
jet.g = G3D::clamp(jet.g, 0.0f, 1.0f);
jet.b = G3D::clamp(jet.b, 0.0f, 1.0f);
return jet;
}
std::string Color3::toString() const {
return G3D::format("(%g, %g, %g)", r, g, b);
}
//----------------------------------------------------------------------------
Color3 Color3::rainbowColorMap(float hue) {
return fromHSV(Vector3(hue, 1.0f, 1.0f));
}
}; // namespace

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