diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..26245e9
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,30 @@
+# use glob syntax.
+syntax: glob
+
+CMakeFiles/
+build/
+src/server/shared/revision.h
+build/
+bin/
+.directory
+*.orig
+*.rej
+*~
+.git/
+.hg/
+win/VC90/*/
+*.ncb
+*.suo
+src/tools/map_extractor/VC90/*/
+src/tools/vmap3_assembler/VC90/*/
+src/tools/vmap3_extractor/VC90/*/
+#externals/lib/*/
+*.*-*
+*.patch
+.hgignore
+.hgtags
+
+# use regexp syntax.
+syntax: regexp
+
+^src/shared/server/shared/revision\.h
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..91a8e3d
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,271 @@
+# Copyright (C) 2005-2010 Trinity
+#
+# 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)
+
+#
+# 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, 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()
+
+if( UNIX )
+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"
+)
+endif()
+
+option(DO_AUTHSERVER "Build authserver" 1)
+option(DO_WORLDSERVER "Build worldserver" 1)
+option(DO_CLI "With CLI" 1)
+option(DO_DEBUG "Debug mode" 0)
+option(DO_PCH "Use precompiled headers" 1)
+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
+)
+
+# 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
+)
+
+message("")
+message("* TrinityCore revision : ${HG_REVISION}")
+message("* Build binaries in : ${CMAKE_BUILD_TYPE} mode")
+message("")
+
+if( NOT CONF_DIR )
+ set(CONF_DIR ${CMAKE_INSTALL_PREFIX}/etc)
+endif()
+
+set(LIBSDIR ${CMAKE_INSTALL_PREFIX}/lib)
+
+message("* Install core to : ${CMAKE_INSTALL_PREFIX}")
+message("* Install libraries to : ${LIBSDIR}")
+message("* Install configs to : ${CONF_DIR}")
+message("")
+
+if( DO_AUTHSERVER )
+ message("* Build authserver : Yes (default)")
+else()
+ message("* Build authserver : No")
+endif()
+
+if( DO_WORLDSERVER )
+ message("* Build worldserver : Yes (default)")
+else()
+ message("* Build worldserver : No")
+endif()
+
+if( DO_SCRIPTS )
+ message("* Build Trinityscripts : Yes (default)")
+ add_definitions(-DDO_SCRIPTS)
+else()
+ message("* Build Trinityscripts : No")
+endif()
+
+if( DO_TOOLS )
+ message("* Build map/vmap tools : Yes")
+else()
+ message("* Build map/vmap tools : No (default)")
+endif()
+
+if( DO_CLI )
+ message("* Build with CLI : Yes (default)")
+ add_definitions(-DENABLE_CLI)
+else()
+ message("* Build with CLI : No")
+endif()
+
+if( DO_RA )
+ message("* Build with RA : Yes")
+ add_definitions(-DENABLE_RA)
+else()
+ message("* Build with RA : No (default)")
+endif()
+
+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_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()
+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( DO_SQL )
+ message("* Install SQL-files : Yes")
+else()
+ message("* Install SQL-files : No (default)")
+endif()
+
+message("")
+
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
+
+# 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()
+
+# 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()
+
+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 1)
+
+add_subdirectory(externals)
+add_subdirectory(src)
+if( DO_SQL )
+ add_subdirectory(sql)
+endif()
+
diff --git a/COPYING b/COPYING
new file mode 100644
index 0000000..cdfdede
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,339 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+
+ Copyright (C)
+
+ 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
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) year name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ , 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Library General
+Public License instead of this License.
diff --git a/README b/README
new file mode 100644
index 0000000..e69de29
diff --git a/THANKS b/THANKS
new file mode 100644
index 0000000..8fc3994
--- /dev/null
+++ b/THANKS
@@ -0,0 +1,67 @@
+= TrinityCore -- Thanks/credits file =
+
+TrinityCore is a derivation/rewrite of MaNGOS, which was originally written
+by Team Python and the WoW Daemon Team. Many people further helped Trinity Core
+by submitting bug reports, code patches, and suggestions. Thanks to the
+community!
+
+Special thanks should go out to the WowwoW team. We have gained help from
+them many times in the creation of this project. Keep up the good work guys.
+
+Thanks to the ScriptDev2 team (http://www.scriptdev2.com) for scripts.
+
+Thanks to the WCell team (especially Ralek) for research on realm reconnect
+sequence, item scaling stats algorithm, gameobject rotation issues.
+
+Thanks go out to the following people for various patches/code (listed in the
+order they were added): w12x, dythzer, XEQT, death420, balrok, TOM_RUS,
+runningnak3d, Seline, KingPin, raczman, bogie, Neo2003, NoFantasy, Derex,
+freghar, toilet1, megamage, MadJack, WarHead, gvcoman, Ntsc, arrai, jrkpote,
+Seraphim, vagoth, KerchumA222, Rognar, Blaymoira, DragonHunter, Molius, ApoC,
+SeT, hunuza, Wyk3d, VladimirMangos, rj686, Arthorius, QAston, Muhaha, dereka,
+Kaldorei, NuRRi, Biglad, Machiavelli, Nivelo, Paradox, Aokromes, EleGoS,
+Visagalis, reno, Cybrax, GriffonHeart, fgenesis, rilex, XTElite1, Anubisss, eL,
+Iskander, arclite, Bladex, EIFEL, Klaimmore, XTZGZoReX, panaut0lordv, DearScorpion,
+BlueSteel, AlexDereka, Drahy, krz, Xeptor, Sethoso, Sarjuuk, pasdVn, nissen,
+Triply, `win, Fog, emsy, McBitter, Lukaasm, maikash, Wormheart, DonTomika,
+DiSlord, Tiretunderl, Ramses_II, cccyril, Cha0S2, miebaik, Trazom, KiriX,
+darkEvil, Sorken, Kudlaty, Charlie2025, Medwise, Rat, Lutik, domingo,
+TrullyONE, rastikzzz, Tassader, Lightguard, KAPATEJIb, Tux`Volant, zhanhang03,
+Asael, Elron, False, nos4r2zod, Disassembler, thumsoul, rvnth, throneinc,
+MrTux, Luniz2k1, Dani, BroodWyrm, raven_coda, Bagsac, Thraxx, Trogvar,
+teacher4, zhenya, Albrecht de Endrau, Phacops, Naicisum, thenecromancer, shax,
+cryingcloud, freeganja, Foks, daveh, Az@zel, evilstar, Corfen, Astellar, Maxxie,
+DEN_North, StarJoker, Nezemnoy, X-Savior, subhuman_bob, Ambal, Brueggus, sparc,
+jojo, Trojan, tvaroh, Genars, BombermaG, Bulkin, nesocip, xILOSWag, SilverIce,
+Uruviel, timmit, SeT, Seizerkiller, Stokrotka, JoN0, Tanatos, Hunteee, Alyen,
+Farah, Them, DaGNU, arthurcik, BudIcePenguin, Amok, Amit86, onkelz28, Azrael,
+Larva, Roland, DerDyddye, Vicos, PSZ, CRAZyBUg, irish, Sephiroth1984, hunuza,
+mike753, Xlybriem, Paytheo, ArticDevil, FearX, Beaste, bufferoverflow, Jeniczek,
+Den, bobaz, crackm, seirge, D_Skywalk, mknjc, Christyan, Saeba, Nevan, tlexii,
+liszt, duckman, Joro, Charlie, smellbee, bigjohnson4, maxdestroyer, Destalker,
+ckegg, Drethek, yad02, Win32, NetSky, Zcuron, Necroo, ogeraisi, Coldblooded,
+Edder, riddick, Craker, NeoLithicX, srounet, SLG, Tidus, neo0608, SyRiOCoP,
+F636y623, Patro, mobel, simak, hectolight, Riccardo, GodsdoG, Gomez, kamir86, fredi,
+qubix, Deafboy, Authorius, DarkRabbit, mrbungle, netoya, peldor, eumario, Alex,
+Moandor, ebx, DasBlub, guenex, Brats, Lucy, arcx, Enril, oiler2112,
+Wizz, Elminster, 123qwe, NeatElves, Turk3y, deicide, vladonix, nugu100,
+Skystar, Reve, jorooo, FrozenDB, miranda.conrado, Tequila, Gommes, Zerg2000,
+aerione_alt, Rastik, FrenchW, wilibald09, Velorien, kancaras, fisherman,
+Aviram, Mufik, loop69, multiplexer, Koani, rechapa79, kozelo, MeanMachine,
+fregh, adrycasillo, IncoGnito, Alez, Itch, Kuteur, MaS0n, peaceman, manuel,
+Gendalph, Lynx3d, raftom, Infinity, Ebrithil, Sorya, HP1, Prince, redcore,
+Boogie, Necro, Thyros, simon, MrSmite, horogandris, Stryker, MaXiMiUS, kaell,
+totoro, Forgiven, Big, Oculus, Lorac, Nemesis, Epsik, iadus3, durotar, hoshie,
+fukifat, imbecile, Nafsih, Meldanor, Turok, Naturamen, Themris, Sundark,
+Azuritus, jotapdiez, EnderGT, Curuad, oc_redfox, rockzOr, Darkshines,
+BlackYoghurt, McLovin, Gyullo, kaxap, Hawthorne, nanouniko, new001, Opterman,
+Typhoon, Cleave, HiZed, The_Game_Master, Athor, Veras, Menia, Jolan, BlackOne,
+johnholiver, Spp, Drevi, kb_z, Tartalo, Shendor, Demonx, Taliesin, defacer,
+SoulForge, Jackpoz, Cass, QuaLiT1, exul182, sunwell, AniRB, clotza, Tommassino,
+dracula70, alexsot, RedSonja, Cnillidan, Proofzor, aqs999, Sony, amsjunior123,
+Sisif, Joshh, alex_1983, arez, RammboNr5, Insider, bodompelle, lobuz, Azazel,
+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, click, silverice, SupaBad, Xanadu
diff --git a/cmake/FindACE.cmake b/cmake/FindACE.cmake
new file mode 100644
index 0000000..4ade5f6
--- /dev/null
+++ b/cmake/FindACE.cmake
@@ -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)
diff --git a/cmake/FindMySQL.cmake b/cmake/FindMySQL.cmake
new file mode 100644
index 0000000..aa62d89
--- /dev/null
+++ b/cmake/FindMySQL.cmake
@@ -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 )
diff --git a/cmake/FindOpenSSL.cmake b/cmake/FindOpenSSL.cmake
new file mode 100644
index 0000000..d045b53
--- /dev/null
+++ b/cmake/FindOpenSSL.cmake
@@ -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 )
diff --git a/cmake/FindPCHSupport.cmake b/cmake/FindPCHSupport.cmake
new file mode 100644
index 0000000..d96a287
--- /dev/null
+++ b/cmake/FindPCHSupport.cmake
@@ -0,0 +1,315 @@
+# - Try to find precompiled headers support for GCC 3.4 and 4.x (and MSVC)
+# Once done this will define:
+#
+# Variable:
+# PCHSupport_FOUND
+#
+# Macro:
+# ADD_PRECOMPILED_HEADER _targetName _input _dowarn
+# ADD_PRECOMPILED_HEADER_TO_TARGET _targetName _input _pch_output_to_use _dowarn
+# ADD_NATIVE_PRECOMPILED_HEADER _targetName _input _dowarn
+# GET_NATIVE_PRECOMPILED_HEADER _targetName _input
+
+IF(CMAKE_COMPILER_IS_GNUCXX)
+
+ EXEC_PROGRAM(
+ ${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(${_out_compile_flags} ${${_flags_var_name}} )
+
+ IF(CMAKE_COMPILER_IS_GNUCXX)
+ GET_TARGET_PROPERTY(_targetType ${_PCH_current_target} TYPE)
+ 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 ${_out_compile_flags} "${_PCH_include_prefix}${item}")
+ ENDFOREACH(item)
+
+ 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)
+
+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}\"
+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)
+
+
+ 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)
+
+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
+ # PCH_ADDITIONAL_COMPILER_FLAGS to -fpch-preprocess
+ # if you want warnings for invalid header files (which is very inconvenient
+ # if you have different versions of the headers for different build types
+ # you may set _pch_dowarn
+ IF (_dowarn)
+ SET(${_cflags} "${PCH_ADDITIONAL_COMPILER_FLAGS} -include ${CMAKE_CURRENT_BINARY_DIR}/${_header_name} -Winvalid-pch " )
+ ELSE (_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)
+
+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}.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)
+
+ IF( "${ARGN}" STREQUAL "0")
+ SET(_dowarn 0)
+ ELSE( "${ARGN}" STREQUAL "0")
+ SET(_dowarn 1)
+ ENDIF("${ARGN}" STREQUAL "0")
+
+
+ _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}
+ )
+
+ ADD_CUSTOM_TARGET(pch_Generate_${_targetName}
+ 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. "
+ "You must set CMAKE_BUILD_TYPE!"
+ )
+ ENDIF(NOT CMAKE_BUILD_TYPE)
+
+ IF( "${ARGN}" STREQUAL "0")
+ SET(_dowarn 0)
+ ELSE( "${ARGN}" STREQUAL "0")
+ 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)
+
+ GET_FILENAME_COMPONENT(_outdir ${_output} PATH )
+
+ GET_TARGET_PROPERTY(_targetType ${_PCH_current_target} TYPE)
+ _PCH_WRITE_PCHDEP_CXX(${_targetName} ${_input} _pch_dephelp_cxx)
+
+ IF(${_targetType} STREQUAL SHARED_LIBRARY)
+ 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}")
+ SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_BINARY_DIR}/${_name} PROPERTIES GENERATED 1)
+ ADD_CUSTOM_COMMAND(
+ 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(${_input} )
+ #message("_output ${_output}")
+
+ ADD_CUSTOM_COMMAND(
+ 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
+# Not needed by Xcode
+
+MACRO(GET_NATIVE_PRECOMPILED_HEADER _targetName _input)
+
+ 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")
+
+ # 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)
+
+ GET_TARGET_PROPERTY(oldProps ${_targetName} COMPILE_FLAGS)
+ if (${oldProps} MATCHES NOTFOUND)
+ SET(oldProps "")
+ endif(${oldProps} MATCHES NOTFOUND)
+
+ SET(newProperties "${oldProps} /Yu\"${_input}.h\" /FI\"${_input}.h\"")
+ SET_TARGET_PROPERTIES(${_targetName} PROPERTIES COMPILE_FLAGS "${newProperties}")
+
+ #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 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)
+
+ # 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)
\ No newline at end of file
diff --git a/cmake/FindPlatform.cmake b/cmake/FindPlatform.cmake
new file mode 100644
index 0000000..60ce001
--- /dev/null
+++ b/cmake/FindPlatform.cmake
@@ -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()
diff --git a/cmake/FindReadline.cmake b/cmake/FindReadline.cmake
new file mode 100644
index 0000000..993ac51
--- /dev/null
+++ b/cmake/FindReadline.cmake
@@ -0,0 +1,22 @@
+# find Readline (terminal input library) includes and library
+#
+# READLINE_INCLUDE_DIR - where the directory containing the READLINE headers can be found
+# READLINE_LIBRARY - full path to the READLINE library
+# READLINE_FOUND - TRUE if READLINE was found
+
+MACRO(FIND_READLINE)
+
+FIND_PATH(READLINE_INCLUDE_DIR readline/readline.h)
+FIND_LIBRARY(READLINE_LIBRARY NAMES readline)
+
+IF (READLINE_INCLUDE_DIR AND READLINE_LIBRARY)
+ SET(READLINE_FOUND TRUE)
+ MESSAGE(STATUS "Found Readline library: ${READLINE_LIBRARY}")
+ MESSAGE(STATUS "Include dir is: ${READLINE_INCLUDE_DIR}")
+ INCLUDE_DIRECTORIES(${READLINE_INCLUDE_DIR})
+ELSE (READLINE_INCLUDE_DIR AND READLINE_LIBRARY)
+ SET(READLINE_FOUND FALSE)
+ MESSAGE(FATAL_ERROR "** Readline library not found!\n** Your distro may provide a binary for Readline e.g. for ubuntu try apt-get install libreadline5-dev")
+ENDIF (READLINE_INCLUDE_DIR AND READLINE_LIBRARY)
+
+ENDMACRO(FIND_READLINE)
diff --git a/cmake/FindTermcap.cmake b/cmake/FindTermcap.cmake
new file mode 100644
index 0000000..b3780d3
--- /dev/null
+++ b/cmake/FindTermcap.cmake
@@ -0,0 +1,33 @@
+# find Terrmcap (terminal input library) includes and library
+#
+# TERMCAP_INCLUDE_DIR - where the directory containing the TERMCAP headers can be found
+# TERMCAP_LIBRARY - full path to the TERMCAP library
+# TERMCAP_FOUND - TRUE if TERMCAP was found
+
+MACRO(FIND_TERMCAP)
+
+FIND_PATH(TERMCAP_INCLUDE_DIR termcap.h
+ /usr/include
+ /usr/local/include
+
+ /opt/local/include
+)
+
+FIND_LIBRARY(TERMCAP_LIBRARY NAMES termcap PATH
+ /usr/lib
+ /usr/local/lib
+ /opt/local/lib
+ /usr/lib64
+)
+
+IF (TERMCAP_INCLUDE_DIR AND TERMCAP_LIBRARY)
+ SET(TERMCAP_FOUND TRUE)
+ MESSAGE(STATUS "Found GNU termcap: ${TERMCAP_LIBRARY}")
+ MESSAGE(STATUS "Include dir is: ${TERMCAP_INCLUDE_DIR}")
+ INCLUDE_DIRECTORIES(${TERMCAP_INCLUDE_DIR})
+ELSE (TERMCAP_INCLUDE_DIR AND TERMCAP_LIBRARY)
+ SET(TERMCAP_FOUND FALSE)
+ MESSAGE(FATAL_ERROR "Could not find GNU termcap")
+ENDIF (TERMCAP_INCLUDE_DIR AND TERMCAP_LIBRARY)
+
+ENDMACRO(FIND_TERMCAP)
diff --git a/cmake/cmake_uninstall.cmake.in b/cmake/cmake_uninstall.cmake.in
new file mode 100644
index 0000000..06f9c82
--- /dev/null
+++ b/cmake/cmake_uninstall.cmake.in
@@ -0,0 +1,23 @@
+# from cmake wiki
+IF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
+ MESSAGE(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"")
+ENDIF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
+
+FILE(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
+STRING(REGEX REPLACE "\n" ";" files "${files}")
+FOREACH(file ${files})
+ MESSAGE(STATUS "Uninstalling \"${file}\"")
+ IF(EXISTS "${file}")
+ EXEC_PROGRAM(
+ "@CMAKE_COMMAND@" ARGS "-E remove \"${file}\""
+ OUTPUT_VARIABLE rm_out
+ RETURN_VALUE rm_retval
+ )
+ IF("${rm_retval}" STREQUAL 0)
+ ELSE("${rm_retval}" STREQUAL 0)
+ MESSAGE(FATAL_ERROR "Problem when removing \"${file}\"")
+ ENDIF("${rm_retval}" STREQUAL 0)
+ ELSE(EXISTS "${file}")
+ MESSAGE(STATUS "File \"${file}\" does not exist.")
+ ENDIF(EXISTS "${file}")
+ENDFOREACH(file)
diff --git a/config.h.cmake b/config.h.cmake
new file mode 100644
index 0000000..b017c89
--- /dev/null
+++ b/config.h.cmake
@@ -0,0 +1,8 @@
+#ifndef HAVE_CONFIG_H
+#define HAVE_CONFIG_H
+
+#cmakedefine HAVE_ACE_STACK_TRACE_H
+
+#cmakedefine USE_MULTI_THREAD_MAP
+
+#endif /* HAVE_CONFIG_H */
diff --git a/contrib/cleanup/tab2spaces.sh b/contrib/cleanup/tab2spaces.sh
new file mode 100644
index 0000000..1022be7
--- /dev/null
+++ b/contrib/cleanup/tab2spaces.sh
@@ -0,0 +1,2 @@
+# Be sure to specify files instead of * when running the script.
+perl -p -i -e "s/\t/ /g" *
diff --git a/contrib/cleanup/whitespace.sh b/contrib/cleanup/whitespace.sh
new file mode 100644
index 0000000..a351e25
--- /dev/null
+++ b/contrib/cleanup/whitespace.sh
@@ -0,0 +1,2 @@
+# Be sure to specify files instead of * when running the script.
+perl -p -i -e "s/ +$//g" *
diff --git a/contrib/conf_merge/README b/contrib/conf_merge/README
new file mode 100644
index 0000000..3d027b7
--- /dev/null
+++ b/contrib/conf_merge/README
@@ -0,0 +1,6 @@
+This is a PHP script for merging a new .dist file with your existing .conf file (trinitycore and trinityrealm)
+It should also work with mangos dist/conf files as well.
+
+It uses sessions so it is multi user safe, it adds any options that are removed to the bottom of the file,
+commented out, just in case it removes something it shouldn't,
+and, if you add all of your custom patch configs below "# Custom" they will be copied exactly as they are.
diff --git a/contrib/conf_merge/index.php b/contrib/conf_merge/index.php
new file mode 100644
index 0000000..537937c
--- /dev/null
+++ b/contrib/conf_merge/index.php
@@ -0,0 +1,40 @@
+
+
+
diff --git a/contrib/conf_merge/merge.php b/contrib/conf_merge/merge.php
new file mode 100644
index 0000000..6d8bedb
--- /dev/null
+++ b/contrib/conf_merge/merge.php
@@ -0,0 +1,159 @@
+ $v)
+ {
+ if (array_key_exists($k, $array1))
+ {
+ $array1[$k] = $v;
+ unset($array2[$k]);
+ }
+ }
+ $in_file1 = fopen($upload1,r);
+ $line = trim(fgets($in_file1));
+ while (!feof($in_file1))
+ {
+ if (substr($line,0,1) != '#' && substr($line,0,1) != '')
+ {
+ $array = array();
+ while (substr($line,0,1) != '#' && substr($line,0,1) != '')
+ {
+ list($key, $val) = explode("=",$line);
+ $key = trim($key);
+ $val = trim($val);
+ $array[$key] = $val;
+ $line = trim(fgets($in_file1));
+ }
+ foreach($array as $k => $v)
+ {
+ if (array_key_exists($k, $array1))
+ fwrite($out_file, $k."=".$array1[$k].$eol);
+ else
+ continue;
+ }
+ unset($array);
+ if (!feof($in_file1))
+ fwrite($out_file, $line.$eol);
+ }
+ else
+ fwrite($out_file, $line.$eol);
+ $line = trim(fgets($in_file1));
+ }
+ if ($custom_found)
+ {
+ fwrite($out_file, $eol);
+ fwrite($out_file, "###############################################################################".$eol);
+ fwrite($out_file, "# Custom".$eol);
+ $line = trim(fgets($in_file2));
+ while (!feof($in_file2))
+ {
+ fwrite($out_file, $line.$eol);
+ $line = trim(fgets($in_file2));
+ }
+ }
+ $first = true;
+ foreach($array2 as $k => $v)
+ {
+ if ($first)
+ {
+ fwrite($out_file, $eol);
+ fwrite($out_file, "###############################################################################".$eol);
+ fwrite($out_file, "# The Following values were removed from the config.".$eol);
+ $first = false;
+ }
+ fwrite($out_file, "# ".$k."=".$v.$eol);
+ }
+ unset($array1);
+ unset($array2);
+ fclose($in_file1);
+ fclose($in_file2);
+ fclose($out_file);
+ unlink($upload1);
+ unlink($upload2);
+
+ echo "Process done";
+ echo " Click here to retrieve your merged conf";
+ }
+}
+else
+{
+ echo "An error has occurred";
+}
+?>
diff --git a/docs/AuctionHouseBot.txt b/docs/AuctionHouseBot.txt
new file mode 100644
index 0000000..cc15a08
--- /dev/null
+++ b/docs/AuctionHouseBot.txt
@@ -0,0 +1,236 @@
+Populates the auction houses with items. It can make the game feel a bit more
+like official on small servers. Items and prices are chosen randomly based on
+the parameters you define. If an auction expires, auctions are deleted quietly.
+AHBot will not buy it's own items, and will not receive mail from the AH
+or get returned mail.
+
+===============================================================================
+~~HOW TO CONFIGURE~~
+===============================================================================
+Step 1.) Create a character that you are going to use as the auction house bot
+ character. This character will be the auction's owner for all the
+ items created by the bot.
+Step 2.) Go into the realm database and note the account number for the
+ character.
+Step 3.) Go into the characters database and note the character's GUID.
+Step 4.) Log in at least once with this character.
+ (Do not change the configuration before this)
+Step 5.) Tune the configuration options in the configuration file and the
+ Database.
+
+#These are the settings in the configuration file:
+AuctionHouseBot.DEBUG = 0
+AuctionHouseBot.EnableSeller = 0
+AuctionHouseBot.EnableBuyer = 0
+AuctionHouseBot.UseBuyPriceForSeller = 0
+AuctionHouseBot.UseBuyPriceForBuyer = 0
+AuctionHouseBot.Account = 0
+AuctionHouseBot.GUID = 0
+AuctionHouseBot.ItemsPerCycle = 200
+
+AuctionHouseBot.DEBUG enables (1) or disables (0) Debug output
+AuctionHouseBot.EnableSeller enables (1) or disables (0) the Seller
+AuctionHouseBot.EnableBuyer enables (1) or disables (0) the Buyer
+AuctionHouseBot.UseBuyPriceForSeller Use SellPrice (0) or BuyPrice (1) for determining prices
+AuctionHouseBot.UseBuyPriceForBuyer Use SellPrice (0) or BuyPrice (1) for determining prices
+AuctionHouseBot.Account is the account number (in realmd->account table) of the player you want to run as the auction bot. Note: a value of 0 will disable the bot.
+AuctionHouseBot.GUID is the GUID (in characters->characters table) of the player you want to run as the auction bot. Note: a value of 0 will disable the bot.
+AuctionHouseBot.ItemsPerCycle determines how many items are added each time AHBot is run (once per minute, by default)
+
+#These are the Filters For filtering certain items/trade goods from the AH
+AuctionHouseBot.VendorItems = 0
+AuctionHouseBot.VendorTradeGoods = 0
+AuctionHouseBot.LootItems = 1
+AuctionHouseBot.LootTradeGoods = 1
+AuctionHouseBot.OtherItems = 0
+AuctionHouseBot.OtherTradeGoods = 0
+AuctionHouseBot.No_Bind = 1
+AuctionHouseBot.Bind_When_Picked_Up = 0
+AuctionHouseBot.Bind_When_Equipped = 1
+AuctionHouseBot.Bind_When_Use = 1
+AuctionHouseBot.Bind_Quest_Item = 0
+AuctionHouseBot.DisableBeta_PTR_Unused = 0
+AuctionHouseBot.DisablePermEnchant = 0
+AuctionHouseBot.DisableConjured = 0
+AuctionHouseBot.DisableGems = 0
+AuctionHouseBot.DisableMoney = 0
+AuctionHouseBot.DisableMoneyLoot = 0
+AuctionHouseBot.DisableLootable = 0
+AuctionHouseBot.DisableKeys = 0
+AuctionHouseBot.DisableDuration = 0
+AuctionHouseBot.DisableBOP_Or_Quest_NoReqLevel = 0
+
+AuctionHouseBot.VendorItems is a boolean value (0 or 1) that indicates whether to include Vendor only items
+AuctionHouseBot.VendorTradeGoods is a boolean value (0 or 1) that indicates whether to include Vendor only Trade Goods
+AuctionHouseBot.LootItems is a boolean value (0 or 1) that indicates whether to include Loot/Fish/Skin/etc. only items
+AuctionHouseBot.LootTradeGoods is a boolean value (0 or 1) that indicates whether to include Loot/Fish/Skin/etc. only Trade Goods
+AuctionHouseBot.OtherItems is a boolean value (0 or 1) that indicates whether to include Other items not covered by the first 2
+AuctionHouseBot.OtherTradeGoods is a boolean value (0 or 1) that indicates whether to include Other Trade Goods not covered by the first 2
+AuctionHouseBot.No_Bind is a boolean value (0 or 1) that indicates whether to include items with a bonding of 0
+AuctionHouseBot.Bind_When_Picked_Up = is a boolean value (0 or 1) that indicates whether to include items with a bonding of 1
+AuctionHouseBot.Bind_When_Equipped = is a boolean value (0 or 1) that indicates whether to include items with a bonding of 2
+AuctionHouseBot.Bind_When_Use = is a boolean value (0 or 1) that indicates whether to include items with a bonding of 3
+AuctionHouseBot.Bind_Quest_Item = is a boolean value (0 or 1) that indicates whether to include items with a bonding of 4
+AuctionHouseBot.DisableBeta_PTR_Unused is a boolean value (0 or 1) that will Disable certain items that are usually unavailable to Players
+AuctionHouseBot.DisablePermEnchant is a boolean value (0 or 1) that will Disable Items with a Permanent Enchantment
+AuctionHouseBot.DisableConjured is a boolean value (0 or 1) that will Disable Conjured Items
+AuctionHouseBot.DisableGems is a boolean value (0 or 1) that will Disable Gems
+AuctionHouseBot.DisableMoney is a boolean value (0 or 1) that will Disable Items that are used as money
+AuctionHouseBot.DisableMoneyLoot is a boolean value (0 or 1) that will Disable Items that have Money as a loot
+AuctionHouseBot.DisableLootable is a boolean value (0 or 1) that will Disable Items that have other items as loot
+AuctionHouseBot.DisableKeys is a boolean value (0 or 1) that will Disable Items that are keys
+AuctionHouseBot.DisableDuration is a boolean value (0 or 1) that will Disable Items with a duration
+AuctionHouseBot.DisableBOP_Or_Quest_NoReqLevel is a boolean value (0 or 1) that will Disable items that are BOP or Quest Item with a Required level that is less than the Item Level
+
+#These Filters are boolean (0 or 1) and will disable items that are
+#specifically meant for the Class named.
+#(UnusedClass is Class 10, which was skipped for some reason)
+AuctionHouseBot.DisableWarriorItems = 0
+AuctionHouseBot.DisablePaladinItems = 0
+AuctionHouseBot.DisableHunterItems = 0
+AuctionHouseBot.DisableRogueItems = 0
+AuctionHouseBot.DisablePriestItems = 0
+AuctionHouseBot.DisableDKItems = 0
+AuctionHouseBot.DisableShamanItems = 0
+AuctionHouseBot.DisableMageItems = 0
+AuctionHouseBot.DisableWarlockItems = 0
+AuctionHouseBot.DisableUnusedClassItems = 0
+AuctionHouseBot.DisableDruidItems = 0
+
+#These are the Filters For filtering certain items/trade goods from the AH
+AuctionHouseBot.DisableItemsBelowLevel = 0
+AuctionHouseBot.DisableItemsAboveLevel = 0
+AuctionHouseBot.DisableTGsBelowLevel = 0
+AuctionHouseBot.DisableTGsAboveLevel = 0
+AuctionHouseBot.DisableItemsBelowGUID = 0
+AuctionHouseBot.DisableItemsAboveGUID = 0
+AuctionHouseBot.DisableTGsBelowGUID = 0
+AuctionHouseBot.DisableTGsAboveGUID = 0
+AuctionHouseBot.DisableItemsBelowReqLevel = 0
+AuctionHouseBot.DisableItemsAboveReqLevel = 0
+AuctionHouseBot.DisableTGsBelowReqLevel = 0
+AuctionHouseBot.DisableTGsAboveReqLevel = 0
+AuctionHouseBot.DisableItemsBelowReqSkillRank = 0
+AuctionHouseBot.DisableItemsAboveReqSkillRank = 0
+AuctionHouseBot.DisableTGsBelowReqSkillRank = 0
+AuctionHouseBot.DisableTGsAboveReqSkillRank = 0
+
+#These are the settings in the Database:
+#Each Auctionhouse has it's own set of these
+
+MinItems = 0
+#The Minimum number of items you want to keep in the auction houses.
+#(default 0 - minimum will be the same as maximum).
+#If it is higher than the value of the corresponding maxItems setting,
+#it will be set down to match the maxItems setting.
+
+MaxItems = 0
+#The Maximum number of items you want to keep in the auction houses.
+
+#These must add up to 100 each one is the percentage
+#of the auction items that should be trade goods of
+#that quality. A value of 0 will disable.
+
+PercentGreyTradeGoods = 0
+PercentWhiteTradeGoods = 27
+PercentGreenTradeGoods = 12
+PercentBlueTradeGoods = 10
+PercentPurpleTradeGoods = 1
+PercentOrangeTradeGoods = 0
+PercentYellowTradeGoods = 0
+
+PercentGreyItems = 0
+PercentWhiteItems = 10
+PercentGreenItems = 30
+PercentBlueItems = 8
+PercentPurpleItems = 2
+PercentOrangeItems = 0
+PercentYellowItems = 0
+
+#MinPrice(Color) is the minimum price adjustment for items. For example the default is 150, which means 150%. So if an item vendors for 1g it would go to auction for a minimum of 1.5g.
+#MaxPrice(Color) is the maximum price adjustment for items.
+#MinBidPrice(Color) these two control the starting bid as a percent of the buyout price. For example, if MinBidPrice is 30 and MaxBidPrice is 80 the starting bid for the auction will randomly be between 30-80% of the randomly chosen buyout price.
+#MaxBidPrice(Color) these two control the starting bid as a percent of the buyout price. For example, if MinBidPrice is 30 and MaxBidPrice is 80 the starting bid for the auction will randomly be between 30-80% of the randomly chosen buyout price.
+#MaxStack(Color) is maximum stack size to create for this quality type. A value of zero will disable the maximum stack size for this quality allowing the bot to create stacks (of random size) of items as big as the item type allows.
+
+MinPriceGrey = 100
+MaxPriceGrey = 150
+MinBidPriceGrey = 70
+MaxBidPriceGrey = 100
+MaxStackGrey = 0
+MinPriceWhite = 150
+MaxPriceWhite = 250
+MinBidPriceWhite = 70
+MaxBidPriceWhite = 100
+MaxStackWhite = 0
+MinPriceGreen = 800
+MaxPriceGreen = 1400
+MinBidPriceGreen = 80
+MaxBidPriceGreen = 100
+MaxStackGreen = 0
+MinPriceBlue = 1250
+MaxPriceBlue = 1750
+MinBidPriceBlue = 75
+MaxBidPriceBlue = 100
+MaxStackBlue = 0
+MinPricePurple = 2250
+MaxPricePurple = 4550
+MinBidPricePurple = 80
+MaxBidPricePurple = 100
+MaxStackPurple = 0
+MinPriceOrange = 4250
+MaxPriceOrange = 5550
+MinBidPriceOrange = 80
+MaxBidPriceOrange = 100
+MaxStackOrange = 0
+MinPriceYellow = 5250
+MaxPriceYellow = 6550
+MinBidPriceYellow = 80
+MaxBidPriceYellow = 100
+MaxStackYellow = 0
+
+#These are the multipliers that are applied to the vendor price for an item, that determines if AHBot will buy it or not.
+#1 means AHBot will pay the same as (or less than) a vendor would pay, 2 means up to twice as much, etc.
+
+BuyerPriceGrey = 1
+BuyerPriceWhite = 3
+BuyerPriceGreen = 5
+BuyerPriceBlue = 12
+BuyerPricePurple = 15
+BuyerPriceOrange = 20
+BuyerPriceYellow = 22
+
+#BuyerBiddingInterval is the time (in minutes) between bids.
+#BuyerBidsPerInterval is the number of bids the buyer will make in a cycle
+
+BuyerBiddingInterval = 1
+BuyerBidsPerInterval = 1
+
+
+
+How to use ahcommands from the console (CLI) or in game with GM level 3 players:
+ahbotoptions - will display usage instructions
+ahbotoptions help - will display the list of commands
+
+ahexpire - will expire all the auctions in the requested auction house that were created by AHBot.
+minitems - will set the minimum number of items in the AH before it starts being filled again.
+maxitems - will set the maximum number of items in the AH.
+percentages - will set the percentage of each quality in the AH
+minprice - will set the minimum price multiplier for auctions.
+maxprice - will set the maximum price multiplier for auctions.
+minbidprice - will set the minimum starting bid as a percent of the buyout price for auctions.
+maxbidprice - will set the maximum starting bid as a percent of the buyout price for auctions.
+maxstack - will set the maximum number of items in stacks for auctions. 0 will set the maximum to the maximum for that item type.
+buyerprice - will set the bid price multiplier for auctions.
+biddinginterval - will set the number of minutes between bids on auctions.
+bidsperinterval - will set the number of bids to enter per cycle.
+
+The auction house IDs are:
+2 - Alliance
+6 - Horde
+7 - Neutral
+
+
+AHBot Originally made by Chris K. Currently maintained by Paradox
+Much thanks to Chris K, grether and Dolomit6!
+AHBot Now includes AHBuyer created by Kerbe as a derivative of AHBot, and later modified by Paradox
diff --git a/docs/DocStructure.dox b/docs/DocStructure.dox
new file mode 100644
index 0000000..dee8b5a
--- /dev/null
+++ b/docs/DocStructure.dox
@@ -0,0 +1,31 @@
+/*! \mainpage
+ *
+ * \section intro_sec Introduction and links
+ * This is the source documentation for the \b %MaNGOS (Massive Network Game %Object Server) project.\n
+ * %MaNGOS is an object-oriented Massively Multiplayer Online Role-Playing Game Server (MMORPGS).\n
+ * The project documentation and the bug tracker can be found on the %MaNGOS wiki.
+ *
+ * \section begin Where to begin?
+ * If you are interested in understanding the source code of this project you can begin
+ * - On the wiki to get an overview of the different modules of the server
+ * - In this source doumentation, starting at the module hierarchy
+ */
+
+/*! \defgroup realmd Realm Daemon
+ */
+
+/*! \defgroup mangos Mangos Deamon
+ */
+
+/*! \defgroup mangosd Daemon starter
+ \ingroup mangos
+ */
+
+/*! \defgroup u2w User Connections
+ \ingroup mangos
+ */
+
+/*! \defgroup world The World
+ \ingroup mangos
+ */
+
diff --git a/docs/Doxyfile.in b/docs/Doxyfile.in
new file mode 100644
index 0000000..9893593
--- /dev/null
+++ b/docs/Doxyfile.in
@@ -0,0 +1,1314 @@
+# Doxyfile 1.5.3
+
+# This file describes the settings to be used by the documentation system
+# doxygen (www.doxygen.org) for a project
+#
+# All text after a hash (#) is considered a comment and will be ignored
+# The format is:
+# TAG = value [value, ...]
+# For lists items can also be appended using:
+# TAG += value [value, ...]
+# Values that contain spaces should be placed between quotes (" ")
+
+#---------------------------------------------------------------------------
+# Project related configuration options
+#---------------------------------------------------------------------------
+
+# This tag specifies the encoding used for all characters in the config file that
+# follow. The default is UTF-8 which is also the encoding used for all text before
+# the first occurrence of this tag. Doxygen uses libiconv (or the iconv built into
+# libc) for the transcoding. See http://www.gnu.org/software/libiconv for the list of
+# possible encodings.
+
+DOXYFILE_ENCODING = UTF-8
+
+# The PROJECT_NAME tag is a single word (or a sequence of words surrounded
+# by quotes) that should identify the project.
+
+PROJECT_NAME = @PACKAGE@
+
+# The PROJECT_NUMBER tag can be used to enter a project or revision number.
+# This could be handy for archiving the generated documentation or
+# if some version control system is used.
+
+PROJECT_NUMBER = @VERSION@
+
+# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
+# base path where the generated documentation will be put.
+# If a relative path is entered, it will be relative to the location
+# where doxygen was started. If left blank the current directory will be used.
+
+OUTPUT_DIRECTORY = ./
+
+# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create
+# 4096 sub-directories (in 2 levels) under the output directory of each output
+# format and will distribute the generated files over these directories.
+# Enabling this option can be useful when feeding doxygen a huge amount of
+# source files, where putting all generated files in the same directory would
+# otherwise cause performance problems for the file system.
+
+CREATE_SUBDIRS = NO
+
+# The OUTPUT_LANGUAGE tag is used to specify the language in which all
+# documentation generated by doxygen is written. Doxygen will use this
+# information to generate all constant output in the proper language.
+# The default language is English, other supported languages are:
+# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional,
+# Croatian, Czech, Danish, Dutch, Finnish, French, German, Greek, Hungarian,
+# Italian, Japanese, Japanese-en (Japanese with English messages), Korean,
+# Korean-en, Lithuanian, Norwegian, Polish, Portuguese, Romanian, Russian,
+# Serbian, Slovak, Slovene, Spanish, Swedish, and Ukrainian.
+
+OUTPUT_LANGUAGE = English
+
+# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will
+# include brief member descriptions after the members that are listed in
+# the file and class documentation (similar to JavaDoc).
+# Set to NO to disable this.
+
+BRIEF_MEMBER_DESC = YES
+
+# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend
+# the brief description of a member or function before the detailed description.
+# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the
+# brief descriptions will be completely suppressed.
+
+REPEAT_BRIEF = YES
+
+# This tag implements a quasi-intelligent brief description abbreviator
+# that is used to form the text in various listings. Each string
+# in this list, if found as the leading text of the brief description, will be
+# stripped from the text and the result after processing the whole list, is
+# used as the annotated text. Otherwise, the brief description is used as-is.
+# If left blank, the following values are used ("$name" is automatically
+# replaced with the name of the entity): "The $name class" "The $name widget"
+# "The $name file" "is" "provides" "specifies" "contains"
+# "represents" "a" "an" "the"
+
+ABBREVIATE_BRIEF =
+
+# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then
+# Doxygen will generate a detailed section even if there is only a brief
+# description.
+
+ALWAYS_DETAILED_SEC = NO
+
+# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all
+# inherited members of a class in the documentation of that class as if those
+# members were ordinary class members. Constructors, destructors and assignment
+# operators of the base classes will not be shown.
+
+INLINE_INHERITED_MEMB = NO
+
+# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full
+# path before files name in the file list and in the header files. If set
+# to NO the shortest path that makes the file name unique will be used.
+
+FULL_PATH_NAMES = NO
+
+# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag
+# can be used to strip a user-defined part of the path. Stripping is
+# only done if one of the specified strings matches the left-hand part of
+# the path. The tag can be used to show relative paths in the file list.
+# If left blank the directory from which doxygen is run is used as the
+# path to strip.
+
+STRIP_FROM_PATH = @top_srcdir@/
+
+# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of
+# the path mentioned in the documentation of a class, which tells
+# the reader which header file to include in order to use a class.
+# If left blank only the name of the header file containing the class
+# definition is used. Otherwise one should specify the include paths that
+# are normally passed to the compiler using the -I flag.
+
+STRIP_FROM_INC_PATH =
+
+# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter
+# (but less readable) file names. This can be useful is your file systems
+# doesn't support long names like on DOS, Mac, or CD-ROM.
+
+SHORT_NAMES = NO
+
+# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen
+# will interpret the first line (until the first dot) of a JavaDoc-style
+# comment as the brief description. If set to NO, the JavaDoc
+# comments will behave just like regular Qt-style comments
+# (thus requiring an explicit @brief command for a brief description.)
+
+JAVADOC_AUTOBRIEF = YES
+
+# If the QT_AUTOBRIEF tag is set to YES then Doxygen will
+# interpret the first line (until the first dot) of a Qt-style
+# comment as the brief description. If set to NO, the comments
+# will behave just like regular Qt-style comments (thus requiring
+# an explicit \brief command for a brief description.)
+
+QT_AUTOBRIEF = NO
+
+# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen
+# treat a multi-line C++ special comment block (i.e. a block of //! or ///
+# comments) as a brief description. This used to be the default behaviour.
+# The new default is to treat a multi-line C++ comment block as a detailed
+# description. Set this tag to YES if you prefer the old behaviour instead.
+
+MULTILINE_CPP_IS_BRIEF = NO
+
+# If the DETAILS_AT_TOP tag is set to YES then Doxygen
+# will output the detailed description near the top, like JavaDoc.
+# If set to NO, the detailed description appears after the member
+# documentation.
+
+DETAILS_AT_TOP = NO
+
+# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented
+# member inherits the documentation from any documented member that it
+# re-implements.
+
+INHERIT_DOCS = YES
+
+# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce
+# a new page for each member. If set to NO, the documentation of a member will
+# be part of the file/class/namespace that contains it.
+
+SEPARATE_MEMBER_PAGES = NO
+
+# The TAB_SIZE tag can be used to set the number of spaces in a tab.
+# Doxygen uses this value to replace tabs by spaces in code fragments.
+
+TAB_SIZE = 4
+
+# This tag can be used to specify a number of aliases that acts
+# as commands in the documentation. An alias has the form "name=value".
+# For example adding "sideeffect=\par Side Effects:\n" will allow you to
+# put the command \sideeffect (or @sideeffect) in the documentation, which
+# will result in a user-defined paragraph with heading "Side Effects:".
+# You can put \n's in the value part of an alias to insert newlines.
+
+ALIASES = "memo=\par Note:\n " \
+ "draft=\xrefitem draft \"Draft\" \"Draft List\" This API may be changed in the future versions and was introduced in " \
+ "stable=\xrefitem stable \"Stable\" \"Stable List\" " \
+ "deprecated=\xrefitem deprecated \"Deprecated\" \"Deprecated List\" " \
+ "obsolete=\xrefitem obsolete \"Obsolete\" \"Obsolete List\" " \
+ "system=\xrefitem system \"System\" \"System List\" \n Do not use unless you know what you are doing. " \
+ "internal=\xrefitem internal \"Internal\" \"Internal List\" Do not use. This API is for interal use only. "
+
+# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C
+# sources only. Doxygen will then generate output that is more tailored for C.
+# For instance, some of the names that are used will be different. The list
+# of all members will be omitted, etc.
+
+OPTIMIZE_OUTPUT_FOR_C = YES
+
+# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java
+# sources only. Doxygen will then generate output that is more tailored for Java.
+# For instance, namespaces will be presented as packages, qualified scopes
+# will look different, etc.
+
+OPTIMIZE_OUTPUT_JAVA = NO
+
+# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want to
+# include (a tag file for) the STL sources as input, then you should
+# set this tag to YES in order to let doxygen match functions declarations and
+# definitions whose arguments contain STL classes (e.g. func(std::string); v.s.
+# func(std::string) {}). This also make the inheritance and collaboration
+# diagrams that involve STL classes more complete and accurate.
+
+BUILTIN_STL_SUPPORT = NO
+
+# If you use Microsoft's C++/CLI language, you should set this option to YES to
+# enable parsing support.
+
+CPP_CLI_SUPPORT = NO
+
+# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
+# tag is set to YES, then doxygen will reuse the documentation of the first
+# member in the group (if any) for the other members of the group. By default
+# all members of a group must be documented explicitly.
+
+DISTRIBUTE_GROUP_DOC = NO
+
+# Set the SUBGROUPING tag to YES (the default) to allow class member groups of
+# the same type (for instance a group of public functions) to be put as a
+# subgroup of that type (e.g. under the Public Functions section). Set it to
+# NO to prevent subgrouping. Alternatively, this can be done per class using
+# the \nosubgrouping command.
+
+SUBGROUPING = YES
+
+#---------------------------------------------------------------------------
+# Build related configuration options
+#---------------------------------------------------------------------------
+
+# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in
+# documentation are documented, even if no documentation was available.
+# Private class members and static file members will be hidden unless
+# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
+
+EXTRACT_ALL = NO
+
+# If the EXTRACT_PRIVATE tag is set to YES all private members of a class
+# will be included in the documentation.
+
+EXTRACT_PRIVATE = NO
+
+# If the EXTRACT_STATIC tag is set to YES all static members of a file
+# will be included in the documentation.
+
+EXTRACT_STATIC = NO
+
+# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs)
+# defined locally in source files will be included in the documentation.
+# If set to NO only classes defined in header files are included.
+
+EXTRACT_LOCAL_CLASSES = YES
+
+# This flag is only useful for Objective-C code. When set to YES local
+# methods, which are defined in the implementation section but not in
+# the interface are included in the documentation.
+# If set to NO (the default) only methods in the interface are included.
+
+EXTRACT_LOCAL_METHODS = YES
+
+# If this flag is set to YES, the members of anonymous namespaces will be extracted
+# and appear in the documentation as a namespace called 'anonymous_namespace{file}',
+# where file will be replaced with the base name of the file that contains the anonymous
+# namespace. By default anonymous namespace are hidden.
+
+EXTRACT_ANON_NSPACES = NO
+
+# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all
+# undocumented members of documented classes, files or namespaces.
+# If set to NO (the default) these members will be included in the
+# various overviews, but no documentation section is generated.
+# This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_MEMBERS = NO
+
+# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all
+# undocumented classes that are normally visible in the class hierarchy.
+# If set to NO (the default) these classes will be included in the various
+# overviews. This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_CLASSES = NO
+
+# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all
+# friend (class|struct|union) declarations.
+# If set to NO (the default) these declarations will be included in the
+# documentation.
+
+HIDE_FRIEND_COMPOUNDS = NO
+
+# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any
+# documentation blocks found inside the body of a function.
+# If set to NO (the default) these blocks will be appended to the
+# function's detailed documentation block.
+
+HIDE_IN_BODY_DOCS = NO
+
+# The INTERNAL_DOCS tag determines if documentation
+# that is typed after a \internal command is included. If the tag is set
+# to NO (the default) then the documentation will be excluded.
+# Set it to YES to include the internal documentation.
+
+INTERNAL_DOCS = YES
+
+# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate
+# file names in lower-case letters. If set to YES upper-case letters are also
+# allowed. This is useful if you have classes or files whose names only differ
+# in case and if your file system supports case sensitive file names. Windows
+# and Mac users are advised to set this option to NO.
+
+CASE_SENSE_NAMES = YES
+
+# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen
+# will show members with their full class and namespace scopes in the
+# documentation. If set to YES the scope will be hidden.
+
+HIDE_SCOPE_NAMES = NO
+
+# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen
+# will put a list of the files that are included by a file in the documentation
+# of that file.
+
+SHOW_INCLUDE_FILES = YES
+
+# If the INLINE_INFO tag is set to YES (the default) then a tag [inline]
+# is inserted in the documentation for inline members.
+
+INLINE_INFO = YES
+
+# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen
+# will sort the (detailed) documentation of file and class members
+# alphabetically by member name. If set to NO the members will appear in
+# declaration order.
+
+SORT_MEMBER_DOCS = YES
+
+# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the
+# brief documentation of file, namespace and class members alphabetically
+# by member name. If set to NO (the default) the members will appear in
+# declaration order.
+
+SORT_BRIEF_DOCS = NO
+
+# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be
+# sorted by fully-qualified names, including namespaces. If set to
+# NO (the default), the class list will be sorted only by class name,
+# not including the namespace part.
+# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.
+# Note: This option applies only to the class list, not to the
+# alphabetical list.
+
+SORT_BY_SCOPE_NAME = NO
+
+# The GENERATE_TODOLIST tag can be used to enable (YES) or
+# disable (NO) the todo list. This list is created by putting \todo
+# commands in the documentation.
+
+GENERATE_TODOLIST = YES
+
+# The GENERATE_TESTLIST tag can be used to enable (YES) or
+# disable (NO) the test list. This list is created by putting \test
+# commands in the documentation.
+
+GENERATE_TESTLIST = YES
+
+# The GENERATE_BUGLIST tag can be used to enable (YES) or
+# disable (NO) the bug list. This list is created by putting \bug
+# commands in the documentation.
+
+GENERATE_BUGLIST = YES
+
+# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or
+# disable (NO) the deprecated list. This list is created by putting
+# \deprecated commands in the documentation.
+
+GENERATE_DEPRECATEDLIST= YES
+
+# The ENABLED_SECTIONS tag can be used to enable conditional
+# documentation sections, marked by \if sectionname ... \endif.
+
+ENABLED_SECTIONS =
+
+# The MAX_INITIALIZER_LINES tag determines the maximum number of lines
+# the initial value of a variable or define consists of for it to appear in
+# the documentation. If the initializer consists of more lines than specified
+# here it will be hidden. Use a value of 0 to hide initializers completely.
+# The appearance of the initializer of individual variables and defines in the
+# documentation can be controlled using \showinitializer or \hideinitializer
+# command in the documentation regardless of this setting.
+
+MAX_INITIALIZER_LINES = 30
+
+# Set the SHOW_USED_FILES tag to NO to disable the list of files generated
+# at the bottom of the documentation of classes and structs. If set to YES the
+# list will mention the files that were used to generate the documentation.
+
+SHOW_USED_FILES = YES
+
+# If the sources in your project are distributed over multiple directories
+# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy
+# in the documentation. The default is NO.
+
+SHOW_DIRECTORIES = NO
+
+# The FILE_VERSION_FILTER tag can be used to specify a program or script that
+# doxygen should invoke to get the current version for each file (typically from the
+# version control system). Doxygen will invoke the program by executing (via
+# popen()) the command , where is the value of
+# the FILE_VERSION_FILTER tag, and is the name of an input file
+# provided by doxygen. Whatever the program writes to standard output
+# is used as the file version. See the manual for examples.
+
+FILE_VERSION_FILTER =
+
+#---------------------------------------------------------------------------
+# configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+
+# The QUIET tag can be used to turn on/off the messages that are generated
+# by doxygen. Possible values are YES and NO. If left blank NO is used.
+
+QUIET = NO
+
+# The WARNINGS tag can be used to turn on/off the warning messages that are
+# generated by doxygen. Possible values are YES and NO. If left blank
+# NO is used.
+
+WARNINGS = YES
+
+# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings
+# for undocumented members. If EXTRACT_ALL is set to YES then this flag will
+# automatically be disabled.
+
+WARN_IF_UNDOCUMENTED = YES
+
+# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for
+# potential errors in the documentation, such as not documenting some
+# parameters in a documented function, or documenting parameters that
+# don't exist or using markup commands wrongly.
+
+WARN_IF_DOC_ERROR = YES
+
+# This WARN_NO_PARAMDOC option can be abled to get warnings for
+# functions that are documented, but have no documentation for their parameters
+# or return value. If set to NO (the default) doxygen will only warn about
+# wrong or incomplete parameter documentation, but not about the absence of
+# documentation.
+
+WARN_NO_PARAMDOC = NO
+
+# The WARN_FORMAT tag determines the format of the warning messages that
+# doxygen can produce. The string should contain the $file, $line, and $text
+# tags, which will be replaced by the file and line number from which the
+# warning originated and the warning text. Optionally the format may contain
+# $version, which will be replaced by the version of the file (if it could
+# be obtained via FILE_VERSION_FILTER)
+
+WARN_FORMAT = "$file:$line: $text "
+
+# The WARN_LOGFILE tag can be used to specify a file to which warning
+# and error messages should be written. If left blank the output is written
+# to stderr.
+
+WARN_LOGFILE =
+
+#---------------------------------------------------------------------------
+# configuration options related to the input files
+#---------------------------------------------------------------------------
+
+# The INPUT tag can be used to specify the files and/or directories that contain
+# documented source files. You may enter file names like "myfile.cpp" or
+# directories like "/usr/src/myproject". Separate the files or directories
+# with spaces.
+
+INPUT = @top_srcdir@/src/shared/ \
+ @top_srcdir@/src/shared/Auth/ \
+ @top_srcdir@/src/shared/Database/ \
+ @top_srcdir@/src/game/ \
+ @top_srcdir@/src/realmd/ \
+ @top_srcdir@/src/mangosd/ \
+ DocStructure.dox
+
+# This tag can be used to specify the character encoding of the source files that
+# doxygen parses. Internally doxygen uses the UTF-8 encoding, which is also the default
+# input encoding. Doxygen uses libiconv (or the iconv built into libc) for the transcoding.
+# See http://www.gnu.org/software/libiconv for the list of possible encodings.
+
+INPUT_ENCODING = UTF-8
+
+# If the value of the INPUT tag contains directories, you can use the
+# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
+# and *.h) to filter out the source-files in the directories. If left
+# blank the following patterns are tested:
+# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx
+# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py
+
+FILE_PATTERNS = *.cpp \
+ *.h \
+ *.hpp
+
+# The RECURSIVE tag can be used to turn specify whether or not subdirectories
+# should be searched for input files as well. Possible values are YES and NO.
+# If left blank NO is used.
+
+RECURSIVE = NO
+
+# The EXCLUDE tag can be used to specify files and/or directories that should
+# excluded from the INPUT source files. This way you can easily exclude a
+# subdirectory from a directory tree whose root is specified with the INPUT tag.
+
+EXCLUDE =
+
+# The EXCLUDE_SYMLINKS tag can be used select whether or not files or
+# directories that are symbolic links (a Unix filesystem feature) are excluded
+# from the input.
+
+EXCLUDE_SYMLINKS = NO
+
+# If the value of the INPUT tag contains directories, you can use the
+# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
+# certain files from those directories. Note that the wildcards are matched
+# against the file with absolute path, so to exclude all test directories
+# for example use the pattern */test/*
+
+EXCLUDE_PATTERNS = config*.h
+
+# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
+# (namespaces, classes, functions, etc.) that should be excluded from the output.
+# The symbol name can be a fully qualified name, a word, or if the wildcard * is used,
+# a substring. Examples: ANamespace, AClass, AClass::ANamespace, ANamespace::*Test
+
+EXCLUDE_SYMBOLS =
+
+# The EXAMPLE_PATH tag can be used to specify one or more files or
+# directories that contain example code fragments that are included (see
+# the \include command).
+
+EXAMPLE_PATH =
+
+# If the value of the EXAMPLE_PATH tag contains directories, you can use the
+# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
+# and *.h) to filter out the source-files in the directories. If left
+# blank all files are included.
+
+EXAMPLE_PATTERNS =
+
+# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be
+# searched for input files to be used with the \include or \dontinclude
+# commands irrespective of the value of the RECURSIVE tag.
+# Possible values are YES and NO. If left blank NO is used.
+
+EXAMPLE_RECURSIVE = NO
+
+# The IMAGE_PATH tag can be used to specify one or more files or
+# directories that contain image that are included in the documentation (see
+# the \image command).
+
+IMAGE_PATH =
+
+# The INPUT_FILTER tag can be used to specify a program that doxygen should
+# invoke to filter for each input file. Doxygen will invoke the filter program
+# by executing (via popen()) the command , where
+# is the value of the INPUT_FILTER tag, and is the name of an
+# input file. Doxygen will then use the output that the filter program writes
+# to standard output. If FILTER_PATTERNS is specified, this tag will be
+# ignored.
+
+INPUT_FILTER =
+
+# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern
+# basis. Doxygen will compare the file name with each pattern and apply the
+# filter if there is a match. The filters are a list of the form:
+# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further
+# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER
+# is applied to all files.
+
+FILTER_PATTERNS =
+
+# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using
+# INPUT_FILTER) will be used to filter the input files when producing source
+# files to browse (i.e. when SOURCE_BROWSER is set to YES).
+
+FILTER_SOURCE_FILES = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to source browsing
+#---------------------------------------------------------------------------
+
+# If the SOURCE_BROWSER tag is set to YES then a list of source files will
+# be generated. Documented entities will be cross-referenced with these sources.
+# Note: To get rid of all source code in the generated output, make sure also
+# VERBATIM_HEADERS is set to NO. If you have enabled CALL_GRAPH or CALLER_GRAPH
+# then you must also enable this option. If you don't then doxygen will produce
+# a warning and turn it on anyway
+
+SOURCE_BROWSER = YES
+
+# Setting the INLINE_SOURCES tag to YES will include the body
+# of functions and classes directly in the documentation.
+
+INLINE_SOURCES = NO
+
+# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct
+# doxygen to hide any special comment blocks from generated source code
+# fragments. Normal C and C++ comments will always remain visible.
+
+STRIP_CODE_COMMENTS = YES
+
+# If the REFERENCED_BY_RELATION tag is set to YES (the default)
+# then for each documented function all documented
+# functions referencing it will be listed.
+
+REFERENCED_BY_RELATION = YES
+
+# If the REFERENCES_RELATION tag is set to YES (the default)
+# then for each documented function all documented entities
+# called/used by that function will be listed.
+
+REFERENCES_RELATION = YES
+
+# If the REFERENCES_LINK_SOURCE tag is set to YES (the default)
+# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from
+# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will
+# link to the source code. Otherwise they will link to the documentstion.
+
+REFERENCES_LINK_SOURCE = YES
+
+# If the USE_HTAGS tag is set to YES then the references to source code
+# will point to the HTML generated by the htags(1) tool instead of doxygen
+# built-in source browser. The htags tool is part of GNU's global source
+# tagging system (see http://www.gnu.org/software/global/global.html). You
+# will need version 4.8.6 or higher.
+
+USE_HTAGS = NO
+
+# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen
+# will generate a verbatim copy of the header file for each class for
+# which an include is specified. Set to NO to disable this.
+
+VERBATIM_HEADERS = YES
+
+#---------------------------------------------------------------------------
+# configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+
+# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index
+# of all compounds will be generated. Enable this if the project
+# contains a lot of classes, structs, unions or interfaces.
+
+ALPHABETICAL_INDEX = YES
+
+# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then
+# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns
+# in which this list will be split (can be a number in the range [1..20])
+
+COLS_IN_ALPHA_INDEX = 5
+
+# In case all classes in a project start with a common prefix, all
+# classes will be put under the same header in the alphabetical index.
+# The IGNORE_PREFIX tag can be used to specify one or more prefixes that
+# should be ignored while generating the index headers.
+
+IGNORE_PREFIX =
+
+#---------------------------------------------------------------------------
+# configuration options related to the HTML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_HTML tag is set to YES (the default) Doxygen will
+# generate HTML output.
+
+GENERATE_HTML = YES
+
+# The HTML_OUTPUT tag is used to specify where the HTML docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `html' will be used as the default path.
+
+HTML_OUTPUT = html
+
+# The HTML_FILE_EXTENSION tag can be used to specify the file extension for
+# each generated HTML page (for example: .htm,.php,.asp). If it is left blank
+# doxygen will generate files with .html extension.
+
+HTML_FILE_EXTENSION = .html
+
+# The HTML_HEADER tag can be used to specify a personal HTML header for
+# each generated HTML page. If it is left blank doxygen will generate a
+# standard header.
+
+HTML_HEADER =
+
+# The HTML_FOOTER tag can be used to specify a personal HTML footer for
+# each generated HTML page. If it is left blank doxygen will generate a
+# standard footer.
+
+HTML_FOOTER =
+
+# The HTML_STYLESHEET tag can be used to specify a user-defined cascading
+# style sheet that is used by each HTML page. It can be used to
+# fine-tune the look of the HTML output. If the tag is left blank doxygen
+# will generate a default style sheet. Note that doxygen will try to copy
+# the style sheet file to the HTML output directory, so don't put your own
+# stylesheet in the HTML output directory as well, or it will be erased!
+
+HTML_STYLESHEET =
+
+# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes,
+# files or namespaces will be aligned in HTML using tables. If set to
+# NO a bullet list will be used.
+
+HTML_ALIGN_MEMBERS = YES
+
+# If the GENERATE_HTMLHELP tag is set to YES, additional index files
+# will be generated that can be used as input for tools like the
+# Microsoft HTML help workshop to generate a compressed HTML help file (.chm)
+# of the generated HTML documentation.
+
+GENERATE_HTMLHELP = NO
+
+# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML
+# documentation will contain sections that can be hidden and shown after the
+# page has loaded. For this to work a browser that supports
+# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox
+# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari).
+
+HTML_DYNAMIC_SECTIONS = NO
+
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can
+# be used to specify the file name of the resulting .chm file. You
+# can add a path in front of the file if the result should not be
+# written to the html output directory.
+
+CHM_FILE =
+
+# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can
+# be used to specify the location (absolute path including file name) of
+# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run
+# the HTML help compiler on the generated index.hhp.
+
+HHC_LOCATION =
+
+# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag
+# controls if a separate .chi index file is generated (YES) or that
+# it should be included in the master .chm file (NO).
+
+GENERATE_CHI = NO
+
+# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag
+# controls whether a binary table of contents is generated (YES) or a
+# normal table of contents (NO) in the .chm file.
+
+BINARY_TOC = NO
+
+# The TOC_EXPAND flag can be set to YES to add extra items for group members
+# to the contents of the HTML help documentation and to the tree view.
+
+TOC_EXPAND = NO
+
+# The DISABLE_INDEX tag can be used to turn on/off the condensed index at
+# top of each HTML page. The value NO (the default) enables the index and
+# the value YES disables it.
+
+DISABLE_INDEX = NO
+
+# This tag can be used to set the number of enum values (range [1..20])
+# that doxygen will group on one line in the generated HTML documentation.
+
+ENUM_VALUES_PER_LINE = 4
+
+# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be
+# generated containing a tree-like index structure (just like the one that
+# is generated for HTML Help). For this to work a browser that supports
+# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+,
+# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are
+# probably better off using the HTML help feature.
+
+GENERATE_TREEVIEW = NO
+
+# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be
+# used to set the initial width (in pixels) of the frame in which the tree
+# is shown.
+
+TREEVIEW_WIDTH = 250
+
+#---------------------------------------------------------------------------
+# configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will
+# generate Latex output.
+
+GENERATE_LATEX = NO
+
+# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `latex' will be used as the default path.
+
+LATEX_OUTPUT = latex
+
+# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be
+# invoked. If left blank `latex' will be used as the default command name.
+
+LATEX_CMD_NAME = latex
+
+# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to
+# generate index for LaTeX. If left blank `makeindex' will be used as the
+# default command name.
+
+MAKEINDEX_CMD_NAME = makeindex
+
+# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact
+# LaTeX documents. This may be useful for small projects and may help to
+# save some trees in general.
+
+COMPACT_LATEX = NO
+
+# The PAPER_TYPE tag can be used to set the paper type that is used
+# by the printer. Possible values are: a4, a4wide, letter, legal and
+# executive. If left blank a4wide will be used.
+
+PAPER_TYPE = a4wide
+
+# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX
+# packages that should be included in the LaTeX output.
+
+EXTRA_PACKAGES =
+
+# The LATEX_HEADER tag can be used to specify a personal LaTeX header for
+# the generated latex document. The header should contain everything until
+# the first chapter. If it is left blank doxygen will generate a
+# standard header. Notice: only use this tag if you know what you are doing!
+
+LATEX_HEADER =
+
+# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated
+# is prepared for conversion to pdf (using ps2pdf). The pdf file will
+# contain links (just like the HTML output) instead of page references
+# This makes the output suitable for online browsing using a pdf viewer.
+
+PDF_HYPERLINKS = NO
+
+# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of
+# plain latex in the generated Makefile. Set this option to YES to get a
+# higher quality PDF documentation.
+
+USE_PDFLATEX = NO
+
+# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode.
+# command to the generated LaTeX files. This will instruct LaTeX to keep
+# running if errors occur, instead of asking the user for help.
+# This option is also used when generating formulas in HTML.
+
+LATEX_BATCHMODE = NO
+
+# If LATEX_HIDE_INDICES is set to YES then doxygen will not
+# include the index chapters (such as File Index, Compound Index, etc.)
+# in the output.
+
+LATEX_HIDE_INDICES = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the RTF output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output
+# The RTF output is optimized for Word 97 and may not look very pretty with
+# other RTF readers or editors.
+
+GENERATE_RTF = NO
+
+# The RTF_OUTPUT tag is used to specify where the RTF docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `rtf' will be used as the default path.
+
+RTF_OUTPUT = rtf
+
+# If the COMPACT_RTF tag is set to YES Doxygen generates more compact
+# RTF documents. This may be useful for small projects and may help to
+# save some trees in general.
+
+COMPACT_RTF = NO
+
+# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated
+# will contain hyperlink fields. The RTF file will
+# contain links (just like the HTML output) instead of page references.
+# This makes the output suitable for online browsing using WORD or other
+# programs which support those fields.
+# Note: wordpad (write) and others do not support links.
+
+RTF_HYPERLINKS = NO
+
+# Load stylesheet definitions from file. Syntax is similar to doxygen's
+# config file, i.e. a series of assignments. You only have to provide
+# replacements, missing definitions are set to their default value.
+
+RTF_STYLESHEET_FILE =
+
+# Set optional variables used in the generation of an rtf document.
+# Syntax is similar to doxygen's config file.
+
+RTF_EXTENSIONS_FILE =
+
+#---------------------------------------------------------------------------
+# configuration options related to the man page output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_MAN tag is set to YES (the default) Doxygen will
+# generate man pages
+
+GENERATE_MAN = NO
+
+# The MAN_OUTPUT tag is used to specify where the man pages will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `man' will be used as the default path.
+
+MAN_OUTPUT = man
+
+# The MAN_EXTENSION tag determines the extension that is added to
+# the generated man pages (default is the subroutine's section .3)
+
+MAN_EXTENSION = .3
+
+# If the MAN_LINKS tag is set to YES and Doxygen generates man output,
+# then it will generate one additional man file for each entity
+# documented in the real man page(s). These additional files
+# only source the real man page, but without them the man command
+# would be unable to find the correct page. The default is NO.
+
+MAN_LINKS = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the XML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_XML tag is set to YES Doxygen will
+# generate an XML file that captures the structure of
+# the code including all documentation.
+
+GENERATE_XML = NO
+
+# The XML_OUTPUT tag is used to specify where the XML pages will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `xml' will be used as the default path.
+
+XML_OUTPUT = xml
+
+# The XML_SCHEMA tag can be used to specify an XML schema,
+# which can be used by a validating XML parser to check the
+# syntax of the XML files.
+
+XML_SCHEMA =
+
+# The XML_DTD tag can be used to specify an XML DTD,
+# which can be used by a validating XML parser to check the
+# syntax of the XML files.
+
+XML_DTD =
+
+# If the XML_PROGRAMLISTING tag is set to YES Doxygen will
+# dump the program listings (including syntax highlighting
+# and cross-referencing information) to the XML output. Note that
+# enabling this will significantly increase the size of the XML output.
+
+XML_PROGRAMLISTING = YES
+
+#---------------------------------------------------------------------------
+# configuration options for the AutoGen Definitions output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will
+# generate an AutoGen Definitions (see autogen.sf.net) file
+# that captures the structure of the code including all
+# documentation. Note that this feature is still experimental
+# and incomplete at the moment.
+
+GENERATE_AUTOGEN_DEF = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the Perl module output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_PERLMOD tag is set to YES Doxygen will
+# generate a Perl module file that captures the structure of
+# the code including all documentation. Note that this
+# feature is still experimental and incomplete at the
+# moment.
+
+GENERATE_PERLMOD = NO
+
+# If the PERLMOD_LATEX tag is set to YES Doxygen will generate
+# the necessary Makefile rules, Perl scripts and LaTeX code to be able
+# to generate PDF and DVI output from the Perl module output.
+
+PERLMOD_LATEX = YES
+
+# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be
+# nicely formatted so it can be parsed by a human reader. This is useful
+# if you want to understand what is going on. On the other hand, if this
+# tag is set to NO the size of the Perl module output will be much smaller
+# and Perl will parse it just the same.
+
+PERLMOD_PRETTY = YES
+
+# The names of the make variables in the generated doxyrules.make file
+# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX.
+# This is useful so different doxyrules.make files included by the same
+# Makefile don't overwrite each other's variables.
+
+PERLMOD_MAKEVAR_PREFIX =
+
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor
+#---------------------------------------------------------------------------
+
+# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will
+# evaluate all C-preprocessor directives found in the sources and include
+# files.
+
+ENABLE_PREPROCESSING = YES
+
+# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro
+# names in the source code. If set to NO (the default) only conditional
+# compilation will be performed. Macro expansion can be done in a controlled
+# way by setting EXPAND_ONLY_PREDEF to YES.
+
+MACRO_EXPANSION = YES
+
+# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES
+# then the macro expansion is limited to the macros specified with the
+# PREDEFINED and EXPAND_AS_DEFINED tags.
+
+EXPAND_ONLY_PREDEF = YES
+
+# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files
+# in the INCLUDE_PATH (see below) will be search if a #include is found.
+
+SEARCH_INCLUDES = YES
+
+# The INCLUDE_PATH tag can be used to specify one or more directories that
+# contain include files that are not input files but should be processed by
+# the preprocessor.
+
+INCLUDE_PATH =
+
+# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
+# patterns (like *.h and *.hpp) to filter out the header-files in the
+# directories. If left blank, the patterns specified with FILE_PATTERNS will
+# be used.
+
+INCLUDE_FILE_PATTERNS =
+
+# The PREDEFINED tag can be used to specify one or more macro names that
+# are defined before the preprocessor is started (similar to the -D option of
+# gcc). The argument of the tag is a list of macros of the form: name
+# or name=definition (no spaces). If the definition and the = are
+# omitted =1 is assumed. To prevent a macro definition from being
+# undefined via #undef or recursively expanded use the := operator
+# instead of the = operator.
+
+PREDEFINED = U_EXPORT2 \
+ U_STABLE \
+ U_DRAFT \
+ U_INTERNAL \
+ U_SYSTEM \
+ U_DEPRECATED \
+ U_OBSOLETE
+
+# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
+# this tag can be used to specify a list of macro names that should be expanded.
+# The macro definition that is found in the sources will be used.
+# Use the PREDEFINED tag if you want to use a different macro definition.
+
+EXPAND_AS_DEFINED =
+
+# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then
+# doxygen's preprocessor will remove all function-like macros that are alone
+# on a line, have an all uppercase name, and do not end with a semicolon. Such
+# function macros are typically used for boiler-plate code, and will confuse
+# the parser if not removed.
+
+SKIP_FUNCTION_MACROS = YES
+
+#---------------------------------------------------------------------------
+# Configuration::additions related to external references
+#---------------------------------------------------------------------------
+
+# The TAGFILES option can be used to specify one or more tagfiles.
+# Optionally an initial location of the external documentation
+# can be added for each tagfile. The format of a tag file without
+# this location is as follows:
+# TAGFILES = file1 file2 ...
+# Adding location for the tag files is done as follows:
+# TAGFILES = file1=loc1 "file2 = loc2" ...
+# where "loc1" and "loc2" can be relative or absolute paths or
+# URLs. If a location is present for each tag, the installdox tool
+# does not have to be run to correct the links.
+# Note that each tag file must have a unique name
+# (where the name does NOT include the path)
+# If a tag file is not located in the directory in which doxygen
+# is run, you must also specify the path to the tagfile here.
+
+TAGFILES =
+
+# When a file name is specified after GENERATE_TAGFILE, doxygen will create
+# a tag file that is based on the input files it reads.
+
+GENERATE_TAGFILE = "@srcdir@/html/mangos-ng-docs.tag "
+
+# If the ALLEXTERNALS tag is set to YES all external classes will be listed
+# in the class index. If set to NO only the inherited external classes
+# will be listed.
+
+ALLEXTERNALS = NO
+
+# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed
+# in the modules index. If set to NO, only the current project's groups will
+# be listed.
+
+EXTERNAL_GROUPS = YES
+
+# The PERL_PATH should be the absolute path and name of the perl script
+# interpreter (i.e. the result of `which perl').
+
+PERL_PATH = /usr/bin/perl
+
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool
+#---------------------------------------------------------------------------
+
+# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will
+# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base
+# or super classes. Setting the tag to NO turns the diagrams off. Note that
+# this option is superseded by the HAVE_DOT option below. This is only a
+# fallback. It is recommended to install and use dot, since it yields more
+# powerful graphs.
+
+CLASS_DIAGRAMS = YES
+
+# You can define message sequence charts within doxygen comments using the \msc
+# command. Doxygen will then run the mscgen tool (see http://www.mcternan.me.uk/mscgen/) to
+# produce the chart and insert it in the documentation. The MSCGEN_PATH tag allows you to
+# specify the directory where the mscgen tool resides. If left empty the tool is assumed to
+# be found in the default search path.
+
+MSCGEN_PATH =
+
+# If set to YES, the inheritance and collaboration graphs will hide
+# inheritance and usage relations if the target is undocumented
+# or is not a class.
+
+HIDE_UNDOC_RELATIONS = YES
+
+# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
+# available from the path. This tool is part of Graphviz, a graph visualization
+# toolkit from AT&T and Lucent Bell Labs. The other options in this section
+# have no effect if this option is set to NO (the default)
+
+HAVE_DOT = NO
+
+# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for each documented class showing the direct and
+# indirect inheritance relations. Setting this tag to YES will force the
+# the CLASS_DIAGRAMS tag to NO.
+
+CLASS_GRAPH = YES
+
+# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for each documented class showing the direct and
+# indirect implementation dependencies (inheritance, containment, and
+# class references variables) of the class with other documented classes.
+
+COLLABORATION_GRAPH = YES
+
+# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for groups, showing the direct groups dependencies
+
+GROUP_GRAPHS = YES
+
+# If the UML_LOOK tag is set to YES doxygen will generate inheritance and
+# collaboration diagrams in a style similar to the OMG's Unified Modeling
+# Language.
+
+UML_LOOK = NO
+
+# If set to YES, the inheritance and collaboration graphs will show the
+# relations between templates and their instances.
+
+TEMPLATE_RELATIONS = NO
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT
+# tags are set to YES then doxygen will generate a graph for each documented
+# file showing the direct and indirect include dependencies of the file with
+# other documented files.
+
+INCLUDE_GRAPH = YES
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and
+# HAVE_DOT tags are set to YES then doxygen will generate a graph for each
+# documented header file showing the documented files that directly or
+# indirectly include this file.
+
+INCLUDED_BY_GRAPH = YES
+
+# If the CALL_GRAPH, SOURCE_BROWSER and HAVE_DOT tags are set to YES then doxygen will
+# generate a call dependency graph for every global function or class method.
+# Note that enabling this option will significantly increase the time of a run.
+# So in most cases it will be better to enable call graphs for selected
+# functions only using the \callgraph command.
+
+CALL_GRAPH = NO
+
+# If the CALLER_GRAPH, SOURCE_BROWSER and HAVE_DOT tags are set to YES then doxygen will
+# generate a caller dependency graph for every global function or class method.
+# Note that enabling this option will significantly increase the time of a run.
+# So in most cases it will be better to enable caller graphs for selected
+# functions only using the \callergraph command.
+
+CALLER_GRAPH = NO
+
+# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen
+# will graphical hierarchy of all classes instead of a textual one.
+
+GRAPHICAL_HIERARCHY = YES
+
+# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES
+# then doxygen will show the dependencies a directory has on other directories
+# in a graphical way. The dependency relations are determined by the #include
+# relations between the files in the directories.
+
+DIRECTORY_GRAPH = YES
+
+# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
+# generated by dot. Possible values are png, jpg, or gif
+# If left blank png will be used.
+
+DOT_IMAGE_FORMAT = png
+
+# The tag DOT_PATH can be used to specify the path where the dot tool can be
+# found. If left blank, it is assumed the dot tool can be found in the path.
+
+DOT_PATH =
+
+# The DOTFILE_DIRS tag can be used to specify one or more directories that
+# contain dot files that are included in the documentation (see the
+# \dotfile command).
+
+DOTFILE_DIRS =
+
+# The MAX_DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of
+# nodes that will be shown in the graph. If the number of nodes in a graph
+# becomes larger than this value, doxygen will truncate the graph, which is
+# visualized by representing a node as a red box. Note that doxygen if the number
+# of direct children of the root node in a graph is already larger than
+# MAX_DOT_GRAPH_NOTES then the graph will not be shown at all. Also note
+# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH.
+
+DOT_GRAPH_MAX_NODES = 50
+
+# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the
+# graphs generated by dot. A depth value of 3 means that only nodes reachable
+# from the root by following a path via at most 3 edges will be shown. Nodes
+# that lay further from the root node will be omitted. Note that setting this
+# option to 1 or 2 may greatly reduce the computation time needed for large
+# code bases. Also note that the size of a graph can be further restricted by
+# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction.
+
+MAX_DOT_GRAPH_DEPTH = 0
+
+# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent
+# background. This is disabled by default, which results in a white background.
+# Warning: Depending on the platform used, enabling this option may lead to
+# badly anti-aliased labels on the edges of a graph (i.e. they become hard to
+# read).
+
+DOT_TRANSPARENT = NO
+
+# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output
+# files in one run (i.e. multiple -o and -T options on the command line). This
+# makes dot run faster, but since only newer versions of dot (>1.8.10)
+# support this, this feature is disabled by default.
+
+DOT_MULTI_TARGETS = NO
+
+# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will
+# generate a legend page explaining the meaning of the various boxes and
+# arrows in the dot generated graphs.
+
+GENERATE_LEGEND = YES
+
+# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will
+# remove the intermediate dot files that are used to generate
+# the various graphs.
+
+DOT_CLEANUP = YES
+
+#---------------------------------------------------------------------------
+# Configuration::additions related to the search engine
+#---------------------------------------------------------------------------
+
+# The SEARCHENGINE tag specifies whether or not a search engine should be
+# used. If set to NO the values of all tags below this one will be ignored.
+
+SEARCHENGINE = YES
diff --git a/docs/EventAI.txt b/docs/EventAI.txt
new file mode 100644
index 0000000..7d0294d
--- /dev/null
+++ b/docs/EventAI.txt
@@ -0,0 +1,868 @@
+=============================================
+EventAI documentation: (updated May 19, 2009)
+=============================================
+
+EventAI allows users to create new creature scripts entierly within the database.
+
+For the AI to be used, you must first make sure to set AIname for each creature that should use this AI.
+UPDATE creature_template SET AIName = 'EventAI' WHERE entry IN (...);
+
+
+=========================================
+Basic structure of EventAI
+=========================================
+
+EventAI follows a basic if (Event) then do (Action) format.
+Below is the list of current fields of the creature_ai_scripts table.
+
+(Field_Name) (Description)
+id This value is merely an incrementing counter of the current Event number. Required for sql queries.
+creature_id Creature id which should trigger this event.
+
+event_type The type of event (see "Event types" below)
+event_inverse_phase_mask Mask with phases this event should NOT trigger in*
+event_chance Percentage chance of triggering the event (1 - 100)
+event_flags Event flags (repeatable, ... (see below))
+event_param1 Variables for the event (depends on event_type)
+event_param2
+event_param3
+event_param4
+
+action1_type An action to take when the event occurs (see "Action types" below)
+action1_param1 Variables used by Action1 (depends on action_type)
+action1_param2
+action1_param3
+
+action2_type
+action2_param1
+action2_param2
+action2_param3
+
+action3_type
+action3_param1
+action3_param2
+action3_param3
+
+All params are signed 32-bit values (+/- 2147483647). Time values are always in milliseconds.
+In case of a percentage value, use value/100 (ie. param = 500 then that means 500%, -50 = -50%)
+
+[*] Phase mask is a bitmask of phases which shouldn't trigger this event. (ie. Phase mask of value 12 (binary 1100) results in triggering this event in phases 0, 1 and all others with exception for phases 2 and 3 (counting from 0).
+
+
+=========================================
+Event types
+=========================================
+
+A list of event types EventAI is able to handle.
+Each event type has its own specific interpretation of the params that accompany it.
+Params are always read in the ascending order (from Param1 to Param3).
+Events will not repeat until the creature exits combat or unless EFLAG_REPEATABLE is set.
+Some events such as EVENT_T_AGGRO, EVENT_T_DEATH, EVENT_T_SPAWNED, and EVENT_T_EVADE cannot repeat.
+
+# Internal name Param usage Description
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+0 EVENT_T_TIMER InitialMin, InitialMax, RepeatMin, RepeatMax Expires at first between (Param1) and (Param2) and then between every (Param3) and (Param4), but only in combat.
+1 EVENT_T_TIMER_OOC InitialMin, InitialMax, RepeatMin, RepeatMax Expires at first between (Param1) and (Param2) and then between every (Param3) and (Param4), but only out of combat.
+2 EVENT_T_HP HPMax%, HPMin%, RepeatMin, RepeatMax Expires when HP is between (Param1) and (Param2). Will repeat every (Param3) and (Param4).
+3 EVENT_T_MANA ManaMax%,ManaMin% RepeatMin, RepeatMax Expires once Mana% is between (Param1) and (Param2). Will repeat every (Param3) and (Param4).
+4 EVENT_T_AGGRO NONE Expires upon initial aggro (does not repeat).
+5 EVENT_T_KILL RepeatMin, RepeatMax Expires upon killing a player. Will repeat between (Param1) and (Param2).
+6 EVENT_T_DEATH NONE Expires upon creature death.
+7 EVENT_T_EVADE NONE Expires upon creature EnterEvadeMode().
+8 EVENT_T_SPELLHIT SpellID, Schoolmask, RepeatMin, RepeatMax Expires upon a spell hit. When (param1) is set, it will be used as a trigger. With (param2) specified, the expiration is limited to specific spell schools (-1 for all). Will repeat every (Param3) and (Param4).
+9 EVENT_T_RANGE MinDist, MaxDist, RepeatMin, RepeatMax Expires when the highest threat target distance is greater than (Param1) and less than (Param2). Will repeat every (Param3) and (Param4).
+10 EVENT_T_OOC_LOS Hostile-or-Not, MaxAllowedRange, RepeatMin, RepeatMax Expires when a unit moves within distance (MaxAllowedRange) of a creature. If (Param1) is zero it will expire only when unit is hostile, friendly otherwise (Param1 = 1), depends generally on faction. Will repeat every (Param3) and (Param4). Does not expire when the creature is in combat.
+11 EVENT_T_SPAWNED NONE Expires on initial spawn and on creature respawn (useful for setting ranged movement type).
+12 EVENT_T_TARGET_HP HPMax%, HPMin%, RepeatMin, RepeatMax Expires when current target's HP is between (Param1) and (Param2). Will repeat every (Param3) and (Param4).
+13 EVENT_T_TARGET_CASTING RepeatMin, RepeatatMax Expires when the current target is casting a spell. Will repeat every (Param1) and (Param2).
+14 EVENT_T_FRIENDLY_HP HPDeficit, Radius, RepeatMin, RepeatMax Expires when a friendly unit in radius has at least (Param1) HP missing. Will repeat every (Param3) and (Param4).
+15 EVENT_T_FRIENDLY_IS_CC DispelType, Radius, RepeatMin, RepeatMax Expires when a friendly unit is crowd controlled within the given radius (Param2). Will repeat every (Param3) and (Param4).
+16 EVENT_T_MISSING_BUFF SpellId, Radius, RepeatMin, RepeatMax Expires when a friendly unit is missing aura(s) given by a spell (Param1) within radius (Param2). Will repeat every (Param3) and (Param4).
+17 EVENT_T_SUMMONED_UNIT CreatureId, RepeatMin, RepeatMax Expires after creature with entry = (Param1) is spawned (Param1 = 0 means all spawns). Will repeat every (Param2) and (Param3).
+18 EVENT_T_TARGET_MANA ManaMax%, ManaMin%, RepeatMin, RepeatMax
+21 EVENT_T_REACHED_HOME NONE Expires when a creature reach it's home(spawn) location after evade.
+22 EVENT_T_RECEIVE_EMOTE EmoteId, Condition, CondValue1, CondValue2 Expires when a creature receives an emote with emote text id (enum TextEmotes) in (Param1). Conditions can be defined (Param2) with optional values (Param3,Param4), see enum ConditionType.
+23 EVENT_T_BUFFED SpellID, AmmountInStack, RepeatMin, RepeatMax Expires when a creature has spell (Param1) auras applied in a stack greater or equal to value provided in (Param2). Will repeat every (Param3) and (Param4).
+24 EVENT_T_TARGET_BUFFED SpellID, AmmountInStack, RepeatMin, RepeatMax Expires when a target unit has spell (Param1) auras applied in a stack greater or equal to value provided in (Param2). Will repeat every (Param3) and (Param4).
+35 EVENT_T_RESET NONE Expires when creature leaves combat, spawns or respawns.
+
+=========================================
+Action Types
+=========================================
+
+A list of action types that EventAI can handle.
+Each event type has its own specific interpretation of it's params, like every event type.
+
+# Internal name Param usage Description
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+0 ACTION_T_NONE No Action Does nothing.
+1 ACTION_T_TEXT -TextId1, -TextId2, -TextId3 Simply displays the specified -TextId. When -TextId2 and -TextId3 are specified, the selection will be randomized. Text types are defined, along with other options for the text, in a table below. All values needs to be negative.
+2 ACTION_T_SET_FACTION FactionId Changes faction for a creature. When param1 is zero, creature will revert to it's default faction.
+3 ACTION_T_MORPH_TO_ENTRY_OR_MODEL CreatureEntry, ModelId Set either model from creature_template.entry (Param1) OR explicit modelId (Param2). If (Param1) AND (Param2) are both 0, demorph and revert to the default model.
+4 ACTION_T_SOUND SoundId Plays a sound
+5 ACTION_T_EMOTE EmoteId Does an emote
+6 ACTION_T_RANDOM_SAY UNUSED
+7 ACTION_T_RANDOM_YELL UNUSED
+8 ACTION_T_RANDOM_TEXTEMOTE UNUSED
+9 ACTION_T_RANDOM_SOUND SoundId1, SoundId2, SoundId3 Plays a random sound *
+10 ACTION_T_RANDOM_EMOTE EmoteId1, EmoteId2, EmoteId3 Emotes a random emote
+11 ACTION_T_CAST SpellId, Target, CastFlags Casts spell (Param1) on a target (Param2) using cast flags (specified below).
+12 ACTION_T_SUMMON CreatureID, Target, Duration Summons a creature (Param1) for (Param3) duration and orders it to attach (Param2) target. Spawns on top of current creature.
+13 ACTION_T_THREAT_SINGLE_PCT Threat%, Target Modifies a threat by (Param1) percent on a target (Param2).
+14 ACTION_T_THREAT_ALL_PCT Threat% Modifies a threat by (Param1) on all targets in the threat list (using -100% here will result in full aggro dump).
+15 ACTION_T_QUEST_EVENT QuestID, Target Calls AreaExploredOrEventHappens with (Param1) for a target in (Param2).
+16 ACTION_T_QUEST_CASTCREATUREGO CreatureID, SpellId, Target Sends CastCreatureOrGo for a creature specified by CreatureId (Param1) with provided spell id (Param2) for a target in (Param3).
+17 ACTION_T_SET_UNIT_FIELD Field_Number, Value, Target Sets a unit field (Param1) to provided value (Param2) on a target in (Param3).
+18 ACTION_T_SET_UNIT_FLAG Flags, Target Sets flag (flags can be used together to modify multiple flags at once) on a target (Param2).
+19 ACTION_T_REMOVE_UNIT_FLAG Flags, Target Removes flag on a target (Param2).
+20 ACTION_T_AUTO_ATTACK AllowAutoAttack Stop melee attack when (Param1) is zero, otherwise continue attacking / allow melee attack.
+21 ACTION_T_COMBAT_MOVEMENT AllowCombatMovement Stop combat based movement when (Param1) is zero, otherwise continue/allow combat based movement (targeted movement generator).
+22 ACTION_T_SET_PHASE Phase Sets the current phase to (Param1).
+23 ACTION_T_INC_PHASE Value Increments the phase by (Param1). May be negative to decrement, but should not be zero.
+24 ACTION_T_EVADE No Params Forces the creature to evade, wiping all threat and dropping combat.
+25 ACTION_T_FLEE_FOR_ASSIST No Params Causes the creature to flee for assistence (often at low health).
+26 ACTION_T_QUEST_EVENT_ALL QuestId Calls GroupEventHappens with (Param1). Only used if it's _expected_ event should call quest completion for all players in a current party.
+27 ACTION_T_CASTCREATUREGO_ALL QuestId, SpellId Calls CastedCreatureOrGo for all players on the threat list with quest id specified in (Param1) and spell id in (Param2).
+28 ACTION_T_REMOVEAURASFROMSPELL Target, Spellid Removes all auras on a target (Param1) caused by a spell (Param2).
+29 ACTION_T_RANGED_MOVEMENT Distance, Angle Changes the movement generator to a ranged type. (note: default melee type can still be set by using 0 as angle and 0 as distance).
+30 ACTION_T_RANDOM_PHASE PhaseId1, PhaseId2, PhaseId3 Sets a phase to a specified id(s)*
+31 ACTION_T_RANDOM_PHASE_RANGE PhaseMin, PhaseMax Sets a phase to a random id (Phase = PhaseMin + rnd % PhaseMin-PhaseMax). PhaseMax must be greater than PhaseMin.
+32 ACTION_T_SUMMON CreatureID, Target, SummonID Summons a creature (Param1) to attack target (Param2) at location specified by EventAI_Summons (Param3).
+33 ACTION_T_KILLED_MONSTER CreatureID, Target Calls KilledMonster (Param1) for a target (Param2).
+34 ACTION_T_SET_INST_DATA Field, Data Calls ScriptedInstance::SetData with field (Param1) and data (Param2).
+35 ACTION_T_SET_INST_DATA64 Field, Target Calls ScriptedInstance::SetData64 with field (Param1) and target's GUID (Param2).
+36 ACTION_T_UPDATE_TEMPLATE TemplateId, Team Changes a creature's template to (Param1) with team = Alliance or Horde when (Param2) is either false or true respectively.
+37 ACTION_T_DIE No Params Kills the creature
+38 ACTION_T_ZONE_COMBAT_PULSE No Params Puts all players within an instance into combat with the creature. Only works when a creature is already in combat. Doesn't work outside instances.
+39 ACTION_T_CALL_FOR_HELP Radius Call any friendly out-of-combat creatures in a radius (Param1) to attack current creature's target.
+40 ACTION_T_SET_SHEATH Sheath Sets sheath state for a creature (0 = no weapon, 1 = melee weapon, 2 = ranged weapon).
+41 ACTION_T_FORCE_DESPAWN No Params Despawns the creature
+42 ACTION_T_SET_INVINCIBILITY_HP_LEVEL hp_level, is_percent Set min. health level for creature that can be set at damage as flat value or percent from max health
+
+* = Use -1 where the param is expected to do nothing. Random constant is generated for each event, so if you have a random yell and a random sound, they will be linked up with each other (ie. param2 with param2).
+
+
+=========================================
+Event Types
+=========================================
+Note:
+COMBAT ONLY - Means that this event will only trigger durring combat.
+OUT OF COMBAT ONLY - Means that this event will only trigger while out of combat.
+BOTH - This event can trigger both in and out of combat.
+
+Events that do not have lables on them are events that are directly involved with the in and out of combat state.
+
+------------------
+0 = EVENT_T_TIMER:
+------------------
+Parameter 1: InitialMin - Minumum Time used to calculate Random Initial Expire
+Parameter 2: InitialMax - Maximum Time used to calculate Random Initial Expire
+Parameter 3: RepeatMin - Minimum Time used to calculate Random Repeat Expire
+Parameter 4: RepeatMax - Maximum Time used to calculate Random Repeat Expire
+
+COMBAT ONLY! - Expires first between (Param1) and (Param2) and then between every (Param3) and (Param4) from then on.
+This is commonly used for spells that repeat cast during combat (Simulate Spell Cooldown).
+
+----------------------
+1 = EVENT_T_TIMER_OOC:
+----------------------
+Parameter 1: InitialMin - Minumum Time used to calculate Random Initial Expire
+Parameter 2: InitialMax - Maximum Time used to calculate Random Initial Expire
+Parameter 3: RepeatMin - Minimum Time used to calculate Random Repeat Expire
+Parameter 4: RepeatMax - Maximum Time used to calculate Random Repeat Expire
+
+OUT OF COMBAT ONLY! - Expires first between (Param1) and (Param2) and then between every (Param3) and (Param4) from then on.
+This is commonly used for events that occur and repeat outside of combat.
+
+---------------
+2 = EVENT_T_HP:
+---------------
+Parameter 1: HPMax% - Maximum HP% That this Event will Expire
+Parameter 2: HPMin% - Minimum HP% That this Event will Expire
+Parameter 3: RepeatMin - Minimum Time used to calculate Random Repeat Expire
+Parameter 4: RepeatMax - Maximum Time used to calculate Random Repeat Expire
+
+BOTH - Expires when HP is between (Param1) and (Param2). Will repeat every (Param3) and (Param4).
+This is commonly used for events that trigger at a specific HP% (Such as Heal/Enrage Spells or NPC's that Flee).
+
+-----------------
+3 = EVENT_T_MANA:
+-----------------
+Parameter 1: ManaMax% - Maximum Mana% That this Event will Expire
+Parameter 2: ManaMin% - Minimum Mana% That this Event will Expire
+Parameter 3: RepeatMin - Minimum Time used to calculate Random Repeat Expire
+Parameter 4: RepeatMax - Maximum Time used to calculate Random Repeat Expire
+
+BOTH - Expires once Mana% is between (Param1) and (Param2). Will repeat every (Param3) and (Param4).
+This is commonly used for events where an NPC low on Mana will do something (Such as stop casting spells and switch to melee).
+
+------------------
+4 = EVENT_T_AGGRO:
+------------------
+This Event Expires upon initial aggro (does not repeat).
+
+-----------------
+5 = EVENT_T_KILL:
+-----------------
+Parameter 1: RepeatMin - Minimum Time used to calculate Random Repeat Expire
+Parameter 2: RepeatMax - Maximum Time used to calculate Random Repeat Expire
+
+COMBAT ONLY! - Expires upon killing a player. Will repeat every (Param1) and (Param2).
+This Event Expires upon killing a player. It is commonly used for NPC's who yell or do something after killing a player.
+
+------------------
+6 = EVENT_T_DEATH:
+------------------
+This Event Expires upon Death of the Scripted NPC.
+This is commonly used for NPC's who have a yell on death or cast some kind if summon spell when they die.
+
+------------------
+7 = EVENT_T_EVADE:
+------------------
+This Event Expires upon the creature EnterEvadeMode().
+This is commonly used for NPC's who use phases, allows you to reset their phase to 0 upon evade to prevent possible strange behavior.
+
+---------------------
+8 = EVENT_T_SPELLHIT:
+---------------------
+Parameter 1: SpellID - The Spell ID that will trigger the event to occur (NOTE: If you use Spell School as the trigger set this value to 0)
+Parameter 2: School - Spell School to trigger the event (NOTE: If you use a SpellID then set this value to -1) - *See Below for Spell School Bitmask Values*
+Parameter 3: RepeatMin - Minimum Time used to calculate Random Repeat Expire
+Parameter 4: RepeatMax - Maximum Time used to calculate Random Repeat Expire
+
+BOTH - Expires upon Spell hit. If (param1) is set will only expire on that spell OR If (param2) is set it will only expire on spells of that school. Will repeat every (Param3) and (Param4).
+This Event is commonly used for NPC's who can do special things when you cast a spell (Or specific spell) on them.
+
+(name, school, schoolmask)
+SPELL_SCHOOL_NORMAL = 0, ==> 1
+SPELL_SCHOOL_HOLY = 1, ==> 2
+SPELL_SCHOOL_FIRE = 2, ==> 4
+SPELL_SCHOOL_NATURE = 3, ==> 8
+SPELL_SCHOOL_FROST = 4, ==> 16
+SPELL_SCHOOL_SHADOW = 5, ==> 32
+SPELL_SCHOOL_ARCANE = 6, ==> 64
+Use These Values For Schoolmask (Param2) or Any Combinations Of These Schoolmasks for Multiple Schools.
+
+------------------
+9 = EVENT_T_RANGE:
+------------------
+Parameter 1: MinDist - This Distance is the Minimum Distance between the NPC and it's target to allow this Event to Expire
+Parameter 2: MaxDist - This Distance is the Maximum Distance between the NPC and it's target to allow this Event to Expire
+Parameter 3: RepeatMin - Minimum Time used to calculate Random Repeat Expire
+Parameter 4: RepeatMax - Maximum Time used to calculate Random Repeat Expire
+
+COMBAT ONLY! - Expires when the highest threat target distance is greater than (Param1) and less than (Param2). Will repeat every (Param3) and (Param4).
+This Event is commonly used for NPC's who have Ranged Combat and will Throw/Shoot between a certian distance.
+
+---------------------
+10 = EVENT_T_OOC_LOS:
+---------------------
+Parameter 1: Hostile-or-Not - This will expire if Unit are hostile. If Param1=1 it will only expire if Unit are not Hostile(generally determined by faction)
+Parameter 2: MaxAllowedRange - Expires when a Unit moves within this distance to creature
+Parameter 3: RepeatMin - Minimum Time used to calculate Random Repeat Expire
+Parameter 4: RepeatMax - Maximum Time used to calculate Random Repeat Expire
+
+OUT OF COMBAT!
+This Event is commonly used for NPC's who do something or say something to you when you walk past them Out of Combat.
+
+---------------------
+11 = EVENT_T_SPAWNED:
+---------------------
+Expires at initial spawn and at creature respawn.
+This Event is commonly used for setting ranged movement type or Summoning a Pet on Spawn
+Parameter 1: 0: works always, 1: works on map in Parameter 2, 2: works on zone/subzone in Parameter 2
+Parameter 2: depends on Parameter 1: for 1 it is map ID, for 2 it is area ID to check
+
+-----------------------
+12 = EVENT_T_TARGET_HP:
+-----------------------
+Parameter 1: HPMax% - Maximum HP% That this Event will Expire
+Parameter 2: HPMin% - Minimum HP% That this Event will Expire
+Parameter 3: RepeatMin - Minimum Time used to calculate Random Repeat Expire
+Parameter 4: RepeatMax - Maximum Time used to calculate Random Repeat Expire
+
+COMBAT ONLY! - Expires when Current NPC's Target's HP is between (Param1) and (Param2). Will repeat every (Param3) and (Param4).
+This Event is commonly used for NPC's who have a special ability (Like Execute) that only casts when a Player HP is low.
+
+----------------------------
+13 = EVENT_T_TARGET_CASTING:
+----------------------------
+Parameter 1: RepeatMin - Minimum Time used to calculate Random Repeat Expire
+Parameter 2: RepeatMax - Maximum Time used to calculate Random Repeat Expire
+
+COMBAT ONLY! - Expires when the current target is casting a spell. Will repeat every (Param1) and (Param2).
+This event is commonly used for NPC's who will cast a counter spell when their target starts to cast a spell.
+
+-------------------------
+14 = EVENT_T_FRIENDLY_HP:
+-------------------------
+Parameter 1: HPDeficit - This is the Amount of HP Missing from Full HP to trigger this event (You would need to calculate the amount of HP the event happens and subtract that from Full HP Value to get this number)
+Parameter 2: Radius - This is the Range in Yards the NPC will scan for nearby Friendlies (Faction is Friendly To) for the missing amount of HP in Param1.
+Parameter 3: RepeatMin - Minimum Time used to calculate Random Repeat Expire
+Parameter 4: RepeatMax - Maximum Time used to calculate Random Repeat Expire
+
+COMBAT ONLY! - Expires when a friendly unit in radius(param2) has at least (param1) hp missing. Will repeat every (Param3) and (Param4).
+This is commonly used when an NPC in Combat will heal a nearby Friendly NPC in Combat with a Heal/Renew Spell.
+
+----------------------------
+15 = EVENT_T_FRIENDLY_IS_CC:
+----------------------------
+Parameter 1: DispelType - Dispel Type to trigger the event - *See Below for Dispel Bitmask Values*
+Parameter 2: Radius - This is the Range in Yards the NPC will scan for nearby Friendlies being Crowd Controlled
+Parameter 3: RepeatMin - Minimum Time used to calculate Random Repeat Expire
+Parameter 4: RepeatMax - Maximum Time used to calculate Random Repeat Expire
+
+COMBAT ONLY! - Expires when a friendly unit is Crowd controlled within the given radius (param2). Will repeat every (Param3) and (Param4).
+This is commonly used for NPC's who can come to the resule of other Friendly NPC's if being Crowd Controlled
+
+--------------------------
+16 = EVENT_T_MISSING_BUFF:
+--------------------------
+Parameter 1: SpellId - This is the SpellID That the Aura Check will look for (If it is missing this Aura)
+Parameter 2: Radius - This is the Range in Yards the NPC will scan for nearby Friendlies (Faction is Friendly To) for the missing Aura.
+Parameter 3: RepeatMin - Minimum Time used to calculate Random Repeat Expire
+Parameter 4: RepeatMax - Maximum Time used to calculate Random Repeat Expire
+
+BOTH - Expires when a friendly unit is missing aura's given by spell (param1) within radius (param2). Will repeat every (Param3) and (Param4).
+This is commonly used for NPC's who watch friendly units for a debuff to end so they can recast it on them again.
+
+---------------------------
+17 = EVENT_T_SUMMONED_UNIT:
+---------------------------
+Parameter 1: CreatureId - The CreatureID that the NPC is watching to spawn to trigger this event
+Parameter 2: RepeatMin - Minimum Time used to calculate Random Repeat Expire
+Parameter 3: RepeatMax - Maximum Time used to calculate Random Repeat Expire
+
+BOTH - Expires after creature with entry(Param1) is spawned or for all spawns if param1 = 0. Will repeat every (Param2) and (Param3) .
+This is commonly used for NPC's who will do something special once another NPC is summoned. Usually used is Complex Scripts or Special Events.
+
+---------------------------
+21 = EVENT_T_REACHED_HOME:
+---------------------------
+Expires only when creature has returned to it's home location after Evade. Out of combat event.
+Most commonly used to cast spells that can not be casted in EVENT_T_EVADE and other effects that does not fit in while still running back to spawn/home location.
+
+---------------------------
+22 = EVENT_T_RECEIVE_EMOTE:
+---------------------------
+Expires only when creature receive emote from player. Valid text emote id's are in Mangos source (enum TextEmotes)
+Event does not require any conditions to process, however many are ecpected to have condition.
+
+---------------------------
+23 = EVENT_T_BUFFED :
+---------------------------
+Parameter 1: SpellId - This is the SpellID That the Aura Check will look for
+Parameter 2: Amount - This is the amount of SpellID's auras at creature required for event expire.
+Parameter 3: RepeatMin - Minimum Time used to calculate Random Repeat Expire
+Parameter 4: RepeatMax - Maximum Time used to calculate Random Repeat Expire
+
+---------------------------
+24 = EVENT_T_TARGET_BUFFED:
+---------------------------
+Parameter 1: SpellId - This is the SpellID That the Aura Check will look for
+Parameter 2: Amount - This is the amount of SpellID's auras at target unit required for event expire.
+Parameter 3: RepeatMin - Minimum Time used to calculate Random Repeat Expire
+Parameter 4: RepeatMax - Maximum Time used to calculate Random Repeat Expire
+
+EventAI use conditions from available in Mangos (enum ConditionType)
+Current implemented conditions:
+CONDITION_NONE (0) 0 0
+CONDITION_AURA (1) spell_id effindex
+CONDITION_ITEM (2) item_id count
+CONDITION_ITEM_EQUIPPED (3) item_id count
+CONDITION_ZONEID (4) zone_id 0
+CONDITION_REPUTATION_RANK (5) faction_id min_rank
+CONDITION_TEAM (6) player_team 0 (469-Alliance / 67-Horde)
+CONDITION_SKILL (7) skill_id min_skill_value
+CONDITION_QUESTREWARDED (8) quest_id 0, if quest are rewarded
+CONDITION_QUESTTAKEN (9) quest_id 0, while quest active(incomplete)
+CONDITION_ACTIVE_EVENT (12) event_id 0, note this is id from dbc, also defined in Mangos source(enum HolidayIds) NOT id of game_event in database
+
+=========================================
+Action Types
+=========================================
+
+-----------------
+1 = ACTION_T_TEXT:
+-----------------
+Parameter 1: The entry of the text that the NPC should use from eventai_texts table. Optionally a entry from other tables can be used (such as custom_texts).
+ Entry are required to be negative and exist in a *_texts-table. The type text to be displayed are defined in the texts-table itself (Say, Yell, Whisper, Emote Text, Boss Whisper, Boss Emote)
+ Other options are also to be defined in the texts-table, such as a sound to be heard with the text and the language used in output (common, dwarvish, etc).
+ In case this entry has a localized version of the text, the localized text will be displayed in client that support this locale.
+
+Parameter 2: Optional. TextId can be defined in addition. The same apply to this as explained above, however eventAI will randomize between the two.
+Parameter 3: Optional, if Parameter 2 exist. In this case, eventAI will randomize between three.
+
+Read at bottom for documentation of creature_ai_texts-table.
+
+------------------
+2 = ACTION_T_SET_FACTION:
+------------------
+Parameter 1: FactionId from Faction.dbc OR 0. Changes faction for creature. If 0, creature will revert to it's default faction if previously changed.
+
+-----------------------
+3 = ACTION_T_MORPH_TO_ENTRY_OR_MODEL:
+-----------------------
+Parameter 1: Creature entry from creature_template. Action will then change to the model this creature are using.
+Parameter 2: If parameter 1 is 0, then this modelId will be used (in case parameter 1 exist, parameter 2 will not be used)
+
+If both parameter 1 and 2 is 0, the creature will DeMorph, and use it's default model.
+
+-------------------
+4 = ACTION_T_SOUND:
+-------------------
+Parameter 1: The Sound ID to be played. (Sound IDs are contained in the DBC files.)
+
+The creature will play the specified sound.
+This is commonly used for Bosses who Yell and then also have a Voice for the same thing.
+
+-------------------
+5 = ACTION_T_EMOTE:
+-------------------
+Parameter 1: The Emote ID that the creature should perform. (Emote IDs are also contained in the DBC but they can be found in the mangos source as well).
+
+The creature will perform a visual emote. Unlike a text emote, a visual emote is one where the creature will actually move or perform a gesture.
+This is commonly used for NPC's who may perform a special action (Salute, Roar, ect...). Not all player emotes work for creature models.
+
+------------------------
+6 = ACTION_T_RANDOM_SAY:
+------------------------
+UNUSED Can be reused to create new action type
+
+-------------------------
+7 = ACTION_T_RANDOM_YELL:
+-------------------------
+UNUSED Can be reused to create new action type
+
+------------------------------
+8 = ACTION_T_RANDOM_TEXTEMOTE:
+------------------------------
+UNUSED Can be reused to create new action type
+
+--------------------------
+9 = ACTION_T_RANDOM_SOUND:
+--------------------------
+Parameter 1: The Sound ID to be played as Random Choice #1.
+Parameter 2: The Sound ID to be played as Random Choice #2.
+Parameter 3: The Sound ID to be played as Random Choice #3.
+
+Similar to the ACTION_T_SOUND action, it will choose at random a sound to play.
+
+---------------------------
+10 = ACTION_T_RANDOM_EMOTE:
+---------------------------
+Parameter 1: The Emote ID to be played as Random Choice #1.
+Parameter 2: The Emote ID to be played as Random Choice #2.
+Parameter 3: The Emote ID to be played as Random Choice #3.
+
+Similar to the ACTION_T_EMOTE action, it will choose at random an Emote to Visually Perform.
+
+-------------------
+11 = ACTION_T_CAST:
+-------------------
+Parameter 1: SpellId - The Spell ID to use for the NPC to cast. The value used in this field needs to be a valid Spell ID.
+Parameter 2: Target - The Target Type defining who the creature should cast the spell at. The value in this field needs to be a valid Target Type as specified in the reference tables below.
+Parameter 3: CastFlags - See Table Below for Cast Flag Bitmask Values. If you are unsure what to set this value at leave it at 0.
+
+The creature will cast a spell specified by a spell ID on a target specified by the target type.
+This is commonly used for NPC's who cast spells.
+
+---------------------
+12 = ACTION_T_SUMMON:
+---------------------
+Parameter 1: CreatureID - The Creature Template ID to be Summoned. The value here needs to be a valid Creature Template ID.
+Parameter 2: Target - The Target Type defining who the Summoned creature will attack once spawned. The value in this field needs to be a valid Target Type as specified in the reference tables below.
+Parameter 3: Duration - The duration until the summoned creature should be unsummoned AFTER Combat ends. The value in this field is in milliseconds or 0.
+
+The NPC will Summon another creature at the same spot as itself that will attack the specified target.
+NOTE: Almost all Creature Summons have proper Summon Spells that should be used when possible. This Action is a powerful last resort option only to be used if nothing else works.
+NOTE: Using Target Type 0 will cause the Summoned creature to not attack anyone.
+NOTE: If Duration is set at 0, then the summoned creature will not despawn until it has died.
+This is used as a manual way to force an NPC to Summon.
+--------------------------------
+13 = ACTION_T_THREAT_SINGLE_PCT:
+--------------------------------
+Parameter 1: Threat% - Threat percent that should be modified. The value in this field can range from -100 to +100. If it is negative, threat will be taken away and if positive, threat will be added.
+Parameter 2: Target - The Target Type defining on whom the threat change should occur. The value in this field needs to be a valid target type as specified in the reference tables below.
+
+This action will modify the threat of a target in the creature's threat list by the specified percent.
+This is commonly used to allow an NPC to adjust the Threat to a single player.
+
+-----------------------------
+14 = ACTION_T_THREAT_ALL_PCT:
+-----------------------------
+Parameter 1: Threat% - The percent that should be used in modifying everyone's threat in the creature's threat list. The value here can range from -100 to +100.
+
+This action will modify the threat for everyone in the creature's threat list by the specified percent.
+NOTE: Using -100 will cause the creature to reset everyone's threat to 0 so that everyone has the same amount of threat. It will NOT remove anyone from the threat list.
+This is commonly used to allow an NPC to drop threat for all players to zero.
+
+--------------------------
+15 = ACTION_T_QUEST_EVENT:
+--------------------------
+Parameter 1: QuestID - The Quest Template ID. The value here must be a valid quest template ID. Furthermore, the quest should have SpecialFlags | 2 as it would need to be completed by an external event which is the activation of this action.
+Parameter 2: Target - The Target Type defining whom the quest should be completed for. The value in this field needs to be a valid target type as specified in the reference tables below.
+
+This action will satisfy the external completion requirement for the quest for the specified target defined by the target type.
+NOTE: This action can only be used with player targets so it must be ensured that the target type will point to a player.
+This is commonly used for Quests where only ONE player will gain credit for the quest.
+
+-----------------------------
+16 = ACTION_T_CASTCREATUREGO:
+-----------------------------
+Parameter 1: CreatureID - The Creature Template ID to be Summoned. The value here needs to be a valid Creature Template ID.
+Parameter 2: SpellId - The Spell ID to use to simulate the cast. The value used in this field needs to be a valid Spell ID.
+Parameter 3: Target - The Target Type defining whom the quest credit should be given to. The value in this field needs to be a valid target type as specified in the reference tables below.
+
+This action will call CastedCreatureOrGO() function for the player. It can be used to give quest credit for casting a spell on the creature.
+This is commonly used for NPC's who have a special requirement to have a Spell cast on them to complete a quest.
+
+-----------------------------
+17 = ACTION_T_SET_UNIT_FIELD:
+-----------------------------
+Parameter 1: Field_Number - The index of the Field Number to be changed. Use (http://wiki.udbforums.org/index.php/Character_data) for a list of indeces and what they control. Creatures only contain the OBJECT_FIELD_* and UNIT_FIELD_* fields. They do not contain the PLAYER_FIELD_* fields.
+Parameter 2: Value - The new value to be put in the field.
+Parameter 3: Target - The Target Type defining for whom the unit field should be changed. The value in this field needs to be a valid target type as specified in the reference tables below.
+
+When activated, this action can change the target's unit field values. More information on the field value indeces can be found at (http://wiki.udbforums.org/index.php/Character_data)
+
+----------------------------
+18 = ACTION_T_SET_UNIT_FLAG:
+----------------------------
+Parameter 1: Flags - The flag(s) to be set. Multiple flags can be set by using bitwise-OR on them (adding them together).
+Parameter 2: Target - The Target Type defining for whom the flags should be changed. The value in this field needs to be a valid Target Type as specified in the reference tables below.
+
+When activated, this action changes the target's flags by adding (turning on) more flags. For example, this action can make the creature unattackable/unselectable if the right flags are used.
+
+-------------------------------
+19 = ACTION_T_REMOVE_UNIT_FLAG:
+-------------------------------
+Parameter 1: Flags - The flag(s) to be removed. Multiple flags can be set by using bitwise-OR on them (adding them together).
+Parameter 2: Target - The target type defining for whom the flags should be changed. The value in this field needs to be a valid Target Type as specified in the reference tables below.
+
+When activated, this action changes the target's flags by removing (turning off) flags. For example, this action can make the creature normal after it was unattackable/unselectable if the right flags are used.
+
+--------------------------
+20 = ACTION_T_AUTO_ATTACK:
+--------------------------
+Parameter 1: AllowAutoAttack - If zero, then the creature will stop its melee attacks. If non-zero, then the creature will either continue its melee attacks (the action would then have no effect) or it will start its melee attacks on the target with the top threat if its melee attacks were previously stopped.
+
+This action controls whether or not the creature should stop or start the auto melee attack.
+NOTE: The ACID Dev Team has conformed to using either 0 or 1 for the Param values (0 = Stop Melee, 1 = Start Melee).
+This is commonly used in combination with EVENT_T_RANGE and ACTION_T_COMBAT_MOVEMENT for Ranged Combat for Mages and Spell Casters.
+
+------------------------------
+21 = ACTION_T_COMBAT_MOVEMENT:
+------------------------------
+Parameter 1: If zero, then the creature will stop moving towards its victim (if its victim gets out of melee range) and will be stationary. If non-zero, then the creature will either continue to follow its victim (the action would have no effect) or it will start to follow the target with the top threat if its movement was disabled before.
+Parameter 2: If non-zero, then stop melee combat state (if param1=0) or start melee combat state (if param1!=0) and creature in combat with selected target.
+
+This action controls whether or not the creature will always move towards its target.
+NOTE: The ACID Dev Team has conformed to using either 0 or 1 for the Param values. (0 = Stop Movement, 1 = Start Movement)
+This is commonly used with EVENT_T_RANGE and ACTION_T_AUTO_ATTACK for NPC's who engage in Ranged Comabt (Either Spells or Ranged Attacks)
+Parameter 2 specialy used for ranged combat proper client side visual show ranged weapon in proper state.
+
+------------------------
+22 = ACTION_T_SET_PHASE:
+------------------------
+Parameter 1: The new phase to set the creature in. This number must be an integer between 0 and 31. Numbers outside of that range will result in an error.
+
+When activated, this action sets the creature's event to the specified value.
+NOTE: The creature's current Phase is NOT reset at creature evade. You must manually set the phase back to 0 at EVENT_T_RESET.
+NOTE: The value used for the Param is the actual Phase Number (Not The Event_Inverse_Phase_Mask)
+This is commonly used for complex scripts with several phases and you need to switch to a different phase.
+
+------------------------
+23 = ACTION_T_INC_PHASE:
+------------------------
+Parameter 1: Value - The number of phases to increase or decrease. Use negative values to decrease the current phase.
+
+When activated, this action will increase (or decrease) the current creature's phase.
+NOTE: After increasing or decreasing the phase by this action, the current phase must NOT be lower than 0 or exceed 31.
+This can be used instead of ACTION_T_SET_PHASE to change phases in scripts. Just a user friendly option for changing phases.
+
+--------------------
+24 = ACTION_T_EVADE:
+--------------------
+When activated, the creature will immediately exit out of combat, clear its threat list, and move back to its spawn point. Basically, this action will reset the whole encounter.
+NOTE: All Param Values Are 0 for this Action.
+
+-------------------
+25 = ACTION_T_FLEE:
+-------------------
+When activated, the creature will try to flee from combat. Currently this is done by it casting a fear-like spell on itself called "Run Away".
+A Better Flee system is in Development.
+NOTE: All Param Values Are 0 for this Action.
+
+------------------------------
+26 = ACTION_T_QUEST_EVENT_ALL:
+------------------------------
+Parameter 1: QuestId - The quest ID to finish for everyone.
+
+This action does the same thing as the ACTION_T_QUEST_EVENT does but it does it for all players in the creature's threat list.
+NOTE: If a player is not in the NPC's threat list for whatever reason, he/she won't get the quest completed.
+
+---------------------------------
+27 = ACTION_T_CASTCREATUREGO_ALL:
+---------------------------------
+Parameter 1: QuestId - The quest template ID.
+Parameter 2: SpellId - The spell ID used to simulate the cast.
+
+This action does the same thing as the ACTION_T_CASTCREATUREGO does but it does it for all players in the creature's threat list.
+NOTE: If a player is not in its threat list for whatever reason, he/she won't receive the cast emulation.
+
+-----------------------------------
+28 = ACTION_T_REMOVEAURASFROMSPELL:
+-----------------------------------
+Parameter 1: Target - The target type defining for whom the unit field should be changed. The value in this field needs to be a valid target type as specified in the reference tables below.
+Parameter 2: SpellId - The spell ID whose auras will be removed.
+
+This action will remove all auras from a specific spell from the target.
+This is commonly used for NPC's who have an OOC Aura that is removed at combat start or a similar idea (Like Stealth or Shape Shift)
+
+------------------------------
+29 = ACTION_T_RANGED_MOVEMENT:
+------------------------------
+Parameter 1: Distance - The distance the mob should keep between it and its target.
+Parameter 2: Angle - The angle the mob should use.
+
+This action changes the movement type generator to ranged type using the specified values for angle and distance.
+NOTE: Specifying zero angle and distance will make it just melee instead.
+This is commonly used for NPC's who always attack at range and you can specify the distance they will maintain from the target.
+
+---------------------------
+30 = ACTION_T_RANDOM_PHASE:
+---------------------------
+Parameter 1: PhaseId1 - A possible random phase choice.
+Parameter 2: PhaseId2 - A possible random phase choice.
+Parameter 3: PhaseId3 - A possible random phase choice.
+
+Randomly sets the phase to one from the three parameter choices.
+NOTE: Use -1 to specify that if this param is picked to do nothing. Random is constant between actions within an event. So if you have a random Yell and a random Sound they will match up (ex: param2 with param2)
+NOTE 2: PLEASE NOTE THAT EACH OF THE PARAM VALUES ARE ACTUAL PHASE NUMBERS NOT THE INVERSE PHASE MASK VALUE.
+This is commonly used for Spellcasting NPC's who on Aggro may select at random a school of spells to use for the fight. Use this if you have up to 3 phases used, otherwise use Action 31 for more then 3 phases.
+
+---------------------------------
+31 = ACTION_T_RANDOM_PHASE_RANGE:
+---------------------------------
+Parameter 1: PhaseMin - The minimum of the phase range.
+Parameter 2: PhaseMax - The maximum of the phase range. The number here must be greater than PhaseMin.
+
+Randomly sets the phase between a range of phases controlled by the parameters. Sets the phase to a random id (Phase = PhaseMin + rnd % PhaseMin-PhaseMax).
+NOTE: PhaseMax must be greater than PhaseMin.
+NOTE 2: PLEASE NOTE THAT EACH OF THE PARAM VALUES ARE ACTUAL PHASE NUMBERS NOT THE INVERSE PHASE MASK VALUE.
+This is commonly used for Spellcasting NPC's who on Aggro may select at random a school of spells to use for the fight. Use this if you have MORE then 3 phases used, otherwise use Action 30.
+
+---------------------
+32 = ACTION_T_SUMMON:
+---------------------
+Parameter 1: CreatureID - The creature template ID to be summoned. The value here needs to be a valid creature template ID.
+Parameter 2: Target - The target type defining who the summoned creature will attack. The value in this field needs to be a valid target type as specified in the reference tables below. NOTE: Using target type 0 will cause the summoned creature to not attack anyone.
+Parameter 3: SummonID - The summon ID from the creature_ai_summons table controlling the position (and spawntime) where the summoned mob should be spawned at.
+
+Summons creature (param1) to attack target (param2) at location specified by creature_ai_summons (param3).
+NOTE: Param3 Value is the ID Value used for the entry used in creature_ai_summons for this action. You MUST have an creature_ai_summons entry to use this action.
+This is commonly used for NPC's who need to Summon a creature at a specific location. (Normally used for complex events)
+
+-----------------------------
+33 = ACTION_T_KILLED_MONSTER:
+-----------------------------
+Parameter 1: CreatureID - The creature template ID. The value here must be a valid creature template ID.
+Parameter 2: Target - The target type defining whom the quest kill count should be given to. The value in this field needs to be a valid target type as specified in the reference tables below.
+
+When activated, this action will call KilledMonster() function for the player. It can be used to give creature credit for killing a creature. In general if the quest is set to be accompished on different creatures (e.g. "Credit" templates).
+NOTE: It can be ANY creature including certain quest specific triggers
+This is commonly used for giving the player Quest Credits for NPC kills (Many NPC's may use the same CreatureID for the Kill Credit)
+
+----------------------------
+34 = ACTION_T_SET_INST_DATA:
+----------------------------
+Parameter 1: Field - The field to change in the instance script. Again, this field needs to be a valid field that has been already defined in the instance's script.
+Parameter 2: Data - The value to put at that field index.
+
+Sets data for the instance. Note that this will only work when the creature is inside an instantiable zone that has a valid script (ScriptedInstance) assigned.
+This is commonly used to link an EventAI script with a existing Script Library C++ Script. You make make things happen like opening doors on specific events that happen.
+
+------------------------------
+35 = ACTION_T_SET_INST_DATA64:
+------------------------------
+Parameter 1: Field - The field to change in the instance script. Again, this field needs to be a valid field that has been already defined in the instance's script.
+Parameter 2: Target - The target type to use to get the GUID that will be stored at the field index. The value in this field needs to be a valid target type as specified in the reference tables below.
+
+Sets GUID (64 bits) data for the instance based on the target. Note that this will only work when the creature is inside an instantiable zone that has a valid script (ScriptedInstance) assigned.
+Calls ScriptedInstance::SetData64 with field (param1) and data (param2) target's GUID.
+
+------------------------------
+36 = ACTION_T_UPDATE_TEMPLATE:
+------------------------------
+Parameter 1: TemplateId - The creature template ID. The value here must be a valid creature template ID.
+Parameter 2: Team - Use model_id from team : Alliance(0) or Horde (1).
+
+This function temporarily changes creature entry to new entry, display is changed, loot is changed, but AI is not changed. At respawn creature will be reverted to original entry.
+Changes the creature to a new creature template of (param1) with team = Alliance if (param2) = false or Horde if (param2) = true
+
+------------------
+37 = ACTION_T_DIE:
+------------------
+Kills the creature
+This is commonly used if you need to Instakill the creature for one reason or another.
+
+--------------------------------
+38 = ACTION_T_ZONE_COMBAT_PULSE:
+--------------------------------
+Places all players within the instance into combat with the creature. Only works in combat and only works inside of instances.
+
+----------------------------
+39 = ACTION_T_CALL_FOR_HELP:
+----------------------------
+Parameter 1: Radius - All friendly (not only same faction) creatures will go to help
+
+Call any friendly creatures (if its not in combat/etc) in radius attack creature target.
+Mostly used when call to help more wide that normal aggro radius or auto-used call for assistance, and need apply at some event.
+
+-------------------------
+40 ACTION_T_SET_SHEATH:
+-------------------------
+Parameter 1: Sheath state
+0 SHEATH_STATE_UNARMED not prepared weapon show (not used mostly by creatures)
+1 SHEATH_STATE_MELEE melee weapon prepared show
+2 SHEATH_STATE_RANGED ranged weapon prepared show
+
+Let set sheath state for creature.
+Note: SHEATH_STATE_RANGED case work in combat state only if combat not start as melee commands.
+This possible setup by set ar event AI start (single used EVENT_T_TIMER_OOC set ACTION_T_COMBAT_MOVEMENT 0 for creature that prefered ranged attack)
+
+-------------------------
+41 ACTION_T_FORCE_DESPAWN
+-------------------------
+Despawns the creature (in or out of combat)
+No parameters
+
+-------------------------
+42 ACTION_T_SET_INVINCIBILITY_HP_LEVEL
+-------------------------
+Parameter 1: min. health level for creature that can be set at damage, 0 used as absent min. health value for apply damage.
+Parameter 2: format of paramater 1 value
+0 paramater 1 used as flat value
+1 paramater 1 used as percent (0..100) from creature max health
+
+=========================================
+Target Types
+=========================================
+Below is the list of current Target types that EventAI can handle.
+Target types are used by certain actions and may effect actions differently
+
+(# Internal Name Discription)
+0 TARGET_T_SELF Self cast
+1 TARGET_T_HOSTILE Our current target (ie: highest aggro)
+2 TARGET_T_HOSTILE_SECOND_AGGRO Second highest aggro (generaly used for cleaves and some special attacks)
+3 TARGET_T_HOSTILE_LAST_AGGRO Dead last on aggro (no idea what this could be used for)
+4 TARGET_T_HOSTILE_RANDOM Just any random target on our threat list
+5 TARGET_T_HOSTILE_RANDOM_NOT_TOP Any random target except top threat
+6 TARGET_T_ACTION_INVOKER Unit who caused this Event to occur (only works for EVENT_T_AGGRO, EVENT_T_KILL, EVENT_T_DEATH, EVENT_T_SPELLHIT, EVENT_T_OOC_LOS, EVENT_T_FRIENDLY_HP)
+
+=========================================
+Cast Flags
+=========================================
+Below is the list of current Cast Flags that EventAI's spell casting can handle.
+Cast flags are handled bitwise. Bit 0 is Interrupt Previous, bit 1 is triggered, etc.
+So for example the number "3" (11 in Binary, selecting first 2 options) would mean that this cast has both CAST_INTURRUPT_PREVIOUS and CAST_TRIGGERED.
+Another example: the number "5" (101 in Binary, selecting first and third options) would mean that this cast has CAST_INTURRUPT_PREVIOUS and CAST_FORCE_CAST.
+
+(bit# Decimal Internal Name Discription)
+0 1 CAST_INTURRUPT_PREVIOUS Interrupts any previous spell casting (basicaly makes sure that this spell goes off)
+1 2 CAST_TRIGGERED Forces the spell to be instant cast and require no mana/reagents.
+2 4 CAST_FORCE_CAST Forces spell to cast even if the target is possibly out of range or the creature is possibly out of mana
+3 8 CAST_NO_MELEE_IF_OOM Prevents creature from entering melee if out of mana or out of range
+4 16 CAST_FORCE_TARGET_SELF Forces the target to cast this spell on itself
+5 32 CAST_AURA_NOT_PRESENT Only casts the spell on the target if the target does not have the aura from that spell on itself already.
+
+NOTE: You can add the numbers in the decimal column to combine flags.
+ For example if you wanted to use CAST_NO_MELEE_IF_OOM(8) and CAST_TRIGGERED(2) you would simply use 10 in the cast flags field (8 + 2 = 10).
+
+=========================================
+Event Flags
+=========================================
+Below is the list of current Event Flags that EventAI can handle. Event flags are handled bitwise.
+
+(bit# Decimal Internal Name Discription)
+0 1 EFLAG_REPEATABLE Event repeats (Does not repeat if this flag is not set)
+1 2 EFLAG_NORMAL Event occurs in Normal instance difficulty (will not occur in Normal if not set)
+2 4 EFLAG_HEROIC Event occurs in Heroic instance difficulty (will not occur in Heroic if not set)
+3 8
+4 16
+5 32
+6 64
+7 128 EFLAG_DEBUG_ONLY Prevents events from occuring on Release builds. Useful for testing new features.
+
+NOTE: You can add the numbers in the decimal column to combine flags.
+
+
+=========================================
+Basic Structure of creature_ai_texts
+=========================================
+Below is a the list of current fields within the texts tables.
+
+Field_Name Description
+-----------------------------------------------------------
+entry This value is mearly an NEGATIVE identifier of the current text number. Required for sql queries. Valid range are -1 to -999999
+content_default This is the actual text presented in the default language (English).
+
+content_loc1 This is the actual text presented in the Localization #1 Clients (Korean)
+content_loc2 This is the actual text presented in the Localization #2 Clients (French)
+content_loc3 This is the actual text presented in the Localization #3 Clients (German)
+content_loc4 This is the actual text presented in the Localization #4 Clients (Chinese)
+content_loc5 This is the actual text presented in the Localization #5 Clients (Taiwanese)
+content_loc6 This is the actual text presented in the Localization #6 Clients (Spanish)
+content_loc7 This is the actual text presented in the Localization #7 Clients (Spanish Mexico)
+content_loc8 This is the actual text presented in the Localization #8 Clients (Russian)
+
+sound This value is the Sound ID that corresponds to the actual text used.
+type Variables used to define type of text (Say/Yell/Textemote/Whisper).
+language This value is the Language that the text is native in.
+emote Value from enum Emote. Only source of text will play this emote (not target, if target are defined in DoScriptText)
+comment This is a comment regarding the text entry
+
+Note: Fields `content_loc1` to `content_loc8` are NULL values by default and are normally handled by seperate localization projects.
+
+=========================================
+Text Types (type)
+=========================================
+Below is the list of current Text types that texts tables can handle. These were previously seperate Actions in ACID.
+
+# Internal Name Description
+-----------------------------------------------------------
+0 CHAT_TYPE_SAY This type sets the text to be displayed as a Say (Speech Bubble).
+1 CHAT_TYPE_YELL This type sets the text to be displayed as a Yell (Red Speech Bubble) and usually has a matching Sound ID.
+2 CHAT_TYPE_TEXT_EMOTE This type sets the text to be displayed as a text emote in orange in the chat log.
+3 CHAT_TYPE_BOSS_EMOTE This type sets the text to be displayed as a text emote in orange in the chat log (Used only for specific Bosses).
+4 CHAT_TYPE_WHISPER This type sets the text to be displayed as a whisper to the player in the chat log.
+5 CHAT_TYPE_BOSS_WHISPER This type sets the text to be displayed as a whisper to the player in the chat log (Used only for specific Bosses).
+6 CHAT_TYPE_ZONE_YELL Same as CHAT_TYPE_YELL but will display to all players in current zone.
+
+=========================================
+Language Types (language)
+=========================================
+Below is the list of current Language types that are allowed.
+This is the Race Language that the text is native to (So it will display properly)
+
+# Internal Name Description
+-----------------------------------------------------------
+0 UNIVERSAL Text in this language is understood by ALL Races.
+1 ORCISH Text in this language is understood ONLY by Horde Races.
+2 DARNASSIAN Text in this language is understood ONLY by the Night Elf Race.
+3 TAURAHE Text in this language is understood ONLY by the Tauren Race.
+6 DWARVISH Text in this language is understood ONLY by the Dwarf Race.
+7 COMMON Text in this language is understood ONLY by Alliance Races.
+8 DEMONIC Text in this language is understood ONLY by the Demon Race (Not Implimented).
+9 TITAN This language was used by Sargeras to speak with other Titians (Not Implemented).
+10 THALASSIAN Text in this language is understood ONLY by the Blood Elf Race.
+11 DRACONIC Text in this language is understood ONLY by the Dragon Race.
+12 KALIMAG Text will display as Kalimag (not readable by players, language of all elementals)
+13 GNOMISH Text in this language is understood ONLY by the Gnome Race.
+14 TROLL Text in this language is understood ONLY by the Troll Race.
+33 GUTTERSPEAK Text in this language is understood ONLY by the Undead Race.
+35 DRAENEI Text in this language is understood ONLY by the Draenai Race.
+36 ZOMBIE (not currently used?)
+37 GNOMISH BINARY Binary language used by Alliance when drinking Binary Brew
+38 GOBLIN BINARY Binary language used by Horce when drinking Binary Brew
diff --git a/docs/HowToScript.txt b/docs/HowToScript.txt
new file mode 100644
index 0000000..73968a0
--- /dev/null
+++ b/docs/HowToScript.txt
@@ -0,0 +1,27 @@
+
+** HOW TO SCRIPT IN C++ **
+
+1 - create a file myscript.cpp in scripts folder.
+2 - copy the content of script_default.cpp, it as the structure on how the scripting fuctions are organized.
+ dont forget to change the name of fuctions, like GossipHello_default to GossipHello_myscript.
+
+3 - in fuction AddSC_default change to AddSC_myscript.
+4 - newscript->Name="default"; change the string to "myscript" this name is the one to be called from the db
+5 - dont forget to change the name in here to newscript->pGossipHello = &GossipHello_default; this is where the scripted fuctions are stored.
+6 - and last thing is in ScriptMgr.cpp
+
+add your AddSC_myscript in here
+
+// -- Scripts to be added --
+extern void AddSC_default();
+// -------------------
+
+and here
+
+// -- Inicialize the Scripts to be Added --
+ AddSC_default();
+// ----------------------------------------
+
+now start using the player fuctions to script ;)
+
+hope it helps, any question use our forum.
\ No newline at end of file
diff --git a/docs/TextTables.txt b/docs/TextTables.txt
new file mode 100644
index 0000000..eac6338
--- /dev/null
+++ b/docs/TextTables.txt
@@ -0,0 +1,87 @@
+=========================================
+Texts Documentation
+=========================================
+
+Scriptdev2 Revision 695 introduces a new format for using texts in EventAI and SD2 Scripts.
+This information relates to the *_texts tables located in the ScriptDev Database.
+
+Any script can at any time access and use text from any of the three text tables, as long as the entry does in fact exist.
+Custom scripters are adviced to store their text data in custom_texts.
+
+The different tables has ranges of entries allowed for that table.
+Reserved EventAI in Mangos entry -1 -> -999999
+script_texts: entry -1000000 -> -1999999
+custom_texts: entry -2000000 -> -2999999
+Any entry out of range for that table will display a startup error.
+
+
+=========================================
+Basic Structure of script_texts and custom_texts
+=========================================
+Below is a the list of current fields within the texts tables.
+
+Field_Name Description
+-----------------------------------------------------------
+entry This value is mearly an NEGATIVE identifier of the current text number. Required for sql queries.
+content_default This is the actual text presented in the default language (English).
+
+content_loc1 This is the actual text presented in the Localization #1 Clients (Korean)
+content_loc2 This is the actual text presented in the Localization #2 Clients (French)
+content_loc3 This is the actual text presented in the Localization #3 Clients (German)
+content_loc4 This is the actual text presented in the Localization #4 Clients (Chinese)
+content_loc5 This is the actual text presented in the Localization #5 Clients (Taiwanese)
+content_loc6 This is the actual text presented in the Localization #6 Clients (Spanish)
+content_loc7 This is the actual text presented in the Localization #7 Clients (Spanish Mexico)
+content_loc8 This is the actual text presented in the Localization #8 Clients (Russian)
+
+sound This value is the Sound ID that corresponds to the actual text used (Defined in SoundEntries.dbc).
+type Variables used to define type of text (Say/Yell/Textemote/Whisper).
+language This value is the Language that the text is native in (Defined in Languages.dbc).
+emote Value from enum Emote (defined in Emotes.dbc). Only source of text will play this emote (not target, if target are defined in DoScriptText)
+comment This is a comment regarding the text entry (For ACID, accepted format is to use Creature ID of NPC using it).
+
+Note: Fields `content_loc1` to `content_loc8` are NULL values by default and are handled by seperate localization projects.
+
+
+=========================================
+Text Types (type)
+=========================================
+Below is the list of current Text types that texts tables can handle. These were previously seperate Actions in ACID.
+
+# Internal Name Description
+-----------------------------------------------------------
+0 CHAT_TYPE_SAY This type sets the text to be displayed as a Say (Speech Bubble).
+1 CHAT_TYPE_YELL This type sets the text to be displayed as a Yell (Red Speech Bubble) and usually has a matching Sound ID.
+2 CHAT_TYPE_TEXT_EMOTE This type sets the text to be displayed as a text emote in orange in the chat log.
+3 CHAT_TYPE_BOSS_EMOTE This type sets the text to be displayed as a text emote in orange in the chat log (Used only for specific Bosses).
+4 CHAT_TYPE_WHISPER This type sets the text to be displayed as a whisper to the player in the chat log.
+5 CHAT_TYPE_BOSS_WHISPER This type sets the text to be displayed as a whisper to the player in the chat log (Used only for specific Bosses).
+6 CHAT_TYPE_ZONE_YELL Same as CHAT_TYPE_YELL but will display to all players in current zone.
+
+
+=========================================
+Language Types (language)
+=========================================
+Below is the list of current Language types that are allowed.
+This is the Race Language that the text is native to (So it will display properly)
+
+# Internal Name Description
+-----------------------------------------------------------
+0 UNIVERSAL Text in this language is understood by ALL Races.
+1 ORCISH Text in this language is understood ONLY by Horde Races.
+2 DARNASSIAN Text in this language is understood ONLY by the Night Elf Race.
+3 TAURAHE Text in this language is understood ONLY by the Tauren Race.
+6 DWARVISH Text in this language is understood ONLY by the Dwarf Race.
+7 COMMON Text in this language is understood ONLY by Alliance Races.
+8 DEMONIC Text in this language is understood ONLY by the Demon Race (Not Implimented).
+9 TITAN This language was used by Sargeras to speak with other Titians (Not Implemented).
+10 THALASSIAN Text in this language is understood ONLY by the Blood Elf Race.
+11 DRACONIC Text in this language is understood ONLY by the Dragon Race.
+12 KALIMAG Text will display as Kalimag (not readable by players, language of all elementals)
+13 GNOMISH Text in this language is understood ONLY by the Gnome Race.
+14 TROLL Text in this language is understood ONLY by the Troll Race.
+33 GUTTERSPEAK Text in this language is understood ONLY by the Undead Race.
+35 DRAENEI Text in this language is understood ONLY by the Draenai Race.
+36 ZOMBIE (not currently used?)
+37 GNOMISH BINARY Binary language used by Alliance when drinking Binary Brew
+38 GOBLIN BINARY Binary language used by Horce when drinking Binary Brew
\ No newline at end of file
diff --git a/docs/UnixInstall.txt b/docs/UnixInstall.txt
new file mode 100644
index 0000000..0509c84
--- /dev/null
+++ b/docs/UnixInstall.txt
@@ -0,0 +1,61 @@
+= TrinityCore -- Linux installation =
+
+Copyright (C) Trinity Core (http://www.trinitycore.org)
+
+CHECK http://www.trinitycore.info/w/Linux_Build_HOWTO FOR FURTHER HELP
+
+Installing Trinity Core is fairly simple on a Linux machine, assuming
+you have all required applications
+
+The most important ones are:
+
+ g++
+ gcc
+ make
+ cmake version 2.6.x or greater
+ libmysql++-dev
+ subversion (for checking out Trinity Database)
+ mercurial (for checking out the core)
+ openssl
+ libssl-dev
+ zlib1g-dev
+ libtool
+ libmysqlclient15-dev
+ patch
+ build-essential
+ mysql-client
+
+Most of these are included on common Linux distros, others you may have to install by your self.
+Please check your distro's repos.
+
+Make a directory to build in, you can call it anything you want like build or bin etc, then go into
+the directory and cmake and make. E.G. you created a dir named build ad want to have your final
+ compiled product installed in /home/trinity/server, an example sequence of commands can be :
+
+ cmake /root/wow/ -DPREFIX=/opt/trinity -DDO_DEBUG=1 -DCMAKE_C_FLAGS="-m32 -D_LARGEFILE_SOURCE -DFD_SETSIZE=131072 -march=prescott -ggdb3 -g3 -pipe -fno-strength-reduce -fno-delete-null-pointer-checks -fno-strict-aliasing -frename-registers"
+ make
+ make install
+
+Thats just about all thats needed. You can however tweak more settings than where to install using flags built into our cmake files. Just open up CMakeLists.txt in the main folder and take a look at some of the flags like
+
+ DO_MYSQL --mysql database support (enabled or disabled by a 1 or 0, enabled by default)
+ DO_SCRIPTS --enable or disable trinity script (enabled or disabled by a 1 or 0, enabled by default)
+ DO_RA --remote administration (enabled or disabled by a 1 or 0)
+ DO_DEBUG --enable debugging (enabled or disabled by a 1 or 0)
+ DO_CLI --enable command line support (enabled or disabled by a 1 or 0, enabled by default)
+ LARGE_CELL --enable large cells (enabled or disabled by a 1 or 0, disabled by default, enabling can cause CPU spikes)
+ SHORT_SLEEP --changes sleep time from 100ms to 50ms
+ PREFIX --prefix directory for install (see example for use)
+ CONF_DIR --location for your trinity config files
+ CMAKE_C_FLAGS --advanced users only
+ CMAKE_CXX_FLAGS --advanced users only
+
+
+Of course, replace the paths in prefix, conf_dir with the directories you wish to install
+Trinity Core to. The datadir is where maps, DBCs, and SQLs are stored. The sysconfdir
+is where configuration files are stored.
+
+Once Trinity Core is installed you will need to
+apply database updates where necessary. Furthermore, you must
+configure your installation by editing the config files in the
+sysconfdir.
diff --git a/docs/UnixRestarter/restarter b/docs/UnixRestarter/restarter
new file mode 100755
index 0000000..1428f1f
--- /dev/null
+++ b/docs/UnixRestarter/restarter
@@ -0,0 +1,2 @@
+#!/bin/bash
+screen -A -m -d -S restarter ./restarter-bin
diff --git a/docs/UnixRestarter/restarter-bin b/docs/UnixRestarter/restarter-bin
new file mode 100755
index 0000000..b86de50
--- /dev/null
+++ b/docs/UnixRestarter/restarter-bin
@@ -0,0 +1,10 @@
+#! /bin/bash
+while true
+do
+ PID2=$(pidof authserver)
+ if (( PID2 < 1 ))
+ then
+ ./startl
+ fi
+ sleep 20
+done
diff --git a/docs/UnixRestarter/start b/docs/UnixRestarter/start
new file mode 100755
index 0000000..435f01a
--- /dev/null
+++ b/docs/UnixRestarter/start
@@ -0,0 +1,10 @@
+#!/bin/sh
+# exit # Comment this in if you are working on your server and don't want it to boot
+cd /opt/trinity/bin # Adjust this to the binary directory of the realm to be run
+pidof restarter >/dev/null # Grap the process ID
+PID1=$?
+if [ $PID1 -eq 1 ] # If not running boot the server in a dedicated screen session and log
+ then
+ echo "Re-/Starting the logonserver on "`date` >> ../restarter.log
+ ./restarter && screen -A -m -d -S worldserver ./startw
+fi
diff --git a/docs/UnixRestarter/startl b/docs/UnixRestarter/startl
new file mode 100755
index 0000000..285e1e8
--- /dev/null
+++ b/docs/UnixRestarter/startl
@@ -0,0 +1 @@
+screen -A -m -d -S authserver ./authserver
diff --git a/docs/UnixRestarter/startw b/docs/UnixRestarter/startw
new file mode 100755
index 0000000..c2f3922
--- /dev/null
+++ b/docs/UnixRestarter/startw
@@ -0,0 +1,35 @@
+#!/bin/sh
+
+###############
+# About: Auto restart worldserver on crash & generate crash report into crash_log_(DATE_TIME).log
+###############
+# 1. Compile TrinityCore with the following command: cmake /root/wow/ -DPREFIX=/opt/trinity -DDO_DEBUG=1 -DCMAKE_C_FLAGS="-m32 -D_LARGEFILE_SOURCE -DFD_SETSIZE=131072 -march=prescott -ggdb3 -g3 -pipe -fno-strength-reduce -fno-delete-null-pointer-checks -fno-strict-aliasing -frename-registers"
+# 2. Put these files: start, startw, startl, restarter, restarter-bin, in /opt/trinity/bin folder.
+# 3. (Only once): cd /opt/trinity/bin && chmod +x start startw startl restarter restarter-bin
+# 4. Usage: ./start or /opt/trinity/bin/start
+# p.s. Make sure you have "gdb" installed.
+###############
+
+# config:
+# path to worldserver binary
+daemon=/opt/trinity/bin/worldserver
+
+# system
+export LD_LIBRARY_PATH=.:lib:$LD_LIBRARY_PATH
+
+if [ "`ulimit -c`" -eq 0 ]; then
+ ulimit -c unlimited
+fi
+
+while true
+do
+ $daemon $*
+ if [ $? -eq 0 ]; then
+ break;
+ fi
+ sleep 10
+ dte=`date +%F_%H-%M-%S`
+ gdb $daemon core.* --batch --eval-command="bt ful" > crash_log_$dte.log
+ rm core.*
+ sleep 5
+done
diff --git a/docs/gpl-2.0.txt b/docs/gpl-2.0.txt
new file mode 100644
index 0000000..d159169
--- /dev/null
+++ b/docs/gpl-2.0.txt
@@ -0,0 +1,339 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Lesser General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+
+ Copyright (C)
+
+ 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.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) year name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ , 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.
diff --git a/externals/CMakeLists.txt b/externals/CMakeLists.txt
new file mode 100644
index 0000000..e39a61a
--- /dev/null
+++ b/externals/CMakeLists.txt
@@ -0,0 +1,26 @@
+# Copyright (C) 2008-2010 Trinity
+#
+# 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.
+
+if(CMAKE_SYSTEM_NAME MATCHES "Linux")
+ add_subdirectory(jemalloc)
+endif()
+
+if(CMAKE_SYSTEM_NAME MATCHES "Windows")
+ add_subdirectory(ace)
+ add_subdirectory(zlib)
+ add_subdirectory(bzip2)
+endif()
+
+add_subdirectory(g3dlite)
+add_subdirectory(sockets)
+
+# temporary disable libmpq building (through CMake at least) for now
+# - needs a proper CMakeLists.txt
+#add_subdirectory(libmpq)
diff --git a/externals/PackageList.txt b/externals/PackageList.txt
new file mode 100644
index 0000000..2954f91
--- /dev/null
+++ b/externals/PackageList.txt
@@ -0,0 +1,53 @@
+TrinityCore uses (parts of or in whole) the following opensource software :
+
+ACE (ADAPTIVE Communication Environment)
+ http://www.cs.wustl.edu/~schmidt/ACE.html
+ Version: 5.7.9
+
+bzip2 (a freely available, patent free, high-quality data compressor)
+ http://www.bzip.org/
+ Version: 1.0.5
+
+G3D (a commercial-grade C++ 3D engine available as Open Source (BSD License)
+ http://g3d.sourceforge.net/
+ Version: 6.09
+
+jemalloc (a general-purpose scalable concurrent malloc-implementation)
+ http://www.canonware.com/jemalloc/
+ Version: 1.0.0
+
+libMPQ (a library for reading MPQ files)
+ https://libmpq.org/
+ Version: 1.0.4
+
+MersenneTwister (a very fast random number generator)
+ http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html
+ Version: 0.4.2
+
+SFMT (SIMD-oriented Fast Mersenne Twister)
+ http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/SFMT/index.html
+ Version: 1.3.3
+
+MySQL (the world's most popular open source database software)
+ http://www.mysql.com/about/
+ Version: 6.0.2
+
+OpenSSL (an opensource toolkit implementing SSL v2/v3 and TLS v1 protocols)
+ http://www.openssl.org/
+ Version: UNKNOWN
+
+sockets (a GPL licensed C++ class library wrapping the berkeley sockets C API)
+ http://www.alhem.net/Sockets/
+ Version: UNKNOWN
+
+utf8-cpp (UTF-8 with C++ in a Portable Way)
+ http://utfcpp.sourceforge.net/
+ Version: 2.3
+
+vld (a free open-source memory leak detection system for Visual C++)
+ http://sites.google.com/site/dmoulding/vld
+ Version: 1.0
+
+zlib (A Massively Spiffy Yet Delicately Unobtrusive Compression Library)
+ http://www.zlib.net/
+ Version: 1.2.5
diff --git a/externals/SFMT/SFMT-alti.h b/externals/SFMT/SFMT-alti.h
new file mode 100644
index 0000000..df3186c
--- /dev/null
+++ b/externals/SFMT/SFMT-alti.h
@@ -0,0 +1,156 @@
+/**
+ * @file SFMT-alti.h
+ *
+ * @brief SIMD oriented Fast Mersenne Twister(SFMT)
+ * pseudorandom number generator
+ *
+ * @author Mutsuo Saito (Hiroshima University)
+ * @author Makoto Matsumoto (Hiroshima University)
+ *
+ * Copyright (C) 2007 Mutsuo Saito, Makoto Matsumoto and Hiroshima
+ * University. All rights reserved.
+ *
+ * The new BSD License is applied to this software.
+ * see LICENSE.txt
+ */
+
+#ifndef SFMT_ALTI_H
+#define SFMT_ALTI_H
+
+inline static vector unsigned int vec_recursion(vector unsigned int a,
+ vector unsigned int b,
+ vector unsigned int c,
+ vector unsigned int d)
+ ALWAYSINLINE;
+
+/**
+ * This function represents the recursion formula in AltiVec and BIG ENDIAN.
+ * @param a a 128-bit part of the interal state array
+ * @param b a 128-bit part of the interal state array
+ * @param c a 128-bit part of the interal state array
+ * @param d a 128-bit part of the interal state array
+ * @return output
+ */
+inline static vector unsigned int vec_recursion(vector unsigned int a,
+ vector unsigned int b,
+ vector unsigned int c,
+ vector unsigned int d) {
+
+ const vector unsigned int sl1 = ALTI_SL1;
+ const vector unsigned int sr1 = ALTI_SR1;
+#ifdef ONLY64
+ const vector unsigned int mask = ALTI_MSK64;
+ const vector unsigned char perm_sl = ALTI_SL2_PERM64;
+ const vector unsigned char perm_sr = ALTI_SR2_PERM64;
+#else
+ const vector unsigned int mask = ALTI_MSK;
+ const vector unsigned char perm_sl = ALTI_SL2_PERM;
+ const vector unsigned char perm_sr = ALTI_SR2_PERM;
+#endif
+ vector unsigned int v, w, x, y, z;
+ x = vec_perm(a, (vector unsigned int)perm_sl, perm_sl);
+ v = a;
+ y = vec_sr(b, sr1);
+ z = vec_perm(c, (vector unsigned int)perm_sr, perm_sr);
+ w = vec_sl(d, sl1);
+ z = vec_xor(z, w);
+ y = vec_and(y, mask);
+ v = vec_xor(v, x);
+ z = vec_xor(z, y);
+ z = vec_xor(z, v);
+ return z;
+}
+
+/**
+ * This function fills the internal state array with pseudorandom
+ * integers.
+ */
+inline static void gen_rand_all(void) {
+ int i;
+ vector unsigned int r, r1, r2;
+
+ r1 = sfmt[N - 2].s;
+ r2 = sfmt[N - 1].s;
+ for (i = 0; i < N - POS1; i++) {
+ r = vec_recursion(sfmt[i].s, sfmt[i + POS1].s, r1, r2);
+ sfmt[i].s = r;
+ r1 = r2;
+ r2 = r;
+ }
+ for (; i < N; i++) {
+ r = vec_recursion(sfmt[i].s, sfmt[i + POS1 - N].s, r1, r2);
+ sfmt[i].s = r;
+ r1 = r2;
+ r2 = r;
+ }
+}
+
+/**
+ * This function fills the user-specified array with pseudorandom
+ * integers.
+ *
+ * @param array an 128-bit array to be filled by pseudorandom numbers.
+ * @param size number of 128-bit pesudorandom numbers to be generated.
+ */
+inline static void gen_rand_array(w128_t *array, int size) {
+ int i, j;
+ vector unsigned int r, r1, r2;
+
+ r1 = sfmt[N - 2].s;
+ r2 = sfmt[N - 1].s;
+ for (i = 0; i < N - POS1; i++) {
+ r = vec_recursion(sfmt[i].s, sfmt[i + POS1].s, r1, r2);
+ array[i].s = r;
+ r1 = r2;
+ r2 = r;
+ }
+ for (; i < N; i++) {
+ r = vec_recursion(sfmt[i].s, array[i + POS1 - N].s, r1, r2);
+ array[i].s = r;
+ r1 = r2;
+ r2 = r;
+ }
+ /* main loop */
+ for (; i < size - N; i++) {
+ r = vec_recursion(array[i - N].s, array[i + POS1 - N].s, r1, r2);
+ array[i].s = r;
+ r1 = r2;
+ r2 = r;
+ }
+ for (j = 0; j < 2 * N - size; j++) {
+ sfmt[j].s = array[j + size - N].s;
+ }
+ for (; i < size; i++) {
+ r = vec_recursion(array[i - N].s, array[i + POS1 - N].s, r1, r2);
+ array[i].s = r;
+ sfmt[j++].s = r;
+ r1 = r2;
+ r2 = r;
+ }
+}
+
+#ifndef ONLY64
+#if defined(__APPLE__)
+#define ALTI_SWAP (vector unsigned char) \
+ (4, 5, 6, 7, 0, 1, 2, 3, 12, 13, 14, 15, 8, 9, 10, 11)
+#else
+#define ALTI_SWAP {4, 5, 6, 7, 0, 1, 2, 3, 12, 13, 14, 15, 8, 9, 10, 11}
+#endif
+/**
+ * This function swaps high and low 32-bit of 64-bit integers in user
+ * specified array.
+ *
+ * @param array an 128-bit array to be swaped.
+ * @param size size of 128-bit array.
+ */
+inline static void swap(w128_t *array, int size) {
+ int i;
+ const vector unsigned char perm = ALTI_SWAP;
+
+ for (i = 0; i < size; i++) {
+ array[i].s = vec_perm(array[i].s, (vector unsigned int)perm, perm);
+ }
+}
+#endif
+
+#endif
diff --git a/externals/SFMT/SFMT-params.h b/externals/SFMT/SFMT-params.h
new file mode 100644
index 0000000..661bbf2
--- /dev/null
+++ b/externals/SFMT/SFMT-params.h
@@ -0,0 +1,97 @@
+#ifndef SFMT_PARAMS_H
+#define SFMT_PARAMS_H
+
+#if !defined(MEXP)
+#ifdef __GNUC__
+ #warning "MEXP is not defined. I assume MEXP is 19937."
+#endif
+ #define MEXP 19937
+#endif
+/*-----------------
+ BASIC DEFINITIONS
+ -----------------*/
+/** Mersenne Exponent. The period of the sequence
+ * is a multiple of 2^MEXP-1.
+ * #define MEXP 19937 */
+/** SFMT generator has an internal state array of 128-bit integers,
+ * and N is its size. */
+#define N (MEXP / 128 + 1)
+/** N32 is the size of internal state array when regarded as an array
+ * of 32-bit integers.*/
+#define N32 (N * 4)
+/** N64 is the size of internal state array when regarded as an array
+ * of 64-bit integers.*/
+#define N64 (N * 2)
+
+/*----------------------
+ the parameters of SFMT
+ following definitions are in paramsXXXX.h file.
+ ----------------------*/
+/** the pick up position of the array.
+#define POS1 122
+*/
+
+/** the parameter of shift left as four 32-bit registers.
+#define SL1 18
+ */
+
+/** the parameter of shift left as one 128-bit register.
+ * The 128-bit integer is shifted by (SL2 * 8) bits.
+#define SL2 1
+*/
+
+/** the parameter of shift right as four 32-bit registers.
+#define SR1 11
+*/
+
+/** the parameter of shift right as one 128-bit register.
+ * The 128-bit integer is shifted by (SL2 * 8) bits.
+#define SR2 1
+*/
+
+/** A bitmask, used in the recursion. These parameters are introduced
+ * to break symmetry of SIMD.
+#define MSK1 0xdfffffefU
+#define MSK2 0xddfecb7fU
+#define MSK3 0xbffaffffU
+#define MSK4 0xbffffff6U
+*/
+
+/** These definitions are part of a 128-bit period certification vector.
+#define PARITY1 0x00000001U
+#define PARITY2 0x00000000U
+#define PARITY3 0x00000000U
+#define PARITY4 0xc98e126aU
+*/
+
+#if MEXP == 607
+ #include "SFMT-params607.h"
+#elif MEXP == 1279
+ #include "SFMT-params1279.h"
+#elif MEXP == 2281
+ #include "SFMT-params2281.h"
+#elif MEXP == 4253
+ #include "SFMT-params4253.h"
+#elif MEXP == 11213
+ #include "SFMT-params11213.h"
+#elif MEXP == 19937
+ #include "SFMT-params19937.h"
+#elif MEXP == 44497
+ #include "SFMT-params44497.h"
+#elif MEXP == 86243
+ #include "SFMT-params86243.h"
+#elif MEXP == 132049
+ #include "SFMT-params132049.h"
+#elif MEXP == 216091
+ #include "SFMT-params216091.h"
+#else
+#ifdef __GNUC__
+ #error "MEXP is not valid."
+ #undef MEXP
+#else
+ #undef MEXP
+#endif
+
+#endif
+
+#endif /* SFMT_PARAMS_H */
diff --git a/externals/SFMT/SFMT-sse2.h b/externals/SFMT/SFMT-sse2.h
new file mode 100644
index 0000000..4e91d9c
--- /dev/null
+++ b/externals/SFMT/SFMT-sse2.h
@@ -0,0 +1,121 @@
+/**
+ * @file SFMT-sse2.h
+ * @brief SIMD oriented Fast Mersenne Twister(SFMT) for Intel SSE2
+ *
+ * @author Mutsuo Saito (Hiroshima University)
+ * @author Makoto Matsumoto (Hiroshima University)
+ *
+ * @note We assume LITTLE ENDIAN in this file
+ *
+ * Copyright (C) 2006, 2007 Mutsuo Saito, Makoto Matsumoto and Hiroshima
+ * University. All rights reserved.
+ *
+ * The new BSD License is applied to this software, see LICENSE.txt
+ */
+
+#ifndef SFMT_SSE2_H
+#define SFMT_SSE2_H
+
+PRE_ALWAYS static __m128i mm_recursion(__m128i *a, __m128i *b, __m128i c,
+ __m128i d, __m128i mask) ALWAYSINLINE;
+
+/**
+ * This function represents the recursion formula.
+ * @param a a 128-bit part of the interal state array
+ * @param b a 128-bit part of the interal state array
+ * @param c a 128-bit part of the interal state array
+ * @param d a 128-bit part of the interal state array
+ * @param mask 128-bit mask
+ * @return output
+ */
+PRE_ALWAYS static __m128i mm_recursion(__m128i *a, __m128i *b,
+ __m128i c, __m128i d, __m128i mask) {
+ __m128i v, x, y, z;
+
+ x = _mm_load_si128(a);
+ y = _mm_srli_epi32(*b, SR1);
+ z = _mm_srli_si128(c, SR2);
+ v = _mm_slli_epi32(d, SL1);
+ z = _mm_xor_si128(z, x);
+ z = _mm_xor_si128(z, v);
+ x = _mm_slli_si128(x, SL2);
+ y = _mm_and_si128(y, mask);
+ z = _mm_xor_si128(z, x);
+ z = _mm_xor_si128(z, y);
+ return z;
+}
+
+/**
+ * This function fills the internal state array with pseudorandom
+ * integers.
+ */
+inline static void gen_rand_all(void) {
+ int i;
+ __m128i r, r1, r2, mask;
+ mask = _mm_set_epi32(MSK4, MSK3, MSK2, MSK1);
+
+ r1 = _mm_load_si128(&sfmt[N - 2].si);
+ r2 = _mm_load_si128(&sfmt[N - 1].si);
+ for (i = 0; i < N - POS1; i++) {
+ r = mm_recursion(&sfmt[i].si, &sfmt[i + POS1].si, r1, r2, mask);
+ _mm_store_si128(&sfmt[i].si, r);
+ r1 = r2;
+ r2 = r;
+ }
+ for (; i < N; i++) {
+ r = mm_recursion(&sfmt[i].si, &sfmt[i + POS1 - N].si, r1, r2, mask);
+ _mm_store_si128(&sfmt[i].si, r);
+ r1 = r2;
+ r2 = r;
+ }
+}
+
+/**
+ * This function fills the user-specified array with pseudorandom
+ * integers.
+ *
+ * @param array an 128-bit array to be filled by pseudorandom numbers.
+ * @param size number of 128-bit pesudorandom numbers to be generated.
+ */
+inline static void gen_rand_array(w128_t *array, int size) {
+ int i, j;
+ __m128i r, r1, r2, mask;
+ mask = _mm_set_epi32(MSK4, MSK3, MSK2, MSK1);
+
+ r1 = _mm_load_si128(&sfmt[N - 2].si);
+ r2 = _mm_load_si128(&sfmt[N - 1].si);
+ for (i = 0; i < N - POS1; i++) {
+ r = mm_recursion(&sfmt[i].si, &sfmt[i + POS1].si, r1, r2, mask);
+ _mm_store_si128(&array[i].si, r);
+ r1 = r2;
+ r2 = r;
+ }
+ for (; i < N; i++) {
+ r = mm_recursion(&sfmt[i].si, &array[i + POS1 - N].si, r1, r2, mask);
+ _mm_store_si128(&array[i].si, r);
+ r1 = r2;
+ r2 = r;
+ }
+ /* main loop */
+ for (; i < size - N; i++) {
+ r = mm_recursion(&array[i - N].si, &array[i + POS1 - N].si, r1, r2,
+ mask);
+ _mm_store_si128(&array[i].si, r);
+ r1 = r2;
+ r2 = r;
+ }
+ for (j = 0; j < 2 * N - size; j++) {
+ r = _mm_load_si128(&array[j + size - N].si);
+ _mm_store_si128(&sfmt[j].si, r);
+ }
+ for (; i < size; i++) {
+ r = mm_recursion(&array[i - N].si, &array[i + POS1 - N].si, r1, r2,
+ mask);
+ _mm_store_si128(&array[i].si, r);
+ _mm_store_si128(&sfmt[j++].si, r);
+ r1 = r2;
+ r2 = r;
+ }
+}
+
+#endif
diff --git a/externals/SFMT/SFMT.c b/externals/SFMT/SFMT.c
new file mode 100644
index 0000000..d36465d
--- /dev/null
+++ b/externals/SFMT/SFMT.c
@@ -0,0 +1,620 @@
+/**
+ * @file SFMT.c
+ * @brief SIMD oriented Fast Mersenne Twister(SFMT)
+ *
+ * @author Mutsuo Saito (Hiroshima University)
+ * @author Makoto Matsumoto (Hiroshima University)
+ *
+ * Copyright (C) 2006,2007 Mutsuo Saito, Makoto Matsumoto and Hiroshima
+ * University. All rights reserved.
+ *
+ * The new BSD License is applied to this software, see LICENSE.txt
+ */
+#include
+#include
+#include "SFMT.h"
+#include "SFMT-params.h"
+
+#if defined(__BIG_ENDIAN__) && !defined(__amd64) && !defined(BIG_ENDIAN64)
+#define BIG_ENDIAN64 1
+#endif
+#if defined(HAVE_ALTIVEC) && !defined(BIG_ENDIAN64)
+#define BIG_ENDIAN64 1
+#endif
+#if defined(ONLY64) && !defined(BIG_ENDIAN64)
+ #if defined(__GNUC__)
+ #error "-DONLY64 must be specified with -DBIG_ENDIAN64"
+ #endif
+#undef ONLY64
+#endif
+/*------------------------------------------------------
+ 128-bit SIMD data type for Altivec, SSE2 or standard C
+ ------------------------------------------------------*/
+#if defined(HAVE_ALTIVEC)
+ #if !defined(__APPLE__)
+ #include
+ #endif
+/** 128-bit data structure */
+union W128_T {
+ vector unsigned int s;
+ uint32_t u[4];
+};
+/** 128-bit data type */
+typedef union W128_T w128_t;
+
+#elif defined(HAVE_SSE2)
+ #include
+
+/** 128-bit data structure */
+union W128_T {
+ __m128i si;
+ uint32_t u[4];
+};
+/** 128-bit data type */
+typedef union W128_T w128_t;
+
+#else
+
+/** 128-bit data structure */
+struct W128_T {
+ uint32_t u[4];
+};
+/** 128-bit data type */
+typedef struct W128_T w128_t;
+
+#endif
+
+/*--------------------------------------
+ FILE GLOBAL VARIABLES
+ internal state, index counter and flag
+ --------------------------------------*/
+/** the 128-bit internal state array */
+static w128_t sfmt[N];
+/** the 32bit integer pointer to the 128-bit internal state array */
+static uint32_t *psfmt32 = &sfmt[0].u[0];
+#if !defined(BIG_ENDIAN64) || defined(ONLY64)
+/** the 64bit integer pointer to the 128-bit internal state array */
+static uint64_t *psfmt64 = (uint64_t *)&sfmt[0].u[0];
+#endif
+/** index counter to the 32-bit internal state array */
+static int idx;
+/** a flag: it is 0 if and only if the internal state is not yet
+ * initialized. */
+static int initialized = 0;
+/** a parity check vector which certificate the period of 2^{MEXP} */
+static uint32_t parity[4] = {PARITY1, PARITY2, PARITY3, PARITY4};
+
+/*----------------
+ STATIC FUNCTIONS
+ ----------------*/
+inline static int idxof(int i);
+inline static void rshift128(w128_t *out, w128_t const *in, int shift);
+inline static void lshift128(w128_t *out, w128_t const *in, int shift);
+inline static void gen_rand_all(void);
+inline static void gen_rand_array(w128_t *array, int size);
+inline static uint32_t func1(uint32_t x);
+inline static uint32_t func2(uint32_t x);
+static void period_certification(void);
+#if defined(BIG_ENDIAN64) && !defined(ONLY64)
+inline static void swap(w128_t *array, int size);
+#endif
+
+#if defined(HAVE_ALTIVEC)
+ #include "SFMT-alti.h"
+#elif defined(HAVE_SSE2)
+ #include "SFMT-sse2.h"
+#endif
+
+/**
+ * This function simulate a 64-bit index of LITTLE ENDIAN
+ * in BIG ENDIAN machine.
+ */
+#ifdef ONLY64
+inline static int idxof(int i) {
+ return i ^ 1;
+}
+#else
+inline static int idxof(int i) {
+ return i;
+}
+#endif
+/**
+ * This function simulates SIMD 128-bit right shift by the standard C.
+ * The 128-bit integer given in in is shifted by (shift * 8) bits.
+ * This function simulates the LITTLE ENDIAN SIMD.
+ * @param out the output of this function
+ * @param in the 128-bit data to be shifted
+ * @param shift the shift value
+ */
+#ifdef ONLY64
+inline static void rshift128(w128_t *out, w128_t const *in, int shift) {
+ uint64_t th, tl, oh, ol;
+
+ th = ((uint64_t)in->u[2] << 32) | ((uint64_t)in->u[3]);
+ tl = ((uint64_t)in->u[0] << 32) | ((uint64_t)in->u[1]);
+
+ oh = th >> (shift * 8);
+ ol = tl >> (shift * 8);
+ ol |= th << (64 - shift * 8);
+ out->u[0] = (uint32_t)(ol >> 32);
+ out->u[1] = (uint32_t)ol;
+ out->u[2] = (uint32_t)(oh >> 32);
+ out->u[3] = (uint32_t)oh;
+}
+#else
+inline static void rshift128(w128_t *out, w128_t const *in, int shift) {
+ uint64_t th, tl, oh, ol;
+
+ th = ((uint64_t)in->u[3] << 32) | ((uint64_t)in->u[2]);
+ tl = ((uint64_t)in->u[1] << 32) | ((uint64_t)in->u[0]);
+
+ oh = th >> (shift * 8);
+ ol = tl >> (shift * 8);
+ ol |= th << (64 - shift * 8);
+ out->u[1] = (uint32_t)(ol >> 32);
+ out->u[0] = (uint32_t)ol;
+ out->u[3] = (uint32_t)(oh >> 32);
+ out->u[2] = (uint32_t)oh;
+}
+#endif
+/**
+ * This function simulates SIMD 128-bit left shift by the standard C.
+ * The 128-bit integer given in in is shifted by (shift * 8) bits.
+ * This function simulates the LITTLE ENDIAN SIMD.
+ * @param out the output of this function
+ * @param in the 128-bit data to be shifted
+ * @param shift the shift value
+ */
+#ifdef ONLY64
+inline static void lshift128(w128_t *out, w128_t const *in, int shift) {
+ uint64_t th, tl, oh, ol;
+
+ th = ((uint64_t)in->u[2] << 32) | ((uint64_t)in->u[3]);
+ tl = ((uint64_t)in->u[0] << 32) | ((uint64_t)in->u[1]);
+
+ oh = th << (shift * 8);
+ ol = tl << (shift * 8);
+ oh |= tl >> (64 - shift * 8);
+ out->u[0] = (uint32_t)(ol >> 32);
+ out->u[1] = (uint32_t)ol;
+ out->u[2] = (uint32_t)(oh >> 32);
+ out->u[3] = (uint32_t)oh;
+}
+#else
+inline static void lshift128(w128_t *out, w128_t const *in, int shift) {
+ uint64_t th, tl, oh, ol;
+
+ th = ((uint64_t)in->u[3] << 32) | ((uint64_t)in->u[2]);
+ tl = ((uint64_t)in->u[1] << 32) | ((uint64_t)in->u[0]);
+
+ oh = th << (shift * 8);
+ ol = tl << (shift * 8);
+ oh |= tl >> (64 - shift * 8);
+ out->u[1] = (uint32_t)(ol >> 32);
+ out->u[0] = (uint32_t)ol;
+ out->u[3] = (uint32_t)(oh >> 32);
+ out->u[2] = (uint32_t)oh;
+}
+#endif
+
+/**
+ * This function represents the recursion formula.
+ * @param r output
+ * @param a a 128-bit part of the internal state array
+ * @param b a 128-bit part of the internal state array
+ * @param c a 128-bit part of the internal state array
+ * @param d a 128-bit part of the internal state array
+ */
+#if (!defined(HAVE_ALTIVEC)) && (!defined(HAVE_SSE2))
+#ifdef ONLY64
+inline static void do_recursion(w128_t *r, w128_t *a, w128_t *b, w128_t *c,
+ w128_t *d) {
+ w128_t x;
+ w128_t y;
+
+ lshift128(&x, a, SL2);
+ rshift128(&y, c, SR2);
+ r->u[0] = a->u[0] ^ x.u[0] ^ ((b->u[0] >> SR1) & MSK2) ^ y.u[0]
+ ^ (d->u[0] << SL1);
+ r->u[1] = a->u[1] ^ x.u[1] ^ ((b->u[1] >> SR1) & MSK1) ^ y.u[1]
+ ^ (d->u[1] << SL1);
+ r->u[2] = a->u[2] ^ x.u[2] ^ ((b->u[2] >> SR1) & MSK4) ^ y.u[2]
+ ^ (d->u[2] << SL1);
+ r->u[3] = a->u[3] ^ x.u[3] ^ ((b->u[3] >> SR1) & MSK3) ^ y.u[3]
+ ^ (d->u[3] << SL1);
+}
+#else
+inline static void do_recursion(w128_t *r, w128_t *a, w128_t *b, w128_t *c,
+ w128_t *d) {
+ w128_t x;
+ w128_t y;
+
+ lshift128(&x, a, SL2);
+ rshift128(&y, c, SR2);
+ r->u[0] = a->u[0] ^ x.u[0] ^ ((b->u[0] >> SR1) & MSK1) ^ y.u[0]
+ ^ (d->u[0] << SL1);
+ r->u[1] = a->u[1] ^ x.u[1] ^ ((b->u[1] >> SR1) & MSK2) ^ y.u[1]
+ ^ (d->u[1] << SL1);
+ r->u[2] = a->u[2] ^ x.u[2] ^ ((b->u[2] >> SR1) & MSK3) ^ y.u[2]
+ ^ (d->u[2] << SL1);
+ r->u[3] = a->u[3] ^ x.u[3] ^ ((b->u[3] >> SR1) & MSK4) ^ y.u[3]
+ ^ (d->u[3] << SL1);
+}
+#endif
+#endif
+
+#if (!defined(HAVE_ALTIVEC)) && (!defined(HAVE_SSE2))
+/**
+ * This function fills the internal state array with pseudorandom
+ * integers.
+ */
+inline static void gen_rand_all(void) {
+ int i;
+ w128_t *r1, *r2;
+
+ r1 = &sfmt[N - 2];
+ r2 = &sfmt[N - 1];
+ for (i = 0; i < N - POS1; i++) {
+ do_recursion(&sfmt[i], &sfmt[i], &sfmt[i + POS1], r1, r2);
+ r1 = r2;
+ r2 = &sfmt[i];
+ }
+ for (; i < N; i++) {
+ do_recursion(&sfmt[i], &sfmt[i], &sfmt[i + POS1 - N], r1, r2);
+ r1 = r2;
+ r2 = &sfmt[i];
+ }
+}
+
+/**
+ * This function fills the user-specified array with pseudorandom
+ * integers.
+ *
+ * @param array an 128-bit array to be filled by pseudorandom numbers.
+ * @param size number of 128-bit pseudorandom numbers to be generated.
+ */
+inline static void gen_rand_array(w128_t *array, int size) {
+ int i, j;
+ w128_t *r1, *r2;
+
+ r1 = &sfmt[N - 2];
+ r2 = &sfmt[N - 1];
+ for (i = 0; i < N - POS1; i++) {
+ do_recursion(&array[i], &sfmt[i], &sfmt[i + POS1], r1, r2);
+ r1 = r2;
+ r2 = &array[i];
+ }
+ for (; i < N; i++) {
+ do_recursion(&array[i], &sfmt[i], &array[i + POS1 - N], r1, r2);
+ r1 = r2;
+ r2 = &array[i];
+ }
+ for (; i < size - N; i++) {
+ do_recursion(&array[i], &array[i - N], &array[i + POS1 - N], r1, r2);
+ r1 = r2;
+ r2 = &array[i];
+ }
+ for (j = 0; j < 2 * N - size; j++) {
+ sfmt[j] = array[j + size - N];
+ }
+ for (; i < size; i++, j++) {
+ do_recursion(&array[i], &array[i - N], &array[i + POS1 - N], r1, r2);
+ r1 = r2;
+ r2 = &array[i];
+ sfmt[j] = array[i];
+ }
+}
+#endif
+
+#if defined(BIG_ENDIAN64) && !defined(ONLY64) && !defined(HAVE_ALTIVEC)
+inline static void swap(w128_t *array, int size) {
+ int i;
+ uint32_t x, y;
+
+ for (i = 0; i < size; i++) {
+ x = array[i].u[0];
+ y = array[i].u[2];
+ array[i].u[0] = array[i].u[1];
+ array[i].u[2] = array[i].u[3];
+ array[i].u[1] = x;
+ array[i].u[3] = y;
+ }
+}
+#endif
+/**
+ * This function represents a function used in the initialization
+ * by init_by_array
+ * @param x 32-bit integer
+ * @return 32-bit integer
+ */
+static uint32_t func1(uint32_t x) {
+ return (x ^ (x >> 27)) * (uint32_t)1664525UL;
+}
+
+/**
+ * This function represents a function used in the initialization
+ * by init_by_array
+ * @param x 32-bit integer
+ * @return 32-bit integer
+ */
+static uint32_t func2(uint32_t x) {
+ return (x ^ (x >> 27)) * (uint32_t)1566083941UL;
+}
+
+/**
+ * This function certificate the period of 2^{MEXP}
+ */
+static void period_certification(void) {
+ int inner = 0;
+ int i, j;
+ uint32_t work;
+
+ for (i = 0; i < 4; i++)
+ inner ^= psfmt32[idxof(i)] & parity[i];
+ for (i = 16; i > 0; i >>= 1)
+ inner ^= inner >> i;
+ inner &= 1;
+ /* check OK */
+ if (inner == 1) {
+ return;
+ }
+ /* check NG, and modification */
+ for (i = 0; i < 4; i++) {
+ work = 1;
+ for (j = 0; j < 32; j++) {
+ if ((work & parity[i]) != 0) {
+ psfmt32[idxof(i)] ^= work;
+ return;
+ }
+ work = work << 1;
+ }
+ }
+}
+
+/*----------------
+ PUBLIC FUNCTIONS
+ ----------------*/
+/**
+ * This function returns the identification string.
+ * The string shows the word size, the Mersenne exponent,
+ * and all parameters of this generator.
+ */
+const char *get_idstring(void) {
+ return IDSTR;
+}
+
+/**
+ * This function returns the minimum size of array used for \b
+ * fill_array32() function.
+ * @return minimum size of array used for fill_array32() function.
+ */
+int get_min_array_size32(void) {
+ return N32;
+}
+
+/**
+ * This function returns the minimum size of array used for \b
+ * fill_array64() function.
+ * @return minimum size of array used for fill_array64() function.
+ */
+int get_min_array_size64(void) {
+ return N64;
+}
+
+#ifndef ONLY64
+/**
+ * This function generates and returns 32-bit pseudorandom number.
+ * init_gen_rand or init_by_array must be called before this function.
+ * @return 32-bit pseudorandom number
+ */
+uint32_t gen_rand32(void) {
+ uint32_t r;
+
+ assert(initialized);
+ if (idx >= N32) {
+ gen_rand_all();
+ idx = 0;
+ }
+ r = psfmt32[idx++];
+ return r;
+}
+#endif
+/**
+ * This function generates and returns 64-bit pseudorandom number.
+ * init_gen_rand or init_by_array must be called before this function.
+ * The function gen_rand64 should not be called after gen_rand32,
+ * unless an initialization is again executed.
+ * @return 64-bit pseudorandom number
+ */
+uint64_t gen_rand64(void) {
+#if defined(BIG_ENDIAN64) && !defined(ONLY64)
+ uint32_t r1, r2;
+#else
+ uint64_t r;
+#endif
+
+ assert(initialized);
+ assert(idx % 2 == 0);
+
+ if (idx >= N32) {
+ gen_rand_all();
+ idx = 0;
+ }
+#if defined(BIG_ENDIAN64) && !defined(ONLY64)
+ r1 = psfmt32[idx];
+ r2 = psfmt32[idx + 1];
+ idx += 2;
+ return ((uint64_t)r2 << 32) | r1;
+#else
+ r = psfmt64[idx / 2];
+ idx += 2;
+ return r;
+#endif
+}
+
+#ifndef ONLY64
+/**
+ * This function generates pseudorandom 32-bit integers in the
+ * specified array[] by one call. The number of pseudorandom integers
+ * is specified by the argument size, which must be at least 624 and a
+ * multiple of four. The generation by this function is much faster
+ * than the following gen_rand function.
+ *
+ * For initialization, init_gen_rand or init_by_array must be called
+ * before the first call of this function. This function can not be
+ * used after calling gen_rand function, without initialization.
+ *
+ * @param array an array where pseudorandom 32-bit integers are filled
+ * by this function. The pointer to the array must be \b "aligned"
+ * (namely, must be a multiple of 16) in the SIMD version, since it
+ * refers to the address of a 128-bit integer. In the standard C
+ * version, the pointer is arbitrary.
+ *
+ * @param size the number of 32-bit pseudorandom integers to be
+ * generated. size must be a multiple of 4, and greater than or equal
+ * to (MEXP / 128 + 1) * 4.
+ *
+ * @note \b memalign or \b posix_memalign is available to get aligned
+ * memory. Mac OSX doesn't have these functions, but \b malloc of OSX
+ * returns the pointer to the aligned memory block.
+ */
+void fill_array32(uint32_t *array, int size) {
+ assert(initialized);
+ assert(idx == N32);
+ assert(size % 4 == 0);
+ assert(size >= N32);
+
+ gen_rand_array((w128_t *)array, size / 4);
+ idx = N32;
+}
+#endif
+
+/**
+ * This function generates pseudorandom 64-bit integers in the
+ * specified array[] by one call. The number of pseudorandom integers
+ * is specified by the argument size, which must be at least 312 and a
+ * multiple of two. The generation by this function is much faster
+ * than the following gen_rand function.
+ *
+ * For initialization, init_gen_rand or init_by_array must be called
+ * before the first call of this function. This function can not be
+ * used after calling gen_rand function, without initialization.
+ *
+ * @param array an array where pseudorandom 64-bit integers are filled
+ * by this function. The pointer to the array must be "aligned"
+ * (namely, must be a multiple of 16) in the SIMD version, since it
+ * refers to the address of a 128-bit integer. In the standard C
+ * version, the pointer is arbitrary.
+ *
+ * @param size the number of 64-bit pseudorandom integers to be
+ * generated. size must be a multiple of 2, and greater than or equal
+ * to (MEXP / 128 + 1) * 2
+ *
+ * @note \b memalign or \b posix_memalign is available to get aligned
+ * memory. Mac OSX doesn't have these functions, but \b malloc of OSX
+ * returns the pointer to the aligned memory block.
+ */
+void fill_array64(uint64_t *array, int size) {
+ assert(initialized);
+ assert(idx == N32);
+ assert(size % 2 == 0);
+ assert(size >= N64);
+
+ gen_rand_array((w128_t *)array, size / 2);
+ idx = N32;
+
+#if defined(BIG_ENDIAN64) && !defined(ONLY64)
+ swap((w128_t *)array, size /2);
+#endif
+}
+
+/**
+ * This function initializes the internal state array with a 32-bit
+ * integer seed.
+ *
+ * @param seed a 32-bit integer used as the seed.
+ */
+void init_gen_rand(uint32_t seed) {
+ int i;
+
+ psfmt32[idxof(0)] = seed;
+ for (i = 1; i < N32; i++) {
+ psfmt32[idxof(i)] = 1812433253UL * (psfmt32[idxof(i - 1)]
+ ^ (psfmt32[idxof(i - 1)] >> 30))
+ + i;
+ }
+ idx = N32;
+ period_certification();
+ initialized = 1;
+}
+
+/**
+ * This function initializes the internal state array,
+ * with an array of 32-bit integers used as the seeds
+ * @param init_key the array of 32-bit integers, used as a seed.
+ * @param key_length the length of init_key.
+ */
+void init_by_array(uint32_t *init_key, int key_length) {
+ int i, j, count;
+ uint32_t r;
+ int lag;
+ int mid;
+ int size = N * 4;
+
+ if (size >= 623) {
+ lag = 11;
+ } else if (size >= 68) {
+ lag = 7;
+ } else if (size >= 39) {
+ lag = 5;
+ } else {
+ lag = 3;
+ }
+ mid = (size - lag) / 2;
+
+ memset(sfmt, 0x8b, sizeof(sfmt));
+ if (key_length + 1 > N32) {
+ count = key_length + 1;
+ } else {
+ count = N32;
+ }
+ r = func1(psfmt32[idxof(0)] ^ psfmt32[idxof(mid)]
+ ^ psfmt32[idxof(N32 - 1)]);
+ psfmt32[idxof(mid)] += r;
+ r += key_length;
+ psfmt32[idxof(mid + lag)] += r;
+ psfmt32[idxof(0)] = r;
+
+ count--;
+ for (i = 1, j = 0; (j < count) && (j < key_length); j++) {
+ r = func1(psfmt32[idxof(i)] ^ psfmt32[idxof((i + mid) % N32)]
+ ^ psfmt32[idxof((i + N32 - 1) % N32)]);
+ psfmt32[idxof((i + mid) % N32)] += r;
+ r += init_key[j] + i;
+ psfmt32[idxof((i + mid + lag) % N32)] += r;
+ psfmt32[idxof(i)] = r;
+ i = (i + 1) % N32;
+ }
+ for (; j < count; j++) {
+ r = func1(psfmt32[idxof(i)] ^ psfmt32[idxof((i + mid) % N32)]
+ ^ psfmt32[idxof((i + N32 - 1) % N32)]);
+ psfmt32[idxof((i + mid) % N32)] += r;
+ r += i;
+ psfmt32[idxof((i + mid + lag) % N32)] += r;
+ psfmt32[idxof(i)] = r;
+ i = (i + 1) % N32;
+ }
+ for (j = 0; j < N32; j++) {
+ r = func2(psfmt32[idxof(i)] + psfmt32[idxof((i + mid) % N32)]
+ + psfmt32[idxof((i + N32 - 1) % N32)]);
+ psfmt32[idxof((i + mid) % N32)] ^= r;
+ r -= i;
+ psfmt32[idxof((i + mid + lag) % N32)] ^= r;
+ psfmt32[idxof(i)] = r;
+ i = (i + 1) % N32;
+ }
+
+ idx = N32;
+ period_certification();
+ initialized = 1;
+}
diff --git a/externals/SFMT/SFMT.h b/externals/SFMT/SFMT.h
new file mode 100644
index 0000000..7c8b35e
--- /dev/null
+++ b/externals/SFMT/SFMT.h
@@ -0,0 +1,157 @@
+/**
+ * @file SFMT.h
+ *
+ * @brief SIMD oriented Fast Mersenne Twister(SFMT) pseudorandom
+ * number generator
+ *
+ * @author Mutsuo Saito (Hiroshima University)
+ * @author Makoto Matsumoto (Hiroshima University)
+ *
+ * Copyright (C) 2006, 2007 Mutsuo Saito, Makoto Matsumoto and Hiroshima
+ * University. All rights reserved.
+ *
+ * The new BSD License is applied to this software.
+ * see LICENSE.txt
+ *
+ * @note We assume that your system has inttypes.h. If your system
+ * doesn't have inttypes.h, you have to typedef uint32_t and uint64_t,
+ * and you have to define PRIu64 and PRIx64 in this file as follows:
+ * @verbatim
+ typedef unsigned int uint32_t
+ typedef unsigned long long uint64_t
+ #define PRIu64 "llu"
+ #define PRIx64 "llx"
+@endverbatim
+ * uint32_t must be exactly 32-bit unsigned integer type (no more, no
+ * less), and uint64_t must be exactly 64-bit unsigned integer type.
+ * PRIu64 and PRIx64 are used for printf function to print 64-bit
+ * unsigned int and 64-bit unsigned int in hexadecimal format.
+ */
+
+#ifndef SFMT_H
+#define SFMT_H
+
+#include
+
+#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
+ #include
+#elif defined(_MSC_VER) || defined(__BORLANDC__)
+ typedef unsigned int uint32_t;
+ typedef unsigned __int64 uint64_t;
+ #define inline __inline
+#else
+ #include
+ #if defined(__GNUC__)
+ #define inline __inline__
+ #endif
+#endif
+
+#ifndef PRIu64
+ #if defined(_MSC_VER) || defined(__BORLANDC__)
+ #define PRIu64 "I64u"
+ #define PRIx64 "I64x"
+ #else
+ #define PRIu64 "llu"
+ #define PRIx64 "llx"
+ #endif
+#endif
+
+#if defined(__GNUC__)
+#define ALWAYSINLINE __attribute__((always_inline))
+#else
+#define ALWAYSINLINE
+#endif
+
+#if defined(_MSC_VER)
+ #if _MSC_VER >= 1200
+ #define PRE_ALWAYS __forceinline
+ #else
+ #define PRE_ALWAYS inline
+ #endif
+#else
+ #define PRE_ALWAYS inline
+#endif
+
+uint32_t gen_rand32(void);
+uint64_t gen_rand64(void);
+void fill_array32(uint32_t *array, int size);
+void fill_array64(uint64_t *array, int size);
+void init_gen_rand(uint32_t seed);
+void init_by_array(uint32_t *init_key, int key_length);
+const char *get_idstring(void);
+int get_min_array_size32(void);
+int get_min_array_size64(void);
+
+/* These real versions are due to Isaku Wada */
+/** generates a random number on [0,1]-real-interval */
+inline static double to_real1(uint32_t v)
+{
+ return v * (1.0/4294967295.0);
+ /* divided by 2^32-1 */
+}
+
+/** generates a random number on [0,1]-real-interval */
+inline static double genrand_real1(void)
+{
+ return to_real1(gen_rand32());
+}
+
+/** generates a random number on [0,1)-real-interval */
+inline static double to_real2(uint32_t v)
+{
+ return v * (1.0/4294967296.0);
+ /* divided by 2^32 */
+}
+
+/** generates a random number on [0,1)-real-interval */
+inline static double genrand_real2(void)
+{
+ return to_real2(gen_rand32());
+}
+
+/** generates a random number on (0,1)-real-interval */
+inline static double to_real3(uint32_t v)
+{
+ return (((double)v) + 0.5)*(1.0/4294967296.0);
+ /* divided by 2^32 */
+}
+
+/** generates a random number on (0,1)-real-interval */
+inline static double genrand_real3(void)
+{
+ return to_real3(gen_rand32());
+}
+/** These real versions are due to Isaku Wada */
+
+/** generates a random number on [0,1) with 53-bit resolution*/
+inline static double to_res53(uint64_t v)
+{
+ return v * (1.0/18446744073709551616.0L);
+}
+
+/** generates a random number on [0,1) with 53-bit resolution from two
+ * 32 bit integers */
+inline static double to_res53_mix(uint32_t x, uint32_t y)
+{
+ return to_res53(x | ((uint64_t)y << 32));
+}
+
+/** generates a random number on [0,1) with 53-bit resolution
+ */
+inline static double genrand_res53(void)
+{
+ return to_res53(gen_rand64());
+}
+
+/** generates a random number on [0,1) with 53-bit resolution
+ using 32bit integer.
+ */
+inline static double genrand_res53_mix(void)
+{
+ uint32_t x, y;
+
+ x = gen_rand32();
+ y = gen_rand32();
+ return to_res53_mix(x, y);
+}
+#endif
diff --git a/externals/ace/ACE.cpp b/externals/ace/ACE.cpp
new file mode 100644
index 0000000..24fb383
--- /dev/null
+++ b/externals/ace/ACE.cpp
@@ -0,0 +1,3543 @@
+// $Id: ACE.cpp 88193 2009-12-16 09:14:06Z mcorino $
+
+#include "ace/ACE.h"
+
+#include "ace/Basic_Types.h"
+#include "ace/Handle_Set.h"
+#include "ace/Auto_Ptr.h"
+#include "ace/SString.h"
+#include "ace/Version.h"
+#include "ace/Message_Block.h"
+#include "ace/Log_Msg.h"
+#include "ace/OS_NS_sys_select.h"
+#include "ace/OS_NS_string.h"
+#include "ace/OS_NS_strings.h"
+#include "ace/OS_NS_signal.h"
+#include "ace/OS_NS_stdio.h"
+#include "ace/OS_NS_sys_resource.h"
+#include "ace/OS_NS_sys_wait.h"
+#include "ace/OS_NS_sys_time.h"
+#include "ace/OS_NS_time.h"
+#include "ace/OS_NS_sys_uio.h"
+#include "ace/OS_NS_sys_stat.h"
+#include "ace/OS_NS_ctype.h"
+#include "ace/OS_NS_fcntl.h"
+#include "ace/OS_TLI.h"
+#include "ace/Truncate.h"
+
+#if defined (ACE_VXWORKS) && (ACE_VXWORKS < 0x620)
+extern "C" int maxFiles;
+#endif /* ACE_VXWORKS */
+
+#if !defined (__ACE_INLINE__)
+#include "ace/ACE.inl"
+#endif /* __ACE_INLINE__ */
+
+#if defined (ACE_HAS_POLL) && defined (ACE_HAS_LIMITED_SELECT)
+# include "ace/OS_NS_poll.h"
+#endif /* ACE_HAS_POLL && ACE_HAS_LIMITED_SELECT */
+
+
+ACE_RCSID (ace,
+ ACE,
+ "$Id: ACE.cpp 88193 2009-12-16 09:14:06Z mcorino $")
+
+
+// Open versioned namespace, if enabled by the user.
+ ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+namespace ACE
+{
+ // private:
+ // Used internally so not exported.
+
+ // Size of allocation granularity.
+ size_t allocation_granularity_ = 0;
+
+ // Size of a VM page.
+ size_t pagesize_ = 0;
+
+ // Are we debugging ACE?
+ // Keeps track of whether we're in some global debug mode.
+ char debug_;
+}
+
+
+int
+ACE::out_of_handles (int error)
+{
+ // EMFILE is common to all platforms.
+ if (error == EMFILE ||
+#if defined (ACE_WIN32)
+ // On Win32, we need to check for ENOBUFS also.
+ error == ENOBUFS ||
+#elif defined (HPUX)
+ // On HPUX, we need to check for EADDRNOTAVAIL also.
+ error == EADDRNOTAVAIL ||
+#elif defined (linux)
+ // On linux, we need to check for ENOENT also.
+ error == ENOENT ||
+ // For RedHat5.2, need to check for EINVAL too.
+ error == EINVAL ||
+ // Without threads check for EOPNOTSUPP
+ error == EOPNOTSUPP ||
+#elif defined (sun)
+ // On sun, we need to check for ENOSR also.
+ error == ENOSR ||
+ // Without threads check for ENOTSUP
+ error == ENOTSUP ||
+#elif defined (__FreeBSD__)
+ // On FreeBSD we need to check for EOPNOTSUPP (LinuxThreads) or
+ // ENOSYS (libc_r threads) also.
+ error == EOPNOTSUPP ||
+ error == ENOSYS ||
+#elif defined (__OpenBSD__)
+ // OpenBSD appears to return EBADF.
+ error == EBADF ||
+#elif defined (__sgi) // irix
+ error == ENOTSUP ||
+#elif defined (DIGITAL_UNIX) // osf1
+ error == ENOTSUP ||
+#endif /* ACE_WIN32 */
+ error == ENFILE)
+ return 1;
+ else
+ return 0;
+}
+
+u_int
+ACE::major_version (void)
+{
+ return ACE_MAJOR_VERSION;
+}
+
+u_int
+ACE::minor_version (void)
+{
+ return ACE_MINOR_VERSION;
+}
+
+u_int
+ACE::beta_version (void)
+{
+ return ACE_BETA_VERSION;
+}
+
+const ACE_TCHAR *
+ACE::compiler_name (void)
+{
+#ifdef ACE_CC_NAME
+ return ACE_CC_NAME;
+#else
+ return ACE_TEXT ("");
+#endif
+}
+
+u_int
+ACE::compiler_major_version (void)
+{
+#ifdef ACE_CC_MAJOR_VERSION
+ return ACE_CC_MAJOR_VERSION;
+#else
+ return 0;
+#endif
+}
+
+u_int
+ACE::compiler_minor_version (void)
+{
+#ifdef ACE_CC_MINOR_VERSION
+ return ACE_CC_MINOR_VERSION;
+#else
+ return 0;
+#endif
+}
+
+u_int
+ACE::compiler_beta_version (void)
+{
+#ifdef ACE_CC_BETA_VERSION
+ return ACE_CC_BETA_VERSION;
+#else
+ return 0;
+#endif
+}
+
+ACE_TCHAR
+ACE::nibble2hex (u_int n)
+{
+ // Yes, this works for UNICODE
+ return ACE_TEXT ("0123456789abcdef")[n & 0x0f];
+}
+
+bool
+ACE::debug (void)
+{
+ static const char* debug = ACE_OS::getenv ("ACE_DEBUG");
+ return (ACE::debug_ != 0) ? ACE::debug_ : (debug != 0 ? (*debug != '0') : false);
+}
+
+void
+ACE::debug (bool onoff)
+{
+ ACE::debug_ = onoff;
+}
+
+int
+ACE::select (int width,
+ ACE_Handle_Set *readfds,
+ ACE_Handle_Set *writefds,
+ ACE_Handle_Set *exceptfds,
+ const ACE_Time_Value *timeout)
+{
+ int result = ACE_OS::select (width,
+ readfds ? readfds->fdset () : 0,
+ writefds ? writefds->fdset () : 0,
+ exceptfds ? exceptfds->fdset () : 0,
+ timeout);
+ if (result > 0)
+ {
+# if !defined (ACE_WIN32)
+ // This isn't needed for Windows... it's a no-op anyway.
+ if (readfds)
+ readfds->sync ((ACE_HANDLE) width);
+ if (writefds)
+ writefds->sync ((ACE_HANDLE) width);
+ if (exceptfds)
+ exceptfds->sync ((ACE_HANDLE) width);
+#endif /* ACE_WIN32 */
+ }
+ return result;
+}
+
+int
+ACE::select (int width,
+ ACE_Handle_Set &readfds,
+ const ACE_Time_Value *timeout)
+{
+ int result = ACE_OS::select (width,
+ readfds.fdset (),
+ 0,
+ 0,
+ timeout);
+
+#if !defined (ACE_WIN32)
+ if (result > 0)
+ readfds.sync ((ACE_HANDLE) width);
+#endif /* ACE_WIN32 */
+ return result;
+}
+
+int
+ACE::terminate_process (pid_t pid)
+{
+#if defined (ACE_HAS_PHARLAP)
+ ACE_UNUSED_ARG (pid);
+ ACE_NOTSUP_RETURN (-1);
+#elif defined (ACE_WIN32)
+ // Create a handle for the given process id.
+ ACE_HANDLE process_handle =
+ ::OpenProcess (PROCESS_TERMINATE,
+ FALSE, // New handle is not inheritable.
+ pid);
+
+ if (process_handle == ACE_INVALID_HANDLE
+ || process_handle == 0)
+ return -1;
+ else
+ {
+ // Kill the process associated with process_handle.
+ BOOL terminate_result =
+ ::TerminateProcess (process_handle, 0);
+ // Free up the kernel resources.
+ ACE_OS::close (process_handle);
+ return terminate_result ? 0 : -1;
+ }
+#else
+ return ACE_OS::kill (pid, 9);
+#endif /* ACE_HAS_PHARLAP */
+}
+
+int
+ACE::process_active (pid_t pid)
+{
+#if !defined(ACE_WIN32)
+ if (ACE_OS::kill (pid, 0) == 0)
+ return 1;
+ else if (errno == ESRCH)
+ return 0;
+ else
+ return -1;
+#else
+ // Create a handle for the given process id.
+ ACE_HANDLE process_handle =
+ ::OpenProcess (PROCESS_QUERY_INFORMATION, FALSE, pid);
+ if (process_handle == ACE_INVALID_HANDLE || process_handle == 0)
+ return 0;
+ else
+ {
+ DWORD status;
+ int result = 1;
+ if (::GetExitCodeProcess (process_handle,
+ &status) == 0
+ || status != STILL_ACTIVE)
+ result = 0;
+
+ ::CloseHandle (process_handle);
+ return result;
+ }
+#endif /* !ACE_WIN32 */
+}
+
+const ACE_TCHAR *
+ACE::execname (const ACE_TCHAR *old_name)
+{
+#if defined (ACE_WIN32)
+ const ACE_TCHAR *suffix = ACE_OS::strrchr (old_name, ACE_TEXT ('.'));
+ if (suffix == 0 || ACE_OS::strcasecmp (suffix, ACE_TEXT (".exe")) != 0)
+ {
+ ACE_TCHAR *new_name = 0;
+
+ size_t size =
+ ACE_OS::strlen (old_name)
+ + ACE_OS::strlen (ACE_TEXT (".exe"))
+ + 1;
+
+ ACE_NEW_RETURN (new_name,
+ ACE_TCHAR[size],
+ 0);
+ ACE_TCHAR *end = new_name;
+
+ end = ACE_OS::strecpy (new_name, old_name);
+
+ // Concatenate the .exe suffix onto the end of the executable.
+ // end points _after_ the terminating nul.
+ ACE_OS::strcpy (end - 1, ACE_TEXT (".exe"));
+
+ return new_name;
+ }
+#endif /* ACE_WIN32 */
+ return old_name;
+}
+
+u_long
+ACE::hash_pjw (const char *str, size_t len)
+{
+ u_long hash = 0;
+
+ for (size_t i = 0; i < len; i++)
+ {
+ const char temp = str[i];
+ hash = (hash << 4) + (temp * 13);
+
+ u_long g = hash & 0xf0000000;
+
+ if (g)
+ {
+ hash ^= (g >> 24);
+ hash ^= g;
+ }
+ }
+
+ return hash;
+}
+
+u_long
+ACE::hash_pjw (const char *str)
+{
+ return ACE::hash_pjw (str, ACE_OS::strlen (str));
+}
+
+#if defined (ACE_HAS_WCHAR)
+u_long
+ACE::hash_pjw (const wchar_t *str, size_t len)
+{
+ u_long hash = 0;
+
+ for (size_t i = 0; i < len; i++)
+ {
+ // @@ UNICODE: Does this function do the correct thing with wchar's?
+
+ const wchar_t temp = str[i];
+ hash = (hash << 4) + (temp * 13);
+
+ u_long g = hash & 0xf0000000;
+
+ if (g)
+ {
+ hash ^= (g >> 24);
+ hash ^= g;
+ }
+ }
+
+ return hash;
+}
+
+u_long
+ACE::hash_pjw (const wchar_t *str)
+{
+ return ACE::hash_pjw (str, ACE_OS::strlen (str));
+}
+#endif /* ACE_HAS_WCHAR */
+
+ACE_TCHAR *
+ACE::strenvdup (const ACE_TCHAR *str)
+{
+ ACE_TRACE ("ACE::strenvdup");
+
+ return ACE_OS::strenvdup (str);
+}
+
+/*
+
+Examples:
+
+Source NT UNIX
+==================================================================
+netsvc netsvc.dll libnetsvc.so
+(PATH will be (LD_LIBRARY_PATH
+evaluated) evaluated)
+
+libnetsvc.dll libnetsvc.dll libnetsvc.dll + warning
+netsvc.so netsvc.so + warning libnetsvc.so
+
+..\../libs/netsvc ..\..\libs\netsvc.dll ../../libs/netsvc.so
+(absolute path used) (absolute path used)
+
+*/
+
+const ACE_TCHAR *
+ACE::basename (const ACE_TCHAR *pathname, ACE_TCHAR delim)
+{
+ ACE_TRACE ("ACE::basename");
+ const ACE_TCHAR *temp = ACE_OS::strrchr (pathname, delim);
+
+ if (temp == 0)
+ return pathname;
+ else
+ return temp + 1;
+}
+
+const ACE_TCHAR *
+ACE::dirname (const ACE_TCHAR *pathname, ACE_TCHAR delim)
+{
+ ACE_TRACE ("ACE::dirname");
+ static ACE_TCHAR return_dirname[MAXPATHLEN + 1];
+
+ const ACE_TCHAR *temp = ACE_OS::strrchr (pathname, delim);
+
+ if (temp == 0)
+ {
+ return_dirname[0] = '.';
+ return_dirname[1] = '\0';
+
+ return return_dirname;
+ }
+ else
+ {
+ // When the len is truncated, there are problems! This should
+ // not happen in normal circomstances
+ size_t len = temp - pathname + 1;
+ if (len > (sizeof return_dirname / sizeof (ACE_TCHAR)))
+ len = sizeof return_dirname / sizeof (ACE_TCHAR);
+
+ ACE_OS::strsncpy (return_dirname,
+ pathname,
+ len);
+ return return_dirname;
+ }
+}
+
+ssize_t
+ACE::recv (ACE_HANDLE handle,
+ void *buf,
+ size_t len,
+ int flags,
+ const ACE_Time_Value *timeout)
+{
+ if (timeout == 0)
+ return ACE_OS::recv (handle, (char *) buf, len, flags);
+ else
+ {
+ int val = 0;
+ if (ACE::enter_recv_timedwait (handle, timeout, val) ==-1)
+ return -1;
+ else
+ {
+ ssize_t bytes_transferred =
+ ACE_OS::recv (handle, (char *) buf, len, flags);
+ ACE::restore_non_blocking_mode (handle, val);
+ return bytes_transferred;
+ }
+ }
+}
+
+#if defined (ACE_HAS_TLI)
+
+ssize_t
+ACE::t_rcv (ACE_HANDLE handle,
+ void *buf,
+ size_t len,
+ int *flags,
+ const ACE_Time_Value *timeout)
+{
+ if (timeout == 0)
+ return ACE_OS::t_rcv (handle, (char *) buf, len, flags);
+ else
+ {
+ int val = 0;
+ if (ACE::enter_recv_timedwait (handle, timeout, val) ==-1)
+ return -1;
+ else
+ {
+ ssize_t bytes_transferred =
+ ACE_OS::t_rcv (handle, (char *) buf, len, flags);
+ ACE::restore_non_blocking_mode (handle, val);
+ return bytes_transferred;
+ }
+ }
+}
+
+#endif /* ACE_HAS_TLI */
+
+ssize_t
+ACE::recv (ACE_HANDLE handle,
+ void *buf,
+ size_t n,
+ const ACE_Time_Value *timeout)
+{
+ if (timeout == 0)
+ return ACE::recv_i (handle, buf, n);
+ else
+ {
+ int val = 0;
+ if (ACE::enter_recv_timedwait (handle, timeout, val) == -1)
+ return -1;
+ else
+ {
+ ssize_t bytes_transferred = ACE::recv_i (handle, buf, n);
+ ACE::restore_non_blocking_mode (handle, val);
+ return bytes_transferred;
+ }
+ }
+}
+
+ssize_t
+ACE::recvmsg (ACE_HANDLE handle,
+ struct msghdr *msg,
+ int flags,
+ const ACE_Time_Value *timeout)
+{
+ if (timeout == 0)
+ return ACE_OS::recvmsg (handle, msg, flags);
+ else
+ {
+ int val = 0;
+ if (ACE::enter_recv_timedwait (handle, timeout, val) == -1)
+ return -1;
+ else
+ {
+ ssize_t bytes_transferred = ACE_OS::recvmsg (handle, msg, flags);
+ ACE::restore_non_blocking_mode (handle, val);
+ return bytes_transferred;
+ }
+ }
+}
+
+ssize_t
+ACE::recvfrom (ACE_HANDLE handle,
+ char *buf,
+ int len,
+ int flags,
+ struct sockaddr *addr,
+ int *addrlen,
+ const ACE_Time_Value *timeout)
+{
+ if (timeout == 0)
+ return ACE_OS::recvfrom (handle, buf, len, flags, addr, addrlen);
+ else
+ {
+ int val = 0;
+ if (ACE::enter_recv_timedwait (handle, timeout, val) == -1)
+ return -1;
+ else
+ {
+ ssize_t bytes_transferred =
+ ACE_OS::recvfrom (handle, buf, len, flags, addr, addrlen);
+ ACE::restore_non_blocking_mode (handle, val);
+ return bytes_transferred;
+ }
+ }
+}
+
+ssize_t
+ACE::recv_n_i (ACE_HANDLE handle,
+ void *buf,
+ size_t len,
+ int flags,
+ size_t *bt)
+{
+ size_t temp;
+ size_t &bytes_transferred = bt == 0 ? temp : *bt;
+ ssize_t n;
+
+ for (bytes_transferred = 0;
+ bytes_transferred < len;
+ bytes_transferred += n)
+ {
+ // Try to transfer as much of the remaining data as possible.
+ n = ACE_OS::recv (handle,
+ static_cast (buf) + bytes_transferred,
+ len - bytes_transferred,
+ flags);
+ // Check EOF.
+ if (n == 0)
+ return 0;
+
+ // Check for other errors.
+ if (n == -1)
+ {
+ // Check for possible blocking.
+ if (errno == EWOULDBLOCK)
+ {
+ // Wait for the blocking to subside.
+ int const result = ACE::handle_read_ready (handle, 0);
+
+ // Did select() succeed?
+ if (result != -1)
+ {
+ // Blocking subsided. Continue data transfer.
+ n = 0;
+ continue;
+ }
+ }
+
+ // Other data transfer or select() failures.
+ return -1;
+ }
+ }
+
+ return static_cast (bytes_transferred);
+}
+
+ssize_t
+ACE::recv_n_i (ACE_HANDLE handle,
+ void *buf,
+ size_t len,
+ int flags,
+ const ACE_Time_Value *timeout,
+ size_t *bt)
+{
+ size_t temp;
+ size_t &bytes_transferred = bt == 0 ? temp : *bt;
+ ssize_t n;
+ ssize_t result = 0;
+ int error = 0;
+
+ int val = 0;
+ ACE::record_and_set_non_blocking_mode (handle, val);
+
+ for (bytes_transferred = 0;
+ bytes_transferred < len;
+ bytes_transferred += n)
+ {
+ // Try to transfer as much of the remaining data as possible.
+ // Since the socket is in non-blocking mode, this call will not
+ // block.
+ n = ACE_OS::recv (handle,
+ static_cast (buf) + bytes_transferred,
+ len - bytes_transferred,
+ flags);
+
+ // Check for errors.
+ if (n == 0 ||
+ n == -1)
+ {
+ // Check for possible blocking.
+ if (n == -1 &&
+ errno == EWOULDBLOCK)
+ {
+ // Wait upto for the blocking to subside.
+ int rtn = ACE::handle_read_ready (handle,
+ timeout);
+
+ // Did select() succeed?
+ if (rtn != -1)
+ {
+ // Blocking subsided in period. Continue
+ // data transfer.
+ n = 0;
+ continue;
+ }
+ }
+
+ // Wait in select() timed out or other data transfer or
+ // select() failures.
+ error = 1;
+ result = n;
+ break;
+ }
+ }
+
+ ACE::restore_non_blocking_mode (handle, val);
+
+ if (error)
+ return result;
+ else
+ return static_cast (bytes_transferred);
+}
+
+#if defined (ACE_HAS_TLI)
+
+ssize_t
+ACE::t_rcv_n_i (ACE_HANDLE handle,
+ void *buf,
+ size_t len,
+ int *flags,
+ size_t *bt)
+{
+ size_t temp;
+ size_t &bytes_transferred = bt == 0 ? temp : *bt;
+ ssize_t n;
+
+ for (bytes_transferred = 0;
+ bytes_transferred < len;
+ bytes_transferred += n)
+ {
+ // Try to transfer as much of the remaining data as possible.
+ n = ACE_OS::t_rcv (handle,
+ (char *) buf + bytes_transferred,
+ len - bytes_transferred,
+ flags);
+ // Check EOF.
+ if (n == 0)
+ return 0;
+
+ // Check for other errors.
+ if (n == -1)
+ {
+ // Check for possible blocking.
+ if (errno == EWOULDBLOCK)
+ {
+ // Wait for the blocking to subside.
+ int result = ACE::handle_read_ready (handle,
+ 0);
+
+ // Did select() succeed?
+ if (result != -1)
+ {
+ // Blocking subsided. Continue data transfer.
+ n = 0;
+ continue;
+ }
+ }
+
+ // Other data transfer or select() failures.
+ return -1;
+ }
+ }
+
+ return bytes_transferred;
+}
+
+ssize_t
+ACE::t_rcv_n_i (ACE_HANDLE handle,
+ void *buf,
+ size_t len,
+ int *flags,
+ const ACE_Time_Value *timeout,
+ size_t *bt)
+{
+ size_t temp;
+ size_t &bytes_transferred = bt == 0 ? temp : *bt;
+ ssize_t n;
+ ssize_t result = 0;
+ int error = 0;
+
+ int val = 0;
+ ACE::record_and_set_non_blocking_mode (handle, val);
+
+ for (bytes_transferred = 0;
+ bytes_transferred < len;
+ bytes_transferred += n)
+ {
+ // Try to transfer as much of the remaining data as possible.
+ // Since the socket is in non-blocking mode, this call will not
+ // block.
+ n = ACE_OS::t_rcv (handle,
+ (char *) buf + bytes_transferred,
+ len - bytes_transferred,
+ flags);
+
+ // Check for errors.
+ if (n == 0 ||
+ n == -1)
+ {
+ // Check for possible blocking.
+ if (n == -1 &&
+ errno == EWOULDBLOCK)
+ {
+ // Wait upto for the blocking to subside.
+ int rtn = ACE::handle_read_ready (handle,
+ timeout);
+
+ // Did select() succeed?
+ if (rtn != -1)
+ {
+ // Blocking subsided in period. Continue
+ // data transfer.
+ n = 0;
+ continue;
+ }
+ }
+
+ // Wait in select() timed out or other data transfer or
+ // select() failures.
+ error = 1;
+ result = n;
+ break;
+ }
+ }
+
+ ACE::restore_non_blocking_mode (handle, val);
+
+ if (error)
+ return result;
+ else
+ return bytes_transferred;
+}
+
+#endif /* ACE_HAS_TLI */
+
+ssize_t
+ACE::recv_n_i (ACE_HANDLE handle,
+ void *buf,
+ size_t len,
+ size_t *bt)
+{
+ size_t temp;
+ size_t &bytes_transferred = bt == 0 ? temp : *bt;
+ ssize_t n;
+
+ for (bytes_transferred = 0;
+ bytes_transferred < len;
+ bytes_transferred += n)
+ {
+ // Try to transfer as much of the remaining data as possible.
+ n = ACE::recv_i (handle,
+ static_cast (buf) + bytes_transferred,
+ len - bytes_transferred);
+ // Check EOF.
+ if (n == 0)
+ {
+ return 0;
+ }
+ // Check for other errors.
+ if (n == -1)
+ {
+ // Check for possible blocking.
+ if (errno == EWOULDBLOCK)
+ {
+ // Wait for the blocking to subside.
+ int result = ACE::handle_read_ready (handle,
+ 0);
+
+ // Did select() succeed?
+ if (result != -1)
+ {
+ // Blocking subsided. Continue data transfer.
+ n = 0;
+ continue;
+ }
+ }
+
+ // Other data transfer or select() failures.
+ return -1;
+ }
+ }
+
+ return static_cast (bytes_transferred);
+}
+
+ssize_t
+ACE::recv_n_i (ACE_HANDLE handle,
+ void *buf,
+ size_t len,
+ const ACE_Time_Value *timeout,
+ size_t *bt)
+{
+ size_t temp;
+ size_t &bytes_transferred = bt == 0 ? temp : *bt;
+ ssize_t n;
+ ssize_t result = 0;
+ int error = 0;
+
+ int val = 0;
+ ACE::record_and_set_non_blocking_mode (handle, val);
+
+ for (bytes_transferred = 0;
+ bytes_transferred < len;
+ bytes_transferred += n)
+ {
+ // Try to transfer as much of the remaining data as possible.
+ // Since the socket is in non-blocking mode, this call will not
+ // block.
+ n = ACE::recv_i (handle,
+ static_cast (buf) + bytes_transferred,
+ len - bytes_transferred);
+
+ // Check for errors.
+ if (n == 0 ||
+ n == -1)
+ {
+ // Check for possible blocking.
+ if (n == -1 &&
+ errno == EWOULDBLOCK)
+ {
+ // Wait upto for the blocking to subside.
+ int rtn = ACE::handle_read_ready (handle,
+ timeout);
+
+ // Did select() succeed?
+ if (rtn != -1)
+ {
+ // Blocking subsided in period. Continue
+ // data transfer.
+ n = 0;
+ continue;
+ }
+ }
+
+ // Wait in select() timed out or other data transfer or
+ // select() failures.
+ error = 1;
+ result = n;
+ break;
+ }
+ }
+
+ ACE::restore_non_blocking_mode (handle, val);
+
+ if (error)
+ return result;
+ else
+ return static_cast (bytes_transferred);
+}
+
+// This is basically an interface to ACE_OS::readv, that doesn't use
+// the struct iovec explicitly. The ... can be passed as an arbitrary
+// number of (char *ptr, int len) tuples. However, the count N is the
+// *total* number of trailing arguments, *not* a couple of the number
+// of tuple pairs!
+
+ssize_t
+ACE::recv (ACE_HANDLE handle, size_t n, ...)
+{
+ va_list argp;
+ int total_tuples = static_cast (n / 2);
+ iovec *iovp;
+#if defined (ACE_HAS_ALLOCA)
+ iovp = (iovec *) alloca (total_tuples * sizeof (iovec));
+#else
+ ACE_NEW_RETURN (iovp,
+ iovec[total_tuples],
+ -1);
+#endif /* !defined (ACE_HAS_ALLOCA) */
+
+ va_start (argp, n);
+
+ for (int i = 0; i < total_tuples; i++)
+ {
+ iovp[i].iov_base = va_arg (argp, char *);
+ iovp[i].iov_len = va_arg (argp, int);
+ }
+
+ ssize_t result = ACE_OS::recvv (handle, iovp, total_tuples);
+#if !defined (ACE_HAS_ALLOCA)
+ delete [] iovp;
+#endif /* !defined (ACE_HAS_ALLOCA) */
+ va_end (argp);
+ return result;
+}
+
+ssize_t
+ACE::recvv (ACE_HANDLE handle,
+ iovec *iov,
+ int iovcnt,
+ const ACE_Time_Value *timeout)
+{
+ if (timeout == 0)
+ return ACE_OS::recvv (handle, iov, iovcnt);
+ else
+ {
+ int val = 0;
+ if (ACE::enter_recv_timedwait (handle, timeout, val) == -1)
+ return -1;
+ else
+ {
+ ssize_t bytes_transferred = ACE_OS::recvv (handle, iov, iovcnt);
+ ACE::restore_non_blocking_mode (handle, val);
+ return bytes_transferred;
+ }
+ }
+}
+
+ssize_t
+ACE::recvv_n_i (ACE_HANDLE handle,
+ iovec *iov,
+ int iovcnt,
+ size_t *bt)
+{
+ size_t temp;
+ size_t &bytes_transferred = bt == 0 ? temp : *bt;
+ bytes_transferred = 0;
+
+ for (int s = 0;
+ s < iovcnt;
+ )
+ {
+ // Try to transfer as much of the remaining data as possible.
+ ssize_t n = ACE_OS::recvv (handle,
+ iov + s,
+ iovcnt - s);
+ // Check EOF.
+ if (n == 0)
+ return 0;
+
+ // Check for other errors.
+ if (n == -1)
+ {
+ // Check for possible blocking.
+ if (errno == EWOULDBLOCK)
+ {
+ // Wait for the blocking to subside.
+ int result = ACE::handle_read_ready (handle,
+ 0);
+
+ // Did select() succeed?
+ if (result != -1)
+ {
+ // Blocking subsided. Continue data transfer.
+ n = 0;
+ continue;
+ }
+ }
+
+ // Other data transfer or select() failures.
+ return -1;
+ }
+
+ for (bytes_transferred += n;
+ s < iovcnt
+ && n >= static_cast (iov[s].iov_len);
+ s++)
+ n -= iov[s].iov_len;
+
+ if (n != 0)
+ {
+ char *base = static_cast (iov[s].iov_base);
+ iov[s].iov_base = base + n;
+ iov[s].iov_len = iov[s].iov_len - n;
+ }
+ }
+
+ return ACE_Utils::truncate_cast (bytes_transferred);
+}
+
+ssize_t
+ACE::recvv_n_i (ACE_HANDLE handle,
+ iovec *iov,
+ int iovcnt,
+ const ACE_Time_Value *timeout,
+ size_t *bt)
+{
+ size_t temp;
+ size_t &bytes_transferred = bt == 0 ? temp : *bt;
+ bytes_transferred = 0;
+ ssize_t result = 0;
+ int error = 0;
+
+ int val = 0;
+ ACE::record_and_set_non_blocking_mode (handle, val);
+
+ for (int s = 0;
+ s < iovcnt;
+ )
+ {
+ // Try to transfer as much of the remaining data as possible.
+ // Since the socket is in non-blocking mode, this call will not
+ // block.
+ ssize_t n = ACE_OS::recvv (handle,
+ iov + s,
+ iovcnt - s);
+
+ // Check for errors.
+ if (n == 0 ||
+ n == -1)
+ {
+ // Check for possible blocking.
+ if (n == -1 &&
+ errno == EWOULDBLOCK)
+ {
+ // Wait upto for the blocking to subside.
+ int rtn = ACE::handle_read_ready (handle,
+ timeout);
+
+ // Did select() succeed?
+ if (rtn != -1)
+ {
+ // Blocking subsided in period. Continue
+ // data transfer.
+ n = 0;
+ continue;
+ }
+ }
+
+ // Wait in select() timed out or other data transfer or
+ // select() failures.
+ error = 1;
+ result = n;
+ break;
+ }
+
+ for (bytes_transferred += n;
+ s < iovcnt
+ && n >= static_cast (iov[s].iov_len);
+ s++)
+ n -= iov[s].iov_len;
+
+ if (n != 0)
+ {
+ char *base = reinterpret_cast (iov[s].iov_base);
+ iov[s].iov_base = base + n;
+ iov[s].iov_len = iov[s].iov_len - n;
+ }
+ }
+
+ ACE::restore_non_blocking_mode (handle, val);
+
+ if (error)
+ {
+ return result;
+ }
+ else
+ {
+ return ACE_Utils::truncate_cast (bytes_transferred);
+ }
+}
+
+ssize_t
+ACE::recv_n (ACE_HANDLE handle,
+ ACE_Message_Block *message_block,
+ const ACE_Time_Value *timeout,
+ size_t *bt)
+{
+ size_t temp;
+ size_t &bytes_transferred = bt == 0 ? temp : *bt;
+ bytes_transferred = 0;
+
+ iovec iov[ACE_IOV_MAX];
+ int iovcnt = 0;
+
+ while (message_block != 0)
+ {
+ // Our current message block chain.
+ const ACE_Message_Block *current_message_block = message_block;
+
+ while (current_message_block != 0)
+ {
+ size_t current_message_block_length =
+ current_message_block->length ();
+ char *this_rd_ptr = current_message_block->rd_ptr ();
+
+ // Check if this block has any space for incoming data.
+ while (current_message_block_length > 0)
+ {
+ u_long const this_chunk_length =
+ ACE_Utils::truncate_cast (
+ current_message_block_length);
+
+ // Collect the data in the iovec.
+ iov[iovcnt].iov_base = this_rd_ptr;
+ iov[iovcnt].iov_len = this_chunk_length;
+ current_message_block_length -= this_chunk_length;
+ this_rd_ptr += this_chunk_length;
+
+ // Increment iovec counter.
+ ++iovcnt;
+
+ // The buffer is full make a OS call. @@ TODO find a way to
+ // find ACE_IOV_MAX for platforms that do not define it rather
+ // than simply setting ACE_IOV_MAX to some arbitrary value such
+ // as 16.
+ if (iovcnt == ACE_IOV_MAX)
+ {
+ size_t current_transfer = 0;
+
+ ssize_t const result = ACE::recvv_n (handle,
+ iov,
+ iovcnt,
+ timeout,
+ ¤t_transfer);
+
+ // Add to total bytes transferred.
+ bytes_transferred += current_transfer;
+
+ // Errors.
+ if (result == -1 || result == 0)
+ return result;
+
+ // Reset iovec counter.
+ iovcnt = 0;
+ }
+ }
+
+ // Select the next message block in the chain.
+ current_message_block = current_message_block->cont ();
+ }
+
+ // Selection of the next message block chain.
+ message_block = message_block->next ();
+ }
+
+ // Check for remaining buffers to be sent. This will happen when
+ // ACE_IOV_MAX is not a multiple of the number of message blocks.
+ if (iovcnt != 0)
+ {
+ size_t current_transfer = 0;
+
+ ssize_t const result = ACE::recvv_n (handle,
+ iov,
+ iovcnt,
+ timeout,
+ ¤t_transfer);
+
+ // Add to total bytes transferred.
+ bytes_transferred += current_transfer;
+
+ // Errors.
+ if (result == -1 || result == 0)
+ {
+ return result;
+ }
+ }
+
+ // Return total bytes transferred.
+ return ACE_Utils::truncate_cast (bytes_transferred);
+}
+
+ssize_t
+ACE::send (ACE_HANDLE handle,
+ const void *buf,
+ size_t n,
+ int flags,
+ const ACE_Time_Value *timeout)
+{
+ if (timeout == 0)
+ return ACE_OS::send (handle, (const char *) buf, n, flags);
+ else
+ {
+ int val = 0;
+ if (ACE::enter_send_timedwait (handle, timeout, val) == -1)
+ return -1;
+ else
+ {
+ ssize_t bytes_transferred = ACE_OS::send (handle, (const char *) buf, n, flags);
+ ACE::restore_non_blocking_mode (handle, val);
+ return bytes_transferred;
+ }
+ }
+}
+
+#if defined (ACE_HAS_TLI)
+
+ssize_t
+ACE::t_snd (ACE_HANDLE handle,
+ const void *buf,
+ size_t n,
+ int flags,
+ const ACE_Time_Value *timeout)
+{
+ if (timeout == 0)
+ return ACE_OS::t_snd (handle, (const char *) buf, n, flags);
+ else
+ {
+ int val = 0;
+ if (ACE::enter_send_timedwait (handle, timeout, val) == -1)
+ return -1;
+ else
+ {
+ ssize_t bytes_transferred = ACE_OS::t_snd (handle, (const char *) buf, n, flags);
+ ACE::restore_non_blocking_mode (handle, val);
+ return bytes_transferred;
+ }
+ }
+}
+
+#endif /* ACE_HAS_TLI */
+
+ssize_t
+ACE::send (ACE_HANDLE handle,
+ const void *buf,
+ size_t n,
+ const ACE_Time_Value *timeout)
+{
+ if (timeout == 0)
+ return ACE::send_i (handle, buf, n);
+ else
+ {
+ int val = 0;
+ if (ACE::enter_send_timedwait (handle, timeout, val) == -1)
+ return -1;
+ else
+ {
+ ssize_t bytes_transferred = ACE::send_i (handle, buf, n);
+ ACE::restore_non_blocking_mode (handle, val);
+ return bytes_transferred;
+ }
+ }
+}
+
+ssize_t
+ACE::sendmsg (ACE_HANDLE handle,
+ const struct msghdr *msg,
+ int flags,
+ const ACE_Time_Value *timeout)
+{
+ if (timeout == 0)
+ return ACE_OS::sendmsg (handle, msg, flags);
+ else
+ {
+ int val = 0;
+ if (ACE::enter_send_timedwait (handle, timeout, val) == -1)
+ return -1;
+ else
+ {
+ ssize_t bytes_transferred = ACE_OS::sendmsg (handle, msg, flags);
+ ACE::restore_non_blocking_mode (handle, val);
+ return bytes_transferred;
+ }
+ }
+}
+
+ssize_t
+ACE::sendto (ACE_HANDLE handle,
+ const char *buf,
+ int len,
+ int flags,
+ const struct sockaddr *addr,
+ int addrlen,
+ const ACE_Time_Value *timeout)
+{
+ if (timeout == 0)
+ return ACE_OS::sendto (handle, buf, len, flags, addr, addrlen);
+ else
+ {
+ int val = 0;
+ if (ACE::enter_send_timedwait (handle, timeout, val) == -1)
+ return -1;
+ else
+ {
+ ssize_t bytes_transferred =
+ ACE_OS::sendto (handle, buf, len, flags, addr, addrlen);
+ ACE::restore_non_blocking_mode (handle, val);
+ return bytes_transferred;
+ }
+ }
+}
+
+ssize_t
+ACE::send_n_i (ACE_HANDLE handle,
+ const void *buf,
+ size_t len,
+ int flags,
+ size_t *bt)
+{
+ size_t temp;
+ size_t &bytes_transferred = bt == 0 ? temp : *bt;
+ ssize_t n;
+
+ for (bytes_transferred = 0;
+ bytes_transferred < len;
+ bytes_transferred += n)
+ {
+ // Try to transfer as much of the remaining data as possible.
+ n = ACE_OS::send (handle,
+ (char *) buf + bytes_transferred,
+ len - bytes_transferred,
+ flags);
+ // Check EOF.
+ if (n == 0)
+ return 0;
+
+ // Check for other errors.
+ if (n == -1)
+ {
+ // Check for possible blocking.
+#if defined (ACE_WIN32)
+ if (errno == EWOULDBLOCK) // If enobufs no need to loop
+#else
+ if (errno == EWOULDBLOCK || errno == ENOBUFS)
+#endif /* ACE_WIN32 */
+ {
+ // Wait for the blocking to subside.
+ int result = ACE::handle_write_ready (handle,
+ 0);
+
+ // Did select() succeed?
+ if (result != -1)
+ {
+ // Blocking subsided. Continue data transfer.
+ n = 0;
+ continue;
+ }
+ }
+
+ // Other data transfer or select() failures.
+ return -1;
+ }
+ }
+
+ return ACE_Utils::truncate_cast (bytes_transferred);
+}
+
+ssize_t
+ACE::send_n_i (ACE_HANDLE handle,
+ const void *buf,
+ size_t len,
+ int flags,
+ const ACE_Time_Value *timeout,
+ size_t *bt)
+{
+ size_t temp;
+ size_t &bytes_transferred = bt == 0 ? temp : *bt;
+ ssize_t n;
+ ssize_t result = 0;
+ int error = 0;
+
+ int val = 0;
+ ACE::record_and_set_non_blocking_mode (handle, val);
+
+ for (bytes_transferred = 0;
+ bytes_transferred < len;
+ bytes_transferred += n)
+ {
+ // Try to transfer as much of the remaining data as possible.
+ // Since the socket is in non-blocking mode, this call will not
+ // block.
+ n = ACE_OS::send (handle,
+ (char *) buf + bytes_transferred,
+ len - bytes_transferred,
+ flags);
+
+ // Check for errors.
+ if (n == 0 ||
+ n == -1)
+ {
+ // Check for possible blocking.
+ if (n == -1 &&
+ (errno == EWOULDBLOCK || errno == ENOBUFS))
+ {
+ // Wait upto for the blocking to subside.
+ int rtn = ACE::handle_write_ready (handle,
+ timeout);
+
+ // Did select() succeed?
+ if (rtn != -1)
+ {
+ // Blocking subsided in period. Continue
+ // data transfer.
+ n = 0;
+ continue;
+ }
+ }
+
+ // Wait in select() timed out or other data transfer or
+ // select() failures.
+ error = 1;
+ result = n;
+ break;
+ }
+ }
+
+ ACE::restore_non_blocking_mode (handle, val);
+
+ if (error)
+ {
+ return result;
+ }
+ else
+ {
+ return ACE_Utils::truncate_cast (bytes_transferred);
+ }
+}
+
+#if defined (ACE_HAS_TLI)
+
+ssize_t
+ACE::t_snd_n_i (ACE_HANDLE handle,
+ const void *buf,
+ size_t len,
+ int flags,
+ size_t *bt)
+{
+ size_t temp;
+ size_t &bytes_transferred = bt == 0 ? temp : *bt;
+ ssize_t n;
+
+ for (bytes_transferred = 0;
+ bytes_transferred < len;
+ bytes_transferred += n)
+ {
+ // Try to transfer as much of the remaining data as possible.
+ n = ACE_OS::t_snd (handle,
+ (char *) buf + bytes_transferred,
+ len - bytes_transferred,
+ flags);
+ // Check EOF.
+ if (n == 0)
+ return 0;
+
+ // Check for other errors.
+ if (n == -1)
+ {
+ // Check for possible blocking.
+ if (errno == EWOULDBLOCK || errno == ENOBUFS)
+ {
+ // Wait for the blocking to subside.
+ int result = ACE::handle_write_ready (handle,
+ 0);
+
+ // Did select() succeed?
+ if (result != -1)
+ {
+ // Blocking subsided. Continue data transfer.
+ n = 0;
+ continue;
+ }
+ }
+
+ // Other data transfer or select() failures.
+ return -1;
+ }
+ }
+
+ return bytes_transferred;
+}
+
+ssize_t
+ACE::t_snd_n_i (ACE_HANDLE handle,
+ const void *buf,
+ size_t len,
+ int flags,
+ const ACE_Time_Value *timeout,
+ size_t *bt)
+{
+ size_t temp;
+ size_t &bytes_transferred = bt == 0 ? temp : *bt;
+ ssize_t n;
+ ssize_t result = 0;
+ int error = 0;
+
+ int val = 0;
+ ACE::record_and_set_non_blocking_mode (handle, val);
+
+ for (bytes_transferred = 0;
+ bytes_transferred < len;
+ bytes_transferred += n)
+ {
+ // Try to transfer as much of the remaining data as possible.
+ // Since the socket is in non-blocking mode, this call will not
+ // block.
+ n = ACE_OS::t_snd (handle,
+ (char *) buf + bytes_transferred,
+ len - bytes_transferred,
+ flags);
+
+ // Check for errors.
+ if (n == 0 ||
+ n == -1)
+ {
+ // Check for possible blocking.
+ if (n == -1 &&
+ errno == EWOULDBLOCK || errno == ENOBUFS)
+ {
+ // Wait upto for the blocking to subside.
+ int rtn = ACE::handle_write_ready (handle,
+ timeout);
+
+ // Did select() succeed?
+ if (rtn != -1)
+ {
+ // Blocking subsided in period. Continue
+ // data transfer.
+ n = 0;
+ continue;
+ }
+ }
+
+ // Wait in select() timed out or other data transfer or
+ // select() failures.
+ error = 1;
+ result = n;
+ break;
+ }
+ }
+
+ ACE::restore_non_blocking_mode (handle, val);
+
+ if (error)
+ return result;
+ else
+ return bytes_transferred;
+}
+
+#endif /* ACE_HAS_TLI */
+
+ssize_t
+ACE::send_n_i (ACE_HANDLE handle,
+ const void *buf,
+ size_t len,
+ size_t *bt)
+{
+ size_t temp;
+ size_t &bytes_transferred = bt == 0 ? temp : *bt;
+ ssize_t n;
+
+ for (bytes_transferred = 0;
+ bytes_transferred < len;
+ bytes_transferred += n)
+ {
+ // Try to transfer as much of the remaining data as possible.
+ n = ACE::send_i (handle,
+ (char *) buf + bytes_transferred,
+ len - bytes_transferred);
+ // Check EOF.
+ if (n == 0)
+ {
+ return 0;
+ }
+
+ // Check for other errors.
+ if (n == -1)
+ {
+ // Check for possible blocking.
+ if (errno == EWOULDBLOCK || errno == ENOBUFS)
+ {
+ // Wait for the blocking to subside.
+ int result = ACE::handle_write_ready (handle,
+ 0);
+
+ // Did select() succeed?
+ if (result != -1)
+ {
+ // Blocking subsided. Continue data transfer.
+ n = 0;
+ continue;
+ }
+ }
+
+ // Other data transfer or select() failures.
+ return -1;
+ }
+ }
+
+ return ACE_Utils::truncate_cast (bytes_transferred);
+}
+
+ssize_t
+ACE::send_n_i (ACE_HANDLE handle,
+ const void *buf,
+ size_t len,
+ const ACE_Time_Value *timeout,
+ size_t *bt)
+{
+ size_t temp;
+ size_t &bytes_transferred = bt == 0 ? temp : *bt;
+ ssize_t n;
+ ssize_t result = 0;
+ int error = 0;
+
+ int val = 0;
+ ACE::record_and_set_non_blocking_mode (handle, val);
+
+ for (bytes_transferred = 0;
+ bytes_transferred < len;
+ bytes_transferred += n)
+ {
+ // Try to transfer as much of the remaining data as possible.
+ // Since the socket is in non-blocking mode, this call will not
+ // block.
+ n = ACE::send_i (handle,
+ (char *) buf + bytes_transferred,
+ len - bytes_transferred);
+
+ // Check for errors.
+ if (n == 0 ||
+ n == -1)
+ {
+ // Check for possible blocking.
+ if (n == -1 &&
+ (errno == EWOULDBLOCK || errno == ENOBUFS))
+ {
+ // Wait upto for the blocking to subside.
+ int rtn = ACE::handle_write_ready (handle,
+ timeout);
+
+ // Did select() succeed?
+ if (rtn != -1)
+ {
+ // Blocking subsided in period. Continue
+ // data transfer.
+ n = 0;
+ continue;
+ }
+ }
+
+ // Wait in select() timed out or other data transfer or
+ // select() failures.
+ error = 1;
+ result = n;
+ break;
+ }
+ }
+
+ ACE::restore_non_blocking_mode (handle, val);
+
+ if (error)
+ {
+ return result;
+ }
+ else
+ {
+ return ACE_Utils::truncate_cast (bytes_transferred);
+ }
+}
+
+// Send N char *ptrs and int lengths. Note that the char *'s precede
+// the ints (basically, an varargs version of writev). The count N is
+// the *total* number of trailing arguments, *not* a couple of the
+// number of tuple pairs!
+
+ssize_t
+ACE::send (ACE_HANDLE handle, size_t n, ...)
+{
+ va_list argp;
+ int total_tuples = static_cast (n / 2);
+ iovec *iovp;
+#if defined (ACE_HAS_ALLOCA)
+ iovp = (iovec *) alloca (total_tuples * sizeof (iovec));
+#else
+ ACE_NEW_RETURN (iovp,
+ iovec[total_tuples],
+ -1);
+#endif /* !defined (ACE_HAS_ALLOCA) */
+
+ va_start (argp, n);
+
+ for (int i = 0; i < total_tuples; i++)
+ {
+ iovp[i].iov_base = va_arg (argp, char *);
+ iovp[i].iov_len = va_arg (argp, int);
+ }
+
+ ssize_t result = ACE_OS::sendv (handle, iovp, total_tuples);
+#if !defined (ACE_HAS_ALLOCA)
+ delete [] iovp;
+#endif /* !defined (ACE_HAS_ALLOCA) */
+ va_end (argp);
+ return result;
+}
+
+ssize_t
+ACE::sendv (ACE_HANDLE handle,
+ const iovec *iov,
+ int iovcnt,
+ const ACE_Time_Value *timeout)
+{
+ if (timeout == 0)
+ return ACE_OS::sendv (handle, iov, iovcnt);
+ else
+ {
+ int val = 0;
+ if (ACE::enter_send_timedwait (handle, timeout, val) == -1)
+ return -1;
+ else
+ {
+ ssize_t bytes_transferred = ACE_OS::sendv (handle, iov, iovcnt);
+ ACE::restore_non_blocking_mode (handle, val);
+ return bytes_transferred;
+ }
+ }
+}
+
+ssize_t
+ACE::sendv_n_i (ACE_HANDLE handle,
+ const iovec *i,
+ int iovcnt,
+ size_t *bt)
+{
+ size_t temp;
+ size_t &bytes_transferred = bt == 0 ? temp : *bt;
+ bytes_transferred = 0;
+
+ iovec *iov = const_cast (i);
+
+ for (int s = 0;
+ s < iovcnt;
+ )
+ {
+ // Try to transfer as much of the remaining data as possible.
+ ssize_t n = ACE_OS::sendv (handle,
+ iov + s,
+ iovcnt - s);
+ // Check EOF.
+ if (n == 0)
+ return 0;
+
+ // Check for other errors.
+ if (n == -1)
+ {
+ // Check for possible blocking.
+ if (errno == EWOULDBLOCK || errno == ENOBUFS)
+ {
+ // Wait for the blocking to subside.
+ int result = ACE::handle_write_ready (handle,
+ 0);
+
+ // Did select() succeed?
+ if (result != -1)
+ {
+ // Blocking subsided. Continue data transfer.
+ n = 0;
+ continue;
+ }
+ }
+
+ // Other data transfer or select() failures.
+ return -1;
+ }
+
+ for (bytes_transferred += n;
+ s < iovcnt
+ && n >= static_cast (iov[s].iov_len);
+ s++)
+ n -= iov[s].iov_len;
+
+ if (n != 0)
+ {
+ char *base = reinterpret_cast (iov[s].iov_base);
+ iov[s].iov_base = base + n;
+ iov[s].iov_len = iov[s].iov_len - n;
+ }
+ }
+
+ return ACE_Utils::truncate_cast (bytes_transferred);
+}
+
+ssize_t
+ACE::sendv_n_i (ACE_HANDLE handle,
+ const iovec *i,
+ int iovcnt,
+ const ACE_Time_Value *timeout,
+ size_t *bt)
+{
+ size_t temp;
+ size_t &bytes_transferred = bt == 0 ? temp : *bt;
+ bytes_transferred = 0;
+ ssize_t result = 0;
+ int error = 0;
+
+ int val = 0;
+ ACE::record_and_set_non_blocking_mode (handle, val);
+
+ iovec *iov = const_cast (i);
+
+ for (int s = 0;
+ s < iovcnt;
+ )
+ {
+ // Try to transfer as much of the remaining data as possible.
+ // Since the socket is in non-blocking mode, this call will not
+ // block.
+ ssize_t n = ACE_OS::sendv (handle,
+ iov + s,
+ iovcnt - s);
+
+ // Check for errors.
+ if (n == 0 ||
+ n == -1)
+ {
+ // Check for possible blocking.
+ if (n == -1 &&
+ (errno == EWOULDBLOCK || errno == ENOBUFS))
+ {
+ // Wait upto for the blocking to subside.
+ int rtn = ACE::handle_write_ready (handle,
+ timeout);
+
+ // Did select() succeed?
+ if (rtn != -1)
+ {
+ // Blocking subsided in period. Continue
+ // data transfer.
+ n = 0;
+ continue;
+ }
+ }
+
+ // Wait in select() timed out or other data transfer or
+ // select() failures.
+ error = 1;
+ result = n;
+ break;
+ }
+
+ for (bytes_transferred += n;
+ s < iovcnt
+ && n >= static_cast (iov[s].iov_len);
+ s++)
+ n -= iov[s].iov_len;
+
+ if (n != 0)
+ {
+ char *base = reinterpret_cast (iov[s].iov_base);
+ iov[s].iov_base = base + n;
+ iov[s].iov_len = iov[s].iov_len - n;
+ }
+ }
+
+ ACE::restore_non_blocking_mode (handle, val);
+
+ if (error)
+ {
+ return result;
+ }
+ else
+ {
+ return ACE_Utils::truncate_cast (bytes_transferred);
+ }
+}
+
+ssize_t
+ACE::write_n (ACE_HANDLE handle,
+ const ACE_Message_Block *message_block,
+ size_t *bt)
+{
+ size_t temp;
+ size_t &bytes_transferred = bt == 0 ? temp : *bt;
+ bytes_transferred = 0;
+
+ iovec iov[ACE_IOV_MAX];
+ int iovcnt = 0;
+
+ while (message_block != 0)
+ {
+ // Our current message block chain.
+ const ACE_Message_Block *current_message_block = message_block;
+
+ while (current_message_block != 0)
+ {
+ size_t current_message_block_length =
+ current_message_block->length ();
+ char *this_block_ptr = current_message_block->rd_ptr ();
+
+ // Check if this block has any data to be sent.
+ while (current_message_block_length > 0)
+ {
+ u_long const this_chunk_length =
+ ACE_Utils::truncate_cast (
+ current_message_block_length);
+
+ // Collect the data in the iovec.
+ iov[iovcnt].iov_base = this_block_ptr;
+ iov[iovcnt].iov_len = this_chunk_length;
+ current_message_block_length -= this_chunk_length;
+ this_block_ptr += this_chunk_length;
+
+ // Increment iovec counter.
+ ++iovcnt;
+
+ // The buffer is full make a OS call. @@ TODO find a way to
+ // find ACE_IOV_MAX for platforms that do not define it rather
+ // than simply setting ACE_IOV_MAX to some arbitrary value such
+ // as 16.
+ if (iovcnt == ACE_IOV_MAX)
+ {
+ size_t current_transfer = 0;
+
+ ssize_t const result = ACE::writev_n (handle,
+ iov,
+ iovcnt,
+ ¤t_transfer);
+
+ // Add to total bytes transferred.
+ bytes_transferred += current_transfer;
+
+ // Errors.
+ if (result == -1 || result == 0)
+ return result;
+
+ // Reset iovec counter.
+ iovcnt = 0;
+ }
+ }
+
+ // Select the next message block in the chain.
+ current_message_block = current_message_block->cont ();
+ }
+
+ // Selection of the next message block chain.
+ message_block = message_block->next ();
+ }
+
+ // Check for remaining buffers to be sent. This will happen when
+ // ACE_IOV_MAX is not a multiple of the number of message blocks.
+ if (iovcnt != 0)
+ {
+ size_t current_transfer = 0;
+
+ ssize_t const result = ACE::writev_n (handle,
+ iov,
+ iovcnt,
+ ¤t_transfer);
+
+ // Add to total bytes transferred.
+ bytes_transferred += current_transfer;
+
+ // Errors.
+ if (result == -1 || result == 0)
+ return result;
+ }
+
+ // Return total bytes transferred.
+ return ACE_Utils::truncate_cast (bytes_transferred);
+}
+
+ssize_t
+ACE::send_n (ACE_HANDLE handle,
+ const ACE_Message_Block *message_block,
+ const ACE_Time_Value *timeout,
+ size_t *bt)
+{
+ size_t temp;
+ size_t &bytes_transferred = bt == 0 ? temp : *bt;
+ bytes_transferred = 0;
+
+ iovec iov[ACE_IOV_MAX];
+ int iovcnt = 0;
+
+ while (message_block != 0)
+ {
+ // Our current message block chain.
+ const ACE_Message_Block *current_message_block = message_block;
+
+ while (current_message_block != 0)
+ {
+ char *this_block_ptr = current_message_block->rd_ptr ();
+ size_t current_message_block_length =
+ current_message_block->length ();
+
+ // Check if this block has any data to be sent.
+ while (current_message_block_length > 0)
+ {
+ u_long const this_chunk_length =
+ ACE_Utils::truncate_cast (
+ current_message_block_length);
+
+ // Collect the data in the iovec.
+ iov[iovcnt].iov_base = this_block_ptr;
+ iov[iovcnt].iov_len = this_chunk_length;
+ current_message_block_length -= this_chunk_length;
+ this_block_ptr += this_chunk_length;
+
+ // Increment iovec counter.
+ ++iovcnt;
+
+ // The buffer is full make a OS call. @@ TODO find a way to
+ // find ACE_IOV_MAX for platforms that do not define it rather
+ // than simply setting ACE_IOV_MAX to some arbitrary value such
+ // as 16.
+ if (iovcnt == ACE_IOV_MAX)
+ {
+ size_t current_transfer = 0;
+
+ ssize_t const result = ACE::sendv_n (handle,
+ iov,
+ iovcnt,
+ timeout,
+ ¤t_transfer);
+
+ // Add to total bytes transferred.
+ bytes_transferred += current_transfer;
+
+ // Errors.
+ if (result == -1 || result == 0)
+ return result;
+
+ // Reset iovec counter.
+ iovcnt = 0;
+ }
+ }
+
+ // Select the next message block in the chain.
+ current_message_block = current_message_block->cont ();
+ }
+
+ // Selection of the next message block chain.
+ message_block = message_block->next ();
+ }
+
+ // Check for remaining buffers to be sent. This will happen when
+ // ACE_IOV_MAX is not a multiple of the number of message blocks.
+ if (iovcnt != 0)
+ {
+ size_t current_transfer = 0;
+
+ ssize_t const result = ACE::sendv_n (handle,
+ iov,
+ iovcnt,
+ timeout,
+ ¤t_transfer);
+
+ // Add to total bytes transferred.
+ bytes_transferred += current_transfer;
+
+ // Errors.
+ if (result == -1 || result == 0)
+ {
+ return result;
+ }
+ }
+
+ // Return total bytes transferred.
+ return ACE_Utils::truncate_cast (bytes_transferred);
+}
+
+ssize_t
+ACE::readv_n (ACE_HANDLE handle,
+ iovec *iov,
+ int iovcnt,
+ size_t *bt)
+{
+ size_t temp;
+ size_t &bytes_transferred = bt == 0 ? temp : *bt;
+ bytes_transferred = 0;
+
+ for (int s = 0;
+ s < iovcnt;
+ )
+ {
+ ssize_t n = ACE_OS::readv (handle,
+ iov + s,
+ iovcnt - s);
+
+ if (n == -1 || n == 0)
+ return n;
+
+ for (bytes_transferred += n;
+ s < iovcnt
+ && n >= static_cast (iov[s].iov_len);
+ s++)
+ n -= iov[s].iov_len;
+
+ if (n != 0)
+ {
+ char *base = reinterpret_cast (iov[s].iov_base);
+ iov[s].iov_base = base + n;
+ iov[s].iov_len = iov[s].iov_len - n;
+ }
+ }
+
+ return ACE_Utils::truncate_cast (bytes_transferred);
+}
+
+ssize_t
+ACE::writev_n (ACE_HANDLE handle,
+ const iovec *i,
+ int iovcnt,
+ size_t *bt)
+{
+ size_t temp;
+ size_t &bytes_transferred = bt == 0 ? temp : *bt;
+ bytes_transferred = 0;
+
+ iovec *iov = const_cast (i);
+
+ for (int s = 0;
+ s < iovcnt;
+ )
+ {
+ ssize_t n = ACE_OS::writev (handle,
+ iov + s,
+ iovcnt - s);
+
+ if (n == -1 || n == 0)
+ {
+ return n;
+ }
+
+ for (bytes_transferred += n;
+ s < iovcnt
+ && n >= static_cast (iov[s].iov_len);
+ s++)
+ n -= iov[s].iov_len;
+
+ if (n != 0)
+ {
+ char *base = reinterpret_cast (iov[s].iov_base);
+ iov[s].iov_base = base + n;
+ iov[s].iov_len = iov[s].iov_len - n;
+ }
+ }
+
+ return ACE_Utils::truncate_cast (bytes_transferred);
+}
+
+int
+ACE::handle_ready (ACE_HANDLE handle,
+ const ACE_Time_Value *timeout,
+ int read_ready,
+ int write_ready,
+ int exception_ready)
+{
+#if defined (ACE_HAS_POLL) && defined (ACE_HAS_LIMITED_SELECT)
+ ACE_UNUSED_ARG (write_ready);
+ ACE_UNUSED_ARG (exception_ready);
+
+ struct pollfd fds;
+
+ fds.fd = handle;
+ fds.events = read_ready ? POLLIN : POLLOUT;
+ fds.revents = 0;
+
+ int result = ACE_OS::poll (&fds, 1, timeout);
+#else
+ ACE_Handle_Set handle_set;
+ handle_set.set_bit (handle);
+
+ // Wait for data or for the timeout to elapse.
+ int select_width;
+# if defined (ACE_WIN32)
+ // This arg is ignored on Windows and causes pointer truncation
+ // warnings on 64-bit compiles.
+ select_width = 0;
+# else
+ select_width = int (handle) + 1;
+# endif /* ACE_WIN64 */
+ int result = ACE_OS::select (select_width,
+ read_ready ? handle_set.fdset () : 0, // read_fds.
+ write_ready ? handle_set.fdset () : 0, // write_fds.
+ exception_ready ? handle_set.fdset () : 0, // exception_fds.
+ timeout);
+
+#endif /* ACE_HAS_POLL && ACE_HAS_LIMITED_SELECT */
+
+ switch (result)
+ {
+ case 0: // Timer expired.
+ errno = ETIME;
+ /* FALLTHRU */
+ case -1: // we got here directly - select() returned -1.
+ return -1;
+ case 1: // Handle has data.
+ /* FALLTHRU */
+ default: // default is case result > 0; return a
+ // ACE_ASSERT (result == 1);
+ return result;
+ }
+}
+
+int
+ACE::enter_recv_timedwait (ACE_HANDLE handle,
+ const ACE_Time_Value *timeout,
+ int &val)
+{
+ int result = ACE::handle_read_ready (handle,
+ timeout);
+
+ if (result == -1)
+ return -1;
+
+ ACE::record_and_set_non_blocking_mode (handle,
+ val);
+
+ return result;
+}
+
+int
+ACE::enter_send_timedwait (ACE_HANDLE handle,
+ const ACE_Time_Value *timeout,
+ int &val)
+{
+ int result = ACE::handle_write_ready (handle,
+ timeout);
+
+ if (result == -1)
+ return -1;
+
+ ACE::record_and_set_non_blocking_mode (handle,
+ val);
+
+ return result;
+}
+
+void
+ACE::record_and_set_non_blocking_mode (ACE_HANDLE handle,
+ int &val)
+{
+ // We need to record whether we are already *in* nonblocking mode,
+ // so that we can correctly reset the state when we're done.
+ val = ACE::get_flags (handle);
+
+ if (ACE_BIT_DISABLED (val, ACE_NONBLOCK))
+ // Set the handle into non-blocking mode if it's not already in
+ // it.
+ ACE::set_flags (handle, ACE_NONBLOCK);
+}
+
+void
+ACE::restore_non_blocking_mode (ACE_HANDLE handle,
+ int val)
+{
+ if (ACE_BIT_DISABLED (val,
+ ACE_NONBLOCK))
+ {
+ // Save/restore errno.
+ ACE_Errno_Guard error (errno);
+ // Only disable ACE_NONBLOCK if we weren't in non-blocking mode
+ // originally.
+ ACE::clr_flags (handle, ACE_NONBLOCK);
+ }
+}
+
+
+// Format buffer into printable format. This is useful for debugging.
+// Portions taken from mdump by J.P. Knight (J.P.Knight@lut.ac.uk)
+// Modifications by Todd Montgomery.
+
+size_t
+ACE::format_hexdump (const char *buffer,
+ size_t size,
+ ACE_TCHAR *obuf,
+ size_t obuf_sz)
+{
+ ACE_TRACE ("ACE::format_hexdump");
+
+ u_char c;
+ ACE_TCHAR textver[16 + 1];
+
+ // We can fit 16 bytes output in text mode per line, 4 chars per byte.
+ size_t maxlen = (obuf_sz / 68) * 16;
+
+ if (size > maxlen)
+ size = maxlen;
+
+ size_t i;
+
+ size_t const lines = size / 16;
+ for (i = 0; i < lines; i++)
+ {
+ size_t j;
+
+ for (j = 0 ; j < 16; j++)
+ {
+ c = (u_char) buffer[(i << 4) + j]; // or, buffer[i*16+j]
+ ACE_OS::sprintf (obuf,
+ ACE_TEXT ("%02x "),
+ c);
+ obuf += 3;
+ if (j == 7)
+ {
+ ACE_OS::sprintf (obuf,
+ ACE_TEXT (" "));
+ ++obuf;
+ }
+ textver[j] = ACE_OS::ace_isprint (c) ? c : '.';
+ }
+
+ textver[j] = 0;
+
+ ACE_OS::sprintf (obuf,
+#if !defined (ACE_WIN32) && defined (ACE_USES_WCHAR)
+ ACE_TEXT (" %ls\n"),
+#else
+ ACE_TEXT (" %s\n"),
+#endif
+ textver);
+
+ while (*obuf != '\0')
+ ++obuf;
+ }
+
+ if (size % 16)
+ {
+ for (i = 0 ; i < size % 16; i++)
+ {
+ c = (u_char) buffer[size - size % 16 + i];
+ ACE_OS::sprintf (obuf,
+ ACE_TEXT ("%02x "),
+ c);
+ obuf += 3;
+ if (i == 7)
+ {
+ ACE_OS::sprintf (obuf,
+ ACE_TEXT (" "));
+ ++obuf;
+ }
+ textver[i] = ACE_OS::ace_isprint (c) ? c : '.';
+ }
+
+ for (i = size % 16; i < 16; i++)
+ {
+ ACE_OS::sprintf (obuf,
+ ACE_TEXT (" "));
+ obuf += 3;
+ if (i == 7)
+ {
+ ACE_OS::sprintf (obuf,
+ ACE_TEXT (" "));
+ ++obuf;
+ }
+ textver[i] = ' ';
+ }
+
+ textver[i] = 0;
+ ACE_OS::sprintf (obuf,
+#if !defined (ACE_WIN32) && defined (ACE_USES_WCHAR)
+ ACE_TEXT (" %ls\n"),
+#else
+ ACE_TEXT (" %s\n"),
+#endif
+ textver);
+ }
+ return size;
+}
+
+// Returns the current timestamp in the form
+// "hour:minute:second:microsecond." The month, day, and year are
+// also stored in the beginning of the date_and_time array.
+
+ACE_TCHAR *
+ACE::timestamp (ACE_TCHAR date_and_time[],
+ size_t date_and_timelen,
+ bool return_pointer_to_first_digit)
+{
+ return ACE::timestamp (ACE_Time_Value::zero,
+ date_and_time,
+ date_and_timelen,
+ return_pointer_to_first_digit);
+}
+
+// Returns the given timestamp in the form
+// "hour:minute:second:microsecond." The month, day, and year are
+// also stored in the beginning of the date_and_time array.
+
+ACE_TCHAR *
+ACE::timestamp (const ACE_Time_Value& time_value,
+ ACE_TCHAR date_and_time[],
+ size_t date_and_timelen,
+ bool return_pointer_to_first_digit)
+{
+ //ACE_TRACE ("ACE::timestamp");
+
+ if (date_and_timelen < 35)
+ {
+ errno = EINVAL;
+ return 0;
+ }
+
+#if defined (WIN32)
+ if (time_value == ACE_Time_Value::zero)
+ {
+ // Emulate Unix. Win32 does NOT support all the UNIX versions
+ // below, so DO we need this ifdef.
+ static const ACE_TCHAR *day_of_week_name[] =
+ {
+ ACE_TEXT ("Sun"),
+ ACE_TEXT ("Mon"),
+ ACE_TEXT ("Tue"),
+ ACE_TEXT ("Wed"),
+ ACE_TEXT ("Thu"),
+ ACE_TEXT ("Fri"),
+ ACE_TEXT ("Sat")
+ };
+
+ static const ACE_TCHAR *month_name[] =
+ {
+ ACE_TEXT ("Jan"),
+ ACE_TEXT ("Feb"),
+ ACE_TEXT ("Mar"),
+ ACE_TEXT ("Apr"),
+ ACE_TEXT ("May"),
+ ACE_TEXT ("Jun"),
+ ACE_TEXT ("Jul"),
+ ACE_TEXT ("Aug"),
+ ACE_TEXT ("Sep"),
+ ACE_TEXT ("Oct"),
+ ACE_TEXT ("Nov"),
+ ACE_TEXT ("Dec")
+ };
+
+ SYSTEMTIME local;
+ ::GetLocalTime (&local);
+
+ ACE_OS::sprintf (date_and_time,
+ ACE_TEXT ("%3s %3s %2d %04d %02d:%02d:%02d.%06d"),
+ day_of_week_name[local.wDayOfWeek],
+ month_name[local.wMonth - 1],
+ (int) local.wDay,
+ (int) local.wYear,
+ (int) local.wHour,
+ (int) local.wMinute,
+ (int) local.wSecond,
+ (int) (local.wMilliseconds * 1000));
+ return &date_and_time[15 + (return_pointer_to_first_digit != 0)];
+ }
+#endif /* WIN32 */
+ ACE_TCHAR timebuf[26]; // This magic number is based on the ctime(3c) man page.
+ ACE_Time_Value cur_time =
+ (time_value == ACE_Time_Value::zero) ?
+ ACE_Time_Value (ACE_OS::gettimeofday ()) : time_value;
+ time_t secs = cur_time.sec ();
+
+ ACE_OS::ctime_r (&secs,
+ timebuf,
+ sizeof timebuf / sizeof (ACE_TCHAR));
+ // date_and_timelen > sizeof timebuf!
+ ACE_OS::strsncpy (date_and_time,
+ timebuf,
+ date_and_timelen);
+ ACE_TCHAR yeartmp[5];
+ ACE_OS::strsncpy (yeartmp,
+ &date_and_time[20],
+ 5);
+ ACE_TCHAR timetmp[9];
+ ACE_OS::strsncpy (timetmp,
+ &date_and_time[11],
+ 9);
+ ACE_OS::sprintf (&date_and_time[11],
+# if defined (ACE_USES_WCHAR)
+ ACE_TEXT ("%ls %ls.%06ld"),
+# else
+ ACE_TEXT ("%s %s.%06ld"),
+# endif /* ACE_USES_WCHAR */
+ yeartmp,
+ timetmp,
+ cur_time.usec ());
+ date_and_time[33] = '\0';
+ return &date_and_time[15 + (return_pointer_to_first_digit != 0)];
+}
+
+// This function rounds the request to a multiple of the page size.
+
+size_t
+ACE::round_to_pagesize (size_t len)
+{
+ ACE_TRACE ("ACE::round_to_pagesize");
+
+ if (ACE::pagesize_ == 0)
+ ACE::pagesize_ = ACE_OS::getpagesize ();
+
+ return (len + (ACE::pagesize_ - 1)) & ~(ACE::pagesize_ - 1);
+}
+
+size_t
+ACE::round_to_allocation_granularity (size_t len)
+{
+ ACE_TRACE ("ACE::round_to_allocation_granularity");
+
+ if (ACE::allocation_granularity_ == 0)
+ ACE::allocation_granularity_ = ACE_OS::allocation_granularity ();
+
+ return (len + (ACE::allocation_granularity_ - 1)) & ~(ACE::allocation_granularity_ - 1);
+}
+
+ACE_HANDLE
+ACE::handle_timed_complete (ACE_HANDLE h,
+ const ACE_Time_Value *timeout,
+ int is_tli)
+{
+ ACE_TRACE ("ACE::handle_timed_complete");
+
+#if !defined (ACE_WIN32) && defined (ACE_HAS_POLL) && defined (ACE_HAS_LIMITED_SELECT)
+
+ struct pollfd fds;
+
+ fds.fd = h;
+ fds.events = POLLIN | POLLOUT;
+ fds.revents = 0;
+
+#else
+ ACE_Handle_Set rd_handles;
+ ACE_Handle_Set wr_handles;
+ rd_handles.set_bit (h);
+ wr_handles.set_bit (h);
+#endif /* !ACE_WIN32 && ACE_HAS_POLL && ACE_HAS_LIMITED_SELECT */
+
+#if defined (ACE_WIN32)
+ // Winsock is different - it sets the exception bit for failed connect,
+ // unlike other platforms, where the write bit is set for both success
+ // and fail.
+ ACE_Handle_Set ex_handles;
+ ex_handles.set_bit (h);
+#endif /* ACE_WIN32 */
+
+ bool need_to_check = false;
+ bool known_failure = false;
+
+#if defined (ACE_WIN32)
+ int n = ACE_OS::select (0, // Ignored on Windows: int (h) + 1,
+ 0,
+ wr_handles,
+ ex_handles,
+ timeout);
+#else
+# if defined (ACE_HAS_POLL) && defined (ACE_HAS_LIMITED_SELECT)
+
+ int n = ACE_OS::poll (&fds, 1, timeout);
+
+# else
+ int n = 0;
+ if (is_tli)
+ n = ACE_OS::select (int (h) + 1,
+ rd_handles,
+ wr_handles,
+ 0,
+ timeout);
+ else
+ n = ACE_OS::select (int (h) + 1,
+ 0,
+ wr_handles,
+ 0,
+ timeout);
+# endif /* ACE_HAS_POLL && ACE_HAS_LIMITED_SELECT */
+#endif /* ACE_WIN32 */
+
+ // If we failed to connect within the time period allocated by the
+ // caller, then we fail (e.g., the remote host might have been too
+ // busy to accept our call).
+ if (n <= 0)
+ {
+ if (n == 0 && timeout != 0)
+ errno = ETIME;
+ return ACE_INVALID_HANDLE;
+ }
+
+ // On Windows, a ready-for-write handle is successfully connected, and
+ // ready-for-exception is a failure. On fails, we need to grab the error
+ // code via getsockopt.
+ // On BSD sockets using select(), the handle becomes writable on
+ // completion either success or fail, so if the select() does not time
+ // out, we need to check for success/fail.
+ // It is believed that TLI sockets use the readable=fail, writeable=success
+ // but that hasn't been as well tested.
+#if defined (ACE_WIN32)
+ ACE_UNUSED_ARG (is_tli);
+
+ // On Win32, ex_handle set indicates a failure. We'll do the check
+ // to try and get an errno value, but the connect failed regardless of
+ // what getsockopt says about the error.
+ if (ex_handles.is_set (h))
+ {
+ need_to_check = true;
+ known_failure = true;
+ }
+#else
+ if (is_tli)
+# if defined (ACE_HAS_POLL) && defined (ACE_HAS_LIMITED_SELECT)
+ need_to_check = (fds.revents & POLLIN) && !(fds.revents & POLLOUT);
+# else
+ need_to_check = rd_handles.is_set (h) && !wr_handles.is_set (h);
+# endif /* ACE_HAS_POLL && ACE_HAS_LIMITED_SELECT */
+
+ else
+# if defined (ACE_HAS_POLL) && defined (ACE_HAS_LIMITED_SELECT)
+ need_to_check = (fds.revents & POLLIN);
+# else
+ need_to_check = true;
+# endif /* ACE_HAS_POLL && ACE_HAS_LIMITED_SELECT */
+#endif /* ACE_WIN32 */
+
+ if (need_to_check)
+ {
+#if defined (SOL_SOCKET) && defined (SO_ERROR)
+ int sock_err = 0;
+ int sock_err_len = sizeof (sock_err);
+ int sockopt_ret = ACE_OS::getsockopt (h, SOL_SOCKET, SO_ERROR,
+ (char *)&sock_err, &sock_err_len);
+ if (sockopt_ret < 0)
+ {
+ h = ACE_INVALID_HANDLE;
+ }
+
+ if (sock_err != 0 || known_failure)
+ {
+ h = ACE_INVALID_HANDLE;
+ errno = sock_err;
+ }
+#else
+ char dummy;
+
+ // The following recv() won't block provided that the
+ // ACE_NONBLOCK flag has not been turned off .
+ n = ACE::recv (h, &dummy, 1, MSG_PEEK);
+
+ // If no data was read/peeked at, check to see if it's because
+ // of a non-connected socket (and therefore an error) or there's
+ // just no data yet.
+ if (n <= 0)
+ {
+ if (n == 0)
+ {
+ errno = ECONNREFUSED;
+ h = ACE_INVALID_HANDLE;
+ }
+ else if (errno != EWOULDBLOCK && errno != EAGAIN)
+ h = ACE_INVALID_HANDLE;
+ }
+#endif
+ }
+
+ // 1. The HANDLE is ready for writing and doesn't need to be checked or
+ // 2. recv() returned an indication of the state of the socket - if there is
+ // either data present, or a recv is legit but there's no data yet,
+ // the connection was successfully established.
+ return h;
+}
+
+// Wait up to amount of time to accept a connection.
+
+int
+ACE::handle_timed_accept (ACE_HANDLE listener,
+ ACE_Time_Value *timeout,
+ bool restart)
+{
+ ACE_TRACE ("ACE::handle_timed_accept");
+ // Make sure we don't bomb out on erroneous values.
+ if (listener == ACE_INVALID_HANDLE)
+ return -1;
+
+#if defined (ACE_HAS_POLL) && defined (ACE_HAS_LIMITED_SELECT)
+
+ struct pollfd fds;
+
+ fds.fd = listener;
+ fds.events = POLLIN;
+ fds.revents = 0;
+
+#else
+ // Use the select() implementation rather than poll().
+ ACE_Handle_Set rd_handle;
+ rd_handle.set_bit (listener);
+#endif /* ACE_HAS_POLL && ACE_HAS_LIMITED_SELECT */
+
+ // We need a loop here if is enabled.
+
+ for (;;)
+ {
+#if defined (ACE_HAS_POLL) && defined (ACE_HAS_LIMITED_SELECT)
+
+ int n = ACE_OS::poll (&fds, 1, timeout);
+
+#else
+ int select_width;
+# if defined (ACE_WIN32)
+ // This arg is ignored on Windows and causes pointer truncation
+ // warnings on 64-bit compiles.
+ select_width = 0;
+# else
+ select_width = int (listener) + 1;
+# endif /* ACE_WIN32 */
+ int n = ACE_OS::select (select_width,
+ rd_handle, 0, 0,
+ timeout);
+#endif /* ACE_HAS_POLL && ACE_HAS_LIMITED_SELECT */
+
+ switch (n)
+ {
+ case -1:
+ if (errno == EINTR && restart)
+ continue;
+ else
+ return -1;
+ /* NOTREACHED */
+ case 0:
+ if (timeout != 0 && *timeout == ACE_Time_Value::zero)
+ errno = EWOULDBLOCK;
+ else
+ errno = ETIMEDOUT;
+ return -1;
+ /* NOTREACHED */
+ case 1:
+ return 0;
+ /* NOTREACHED */
+ default:
+ errno = EINVAL;
+ return -1;
+ /* NOTREACHED */
+ }
+ }
+}
+
+// Make the current process a UNIX daemon. This is based on Stevens
+// code from APUE.
+
+int
+ACE::daemonize (const ACE_TCHAR pathname[],
+ bool close_all_handles,
+ const ACE_TCHAR program_name[])
+{
+ ACE_TRACE ("ACE::daemonize");
+#if !defined (ACE_LACKS_FORK)
+ pid_t pid = ACE_OS::fork ();
+
+ if (pid == -1)
+ return -1;
+ else if (pid != 0)
+ ACE_OS::exit (0); // Parent exits.
+
+ // 1st child continues.
+ ACE_OS::setsid (); // Become session leader.
+
+ ACE_OS::signal (SIGHUP, SIG_IGN);
+
+ pid = ACE_OS::fork (program_name);
+
+ if (pid != 0)
+ ACE_OS::exit (0); // First child terminates.
+
+ // Second child continues.
+
+ if (pathname != 0)
+ // change working directory.
+ ACE_OS::chdir (pathname);
+
+ ACE_OS::umask (0); // clear our file mode creation mask.
+
+ // Close down the I/O handles.
+ if (close_all_handles)
+ {
+ for (int i = ACE::max_handles () - 1; i >= 0; i--)
+ ACE_OS::close (i);
+
+ int fd = ACE_OS::open ("/dev/null", O_RDWR, 0);
+ if (fd != -1)
+ {
+ ACE_OS::dup2 (fd, ACE_STDIN);
+ ACE_OS::dup2 (fd, ACE_STDOUT);
+ ACE_OS::dup2 (fd, ACE_STDERR);
+
+ if (fd > ACE_STDERR)
+ ACE_OS::close (fd);
+ }
+ }
+
+ return 0;
+#else
+ ACE_UNUSED_ARG (pathname);
+ ACE_UNUSED_ARG (close_all_handles);
+ ACE_UNUSED_ARG (program_name);
+
+ ACE_NOTSUP_RETURN (-1);
+#endif /* ACE_LACKS_FORK */
+}
+
+pid_t
+ACE::fork (const ACE_TCHAR *program_name,
+ int avoid_zombies)
+{
+ if (avoid_zombies == 0)
+ return ACE_OS::fork (program_name);
+ else
+ {
+ // This algorithm is adapted from an example in the Stevens book
+ // "Advanced Programming in the Unix Environment" and an item in
+ // Andrew Gierth's Unix Programming FAQ. It creates an orphan
+ // process that's inherited by the init process; init cleans up
+ // when the orphan process terminates.
+ //
+ // Another way to avoid zombies is to ignore or catch the
+ // SIGCHLD signal; we don't use that approach here.
+
+ pid_t pid = ACE_OS::fork ();
+ if (pid == 0)
+ {
+ // The child process forks again to create a grandchild.
+ switch (ACE_OS::fork (program_name))
+ {
+ case 0: // grandchild returns 0.
+ return 0;
+ case -1: // assumes all errnos are < 256
+ ACE_OS::_exit (errno);
+ default: // child terminates, orphaning grandchild
+ ACE_OS::_exit (0);
+ }
+ }
+
+ // Parent process waits for child to terminate.
+ ACE_exitcode status;
+ if (pid < 0 || ACE_OS::waitpid (pid, &status, 0) < 0)
+ return -1;
+
+ // child terminated by calling exit()?
+ if (WIFEXITED ((status)))
+ {
+ // child terminated normally?
+ if (WEXITSTATUS ((status)) == 0)
+ return 1;
+ else
+ errno = WEXITSTATUS ((status));
+ }
+ else
+ // child didn't call exit(); perhaps it received a signal?
+ errno = EINTR;
+
+ return -1;
+ }
+}
+
+int
+ACE::max_handles (void)
+{
+ ACE_TRACE ("ACE::max_handles");
+#if defined (RLIMIT_NOFILE) && !defined (ACE_LACKS_RLIMIT)
+ rlimit rl;
+ int const r = ACE_OS::getrlimit (RLIMIT_NOFILE, &rl);
+# if !defined (RLIM_INFINITY)
+ if (r == 0)
+ return rl.rlim_cur;
+# else
+ if (r == 0 && rl.rlim_cur != RLIM_INFINITY)
+ return rl.rlim_cur;
+ // If == RLIM_INFINITY, fall through to the ACE_LACKS_RLIMIT sections
+# endif /* RLIM_INFINITY */
+#endif /* RLIMIT_NOFILE && !ACE_LACKS_RLIMIT */
+
+#if defined (_SC_OPEN_MAX)
+ return ACE_OS::sysconf (_SC_OPEN_MAX);
+#elif defined (ACE_VXWORKS) && (ACE_VXWORKS < 0x620)
+ return maxFiles;
+#elif defined (FD_SETSIZE)
+ return FD_SETSIZE;
+#else
+ ACE_NOTSUP_RETURN (-1);
+#endif /* _SC_OPEN_MAX */
+}
+
+// Set the number of currently open handles in the process.
+//
+// If NEW_LIMIT == -1 set the limit to the maximum allowable.
+// Otherwise, set it to be the value of NEW_LIMIT.
+
+int
+ACE::set_handle_limit (int new_limit,
+ int increase_limit_only)
+{
+ ACE_TRACE ("ACE::set_handle_limit");
+ int cur_limit = ACE::max_handles ();
+ int max_limit = cur_limit;
+
+ if (cur_limit == -1)
+ return -1;
+
+#if !defined (ACE_LACKS_RLIMIT) && defined (RLIMIT_NOFILE)
+ struct rlimit rl;
+
+ ACE_OS::memset ((void *) &rl, 0, sizeof rl);
+ int r = ACE_OS::getrlimit (RLIMIT_NOFILE, &rl);
+ if (r == 0)
+ max_limit = rl.rlim_max;
+#endif /* ACE_LACKS_RLIMIT */
+
+ if (new_limit == -1)
+ new_limit = max_limit;
+
+ if (new_limit < 0)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+ else if (new_limit > cur_limit)
+ {
+ // Increase the limit.
+#if !defined (ACE_LACKS_RLIMIT) && defined (RLIMIT_NOFILE)
+ rl.rlim_cur = new_limit;
+ return ACE_OS::setrlimit (RLIMIT_NOFILE, &rl);
+#elif defined (ACE_LACKS_RLIMIT_NOFILE)
+ return 0;
+#else
+ // Must return EINVAL errno.
+ ACE_NOTSUP_RETURN (-1);
+#endif /* ACE_LACKS_RLIMIT */
+ }
+ else if (increase_limit_only == 0)
+ {
+ // Decrease the limit.
+#if !defined (ACE_LACKS_RLIMIT) && defined (RLIMIT_NOFILE)
+ rl.rlim_cur = new_limit;
+ return ACE_OS::setrlimit (RLIMIT_NOFILE, &rl);
+#else
+ // We give a chance to platforms without RLIMIT to work.
+ // Instead of ACE_NOTSUP_RETURN (0), just return 0 because
+ // new_limit is <= cur_limit, so it's a no-op.
+ return 0;
+#endif /* ACE_LACKS_RLIMIT */
+ }
+
+ return 0;
+}
+
+// Euclid's greatest common divisor algorithm.
+u_long
+ACE::gcd (u_long x, u_long y)
+{
+ while (y != 0)
+ {
+ u_long r = x % y;
+ x = y;
+ y = r;
+ }
+
+ return x;
+}
+
+
+// Calculates the minimum enclosing frame size for the given values.
+u_long
+ACE::minimum_frame_size (u_long period1, u_long period2)
+{
+ // if one of the periods is zero, treat it as though it as
+ // uninitialized and return the other period as the frame size
+ if (0 == period1)
+ {
+ return period2;
+ }
+ if (0 == period2)
+ {
+ return period1;
+ }
+
+ // if neither is zero, find the greatest common divisor of the two periods
+ u_long greatest_common_divisor = ACE::gcd (period1, period2);
+
+ // explicitly consider cases to reduce risk of possible overflow errors
+ if (greatest_common_divisor == 1)
+ {
+ // periods are relative primes: just multiply them together
+ return period1 * period2;
+ }
+ else if (greatest_common_divisor == period1)
+ {
+ // the first period divides the second: return the second
+ return period2;
+ }
+ else if (greatest_common_divisor == period2)
+ {
+ // the second period divides the first: return the first
+ return period1;
+ }
+ else
+ {
+ // the current frame size and the entry's effective period
+ // have a non-trivial greatest common divisor: return the
+ // product of factors divided by those in their gcd.
+ return (period1 * period2) / greatest_common_divisor;
+ }
+}
+
+
+u_long
+ACE::is_prime (const u_long n,
+ const u_long min_factor,
+ const u_long max_factor)
+{
+ if (n > 3)
+ for (u_long factor = min_factor;
+ factor <= max_factor;
+ ++factor)
+ if (n / factor * factor == n)
+ return factor;
+
+ return 0;
+}
+
+const ACE_TCHAR *
+ACE::sock_error (int error)
+{
+#if defined (ACE_WIN32)
+ static ACE_TCHAR unknown_msg[64];
+
+ switch (error)
+ {
+ case WSAVERNOTSUPPORTED:
+ return ACE_TEXT ("version of WinSock not supported");
+ /* NOTREACHED */
+ case WSASYSNOTREADY:
+ return ACE_TEXT ("WinSock not present or not responding");
+ /* NOTREACHED */
+ case WSAEINVAL:
+ return ACE_TEXT ("app version not supported by DLL");
+ /* NOTREACHED */
+ case WSAHOST_NOT_FOUND:
+ return ACE_TEXT ("Authoritive: Host not found");
+ /* NOTREACHED */
+ case WSATRY_AGAIN:
+ return ACE_TEXT ("Non-authoritive: host not found or server failure");
+ /* NOTREACHED */
+ case WSANO_RECOVERY:
+ return ACE_TEXT ("Non-recoverable: refused or not implemented");
+ /* NOTREACHED */
+ case WSANO_DATA:
+ return ACE_TEXT ("Valid name, no data record for type");
+ /* NOTREACHED */
+ /*
+ case WSANO_ADDRESS:
+ return "Valid name, no MX record";
+ */
+ case WSANOTINITIALISED:
+ return ACE_TEXT ("WSA Startup not initialized");
+ /* NOTREACHED */
+ case WSAENETDOWN:
+ return ACE_TEXT ("Network subsystem failed");
+ /* NOTREACHED */
+ case WSAEINPROGRESS:
+ return ACE_TEXT ("Blocking operation in progress");
+ /* NOTREACHED */
+ case WSAEINTR:
+ return ACE_TEXT ("Blocking call cancelled");
+ /* NOTREACHED */
+ case WSAEAFNOSUPPORT:
+ return ACE_TEXT ("address family not supported");
+ /* NOTREACHED */
+ case WSAEMFILE:
+ return ACE_TEXT ("no file handles available");
+ /* NOTREACHED */
+ case WSAENOBUFS:
+ return ACE_TEXT ("no buffer space available");
+ /* NOTREACHED */
+ case WSAEPROTONOSUPPORT:
+ return ACE_TEXT ("specified protocol not supported");
+ /* NOTREACHED */
+ case WSAEPROTOTYPE:
+ return ACE_TEXT ("protocol wrong type for this socket");
+ /* NOTREACHED */
+ case WSAESOCKTNOSUPPORT:
+ return ACE_TEXT ("socket type not supported for address family");
+ /* NOTREACHED */
+ case WSAENOTSOCK:
+ return ACE_TEXT ("handle is not a socket");
+ /* NOTREACHED */
+ case WSAEWOULDBLOCK:
+ return ACE_TEXT ("resource temporarily unavailable");
+ /* NOTREACHED */
+ case WSAEADDRINUSE:
+ return ACE_TEXT ("address already in use");
+ /* NOTREACHED */
+ case WSAECONNABORTED:
+ return ACE_TEXT ("connection aborted");
+ /* NOTREACHED */
+ case WSAECONNRESET:
+ return ACE_TEXT ("connection reset");
+ /* NOTREACHED */
+ case WSAENOTCONN:
+ return ACE_TEXT ("not connected");
+ /* NOTREACHED */
+ case WSAETIMEDOUT:
+ return ACE_TEXT ("connection timed out");
+ /* NOTREACHED */
+ case WSAECONNREFUSED:
+ return ACE_TEXT ("connection refused");
+ /* NOTREACHED */
+ case WSAEHOSTDOWN:
+ return ACE_TEXT ("host down");
+ /* NOTREACHED */
+ case WSAEHOSTUNREACH:
+ return ACE_TEXT ("host unreachable");
+ /* NOTREACHED */
+ case WSAEADDRNOTAVAIL:
+ return ACE_TEXT ("address not available");
+ /* NOTREACHED */
+ case WSAEISCONN:
+ return ACE_TEXT ("socket is already connected");
+ /* NOTREACHED */
+ case WSAENETRESET:
+ return ACE_TEXT ("network dropped connection on reset");
+ /* NOTREACHED */
+ case WSAEMSGSIZE:
+ return ACE_TEXT ("message too long");
+ /* NOTREACHED */
+ case WSAENETUNREACH:
+ return ACE_TEXT ("network is unreachable");
+ /* NOTREACHED */
+ case WSAEFAULT:
+ return ACE_TEXT ("bad address");
+ /* NOTREACHED */
+ case WSAEDISCON:
+ return ACE_TEXT ("graceful shutdown in progress");
+ /* NOTREACHED */
+ case WSAEACCES:
+ return ACE_TEXT ("permission denied");
+ /* NOTREACHED */
+ case WSAESHUTDOWN:
+ return ACE_TEXT ("cannot send after socket shutdown");
+ /* NOTREACHED */
+ case WSAEPROCLIM:
+ return ACE_TEXT ("too many processes");
+ /* NOTREACHED */
+ case WSAEALREADY:
+ return ACE_TEXT ("operation already in progress");
+ /* NOTREACHED */
+ case WSAEPFNOSUPPORT:
+ return ACE_TEXT ("protocol family not supported");
+ /* NOTREACHED */
+ case WSAENOPROTOOPT:
+ return ACE_TEXT ("bad protocol option");
+ /* NOTREACHED */
+ case WSATYPE_NOT_FOUND:
+ return ACE_TEXT ("class type not found");
+ /* NOTREACHED */
+ case WSAEOPNOTSUPP:
+ return ACE_TEXT ("operation not supported");
+ /* NOTREACHED */
+ case WSAEDESTADDRREQ:
+ return ACE_TEXT ("destination address required");
+ /* NOTREACHED */
+ default:
+ ACE_OS::sprintf (unknown_msg, ACE_TEXT ("unknown error: %d"), error);
+ return unknown_msg;
+ /* NOTREACHED */
+ }
+#else
+ ACE_UNUSED_ARG (error);
+ ACE_NOTSUP_RETURN (0);
+#endif /* ACE_WIN32 */
+}
+
+bool
+ACE::is_sock_error (int error)
+{
+#if defined (ACE_WIN32)
+ switch (error)
+ {
+ case WSAVERNOTSUPPORTED:
+ case WSASYSNOTREADY:
+ case WSAEINVAL:
+ case WSAHOST_NOT_FOUND:
+ case WSATRY_AGAIN:
+ case WSANO_RECOVERY:
+ case WSANO_DATA:
+ /*
+ case WSANO_ADDRESS:
+ */
+ case WSANOTINITIALISED:
+ case WSAENETDOWN:
+ case WSAEINPROGRESS:
+ case WSAEINTR:
+ case WSAEAFNOSUPPORT:
+ case WSAEMFILE:
+ case WSAENOBUFS:
+ case WSAEPROTONOSUPPORT:
+ case WSAEPROTOTYPE:
+ case WSAESOCKTNOSUPPORT:
+ case WSAENOTSOCK:
+ case WSAEWOULDBLOCK:
+ case WSAEADDRINUSE:
+ case WSAECONNABORTED:
+ case WSAECONNRESET:
+ case WSAENOTCONN:
+ case WSAETIMEDOUT:
+ case WSAECONNREFUSED:
+ case WSAEHOSTDOWN:
+ case WSAEHOSTUNREACH:
+ case WSAEADDRNOTAVAIL:
+ case WSAEISCONN:
+ case WSAENETRESET:
+ case WSAEMSGSIZE:
+ case WSAENETUNREACH:
+ case WSAEFAULT:
+ case WSAEDISCON:
+ case WSAEACCES:
+ case WSAESHUTDOWN:
+ case WSAEPROCLIM:
+ case WSAEALREADY:
+ case WSAEPFNOSUPPORT:
+ case WSAENOPROTOOPT:
+ case WSATYPE_NOT_FOUND:
+ case WSAEOPNOTSUPP:
+ return true;
+ }
+#else
+ ACE_UNUSED_ARG (error);
+#endif /* ACE_WIN32 */
+ return false;
+}
+
+char *
+ACE::strndup (const char *str, size_t n)
+{
+ const char *t = str;
+ size_t len;
+
+ // Figure out how long this string is (remember, it might not be
+ // NUL-terminated).
+
+ for (len = 0;
+ len < n && *t++ != '\0';
+ len++)
+ continue;
+
+ char *s;
+ ACE_ALLOCATOR_RETURN (s,
+ (char *) ACE_OS::malloc (len + 1),
+ 0);
+ return ACE_OS::strsncpy (s, str, len + 1);
+}
+
+#if defined (ACE_HAS_WCHAR)
+wchar_t *
+ACE::strndup (const wchar_t *str, size_t n)
+{
+ const wchar_t *t = str;
+ size_t len;
+
+ // Figure out how long this string is (remember, it might not be
+ // NUL-terminated).
+
+ for (len = 0;
+ len < n && *t++ != '\0';
+ len++)
+ continue;
+
+ wchar_t *s;
+ ACE_ALLOCATOR_RETURN (s,
+ static_cast (
+ ACE_OS::malloc ((len + 1) * sizeof (wchar_t))),
+ 0);
+ return ACE_OS::strsncpy (s, str, len + 1);
+}
+#endif /* ACE_HAS_WCHAR */
+
+char *
+ACE::strnnew (const char *str, size_t n)
+{
+ const char *t = str;
+ size_t len;
+
+ // Figure out how long this string is (remember, it might not be
+ // NUL-terminated).
+
+ for (len = 0;
+ len < n && *t++ != L'\0';
+ len++)
+ continue;
+
+ char *s;
+ ACE_NEW_RETURN (s,
+ char[len + 1],
+ 0);
+ return ACE_OS::strsncpy (s, str, len + 1);
+}
+
+#if defined (ACE_HAS_WCHAR)
+wchar_t *
+ACE::strnnew (const wchar_t *str, size_t n)
+{
+ const wchar_t *t = str;
+ size_t len;
+
+ // Figure out how long this string is (remember, it might not be
+ // NUL-terminated).
+
+ for (len = 0;
+ len < n && *t++ != ACE_TEXT_WIDE ('\0');
+ len++)
+ continue;
+
+ wchar_t *s;
+ ACE_NEW_RETURN (s,
+ wchar_t[len + 1],
+ 0);
+ return ACE_OS::strsncpy (s, str, len + 1);
+}
+#endif /* ACE_HAS_WCHAR */
+
+const char *
+ACE::strend (const char *s)
+{
+ while (*s++ != '\0')
+ continue;
+
+ return s;
+}
+
+#if defined ACE_HAS_WCHAR
+const wchar_t *
+ACE::strend (const wchar_t *s)
+{
+ while (*s++ != ACE_TEXT_WIDE ('\0'))
+ continue;
+
+ return s;
+}
+#endif
+
+char *
+ACE::strnew (const char *s)
+{
+ if (s == 0)
+ return 0;
+ char *t = 0;
+ ACE_NEW_RETURN (t,
+ char [ACE_OS::strlen (s) + 1],
+ 0);
+ if (t == 0)
+ return 0;
+ else
+ return ACE_OS::strcpy (t, s);
+}
+
+#if defined (ACE_HAS_WCHAR)
+wchar_t *
+ACE::strnew (const wchar_t *s)
+{
+ if (s == 0)
+ return 0;
+ wchar_t *t = 0;
+ ACE_NEW_RETURN (t,
+ wchar_t[ACE_OS::strlen (s) + 1],
+ 0);
+ if (t == 0)
+ return 0;
+ else
+ return ACE_OS::strcpy (t, s);
+}
+#endif /* ACE_HAS_WCHAR */
+
+// helper functions for ACE::wild_match()
+namespace
+{
+
+ inline bool equal_char (char a, char b, bool case_sensitive)
+ {
+ if (case_sensitive)
+ return a == b;
+ return ACE_OS::ace_tolower (a) == ACE_OS::ace_tolower (b);
+ }
+
+ // precond: *p == '[' start of char class
+ // postcond: *p == ']' end of the char class
+ inline bool equal_class (char s, const char *&p, bool case_sensitive)
+ {
+ ++p;
+ bool negate = false;
+ if (*p == '!')
+ {
+ negate = true;
+ ++p;
+ }
+ // ] and - are regular in 1st position
+ for (bool first = true; *p && (first || *p != ']'); ++p)
+ {
+ if (!first && *p == '-' && p[1] != ']')
+ {
+ if (!p[1] || p[1] <= p[-1]) // invalid range
+ {
+ continue;
+ }
+ // Since we are in the POSIX locale, only the basic ASCII
+ // characters are allowed as the range endpoints. These characters
+ // are the same values in both signed and unsigned chars so we
+ // don't have to account for any "pathological cases."
+ for (char range = p[-1] + 1; range <= p[1]; ++range)
+ {
+ if (equal_char (s, range, case_sensitive))
+ {
+ while (*++p != ']') {}
+ return !negate;
+ }
+ }
+ ++p; // consume the character 1 past the -
+ }
+ else if (equal_char (s, *p, case_sensitive))
+ {
+ while (*++p != ']') {}
+ return !negate;
+ }
+ first = false;
+ }
+ return negate;
+ }
+}
+
+bool
+ACE::wild_match(const char *str, const char *pat, bool case_sensitive,
+ bool character_classes)
+{
+ if (str == pat)
+ return true;
+ if (pat == 0 || str == 0)
+ return false;
+
+ bool star = false, escape = false;
+ const char *s = str;
+ const char *p = pat;
+ while (*s != '\0')
+ {
+ if (!escape && *p == '\\')
+ {
+ ++p;
+ escape = true;
+ }
+ else if (!escape && *p == '*')
+ {
+ star = true;
+ pat = p;
+ while (*++pat == '*') {}
+
+ if (*pat == '\0')
+ return true;
+ p = pat;
+ }
+ else if (!escape && *p == '?')
+ {
+ ++s;
+ ++p;
+ }
+ else if (!escape && character_classes && *p == '[')
+ {
+ if (equal_class (*s, p, case_sensitive))
+ {
+ ++p;
+ }
+ else
+ {
+ if (!star)
+ return false;
+ p = pat;
+ }
+ ++s;
+ }
+ else if (!equal_char (*s, *p, case_sensitive))
+ {
+ if (!star)
+ return false;
+ ++s;
+ p = pat;
+ escape = false;
+ }
+ else
+ {
+ ++s;
+ ++p;
+ escape = false;
+ }
+ }
+ if (*p == '*')
+ while (*++p == '*') {}
+
+ return *p == '\0';
+}
+
+// Close versioned namespace, if enabled by the user.
+ACE_END_VERSIONED_NAMESPACE_DECL
diff --git a/externals/ace/ACE.h b/externals/ace/ACE.h
new file mode 100644
index 0000000..56ce13c
--- /dev/null
+++ b/externals/ace/ACE.h
@@ -0,0 +1,849 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file ACE.h
+ *
+ * $Id: ACE.h 88193 2009-12-16 09:14:06Z mcorino $
+ *
+ * This file contains value added ACE functions that extend the
+ * behavior of the UNIX and Win32 OS calls.
+ *
+ * All these ACE static functions are consolidated in a single place
+ * in order to manage the namespace better. These functions are put
+ * here rather than in @c ACE_OS in order to separate concerns.
+ *
+ * @author Douglas C. Schmidt
+ */
+//=============================================================================
+
+#ifndef ACE_ACE_H
+#define ACE_ACE_H
+
+#include /**/ "ace/pre.h"
+
+#include "ace/config-lite.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ace/OS_NS_math.h"
+#include "ace/Flag_Manip.h"
+#include "ace/Handle_Ops.h"
+#include "ace/Lib_Find.h"
+#include "ace/Init_ACE.h"
+#include "ace/Sock_Connect.h"
+#include "ace/Default_Constants.h"
+
+#if defined (ACE_EXPORT_MACRO)
+# undef ACE_EXPORT_MACRO
+#endif
+#define ACE_EXPORT_MACRO ACE_Export
+
+// Open versioned namespace, if enabled by the user.
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+// Forward declarations.
+class ACE_Time_Value;
+class ACE_Message_Block;
+class ACE_Handle_Set;
+
+/**
+ * @namespace ACE
+ *
+ * @brief The namespace containing the ACE framework itself.
+ *
+ * The ACE namespace contains all types (classes, structures,
+ * typedefs, etc), and global functions and variables in the ACE
+ * framework.
+ */
+namespace ACE
+{
+ // = ACE version information.
+ /// e.g., the "5" in ACE 5.1.12.
+ extern ACE_Export u_int major_version (void);
+
+ /// e.g., the "1" in ACE 5.1.12.
+ extern ACE_Export u_int minor_version (void);
+
+ /// e.g., the "12" in ACE 5.1.12.
+ /// Returns 0 for "stable" (non-beta) releases.
+ extern ACE_Export u_int beta_version (void);
+
+ // = C++ compiler version information.
+ /// E.g., the "SunPro C++" in SunPro C++ 4.32.0
+ extern ACE_Export const ACE_TCHAR * compiler_name (void);
+
+ /// E.g., the "4" in SunPro C++ 4.32.0
+ extern ACE_Export u_int compiler_major_version (void);
+
+ /// E.g., the "32" in SunPro C++ 4.32.0
+ extern ACE_Export u_int compiler_minor_version (void);
+
+ /// E.g., the "0" in SunPro C++ 4.32.0
+ extern ACE_Export u_int compiler_beta_version (void);
+
+ /// Check if error indicates the process being out of handles (file
+ /// descriptors).
+ extern ACE_Export int out_of_handles (int error);
+
+ /// Simple wildcard matching function supporting '*' and '?'
+ /// return true if string s matches pattern.
+ /// If character_classes is true, '[' is treated as a wildcard character
+ /// as described in the fnmatch() POSIX API. The following POSIX "bracket
+ /// expression" features are not implemented: collating symbols, equivalence
+ /// class expressions, and character class expressions. The POSIX locale is
+ /// assumed.
+ extern ACE_Export bool wild_match(const char* s, const char* pattern,
+ bool case_sensitive = true, bool character_classes = false);
+
+ /**
+ * @name I/O operations
+ *
+ * Notes on common parameters:
+ *
+ * @a handle is the connected endpoint that will be used for I/O.
+ *
+ * @a buf is the buffer to write from or receive into.
+ *
+ * @a len is the number of bytes to transfer.
+ *
+ * The @a timeout parameter in the following methods indicates how
+ * long to blocking trying to transfer data. If @a timeout == 0,
+ * then the call behaves as a normal send/recv call, i.e., for
+ * blocking sockets, the call will block until action is possible;
+ * for non-blocking sockets, @c EWOULDBLOCK will be returned if no
+ * action is immediately possible.
+ *
+ * If @a timeout != 0, the call will wait until the relative time
+ * specified in @a *timeout elapses.
+ *
+ * The "_n()" I/O methods keep looping until all the data has been
+ * transferred. These methods also work for sockets in non-blocking
+ * mode i.e., they keep looping on @c EWOULDBLOCK. @a timeout is
+ * used to make sure we keep making progress, i.e., the same timeout
+ * value is used for every I/O operation in the loop and the timeout
+ * is not counted down.
+ *
+ * The return values for the "*_n()" methods match the return values
+ * from the non "_n()" methods and are specified as follows:
+ *
+ * - On complete transfer, the number of bytes transferred is returned.
+ * - On timeout, -1 is returned, @c errno == @c ETIME.
+ * - On error, -1 is returned, @c errno is set to appropriate error.
+ * - On @c EOF, 0 is returned, @c errno is irrelevant.
+ *
+ * On partial transfers, i.e., if any data is transferred before
+ * timeout / error / @c EOF, @a bytes_transferred> will contain the
+ * number of bytes transferred.
+ *
+ * Methods with @a iovec parameter are I/O vector variants of the
+ * I/O operations.
+ *
+ * Methods with the extra @a flags argument will always result in
+ * @c send getting called. Methods without the extra @a flags
+ * argument will result in @c send getting called on Win32
+ * platforms, and @c write getting called on non-Win32 platforms.
+ */
+ //@{
+ extern ACE_Export ssize_t recv (ACE_HANDLE handle,
+ void *buf,
+ size_t len,
+ int flags,
+ const ACE_Time_Value *timeout = 0);
+
+#if defined (ACE_HAS_TLI)
+
+ extern ACE_Export ssize_t t_rcv (ACE_HANDLE handle,
+ void *buf,
+ size_t len,
+ int *flags,
+ const ACE_Time_Value *timeout = 0);
+
+#endif /* ACE_HAS_TLI */
+
+ extern ACE_Export ssize_t recv (ACE_HANDLE handle,
+ void *buf,
+ size_t len,
+ const ACE_Time_Value *timeout = 0);
+
+ extern ACE_Export ssize_t recvmsg (ACE_HANDLE handle,
+ struct msghdr *msg,
+ int flags,
+ const ACE_Time_Value *timeout = 0);
+
+ extern ACE_Export ssize_t recvfrom (ACE_HANDLE handle,
+ char *buf,
+ int len,
+ int flags,
+ struct sockaddr *addr,
+ int *addrlen,
+ const ACE_Time_Value *timeout = 0);
+
+ ACE_NAMESPACE_INLINE_FUNCTION
+ ssize_t recv_n (ACE_HANDLE handle,
+ void *buf,
+ size_t len,
+ int flags,
+ const ACE_Time_Value *timeout = 0,
+ size_t *bytes_transferred = 0);
+
+#if defined (ACE_HAS_TLI)
+
+ ACE_NAMESPACE_INLINE_FUNCTION
+ ssize_t t_rcv_n (ACE_HANDLE handle,
+ void *buf,
+ size_t len,
+ int *flags,
+ const ACE_Time_Value *timeout = 0,
+ size_t *bytes_transferred = 0);
+
+#endif /* ACE_HAS_TLI */
+
+ ACE_NAMESPACE_INLINE_FUNCTION
+ ssize_t recv_n (ACE_HANDLE handle,
+ void *buf,
+ size_t len,
+ const ACE_Time_Value *timeout = 0,
+ size_t *bytes_transferred = 0);
+
+ /// Receive into a variable number of pieces.
+ /**
+ * Accepts a variable, caller-specified, number of pointer/length
+ * pairs. Arguments following @a n are char *, size_t pairs.
+ *
+ * @param handle The I/O handle to receive on
+ * @param n The total number of char *, size_t pairs following @a n.
+ *
+ * @return -1 on error, else total number of bytes received.
+ */
+ extern ACE_Export ssize_t recv (ACE_HANDLE handle, size_t n, ...);
+
+ extern ACE_Export ssize_t recvv (ACE_HANDLE handle,
+ iovec *iov,
+ int iovcnt,
+ const ACE_Time_Value *timeout = 0);
+
+ ACE_NAMESPACE_INLINE_FUNCTION
+ ssize_t recvv_n (ACE_HANDLE handle,
+ iovec *iov,
+ int iovcnt,
+ const ACE_Time_Value *timeout = 0,
+ size_t *bytes_transferred = 0);
+
+ extern ACE_Export ssize_t recv_n (ACE_HANDLE handle,
+ ACE_Message_Block *message_block,
+ const ACE_Time_Value *timeout = 0,
+ size_t *bytes_transferred = 0);
+
+ extern ACE_Export ssize_t send (ACE_HANDLE handle,
+ const void *buf,
+ size_t len,
+ int flags,
+ const ACE_Time_Value *timeout = 0);
+
+#if defined (ACE_HAS_TLI)
+
+ extern ACE_Export ssize_t t_snd (ACE_HANDLE handle,
+ const void *buf,
+ size_t len,
+ int flags,
+ const ACE_Time_Value *timeout = 0);
+
+#endif /* ACE_HAS_TLI */
+
+ extern ACE_Export ssize_t send (ACE_HANDLE handle,
+ const void *buf,
+ size_t len,
+ const ACE_Time_Value *timeout = 0);
+
+ extern ACE_Export ssize_t sendmsg (ACE_HANDLE handle,
+ const struct msghdr *msg,
+ int flags,
+ const ACE_Time_Value *timeout = 0);
+
+ extern ACE_Export ssize_t sendto (ACE_HANDLE handle,
+ const char *buf,
+ int len,
+ int flags,
+ const struct sockaddr *addr,
+ int addrlen,
+ const ACE_Time_Value *timeout = 0);
+
+ ACE_NAMESPACE_INLINE_FUNCTION
+ ssize_t send_n (ACE_HANDLE handle,
+ const void *buf,
+ size_t len,
+ int flags,
+ const ACE_Time_Value *timeout = 0,
+ size_t *bytes_transferred = 0);
+
+#if defined (ACE_HAS_TLI)
+
+ ACE_NAMESPACE_INLINE_FUNCTION
+ ssize_t t_snd_n (ACE_HANDLE handle,
+ const void *buf,
+ size_t len,
+ int flags,
+ const ACE_Time_Value *timeout = 0,
+ size_t *bytes_transferred = 0);
+
+#endif /* ACE_HAS_TLI */
+
+ ACE_NAMESPACE_INLINE_FUNCTION
+ ssize_t send_n (ACE_HANDLE handle,
+ const void *buf,
+ size_t len,
+ const ACE_Time_Value *timeout = 0,
+ size_t *bytes_transferred = 0);
+
+ /// Varargs variant.
+ extern ACE_Export ssize_t send (ACE_HANDLE handle, size_t n, ...);
+
+ extern ACE_Export ssize_t sendv (ACE_HANDLE handle,
+ const iovec *iov,
+ int iovcnt,
+ const ACE_Time_Value *timeout = 0);
+
+ ACE_NAMESPACE_INLINE_FUNCTION
+ ssize_t sendv_n (ACE_HANDLE handle,
+ const iovec *iov,
+ int iovcnt,
+ const ACE_Time_Value *timeout = 0,
+ size_t *bytes_transferred = 0);
+
+ /// Send all the @a message_blocks chained through their @c next and
+ /// @c cont pointers. This call uses the underlying OS gather-write
+ /// operation to reduce the domain-crossing penalty.
+ extern ACE_Export ssize_t send_n (ACE_HANDLE handle,
+ const ACE_Message_Block *message_block,
+ const ACE_Time_Value *timeout = 0,
+ size_t *bytes_transferred = 0);
+
+ // = File system I/O functions (these don't support timeouts).
+
+ ACE_NAMESPACE_INLINE_FUNCTION
+ ssize_t read_n (ACE_HANDLE handle,
+ void *buf,
+ size_t len,
+ size_t *bytes_transferred = 0);
+
+ ACE_NAMESPACE_INLINE_FUNCTION
+ ssize_t write_n (ACE_HANDLE handle,
+ const void *buf,
+ size_t len,
+ size_t *bytes_transferred = 0);
+
+ /// Write all the @a message_blocks chained through their @c next
+ /// and @c cont pointers. This call uses the underlying OS
+ /// gather-write operation to reduce the domain-crossing penalty.
+ extern ACE_Export ssize_t write_n (ACE_HANDLE handle,
+ const ACE_Message_Block *message_block,
+ size_t *bytes_transferred = 0);
+
+ extern ACE_Export ssize_t readv_n (ACE_HANDLE handle,
+ iovec *iov,
+ int iovcnt,
+ size_t *bytes_transferred = 0);
+
+ extern ACE_Export ssize_t writev_n (ACE_HANDLE handle,
+ const iovec *iov,
+ int iovcnt,
+ size_t *bytes_transferred = 0);
+ //@}
+
+ /**
+ * Wait up to @a timeout amount of time to passively establish a
+ * connection. This method doesn't perform the @c accept, it just
+ * does the timed wait.
+ */
+ extern ACE_Export int handle_timed_accept (ACE_HANDLE listener,
+ ACE_Time_Value *timeout,
+ bool restart);
+
+ /**
+ * Wait up to @a timeout amount of time to complete an actively
+ * established non-blocking connection. If @a is_tli is non-0 then
+ * we are being called by a TLI wrapper (which behaves slightly
+ * differently from a socket wrapper).
+ */
+ extern ACE_Export ACE_HANDLE handle_timed_complete (
+ ACE_HANDLE listener,
+ const ACE_Time_Value *timeout,
+ int is_tli = 0);
+
+ /**
+ * Reset the limit on the number of open handles. If @a new_limit
+ * == -1 set the limit to the maximum allowable. Otherwise, set
+ * the limit value to @a new_limit. If @a increase_limit_only is
+ * non-0 then only allow increases to the limit.
+ */
+ extern ACE_Export int set_handle_limit (int new_limit = -1,
+ int increase_limit_only = 0);
+
+ /**
+ * Returns the maximum number of open handles currently permitted in
+ * this process. This maximum may be extended using
+ * @c ACE::set_handle_limit.
+ */
+ extern ACE_Export int max_handles (void);
+
+ // = String functions
+ /**
+ * Return a dynamically allocated duplicate of @a str, substituting
+ * the environment variable if @c str[0] @c == @c '$'. Note that
+ * the pointer is allocated with @c ACE_OS::malloc and must be freed
+ * by @c ACE_OS::free.
+ */
+ extern ACE_Export ACE_TCHAR *strenvdup (const ACE_TCHAR *str);
+
+ /// Returns a pointer to the "end" of the string, i.e., the character
+ /// past the '\0'.
+ extern ACE_Export const char *strend (const char *s);
+
+ /// This method is just like @c strdup, except that it uses
+ /// @c operator @c new rather than @c malloc. If @a s is NULL
+ /// returns NULL rather than segfaulting.
+ extern ACE_Export char *strnew (const char *s);
+
+ /// Delete the memory allocated by @c strnew.
+ ACE_NAMESPACE_INLINE_FUNCTION void strdelete (char *s);
+
+ /// Create a fresh new copy of @a str, up to @a n chars long. Uses
+ /// @c ACE_OS::malloc to allocate the new string.
+ extern ACE_Export char *strndup (const char *str, size_t n);
+
+ /// Create a fresh new copy of @a str, up to @a n chars long. Uses
+ /// @c ACE_OS::malloc to allocate the new string.
+ extern ACE_Export char *strnnew (const char *str, size_t n);
+
+ /// Determine if a specified pathname is "dot dir" (ie. "." or "..").
+ ACE_NAMESPACE_INLINE_FUNCTION bool isdotdir (const char *s);
+
+#if defined (ACE_HAS_WCHAR)
+ extern ACE_Export const wchar_t *strend (const wchar_t *s);
+
+ extern ACE_Export wchar_t *strnew (const wchar_t *s);
+
+ ACE_NAMESPACE_INLINE_FUNCTION void strdelete (wchar_t *s);
+
+ extern ACE_Export wchar_t *strndup (const wchar_t *str, size_t n);
+
+ extern ACE_Export wchar_t *strnnew (const wchar_t *str, size_t n);
+
+ ACE_NAMESPACE_INLINE_FUNCTION bool isdotdir (const wchar_t *s);
+
+#endif /* ACE_HAS_WCHAR */
+
+ /**
+ * On Windows, determines if a specified pathname ends with ".exe"
+ * (not case sensitive). If on Windows and there is no ".exe" suffix,
+ * a new ACE_TCHAR array is allocated and a copy of @c pathname with
+ * the ".exe" suffix is copied into it. In this case, the caller is
+ * responsible for calling delete [] on the returned pointer.
+ *
+ * @param pathname The name to check for a proper suffix.
+ *
+ * @retval @c pathname if there is a proper suffix for Windows. This is
+ * always the return value for non-Windows platforms.
+ * @retval If a suffix needs to be added, returns a pointer to new[]
+ * allocated memory containing the original @c pathname plus
+ * a ".exe" suffix. The caller is responsible for freeing the
+ * memory using delete [].
+ */
+ extern ACE_Export const ACE_TCHAR *execname (const ACE_TCHAR *pathname);
+
+ /**
+ * Returns the "basename" of a @a pathname separated by @a delim.
+ * For instance, the basename of "/tmp/foo.cpp" is "foo.cpp" when
+ * @a delim is @a '/'.
+ */
+ extern ACE_Export const ACE_TCHAR *basename (const ACE_TCHAR *pathname,
+ ACE_TCHAR delim =
+ ACE_DIRECTORY_SEPARATOR_CHAR);
+
+ /**
+ * Returns the "dirname" of a @a pathname. For instance, the
+ * dirname of "/tmp/foo.cpp" is "/tmp" when @a delim is @a '/'. If
+ * @a pathname has no @a delim ".\0" is returned. This method does
+ * not modify @a pathname and is not reentrant.
+ */
+ extern ACE_Export const ACE_TCHAR *dirname (const ACE_TCHAR *pathname,
+ ACE_TCHAR delim =
+ ACE_DIRECTORY_SEPARATOR_CHAR);
+
+ /**
+ * Returns the given timestamp in the form
+ * "hour:minute:second:microsecond." The month, day, and year are
+ * also stored in the beginning of the @a date_and_time array, which
+ * is a user-supplied array of size @a time_len> @c ACE_TCHARs.
+ * Returns 0 if unsuccessful, else returns pointer to beginning of the
+ * "time" portion of @a date_and_time. If @a
+ * return_pointer_to_first_digit is 0 then return a pointer to the
+ * space before the time, else return a pointer to the beginning of
+ * the time portion.
+ */
+ extern ACE_Export ACE_TCHAR *timestamp (const ACE_Time_Value& time_value,
+ ACE_TCHAR date_and_time[],
+ size_t time_len,
+ bool return_pointer_to_first_digit = false);
+
+ /**
+ * Returns the current timestamp in the form
+ * "hour:minute:second:microsecond." The month, day, and year are
+ * also stored in the beginning of the @a date_and_time array, which
+ * is a user-supplied array of size @a time_len> @c ACE_TCHARs.
+ * Returns 0 if unsuccessful, else returns pointer to beginning of the
+ * "time" portion of @a date_and_time. If @a
+ * return_pointer_to_first_digit is 0 then return a pointer to the
+ * space before the time, else return a pointer to the beginning of
+ * the time portion.
+ */
+ extern ACE_Export ACE_TCHAR *timestamp (ACE_TCHAR date_and_time[],
+ size_t time_len,
+ bool return_pointer_to_first_digit = false);
+
+ /**
+ * if @a avoid_zombies == 0 call @c ACE_OS::fork directly, else
+ * create an orphan process that's inherited by the init process;
+ * init cleans up when the orphan process terminates so we don't
+ * create zombies. Returns -1 on failure and either the child PID
+ * on success if @a avoid_zombies == 0 or 1 on success if @a
+ * avoid_zombies != 0 (this latter behavior is a known bug that
+ * needs to be fixed).
+ */
+ extern ACE_Export pid_t fork (
+ const ACE_TCHAR *program_name = ACE_TEXT (""),
+ int avoid_zombies = 0);
+
+ /**
+ * Become a daemon process using the algorithm in Richard Stevens
+ * "Advanced Programming in the UNIX Environment." If
+ * @a close_all_handles is non-zero then all open file handles are
+ * closed.
+ */
+ extern ACE_Export int daemonize (
+ const ACE_TCHAR pathname[] = ACE_TEXT ("/"),
+ bool close_all_handles = ACE_DEFAULT_CLOSE_ALL_HANDLES,
+ const ACE_TCHAR program_name[] = ACE_TEXT (""));
+
+ // = Miscellaneous functions.
+ /// Rounds the request to a multiple of the page size.
+ extern ACE_Export size_t round_to_pagesize (size_t len);
+
+ /// Rounds the request to a multiple of the allocation granularity.
+ extern ACE_Export size_t round_to_allocation_granularity (size_t len);
+
+ // @@ UNICODE what about buffer?
+ /// Format buffer into printable format. This is useful for
+ /// debugging.
+ extern ACE_Export size_t format_hexdump (const char *buffer, size_t size,
+ ACE_TCHAR *obuf, size_t obuf_sz);
+
+ /// Computes the hash value of {str} using the "Hash PJW" routine.
+ extern ACE_Export u_long hash_pjw (const char *str);
+
+ /// Computes the hash value of {str} using the "Hash PJW" routine.
+ extern ACE_Export u_long hash_pjw (const char *str, size_t len);
+
+#if defined (ACE_HAS_WCHAR)
+ /// Computes the hash value of {str} using the "Hash PJW" routine.
+ extern ACE_Export u_long hash_pjw (const wchar_t *str);
+
+ /// Computes the hash value of {str} using the "Hash PJW" routine.
+ extern ACE_Export u_long hash_pjw (const wchar_t *str, size_t len);
+#endif /* ACE_HAS_WCHAR */
+
+ /// Computes CRC-CCITT for the string.
+ extern ACE_Export ACE_UINT16 crc_ccitt(const char *str);
+
+ /// Computes CRC-CCITT for the buffer.
+ extern ACE_Export ACE_UINT16 crc_ccitt(const void *buf, size_t len,
+ ACE_UINT16 crc = 0);
+
+ /// Computes CRC-CCITT for the @ len iovec buffers.
+ extern ACE_Export ACE_UINT16 crc_ccitt(const iovec *iov, int len,
+ ACE_UINT16 crc = 0);
+
+ /// Computes the ISO 8802-3 standard 32 bits CRC for the string.
+ extern ACE_Export ACE_UINT32 crc32 (const char *str);
+
+ /// Computes the ISO 8802-3 standard 32 bits CRC for the buffer.
+ extern ACE_Export ACE_UINT32 crc32 (const void *buf, size_t len,
+ ACE_UINT32 crc = 0);
+
+ /// Computes the ISO 8802-3 standard 32 bits CRC for the
+ /// @ len iovec buffers.
+ extern ACE_Export ACE_UINT32 crc32 (const iovec *iov, int len,
+ ACE_UINT32 crc = 0);
+
+ /// Euclid's greatest common divisor algorithm.
+ extern ACE_Export u_long gcd (u_long x, u_long y);
+
+ /// Calculates the minimum enclosing frame size for the given values.
+ extern ACE_Export u_long minimum_frame_size (u_long period1, u_long period2);
+
+ /**
+ * Function that can burn up noticeable CPU time: brute-force
+ * determination of whether number @a n is prime. Returns 0 if
+ * it is prime, or the smallest factor if it is not prime.
+ * @a min_factor and @a max_factor can be used to partition the work
+ * among threads. For just one thread, typical values are 2 and
+ * n/2.
+ */
+ extern ACE_Export u_long is_prime (const u_long n,
+ const u_long min_factor,
+ const u_long max_factor);
+
+ /// Map troublesome win32 errno values to values that standard C
+ /// strerr function understands. Thank you Microsoft.
+ extern ACE_Export int map_errno (int error);
+
+ /// Returns a string containing the error message corresponding to a
+ /// WinSock error. This works around an omission in the Win32 API.
+ /// @internal
+ extern ACE_Export const ACE_TCHAR * sock_error (int error);
+
+ /// Determins whether the given error code corresponds to to a
+ /// WinSock error. If so returns true, false otherwise.
+ /// @internal
+ extern ACE_Export bool is_sock_error (int error);
+
+ /**
+ * Checks if process with {pid} is still alive. Returns 1 if it is
+ * still alive, 0 if it isn't alive, and -1 if something weird
+ * happened.
+ */
+ extern ACE_Export int process_active (pid_t pid);
+
+ /**
+ * Terminate the process abruptly with id @a pid. On Win32 platforms
+ * this uses {TerminateProcess} and on POSIX platforms is uses
+ * {kill} with the -9 (SIGKILL) signal, which cannot be caught or
+ * ignored. Note that this call is potentially dangerous to use
+ * since the process being terminated may not have a chance to
+ * cleanup before it shuts down.
+ */
+ extern ACE_Export int terminate_process (pid_t pid);
+
+ /**
+ * This method uses process id and object pointer to come up with a
+ * machine wide unique name. The process ID will provide uniqueness
+ * between processes on the same machine. The "this" pointer of the
+ * {object} will provide uniqueness between other "live" objects in
+ * the same process. The uniqueness of this name is therefore only
+ * valid for the life of {object}.
+ */
+ ACE_NAMESPACE_INLINE_FUNCTION void unique_name (const void *object,
+ ACE_TCHAR *name,
+ size_t length);
+
+ /// Computes the base 2 logarithm of {num}.
+ ACE_NAMESPACE_INLINE_FUNCTION u_long log2 (u_long num);
+
+ /// Hex conversion utility.
+ extern ACE_Export ACE_TCHAR nibble2hex (u_int n);
+
+ /// Convert a hex character to its byte representation.
+ ACE_NAMESPACE_INLINE_FUNCTION u_char hex2byte (ACE_TCHAR c);
+
+ // = Set/get the debug level.
+ extern ACE_Export bool debug (void);
+ extern ACE_Export void debug (bool onoff);
+
+ /// Wrapper facade for @c select that uses @c ACE_Handle_Sets.
+ extern ACE_Export int select (int width,
+ ACE_Handle_Set *readfds,
+ ACE_Handle_Set *writefds = 0,
+ ACE_Handle_Set *exceptfds = 0,
+ const ACE_Time_Value *timeout = 0);
+
+ /// Wrapper facade for the most common use of @c select that uses
+ /// @c ACE_Handle_Sets.
+ extern ACE_Export int select (int width,
+ ACE_Handle_Set &readfds,
+ const ACE_Time_Value *timeout = 0);
+
+ /// Timed wait for handle to get read ready.
+ ACE_NAMESPACE_INLINE_FUNCTION
+ int handle_read_ready (ACE_HANDLE handle,
+ const ACE_Time_Value *timeout);
+
+ /// Timed wait for handle to get write ready.
+ ACE_NAMESPACE_INLINE_FUNCTION
+ int handle_write_ready (ACE_HANDLE handle,
+ const ACE_Time_Value *timeout);
+
+ /// Timed wait for handle to get exception ready.
+ ACE_NAMESPACE_INLINE_FUNCTION
+ int handle_exception_ready (ACE_HANDLE handle,
+ const ACE_Time_Value *timeout);
+
+ /// Timed wait for handle to get read, write, or exception ready.
+ extern ACE_Export int handle_ready (ACE_HANDLE handle,
+ const ACE_Time_Value *timeout,
+ int read_ready,
+ int write_ready,
+ int exception_ready);
+
+ /// Wait for @a timeout before proceeding to a @c recv operation.
+ /// @a val keeps track of whether we're in non-blocking mode or
+ /// not.
+ extern ACE_Export int enter_recv_timedwait (ACE_HANDLE handle,
+ const ACE_Time_Value *timeout,
+ int &val);
+
+ /// Wait for @a timeout before proceeding to a @c send operation.
+ /// @a val keeps track of whether we're in non-blocking mode or
+ /// not.
+ extern ACE_Export int enter_send_timedwait (ACE_HANDLE handle,
+ const ACE_Time_Value* timeout,
+ int &val);
+
+ /// This makes sure that @a handle is set into non-blocking mode.
+ /// @a val keeps track of whether were in non-blocking mode or not.
+ extern ACE_Export void record_and_set_non_blocking_mode (ACE_HANDLE handle,
+ int &val);
+
+ /// Cleanup after a timed operation, restore the appropriate
+ /// non-blocking status of @a handle.
+ extern ACE_Export void restore_non_blocking_mode (ACE_HANDLE handle,
+ int val);
+
+ // private:
+ // These functions aren't meant to be used internally, so they are
+ // not exported.
+
+ //
+ // = Recv_n helpers
+ //
+
+ ACE_NAMESPACE_INLINE_FUNCTION ssize_t recv_i (ACE_HANDLE handle,
+ void *buf,
+ size_t len);
+
+ extern ACE_Export ssize_t recv_n_i (ACE_HANDLE handle,
+ void *buf,
+ size_t len,
+ int flags,
+ size_t *bytes_transferred);
+
+ extern ACE_Export ssize_t recv_n_i (ACE_HANDLE handle,
+ void *buf,
+ size_t len,
+ int flags,
+ const ACE_Time_Value *timeout,
+ size_t *bytes_transferred);
+
+#if defined (ACE_HAS_TLI)
+
+ extern ACE_Export ssize_t t_rcv_n_i (ACE_HANDLE handle,
+ void *buf,
+ size_t len,
+ int *flags,
+ size_t *bytes_transferred);
+
+ extern ACE_Export ssize_t t_rcv_n_i (ACE_HANDLE handle,
+ void *buf,
+ size_t len,
+ int *flags,
+ const ACE_Time_Value *timeout,
+ size_t *bytes_transferred);
+
+#endif /* ACE_HAS_TLI */
+
+ extern ACE_Export ssize_t recv_n_i (ACE_HANDLE handle,
+ void *buf,
+ size_t len,
+ size_t *bytes_transferred);
+
+ extern ACE_Export ssize_t recv_n_i (ACE_HANDLE handle,
+ void *buf,
+ size_t len,
+ const ACE_Time_Value *timeout,
+ size_t *bytes_transferred);
+
+ extern ACE_Export ssize_t recvv_n_i (ACE_HANDLE handle,
+ iovec *iov,
+ int iovcnt,
+ size_t *bytes_transferred);
+
+ extern ACE_Export ssize_t recvv_n_i (ACE_HANDLE handle,
+ iovec *iov,
+ int iovcnt,
+ const ACE_Time_Value *timeout,
+ size_t *bytes_transferred);
+
+ //
+ // = Send_n helpers
+ //
+
+ ACE_NAMESPACE_INLINE_FUNCTION ssize_t send_i (ACE_HANDLE handle,
+ const void *buf,
+ size_t len);
+
+ extern ACE_Export ssize_t send_n_i (ACE_HANDLE handle,
+ const void *buf,
+ size_t len,
+ int flags,
+ size_t *bytes_transferred);
+
+ extern ACE_Export ssize_t send_n_i (ACE_HANDLE handle,
+ const void *buf,
+ size_t len,
+ int flags,
+ const ACE_Time_Value *timeout,
+ size_t *bytes_transferred);
+
+#if defined (ACE_HAS_TLI)
+
+ extern ACE_Export ssize_t t_snd_n_i (ACE_HANDLE handle,
+ const void *buf,
+ size_t len,
+ int flags,
+ size_t *bytes_transferred);
+
+ extern ACE_Export ssize_t t_snd_n_i (ACE_HANDLE handle,
+ const void *buf,
+ size_t len,
+ int flags,
+ const ACE_Time_Value *timeout,
+ size_t *bytes_transferred);
+
+#endif /* ACE_HAS_TLI */
+
+ extern ACE_Export ssize_t send_n_i (ACE_HANDLE handle,
+ const void *buf,
+ size_t len,
+ size_t *bytes_transferred);
+
+ extern ACE_Export ssize_t send_n_i (ACE_HANDLE handle,
+ const void *buf,
+ size_t len,
+ const ACE_Time_Value *timeout,
+ size_t *bytes_transferred);
+
+ extern ACE_Export ssize_t sendv_n_i (ACE_HANDLE handle,
+ const iovec *iov,
+ int iovcnt,
+ size_t *bytes_transferred);
+
+ extern ACE_Export ssize_t sendv_n_i (ACE_HANDLE handle,
+ const iovec *iov,
+ int iovcnt,
+ const ACE_Time_Value *timeout,
+ size_t *bytes_transferred);
+
+}
+
+// Close versioned namespace, if enabled by the user.
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#if defined (__ACE_INLINE__)
+#include "ace/ACE.inl"
+#endif /* __ACE_INLINE__ */
+
+#include /**/ "ace/post.h"
+
+#endif /* ACE_ACE_H */
diff --git a/externals/ace/ACE.inl b/externals/ace/ACE.inl
new file mode 100644
index 0000000..4be80bf
--- /dev/null
+++ b/externals/ace/ACE.inl
@@ -0,0 +1,348 @@
+// -*- C++ -*-
+//
+// $Id: ACE.inl 87366 2009-11-05 20:16:30Z olli $
+
+#include "ace/OS_NS_unistd.h"
+#include "ace/OS_NS_Thread.h"
+#include "ace/OS_NS_ctype.h"
+#include "ace/OS_NS_sys_socket.h"
+
+// Open versioned namespace, if enabled by the user.
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+
+// Wrappers for methods that have been moved to ACE_OS.
+
+ACE_INLINE ssize_t
+ACE::read_n (ACE_HANDLE handle,
+ void *buf,
+ size_t len,
+ size_t *bytes_transferred)
+{
+ return ACE_OS::read_n (handle,
+ buf,
+ len,
+ bytes_transferred);
+}
+
+ACE_INLINE ssize_t
+ACE::write_n (ACE_HANDLE handle,
+ const void *buf,
+ size_t len,
+ size_t *bytes_transferred)
+{
+ return ACE_OS::write_n (handle,
+ buf,
+ len,
+ bytes_transferred);
+}
+
+ACE_INLINE ssize_t
+ACE::recv_n (ACE_HANDLE handle,
+ void *buf,
+ size_t len,
+ int flags,
+ const ACE_Time_Value *timeout,
+ size_t *bytes_transferred)
+{
+ if (timeout == 0)
+ return ACE::recv_n_i (handle,
+ buf,
+ len,
+ flags,
+ bytes_transferred);
+ else
+ return ACE::recv_n_i (handle,
+ buf,
+ len,
+ flags,
+ timeout,
+ bytes_transferred);
+}
+
+#if defined (ACE_HAS_TLI)
+
+ACE_INLINE ssize_t
+ACE::t_rcv_n (ACE_HANDLE handle,
+ void *buf,
+ size_t len,
+ int *flags,
+ const ACE_Time_Value *timeout,
+ size_t *bytes_transferred)
+{
+ if (timeout == 0)
+ return ACE::t_rcv_n_i (handle,
+ buf,
+ len,
+ flags,
+ bytes_transferred);
+ else
+ return ACE::t_rcv_n_i (handle,
+ buf,
+ len,
+ flags,
+ timeout,
+ bytes_transferred);
+}
+
+#endif /* ACE_HAS_TLI */
+
+ACE_INLINE ssize_t
+ACE::recv_n (ACE_HANDLE handle,
+ void *buf,
+ size_t len,
+ const ACE_Time_Value *timeout,
+ size_t *bytes_transferred)
+{
+ if (timeout == 0)
+ return ACE::recv_n_i (handle,
+ buf,
+ len,
+ bytes_transferred);
+ else
+ return ACE::recv_n_i (handle,
+ buf,
+ len,
+ timeout,
+ bytes_transferred);
+}
+
+ACE_INLINE ssize_t
+ACE::recvv_n (ACE_HANDLE handle,
+ iovec *iov,
+ int iovcnt,
+ const ACE_Time_Value *timeout,
+ size_t *bytes_transferred)
+{
+ if (timeout == 0)
+ return ACE::recvv_n_i (handle,
+ iov,
+ iovcnt,
+ bytes_transferred);
+ else
+ return ACE::recvv_n_i (handle,
+ iov,
+ iovcnt,
+ timeout,
+ bytes_transferred);
+}
+
+ACE_INLINE ssize_t
+ACE::send_n (ACE_HANDLE handle,
+ const void *buf,
+ size_t len,
+ int flags,
+ const ACE_Time_Value *timeout,
+ size_t *bytes_transferred)
+{
+ if (timeout == 0)
+ return ACE::send_n_i (handle,
+ buf,
+ len,
+ flags,
+ bytes_transferred);
+ else
+ return ACE::send_n_i (handle,
+ buf,
+ len,
+ flags,
+ timeout,
+ bytes_transferred);
+}
+
+#if defined (ACE_HAS_TLI)
+
+ACE_INLINE ssize_t
+ACE::t_snd_n (ACE_HANDLE handle,
+ const void *buf,
+ size_t len,
+ int flags,
+ const ACE_Time_Value *timeout,
+ size_t *bytes_transferred)
+{
+ if (timeout == 0)
+ return ACE::t_snd_n_i (handle,
+ buf,
+ len,
+ flags,
+ bytes_transferred);
+ else
+ return ACE::t_snd_n_i (handle,
+ buf,
+ len,
+ flags,
+ timeout,
+ bytes_transferred);
+}
+
+#endif /* ACE_HAS_TLI */
+
+ACE_INLINE ssize_t
+ACE::send_n (ACE_HANDLE handle,
+ const void *buf,
+ size_t len,
+ const ACE_Time_Value *timeout,
+ size_t *bytes_transferred)
+{
+ if (timeout == 0)
+ return ACE::send_n_i (handle,
+ buf,
+ len,
+ bytes_transferred);
+ else
+ return ACE::send_n_i (handle,
+ buf,
+ len,
+ timeout,
+ bytes_transferred);
+}
+
+ACE_INLINE ssize_t
+ACE::sendv_n (ACE_HANDLE handle,
+ const iovec *iov,
+ int iovcnt,
+ const ACE_Time_Value *timeout,
+ size_t *bytes_transferred)
+{
+ if (timeout == 0)
+ return ACE::sendv_n_i (handle,
+ iov,
+ iovcnt,
+ bytes_transferred);
+ else
+ return ACE::sendv_n_i (handle,
+ iov,
+ iovcnt,
+ timeout,
+ bytes_transferred);
+}
+
+ACE_INLINE ssize_t
+ACE::send_i (ACE_HANDLE handle, const void *buf, size_t len)
+{
+#if defined (ACE_WIN32) || defined (HPUX)
+ return ACE_OS::send (handle, (const char *) buf, len);
+#else
+ return ACE_OS::write (handle, (const char *) buf, len);
+#endif /* ACE_WIN32 */
+}
+
+ACE_INLINE ssize_t
+ACE::recv_i (ACE_HANDLE handle, void *buf, size_t len)
+{
+#if defined (ACE_WIN32) || defined (ACE_OPENVMS) || defined (ACE_TANDEM_T1248_PTHREADS)
+ return ACE_OS::recv (handle, (char *) buf, len);
+#else
+ return ACE_OS::read (handle, (char *) buf, len);
+#endif /* ACE_WIN32 */
+}
+
+ACE_INLINE int
+ACE::handle_read_ready (ACE_HANDLE handle,
+ const ACE_Time_Value *timeout)
+{
+ return ACE::handle_ready (handle,
+ timeout,
+ 1,
+ 0,
+ 0);
+}
+
+ACE_INLINE int
+ACE::handle_write_ready (ACE_HANDLE handle,
+ const ACE_Time_Value *timeout)
+{
+ return ACE::handle_ready (handle,
+ timeout,
+ 0,
+ 1,
+ 0);
+}
+
+ACE_INLINE int
+ACE::handle_exception_ready (ACE_HANDLE handle,
+ const ACE_Time_Value *timeout)
+{
+ return ACE::handle_ready (handle,
+ timeout,
+ 0,
+ 0,
+ 1);
+}
+
+ACE_INLINE void
+ACE::strdelete (char *s)
+{
+ delete [] s;
+}
+
+#if defined (ACE_HAS_WCHAR)
+ACE_INLINE void
+ACE::strdelete (wchar_t *s)
+{
+ delete [] s;
+}
+#endif /* ACE_HAS_WCHAR */
+
+ACE_INLINE bool
+ACE::isdotdir (const char *s)
+{
+ return (s[0] == '.' &&
+ ((s[1] == 0) || (s[1] == '.' && s[2] == 0)));
+}
+
+#if defined (ACE_HAS_WCHAR)
+ACE_INLINE bool
+ACE::isdotdir (const wchar_t *s)
+{
+ return (s[0] == ACE_TEXT ('.') &&
+ ((s[1] == 0) || (s[1] == ACE_TEXT ('.') && s[2] == 0)));
+}
+#endif /* ACE_HAS_WCHAR */
+
+ACE_INLINE void
+ACE::unique_name (const void *object,
+ ACE_TCHAR *name,
+ size_t length)
+{
+ ACE_OS::unique_name (object, name, length);
+}
+
+ACE_INLINE u_long
+ACE::log2 (u_long num)
+{
+ u_long log = 0;
+
+ for (; num > 1; ++log)
+ num >>= 1;
+
+ return log;
+}
+
+ACE_INLINE int
+ACE::map_errno (int error)
+{
+#if defined (ACE_WIN32)
+ switch (error)
+ {
+ case WSAEWOULDBLOCK:
+ return EAGAIN; // Same as UNIX errno EWOULDBLOCK.
+ }
+#endif /* ACE_WIN32 */
+
+ return error;
+}
+
+ACE_INLINE u_char
+ACE::hex2byte (ACE_TCHAR c)
+{
+ if (ACE_OS::ace_isdigit (c))
+ return (u_char) (c - ACE_TEXT ('0'));
+ else if (ACE_OS::ace_islower (c))
+ return (u_char) (10 + c - ACE_TEXT ('a'));
+ else
+ return (u_char) (10 + c - ACE_TEXT ('A'));
+}
+
+// Close versioned namespace, if enabled by the user.
+ACE_END_VERSIONED_NAMESPACE_DECL
diff --git a/externals/ace/ACE.pc.in b/externals/ace/ACE.pc.in
new file mode 100644
index 0000000..90b2a9e
--- /dev/null
+++ b/externals/ace/ACE.pc.in
@@ -0,0 +1,10 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: ACE
+Description: ADAPTIVE Communication Environment
+Version: @VERSION@
+Libs: -L${libdir} -lACE @LIBS@
+Cflags: -I${includedir}
diff --git a/externals/ace/ACE_crc32.cpp b/externals/ace/ACE_crc32.cpp
new file mode 100644
index 0000000..70d93e6
--- /dev/null
+++ b/externals/ace/ACE_crc32.cpp
@@ -0,0 +1,161 @@
+// $Id: ACE_crc32.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/ACE.h"
+
+ACE_RCSID (ace,
+ ACE_crc32,
+ "$Id: ACE_crc32.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+
+namespace
+{
+ /*****************************************************************/
+ /* */
+ /* CRC LOOKUP TABLE */
+ /* ================ */
+ /* The following CRC lookup table was generated automagically */
+ /* by the Rocksoft^tm Model CRC Algorithm Table Generation */
+ /* Program V1.0 using the following model parameters: */
+ /* */
+ /* Width : 4 bytes. */
+ /* Poly : 0x04C11DB7L */
+ /* Reverse : TRUE. */
+ /* */
+ /* For more information on the Rocksoft^tm Model CRC Algorithm, */
+ /* see the document titled "A Painless Guide to CRC Error */
+ /* Detection Algorithms" by Ross Williams */
+ /* (ross@guest.adelaide.edu.au.). This document is likely to be */
+ /* in the FTP archive "ftp.adelaide.edu.au/pub/rocksoft". */
+ /* */
+ /*****************************************************************/
+
+ const ACE_UINT32 crc_table[] =
+ {
+ 0x00000000L, 0x77073096L, 0xEE0E612CL, 0x990951BAL,
+ 0x076DC419L, 0x706AF48FL, 0xE963A535L, 0x9E6495A3L,
+ 0x0EDB8832L, 0x79DCB8A4L, 0xE0D5E91EL, 0x97D2D988L,
+ 0x09B64C2BL, 0x7EB17CBDL, 0xE7B82D07L, 0x90BF1D91L,
+ 0x1DB71064L, 0x6AB020F2L, 0xF3B97148L, 0x84BE41DEL,
+ 0x1ADAD47DL, 0x6DDDE4EBL, 0xF4D4B551L, 0x83D385C7L,
+ 0x136C9856L, 0x646BA8C0L, 0xFD62F97AL, 0x8A65C9ECL,
+ 0x14015C4FL, 0x63066CD9L, 0xFA0F3D63L, 0x8D080DF5L,
+ 0x3B6E20C8L, 0x4C69105EL, 0xD56041E4L, 0xA2677172L,
+ 0x3C03E4D1L, 0x4B04D447L, 0xD20D85FDL, 0xA50AB56BL,
+ 0x35B5A8FAL, 0x42B2986CL, 0xDBBBC9D6L, 0xACBCF940L,
+ 0x32D86CE3L, 0x45DF5C75L, 0xDCD60DCFL, 0xABD13D59L,
+ 0x26D930ACL, 0x51DE003AL, 0xC8D75180L, 0xBFD06116L,
+ 0x21B4F4B5L, 0x56B3C423L, 0xCFBA9599L, 0xB8BDA50FL,
+ 0x2802B89EL, 0x5F058808L, 0xC60CD9B2L, 0xB10BE924L,
+ 0x2F6F7C87L, 0x58684C11L, 0xC1611DABL, 0xB6662D3DL,
+ 0x76DC4190L, 0x01DB7106L, 0x98D220BCL, 0xEFD5102AL,
+ 0x71B18589L, 0x06B6B51FL, 0x9FBFE4A5L, 0xE8B8D433L,
+ 0x7807C9A2L, 0x0F00F934L, 0x9609A88EL, 0xE10E9818L,
+ 0x7F6A0DBBL, 0x086D3D2DL, 0x91646C97L, 0xE6635C01L,
+ 0x6B6B51F4L, 0x1C6C6162L, 0x856530D8L, 0xF262004EL,
+ 0x6C0695EDL, 0x1B01A57BL, 0x8208F4C1L, 0xF50FC457L,
+ 0x65B0D9C6L, 0x12B7E950L, 0x8BBEB8EAL, 0xFCB9887CL,
+ 0x62DD1DDFL, 0x15DA2D49L, 0x8CD37CF3L, 0xFBD44C65L,
+ 0x4DB26158L, 0x3AB551CEL, 0xA3BC0074L, 0xD4BB30E2L,
+ 0x4ADFA541L, 0x3DD895D7L, 0xA4D1C46DL, 0xD3D6F4FBL,
+ 0x4369E96AL, 0x346ED9FCL, 0xAD678846L, 0xDA60B8D0L,
+ 0x44042D73L, 0x33031DE5L, 0xAA0A4C5FL, 0xDD0D7CC9L,
+ 0x5005713CL, 0x270241AAL, 0xBE0B1010L, 0xC90C2086L,
+ 0x5768B525L, 0x206F85B3L, 0xB966D409L, 0xCE61E49FL,
+ 0x5EDEF90EL, 0x29D9C998L, 0xB0D09822L, 0xC7D7A8B4L,
+ 0x59B33D17L, 0x2EB40D81L, 0xB7BD5C3BL, 0xC0BA6CADL,
+ 0xEDB88320L, 0x9ABFB3B6L, 0x03B6E20CL, 0x74B1D29AL,
+ 0xEAD54739L, 0x9DD277AFL, 0x04DB2615L, 0x73DC1683L,
+ 0xE3630B12L, 0x94643B84L, 0x0D6D6A3EL, 0x7A6A5AA8L,
+ 0xE40ECF0BL, 0x9309FF9DL, 0x0A00AE27L, 0x7D079EB1L,
+ 0xF00F9344L, 0x8708A3D2L, 0x1E01F268L, 0x6906C2FEL,
+ 0xF762575DL, 0x806567CBL, 0x196C3671L, 0x6E6B06E7L,
+ 0xFED41B76L, 0x89D32BE0L, 0x10DA7A5AL, 0x67DD4ACCL,
+ 0xF9B9DF6FL, 0x8EBEEFF9L, 0x17B7BE43L, 0x60B08ED5L,
+ 0xD6D6A3E8L, 0xA1D1937EL, 0x38D8C2C4L, 0x4FDFF252L,
+ 0xD1BB67F1L, 0xA6BC5767L, 0x3FB506DDL, 0x48B2364BL,
+ 0xD80D2BDAL, 0xAF0A1B4CL, 0x36034AF6L, 0x41047A60L,
+ 0xDF60EFC3L, 0xA867DF55L, 0x316E8EEFL, 0x4669BE79L,
+ 0xCB61B38CL, 0xBC66831AL, 0x256FD2A0L, 0x5268E236L,
+ 0xCC0C7795L, 0xBB0B4703L, 0x220216B9L, 0x5505262FL,
+ 0xC5BA3BBEL, 0xB2BD0B28L, 0x2BB45A92L, 0x5CB36A04L,
+ 0xC2D7FFA7L, 0xB5D0CF31L, 0x2CD99E8BL, 0x5BDEAE1DL,
+ 0x9B64C2B0L, 0xEC63F226L, 0x756AA39CL, 0x026D930AL,
+ 0x9C0906A9L, 0xEB0E363FL, 0x72076785L, 0x05005713L,
+ 0x95BF4A82L, 0xE2B87A14L, 0x7BB12BAEL, 0x0CB61B38L,
+ 0x92D28E9BL, 0xE5D5BE0DL, 0x7CDCEFB7L, 0x0BDBDF21L,
+ 0x86D3D2D4L, 0xF1D4E242L, 0x68DDB3F8L, 0x1FDA836EL,
+ 0x81BE16CDL, 0xF6B9265BL, 0x6FB077E1L, 0x18B74777L,
+ 0x88085AE6L, 0xFF0F6A70L, 0x66063BCAL, 0x11010B5CL,
+ 0x8F659EFFL, 0xF862AE69L, 0x616BFFD3L, 0x166CCF45L,
+ 0xA00AE278L, 0xD70DD2EEL, 0x4E048354L, 0x3903B3C2L,
+ 0xA7672661L, 0xD06016F7L, 0x4969474DL, 0x3E6E77DBL,
+ 0xAED16A4AL, 0xD9D65ADCL, 0x40DF0B66L, 0x37D83BF0L,
+ 0xA9BCAE53L, 0xDEBB9EC5L, 0x47B2CF7FL, 0x30B5FFE9L,
+ 0xBDBDF21CL, 0xCABAC28AL, 0x53B39330L, 0x24B4A3A6L,
+ 0xBAD03605L, 0xCDD70693L, 0x54DE5729L, 0x23D967BFL,
+ 0xB3667A2EL, 0xC4614AB8L, 0x5D681B02L, 0x2A6F2B94L,
+ 0xB40BBE37L, 0xC30C8EA1L, 0x5A05DF1BL, 0x2D02EF8DL
+ };
+
+ /*****************************************************************/
+ /* End of CRC Lookup Table */
+ /*****************************************************************/
+}
+
+#define COMPUTE(var, ch) (var) = (crc_table[(var ^ ch) & 0xFF] ^ (var >> 8))
+
+// Open versioned namespace, if enabled by the user.
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_UINT32
+ACE::crc32 (const char *string)
+{
+ ACE_UINT32 crc = 0xFFFFFFFF;
+
+ for (const char *p = string;
+ *p != 0;
+ ++p)
+ {
+ COMPUTE (crc, *p);
+ }
+
+ return ~crc;
+}
+
+ACE_UINT32
+ACE::crc32 (const void *buffer, size_t len, ACE_UINT32 crc)
+{
+ crc = ~crc;
+
+ for (const char *p = (const char *) buffer,
+ *e = (const char *) buffer + len;
+ p != e;
+ ++p)
+ {
+ COMPUTE (crc, *p);
+ }
+
+ return ~crc;
+}
+
+ACE_UINT32
+ACE::crc32 (const iovec *iov, int len, ACE_UINT32 crc)
+{
+ crc = ~crc;
+
+ for (int i = 0; i < len; ++i)
+ {
+ for (const char *p = (const char *) iov[i].iov_base,
+ *e = (const char *) iov[i].iov_base + iov[i].iov_len;
+ p != e;
+ ++p)
+ COMPUTE (crc, *p);
+ }
+
+ return ~crc;
+}
+
+// Close versioned namespace, if enabled by the user.
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#undef COMPUTE
diff --git a/externals/ace/ACE_crc_ccitt.cpp b/externals/ace/ACE_crc_ccitt.cpp
new file mode 100644
index 0000000..ef7f5d6
--- /dev/null
+++ b/externals/ace/ACE_crc_ccitt.cpp
@@ -0,0 +1,128 @@
+// $Id: ACE_crc_ccitt.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/ACE.h"
+
+ACE_RCSID (ace,
+ ACE_crc_ccitt,
+ "$Id: ACE_crc_ccitt.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+namespace
+{
+ /*****************************************************************/
+ /* */
+ /* CRC LOOKUP TABLE */
+ /* ================ */
+ /* The following CRC lookup table was generated automagically */
+ /* by the Rocksoft^tm Model CRC Algorithm Table Generation */
+ /* Program V1.0 using the following model parameters: */
+ /* */
+ /* Width : 2 bytes. */
+ /* Poly : 0x1021 */
+ /* Reverse : TRUE. */
+ /* */
+ /* For more information on the Rocksoft^tm Model CRC Algorithm, */
+ /* see the document titled "A Painless Guide to CRC Error */
+ /* Detection Algorithms" by Ross Williams */
+ /* (ross@guest.adelaide.edu.au.). This document is likely to be */
+ /* in the FTP archive "ftp.adelaide.edu.au/pub/rocksoft". */
+ /* */
+ /*****************************************************************/
+
+ const ACE_UINT16 crc_table[] =
+ {
+ 0x0000, 0x1189, 0x2312, 0x329B, 0x4624, 0x57AD, 0x6536, 0x74BF,
+ 0x8C48, 0x9DC1, 0xAF5A, 0xBED3, 0xCA6C, 0xDBE5, 0xE97E, 0xF8F7,
+ 0x1081, 0x0108, 0x3393, 0x221A, 0x56A5, 0x472C, 0x75B7, 0x643E,
+ 0x9CC9, 0x8D40, 0xBFDB, 0xAE52, 0xDAED, 0xCB64, 0xF9FF, 0xE876,
+ 0x2102, 0x308B, 0x0210, 0x1399, 0x6726, 0x76AF, 0x4434, 0x55BD,
+ 0xAD4A, 0xBCC3, 0x8E58, 0x9FD1, 0xEB6E, 0xFAE7, 0xC87C, 0xD9F5,
+ 0x3183, 0x200A, 0x1291, 0x0318, 0x77A7, 0x662E, 0x54B5, 0x453C,
+ 0xBDCB, 0xAC42, 0x9ED9, 0x8F50, 0xFBEF, 0xEA66, 0xD8FD, 0xC974,
+ 0x4204, 0x538D, 0x6116, 0x709F, 0x0420, 0x15A9, 0x2732, 0x36BB,
+ 0xCE4C, 0xDFC5, 0xED5E, 0xFCD7, 0x8868, 0x99E1, 0xAB7A, 0xBAF3,
+ 0x5285, 0x430C, 0x7197, 0x601E, 0x14A1, 0x0528, 0x37B3, 0x263A,
+ 0xDECD, 0xCF44, 0xFDDF, 0xEC56, 0x98E9, 0x8960, 0xBBFB, 0xAA72,
+ 0x6306, 0x728F, 0x4014, 0x519D, 0x2522, 0x34AB, 0x0630, 0x17B9,
+ 0xEF4E, 0xFEC7, 0xCC5C, 0xDDD5, 0xA96A, 0xB8E3, 0x8A78, 0x9BF1,
+ 0x7387, 0x620E, 0x5095, 0x411C, 0x35A3, 0x242A, 0x16B1, 0x0738,
+ 0xFFCF, 0xEE46, 0xDCDD, 0xCD54, 0xB9EB, 0xA862, 0x9AF9, 0x8B70,
+ 0x8408, 0x9581, 0xA71A, 0xB693, 0xC22C, 0xD3A5, 0xE13E, 0xF0B7,
+ 0x0840, 0x19C9, 0x2B52, 0x3ADB, 0x4E64, 0x5FED, 0x6D76, 0x7CFF,
+ 0x9489, 0x8500, 0xB79B, 0xA612, 0xD2AD, 0xC324, 0xF1BF, 0xE036,
+ 0x18C1, 0x0948, 0x3BD3, 0x2A5A, 0x5EE5, 0x4F6C, 0x7DF7, 0x6C7E,
+ 0xA50A, 0xB483, 0x8618, 0x9791, 0xE32E, 0xF2A7, 0xC03C, 0xD1B5,
+ 0x2942, 0x38CB, 0x0A50, 0x1BD9, 0x6F66, 0x7EEF, 0x4C74, 0x5DFD,
+ 0xB58B, 0xA402, 0x9699, 0x8710, 0xF3AF, 0xE226, 0xD0BD, 0xC134,
+ 0x39C3, 0x284A, 0x1AD1, 0x0B58, 0x7FE7, 0x6E6E, 0x5CF5, 0x4D7C,
+ 0xC60C, 0xD785, 0xE51E, 0xF497, 0x8028, 0x91A1, 0xA33A, 0xB2B3,
+ 0x4A44, 0x5BCD, 0x6956, 0x78DF, 0x0C60, 0x1DE9, 0x2F72, 0x3EFB,
+ 0xD68D, 0xC704, 0xF59F, 0xE416, 0x90A9, 0x8120, 0xB3BB, 0xA232,
+ 0x5AC5, 0x4B4C, 0x79D7, 0x685E, 0x1CE1, 0x0D68, 0x3FF3, 0x2E7A,
+ 0xE70E, 0xF687, 0xC41C, 0xD595, 0xA12A, 0xB0A3, 0x8238, 0x93B1,
+ 0x6B46, 0x7ACF, 0x4854, 0x59DD, 0x2D62, 0x3CEB, 0x0E70, 0x1FF9,
+ 0xF78F, 0xE606, 0xD49D, 0xC514, 0xB1AB, 0xA022, 0x92B9, 0x8330,
+ 0x7BC7, 0x6A4E, 0x58D5, 0x495C, 0x3DE3, 0x2C6A, 0x1EF1, 0x0F78
+ };
+
+ /*****************************************************************/
+ /* End of CRC Lookup Table */
+ /*****************************************************************/
+}
+
+#define COMPUTE(var, ch) (var) = (crc_table[(var ^ ch) & 0xFF] ^ (var >> 8))
+
+// Open versioned namespace, if enabled by the user.
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_UINT16
+ACE::crc_ccitt (const char *string)
+{
+ ACE_UINT16 crc = 0xFFFF;
+
+ for (const char *p = string;
+ *p != 0;
+ ++p)
+ {
+ COMPUTE (crc, *p);
+ }
+
+ return ~crc;
+}
+
+ACE_UINT16
+ACE::crc_ccitt (const void *buffer, size_t len, ACE_UINT16 crc)
+{
+ crc = ~crc;
+
+ for (const char *p = (const char *) buffer,
+ *e = (const char *) buffer + len;
+ p != e;
+ ++p)
+ {
+ COMPUTE (crc, *p);
+ }
+
+ return ~crc;
+}
+
+ACE_UINT16
+ACE::crc_ccitt (const iovec *iov, int len, ACE_UINT16 crc)
+{
+ crc = ~crc;
+
+ for (int i = 0; i < len; ++i)
+ {
+ for (const char *p = (const char *) iov[i].iov_base,
+ *e = (const char *) iov[i].iov_base + iov[i].iov_len;
+ p != e;
+ ++p)
+ COMPUTE (crc, *p);
+ }
+
+ return ~crc;
+}
+
+// Close versioned namespace, if enabled by the user.
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#undef COMPUTE
diff --git a/externals/ace/ACE_export.h b/externals/ace/ACE_export.h
new file mode 100644
index 0000000..8ad2a33
--- /dev/null
+++ b/externals/ace/ACE_export.h
@@ -0,0 +1,76 @@
+// -*- C++ -*-
+// $Id: ACE_export.h 80826 2008-03-04 14:51:23Z wotte $
+// Definition for Win32 Export directives.
+// This file is generated automatically by
+// generate_export_file.pl
+// ------------------------------
+
+#ifndef ACE_EXPORT_H
+#define ACE_EXPORT_H
+
+#include "ace/config-lite.h"
+
+#if defined (ACE_AS_STATIC_LIBS)
+
+# if !defined (ACE_HAS_DLL)
+# define ACE_HAS_DLL 0
+# endif /* ! ACE_HAS_DLL */
+#else
+# if !defined (ACE_HAS_DLL)
+# define ACE_HAS_DLL 1
+# endif /* ! ACE_HAS_DLL */
+#endif /* ACE_AS_STATIC_LIB */
+
+#if defined (ACE_HAS_DLL)
+# if (ACE_HAS_DLL == 1)
+# if defined (ACE_BUILD_DLL)
+# define ACE_Export ACE_Proper_Export_Flag
+# define ACE_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T)
+# define ACE_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK)
+# else
+# define ACE_Export ACE_Proper_Import_Flag
+# define ACE_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T)
+# define ACE_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK)
+# endif /* ACE_BUILD_DLL */
+# else
+# define ACE_Export
+# define ACE_SINGLETON_DECLARATION(T)
+# define ACE_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK)
+# endif /* ! ACE_HAS_DLL == 1 */
+#else
+# define ACE_Export
+# define ACE_SINGLETON_DECLARATION(T)
+# define ACE_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK)
+#endif /* ACE_HAS_DLL */
+
+// Added by hand to help with ACE_OS namespace
+#if defined (__TANDEM) && defined (USE_EXPLICIT_EXPORT)
+#define ACE_NAMESPACE_STORAGE_CLASS ACE_EXPORT_MACRO extern
+#else
+#define ACE_NAMESPACE_STORAGE_CLASS extern ACE_EXPORT_MACRO
+#endif
+
+#if defined (__ACE_INLINE__)
+# if defined (_MSC_VER) || defined (__MINGW32__) || defined (CYGWIN32) || \
+ (defined (__SUNPRO_CC) && __SUNPRO_CC >= 0x560) || \
+ (defined (__HP_aCC) && (__HP_aCC >= 60500)) || \
+ (defined (__sgi) && \
+ defined (_COMPILER_VERSION) && _COMPILER_VERSION <= 730)
+# define ACE_NAMESPACE_INLINE_FUNCTION inline
+# else
+# define ACE_NAMESPACE_INLINE_FUNCTION ACE_NAMESPACE_STORAGE_CLASS inline
+# endif
+# define ACE_INLINE_TEMPLATE_FUNCTION inline
+#else
+# define ACE_NAMESPACE_INLINE_FUNCTION ACE_NAMESPACE_STORAGE_CLASS
+// Microsoft Visual C++ will accept 'extern'; others refuse.
+# if defined (_MSC_VER) || defined (__BORLANDC__)
+# define ACE_INLINE_TEMPLATE_FUNCTION ACE_Export
+# else
+# define ACE_INLINE_TEMPLATE_FUNCTION
+# endif
+#endif
+
+#endif /* ACE_EXPORT_H */
+
+// End of auto generated file.
diff --git a/externals/ace/ARGV.cpp b/externals/ace/ARGV.cpp
new file mode 100644
index 0000000..edfd4ef
--- /dev/null
+++ b/externals/ace/ARGV.cpp
@@ -0,0 +1,383 @@
+// $Id: ARGV.cpp 81374 2008-04-16 13:07:47Z iliyan $
+
+#ifndef ACE_ARGV_CPP
+#define ACE_ARGV_CPP
+
+#include "ace/Log_Msg.h"
+#include "ace/OS_NS_unistd.h"
+#include "ace/OS_NS_string.h"
+#include "ace/OS_Memory.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/ARGV.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID(ace, ARGV, "$Id: ARGV.cpp 81374 2008-04-16 13:07:47Z iliyan $")
+
+// Open versioned namespace, if enabled by the user.
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE (ACE_ARGV_Queue_Entry)
+ACE_ALLOC_HOOK_DEFINE (ACE_ARGV)
+
+template
+void
+ACE_ARGV_Queue_Entry_T::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_ARGV_Queue_Entry_T::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("arg_ = %s"), this->arg_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("quote_arg_ = %d"), (int)this->quote_arg_));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+template
+void
+ACE_ARGV_T::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_ARGV_T::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("argc_ = %d"), this->argc_));
+
+ ACE_ARGV *this_obj = const_cast (this);
+
+ for (int i = 0; i < this->argc_; i++)
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("\nargv_[%i] = %s"),
+ i,
+ this_obj->argv ()[i]));
+
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nbuf = %s\n"), this->buf_));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n")));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+// Creates this->argv_ out of this->buf_. New memory is allocated for
+// each element of the array. This is used by the array-to-string
+// style constructor and for creating this->argv_ when in iterative
+// mode.
+
+template
+int
+ACE_ARGV_T::string_to_argv (void)
+{
+ ACE_TRACE ("ACE_ARGV_T::string_to_argv");
+
+ return ACE_OS::string_to_argv (this->buf_,
+ this->argc_,
+ this->argv_,
+ this->substitute_env_args_);
+}
+
+template
+ACE_ARGV_T::ACE_ARGV_T (const CHAR_TYPE buf[],
+ bool substitute_env_args)
+ : substitute_env_args_ (substitute_env_args),
+ iterative_ (false),
+ argc_ (0),
+ argv_ (0),
+ buf_ (0),
+ length_ (0),
+ queue_ ()
+{
+ ACE_TRACE ("ACE_ARGV_T::ACE_ARGV_T CHAR_TYPE[] to CHAR_TYPE *[]");
+
+ if (buf == 0 || buf[0] == 0)
+ return;
+
+ // Make an internal copy of the string.
+ ACE_NEW (this->buf_,
+ CHAR_TYPE[ACE_OS::strlen (buf) + 1]);
+ ACE_OS::strcpy (this->buf_, buf);
+
+ // Create this->argv_.
+ if (this->string_to_argv () == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("string_to_argv")));
+}
+
+template
+ACE_ARGV_T::ACE_ARGV_T (CHAR_TYPE *argv[],
+ bool substitute_env_args,
+ bool quote_arg)
+ : substitute_env_args_ (substitute_env_args),
+ iterative_ (false),
+ argc_ (0),
+ argv_ (0),
+ buf_ (0),
+ length_ (0),
+ queue_ ()
+{
+ ACE_TRACE ("ACE_ARGV_T::ACE_ARGV_T CHAR_TYPE*[] to CHAR_TYPE[]");
+
+ if (argv == 0 || argv[0] == 0)
+ return;
+
+ this->argc_ = ACE_OS::argv_to_string (argv,
+ this->buf_,
+ substitute_env_args,
+ quote_arg);
+}
+
+template
+ACE_ARGV_T::ACE_ARGV_T (int argc,
+ CHAR_TYPE *argv[],
+ bool substitute_env_args,
+ bool quote_arg)
+ : substitute_env_args_ (substitute_env_args),
+ iterative_ (false),
+ argc_ (0),
+ argv_ (0),
+ buf_ (0),
+ length_ (0),
+ queue_ ()
+{
+ ACE_TRACE ("ACE_ARGV_T::ACE_ARGV_T int,CHAR_TYPE*[] to CHAR_TYPE[]");
+
+ this->argc_ = ACE_OS::argv_to_string (argc,
+ argv,
+ this->buf_,
+ substitute_env_args,
+ quote_arg);
+}
+
+
+template
+ACE_ARGV_T::ACE_ARGV_T (CHAR_TYPE *first_argv[],
+ CHAR_TYPE *second_argv[],
+ bool substitute_env_args,
+ bool quote_args)
+ : substitute_env_args_ (substitute_env_args),
+ iterative_ (false),
+ argc_ (0),
+ argv_ (0),
+ buf_ (0),
+ length_ (0),
+ queue_ ()
+{
+ ACE_TRACE ("ACE_ARGV_T::ACE_ARGV_T CHAR_TYPE*[] + CHAR_TYPE *[] to CHAR_TYPE[]");
+
+ int first_argc = 0;
+ int second_argc = 0;
+
+ CHAR_TYPE *first_buf = 0;
+ CHAR_TYPE *second_buf = 0;
+
+ // convert the first argv to a string
+ if (first_argv != 0 && first_argv[0] != 0)
+ {
+ first_argc = ACE_OS::argv_to_string (first_argv,
+ first_buf,
+ substitute_env_args,
+ quote_args);
+ }
+
+ // convert the second argv to a string
+ if (second_argv != 0 && second_argv[0] != 0)
+ {
+ second_argc = ACE_OS::argv_to_string (second_argv,
+ second_buf,
+ substitute_env_args,
+ quote_args);
+ }
+
+ // Add the number of arguments in both the argvs.
+ this->argc_ = first_argc + second_argc;
+
+ size_t buf_len =
+ ACE_OS::strlen (first_buf) + ACE_OS::strlen (second_buf) + 1;
+
+ // Allocate memory to the lenght of the combined argv string.
+ ACE_NEW (this->buf_,
+ CHAR_TYPE[buf_len + 1]);
+
+ // copy the first argv string to the buffer
+ ACE_OS::strcpy (this->buf_, first_buf);
+
+ // concatenate the second argv string to the buffer
+ ACE_OS::strcat (this->buf_, second_buf);
+
+ // Delete the first and second buffers
+ delete [] first_buf;
+ delete [] second_buf;
+}
+
+template
+ACE_ARGV_T::ACE_ARGV_T (bool substitute_env_args)
+ : substitute_env_args_ (substitute_env_args),
+ iterative_ (true),
+ argc_ (0),
+ argv_ (0),
+ buf_ (0),
+ length_ (0),
+ queue_ ()
+{
+ ACE_TRACE ("ACE_ARGV_T::ACE_ARGV_T Iterative");
+
+ // Nothing to do yet -- the user puts in arguments via add ()
+}
+
+template
+int
+ACE_ARGV_T::add (const CHAR_TYPE *next_arg, bool quote_arg)
+{
+ // Only allow this to work in the "iterative" verion -- the
+ // ACE_ARGVs created with the one argument constructor.
+ if (!this->iterative_)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ this->length_ += ACE_OS::strlen (next_arg);
+ if (quote_arg && ACE_OS::strchr (next_arg, ' ') != 0)
+ {
+ this->length_ += 2;
+ if (ACE_OS::strchr (next_arg, '"') != 0)
+ for (const CHAR_TYPE * p = next_arg; *p != '\0'; ++p)
+ if (*p == '"') ++this->length_;
+ }
+ else
+ {
+ quote_arg = false;
+ }
+
+ // Put the new argument at the end of the queue.
+ if (this->queue_.enqueue_tail (ACE_ARGV_Queue_Entry_T (next_arg, quote_arg)) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("Can't add more to ARGV queue")),
+ -1);
+
+ ++this->argc_;
+
+ // Wipe argv_ and buf_ away so that they will be recreated if the
+ // user calls argv () or buf ().
+ if (this->argv_ != 0)
+ {
+ for (int i = 0; this->argv_[i] != 0; i++)
+ ACE_OS::free ((void *) this->argv_[i]);
+
+ delete [] this->argv_;
+ this->argv_ = 0;
+ }
+
+ delete [] this->buf_;
+ this->buf_ = 0;
+
+ return 0;
+}
+
+template
+int
+ACE_ARGV_T::add (CHAR_TYPE *argv[], bool quote_args)
+{
+ for (int i = 0; argv[i] != 0; i++)
+ if (this->add (argv[i], quote_args) == -1)
+ return -1;
+
+ return 0;
+}
+
+// Free up argv_ and buf_
+
+template
+ACE_ARGV_T::~ACE_ARGV_T (void)
+{
+ ACE_TRACE ("ACE_ARGV_T::~ACE_ARGV_T");
+
+ if (this->argv_ != 0)
+ for (int i = 0; this->argv_[i] != 0; i++)
+ ACE_OS::free ((void *) this->argv_[i]);
+
+ delete [] this->argv_;
+ delete [] this->buf_;
+}
+
+// Create buf_ out of the queue_. This is only used in the
+// "iterative" mode.
+
+template
+int
+ACE_ARGV_T::create_buf_from_queue (void)
+{
+ ACE_TRACE ("ACE_ARGV_T::create_buf_from_queue");
+
+ // If the are no arguments, don't do anything
+ if (this->argc_ <= 0)
+ return -1;
+
+ delete [] this->buf_;
+
+ ACE_NEW_RETURN (this->buf_,
+ CHAR_TYPE[this->length_ + this->argc_],
+ -1);
+
+ // Get an iterator over the queue
+ ACE_Unbounded_Queue_Iterator > iter (this->queue_);
+
+ ACE_ARGV_Queue_Entry_T *arg = 0;
+ CHAR_TYPE *ptr = this->buf_;
+ size_t len;
+
+ while (!iter.done ())
+ {
+ // Get next argument from the queue.
+ iter.next (arg);
+ iter.advance ();
+
+ if (arg->quote_arg_)
+ {
+ *ptr++ = '"';
+ if (ACE_OS::strchr (arg->arg_, '"') != 0)
+ {
+ CHAR_TYPE prev = 0;
+ for (const CHAR_TYPE * p = arg->arg_; *p != '\0'; ++p)
+ {
+ if (*p == '"' && prev != '\\') *ptr++ = '\\';
+ prev = *ptr++ = *p;
+ }
+ }
+ else
+ {
+ len = ACE_OS::strlen (arg->arg_);
+ // Copy the argument into buf_
+ ACE_OS::memcpy ((void *) ptr,
+ (const void *) (arg->arg_),
+ len * sizeof (CHAR_TYPE));
+ // Move the pointer down.
+ ptr += len;
+ }
+ *ptr++ = '"';
+ }
+ else
+ {
+ len = ACE_OS::strlen (arg->arg_);
+ // Copy the argument into buf_
+ ACE_OS::memcpy ((void *) ptr,
+ (const void *) (arg->arg_),
+ len * sizeof (CHAR_TYPE));
+ // Move the pointer down.
+ ptr += len;
+ }
+
+ // Put in an argument separating space.
+ *ptr++ = ' ';
+ }
+
+ // Put in the NUL terminator
+ ptr[-1] = '\0';
+
+ return 0;
+}
+
+// Close versioned namespace, if enabled by the user.
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_ARGV_CPP */
diff --git a/externals/ace/ARGV.h b/externals/ace/ARGV.h
new file mode 100644
index 0000000..66e7181
--- /dev/null
+++ b/externals/ace/ARGV.h
@@ -0,0 +1,333 @@
+// -*- C++ -*-
+
+//==========================================================================
+/**
+ * @file ARGV.h
+ *
+ * $Id: ARGV.h 81156 2008-03-30 20:56:47Z iliyan $
+ *
+ * @author Doug Schmidt
+ * @author Everett Anderson
+ */
+//==========================================================================
+
+#ifndef ACE_ARGUMENT_VECTOR_H
+#define ACE_ARGUMENT_VECTOR_H
+#include /**/ "ace/pre.h"
+
+#include /**/ "ace/ACE_export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ace/Global_Macros.h"
+#include "ace/Unbounded_Queue.h"
+
+// Open versioned namespace, if enabled by the user.
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+/**
+ * @class ACE_ARGV_Queue_Entry_T
+ *
+ * @brief An entry in the queue which keeps user supplied arguments.
+ */
+template
+class ACE_ARGV_Queue_Entry_T
+{
+public:
+ // = Initialization and termination.
+ /// Initialize a ACE_ARGV_Queue_Entry_T.
+ ACE_ARGV_Queue_Entry_T (void);
+
+ /**
+ * Initialize a ACE_ARGV_Queue_Entry_T.
+ *
+ * @param arg Pointer to an argument
+ *
+ * @param quote_arg The argument @a arg need to be quoted
+ * while adding to the vector.
+ */
+ ACE_ARGV_Queue_Entry_T (const CHAR_TYPE *arg,
+ bool quote_arg);
+
+ /**
+ * Initialize a ACE_ARGV_Queue_Entry_T.
+ *
+ * @param entry Pointer to a queue entry
+ */
+ ACE_ARGV_Queue_Entry_T (const ACE_ARGV_Queue_Entry_T &entry);
+
+ /// We need this destructor to keep some compilers from complaining.
+ /// It's just a no-op, however.
+ ~ACE_ARGV_Queue_Entry_T (void);
+
+ /// Dump the state of this object.
+ void dump (void) const;
+
+ // Declare the dynamic allocation hooks.
+ ACE_ALLOC_HOOK_DECLARE;
+
+ /// Pointer to the argument.
+ const CHAR_TYPE * arg_;
+
+ /// The argument need to be quoted while adding to the vector.
+ bool quote_arg_;
+};
+
+/**
+ * @class ACE_ARGV_T
+ *
+ * @brief Builds a counted argument vector (ala argc/argv) from either
+ * a string or a set of separate tokens. This class preserves whitespace
+ * within tokens only if the whitespace-containing token is enclosed in
+ * either single (') or double (") quotes. This is consistent with the
+ * expected behavior if an argument vector obtained using this class is
+ * passed to, for example, ACE_Get_Opt.
+ *
+ * This class can substitute environment variable values for tokens that
+ * are environment variable references (e.g., @c $VAR). This only works
+ * if the token is an environment variable reference and nothing else; it
+ * doesn't substitute environment variable references within a token.
+ * For example, @c $HOME/file will not substitute the value of the HOME
+ * environment variable.
+ */
+template
+class ACE_ARGV_T
+{
+public:
+ // = Initialization and termination.
+ /**
+ * Splits the specified string into an argument vector. Arguments in the
+ * string are delimited by whitespace. Whitespace-containing arguments
+ * must be enclosed in quotes, either single (') or double (").
+ *
+ * @param buf A nul-terminated CHAR_TYPE array to split into arguments
+ * for the vector.
+ *
+ * @param substitute_env_args If non-zero, any token that is an
+ * environment variable reference (e.g., @c $VAR) will have
+ * its environment variable value in the resultant vector
+ * in place of the environment variable name.
+ */
+ explicit ACE_ARGV_T (const CHAR_TYPE buf[],
+ bool substitute_env_args = true);
+
+ /**
+ * Initializes the argument vector from a set of arguments. Any environment
+ * variable references are translated (if applicable) during execution of
+ * this method. In contrast with ACE_ARGV_T(CHAR_TYPE *[], bool, bool), this
+ * ctor does not require argv to be 0-terminated as the number of arguments
+ * is provided explicitely.
+ *
+ * @param argc The number of arguments in the argv array.
+ *
+ * @param argv An array of tokens to initialize the object with. All needed
+ * data is copied from @a argv during this call; the pointers
+ * in @a argv are not needed after this call, and the memory
+ * referred to by @a argv is not referenced by this object.
+ *
+ * @param substitute_env_args If non-zero, any element of @a argv that is
+ * an environment variable reference (e.g., @c $VAR) will have
+ * its environment variable value in the resultant vector
+ * in place of the environment variable name.
+ *
+ * @param quote_args If non-zero each argument @a argv[i] needs to
+ * be enclosed in double quotes ('"').
+ */
+ explicit ACE_ARGV_T (int argc,
+ CHAR_TYPE *argv[],
+ bool substitute_env_args = true,
+ bool quote_args = false);
+
+ /**
+ * Initializes the argument vector from a set of arguments. Any environment
+ * variable references are translated (if applicable) during execution of
+ * this method.
+ *
+ * @param argv An array of tokens to initialize the object with. The
+ * array must be terminated with a 0 pointer. All needed
+ * data is copied from @a argv during this call; the pointers
+ * in @a argv are not needed after this call, and the memory
+ * referred to by @a argv is not referenced by this object.
+ *
+ * @param substitute_env_args If non-zero, any element of @a argv that is
+ * an environment variable reference (e.g., @c $VAR) will have
+ * its environment variable value in the resultant vector
+ * in place of the environment variable name.
+ *
+ * @param quote_args If non-zero each argument @a argv[i] needs to
+ * be enclosed in double quotes ('"').
+ */
+ explicit ACE_ARGV_T (CHAR_TYPE *argv[],
+ bool substitute_env_args = true,
+ bool quote_args = false);
+
+ /**
+ * Initializes the argument vector from two combined argument vectors.
+ *
+ * @param first_argv An array of tokens to initialize the object with.
+ * The array must be terminated with a 0 pointer.
+ * @param second_argv An array of tokens that is concatenated with the
+ * the tokens in @a first_argv. The array must be
+ * terminated with a 0 pointer.
+ * @param substitute_env_args If non-zero, any element of @a first_argv
+ * or @a second_argv that is an environment variable
+ * reference (e.g., @c $VAR) will have its environment
+ * variable value in the resultant vector in place
+ * of the environment variable name.
+ *
+ * @param quote_args If non-zero each arguments @a first_argv[i] and
+ * @a second_argv[i] needs to be enclosed
+ * in double quotes ('"').
+ */
+ ACE_ARGV_T (CHAR_TYPE *first_argv[],
+ CHAR_TYPE *second_argv[],
+ bool substitute_env_args = true,
+ bool quote_args = false);
+
+ /**
+ * Initialize this object so arguments can be added later using one
+ * of the add methods. This is referred to as the @i iterative method
+ * of adding arguments to this object.
+ */
+ explicit ACE_ARGV_T (bool substitute_env_args = true);
+
+ /// Destructor.
+ ~ACE_ARGV_T (void);
+
+ /** @name Accessor methods
+ *
+ * These methods access the argument vector contained in this object.
+ */
+ //@{
+ /**
+ * Returns the specified element of the current argument vector.
+ *
+ * @param index Index to the desired element.
+ *
+ * @retval Pointer to the indexed string.
+ * @retval 0 if @a index is out of bounds.
+ */
+ const CHAR_TYPE *operator[] (size_t index);
+
+ /**
+ * Returns the current argument vector. The returned pointers are to data
+ * maintained internally to this class. Do not change or delete either the
+ * pointers or the memory to which they refer.
+ */
+ CHAR_TYPE **argv (void);
+
+ /// Returns the current number of arguments.
+ int argc (void) const;
+
+ /**
+ * Returns a single string form of the current arguments. The returned
+ * pointer refers to memory maintained internally to this class. Do not
+ * change or delete it.
+ */
+ const CHAR_TYPE *buf (void);
+
+ //@}
+
+ /// Dump the state of this object.
+ void dump (void) const;
+
+ // Declare the dynamic allocation hooks.
+ ACE_ALLOC_HOOK_DECLARE;
+
+ /**
+ * Add another argument. This only works in the iterative mode.
+ *
+ * @note This method copies the specified pointer, but not the data
+ * contained in the referenced memory. Thus, if the content of
+ * the memory referred to by @a next_arg are changed after this
+ * method returns, the results are undefined.
+ *
+ * @param next_arg Pointer to the next argument to add to the vector.
+ *
+ * @param quote_arg The argument @a next_arg need to be quoted while
+ * adding to the vector.
+ *
+ * @retval 0 on success; -1 on failure. Most likely @c errno values are:
+ * - EINVAL: This object is not in iterative mode.
+ * - ENOMEM: Not enough memory available to save @a next_arg.
+ */
+ int add (const CHAR_TYPE *next_arg, bool quote_arg = false);
+
+ /**
+ * Add an array of arguments. This only works in the iterative mode.
+ *
+ * @note This method copies the specified pointers, but not the data
+ * contained in the referenced memory. Thus, if the content of
+ * the memory referred to by any of the @a argv elements is
+ * changed after this method returns, the results are undefined.
+ *
+ * @param argv Pointers to the arguments to add to the vector.
+ * @a argv must be terminated by a 0 pointer.
+ *
+ * @param quote_args If non-zero each argument @a argv[i] needs to
+ * be enclosed in double quotes ('"').
+ *
+ * @retval 0 on success; -1 on failure. Most likely @c errno values are:
+ * - EINVAL: This object is not in iterative mode.
+ * - ENOMEM: Not enough memory available to save @a next_arg.
+ */
+ int add (CHAR_TYPE *argv[], bool quote_args = false);
+
+private:
+ /// Copy constructor not implemented.
+ ACE_UNIMPLEMENTED_FUNC (ACE_ARGV_T (const ACE_ARGV_T&))
+
+ /// Assignment operator not implemented.
+ ACE_UNIMPLEMENTED_FUNC (ACE_ARGV_T operator= (const ACE_ARGV_T&))
+
+ /// Creates buf_ from the queue of added args, deletes previous buf_.
+ int create_buf_from_queue (void);
+
+ /// Converts buf_ into the CHAR_TYPE *argv[] format.
+ int string_to_argv (void);
+
+ /// Replace args with environment variable values?
+ bool substitute_env_args_;
+
+ bool iterative_;
+
+ /// Number of arguments in the ARGV array.
+ int argc_;
+
+ /// The array of string arguments.
+ CHAR_TYPE **argv_;
+
+ /// Buffer containing the contents.
+ CHAR_TYPE *buf_;
+
+ /// Total length of the arguments in the queue, not counting
+ /// separating spaces
+ size_t length_;
+
+ /// Queue which keeps user supplied arguments. This is only
+ /// active in the "iterative" mode.
+ ACE_Unbounded_Queue > queue_;
+};
+
+typedef ACE_ARGV_Queue_Entry_T ACE_ARGV_Queue_Entry;
+typedef ACE_ARGV_T ACE_ARGV;
+
+// Close versioned namespace, if enabled by the user.
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#if defined (__ACE_INLINE__)
+#include "ace/ARGV.inl"
+#endif /* __ACE_INLINE__ */
+
+#if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
+#include "ace/ARGV.cpp"
+#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */
+
+#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
+#pragma implementation ("ARGV.cpp")
+#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */
+
+#include /**/ "ace/post.h"
+#endif /* ACE_ARGUMENT_VECTOR_H */
diff --git a/externals/ace/ARGV.inl b/externals/ace/ARGV.inl
new file mode 100644
index 0000000..fdc5b13
--- /dev/null
+++ b/externals/ace/ARGV.inl
@@ -0,0 +1,104 @@
+/* -*- C++ -*- */
+// $Id: ARGV.inl 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/Global_Macros.h"
+
+// Open versioned namespace, if enabled by the user.
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+template ACE_INLINE
+ACE_ARGV_Queue_Entry_T::ACE_ARGV_Queue_Entry_T (void)
+ : arg_(0),
+ quote_arg_(false)
+{
+ // No-op
+}
+
+template ACE_INLINE
+ACE_ARGV_Queue_Entry_T::ACE_ARGV_Queue_Entry_T (const CHAR_TYPE *arg,
+ bool quote_arg)
+ : arg_(arg),
+ quote_arg_(quote_arg)
+{
+ // No-op
+}
+
+template ACE_INLINE
+ACE_ARGV_Queue_Entry_T::ACE_ARGV_Queue_Entry_T (const ACE_ARGV_Queue_Entry_T &entry)
+ : arg_(entry.arg_),
+ quote_arg_(entry.quote_arg_)
+{
+ // No-op
+}
+
+template ACE_INLINE
+ACE_ARGV_Queue_Entry_T::~ACE_ARGV_Queue_Entry_T (void)
+{
+ // No-op just to keep some compilers happy...
+}
+
+// Return the number of args
+template
+ACE_INLINE int
+ACE_ARGV_T::argc (void) const
+{
+ ACE_TRACE ("ACE_ARGV_T::argc");
+ // Try to create the argv_ if it isn't there
+ ACE_ARGV_T *nonconst_this =
+ const_cast *> (this);
+ (void) nonconst_this->argv ();
+ return this->argc_;
+}
+
+// Return the arguments in a space-separated string
+template
+ACE_INLINE const CHAR_TYPE *
+ACE_ARGV_T::buf (void)
+{
+ ACE_TRACE ("ACE_ARGV_T::buf");
+
+ if (this->buf_ == 0 && this->iterative_)
+ this->create_buf_from_queue ();
+
+ return (const CHAR_TYPE *) this->buf_;
+}
+
+// Return the arguments in an entry-per-argument array
+
+template
+ACE_INLINE CHAR_TYPE **
+ACE_ARGV_T::argv (void)
+{
+ ACE_TRACE ("ACE_ARGV_T::argv");
+
+ // Try to create the argv_ if it isn't there
+ if (this->argv_ == 0)
+ {
+ if (this->iterative_ && this->buf_ == 0)
+ this->create_buf_from_queue ();
+
+ // Convert buf_ to argv_
+ if (this->string_to_argv () == -1)
+ return (CHAR_TYPE **) 0;
+ }
+
+ return (CHAR_TYPE **) this->argv_;
+}
+
+// Subscript operator.
+
+template
+ACE_INLINE const CHAR_TYPE *
+ACE_ARGV_T::operator[] (size_t i)
+{
+ ACE_TRACE ("ACE_ARGV_T::operator[]");
+
+ // Don't go out of bounds.
+ if (i >= static_cast (this->argc_))
+ return 0;
+
+ return (const CHAR_TYPE *) this->argv ()[i];
+}
+
+// Close versioned namespace, if enabled by the user.
+ACE_END_VERSIONED_NAMESPACE_DECL
diff --git a/externals/ace/ATM_Acceptor.cpp b/externals/ace/ATM_Acceptor.cpp
new file mode 100644
index 0000000..7e83565
--- /dev/null
+++ b/externals/ace/ATM_Acceptor.cpp
@@ -0,0 +1,309 @@
+// $Id: ATM_Acceptor.cpp 84262 2009-01-29 10:34:33Z johnnyw $
+
+#include "ace/ATM_Acceptor.h"
+
+ACE_RCSID(ace, ATM_Acceptor, "$Id: ATM_Acceptor.cpp 84262 2009-01-29 10:34:33Z johnnyw $")
+
+#if defined (ACE_HAS_ATM)
+
+#if defined (ACE_HAS_LINUX_ATM)
+#include /**/ "linux/atmdev.h"
+#endif /* ACE_HAS_LINUX_ATM */
+
+#if !defined (__ACE_INLINE__)
+#include "ace/ATM_Acceptor.inl"
+#endif /* __ACE_INLINE__ */
+
+
+// Open versioned namespace, if enabled by the user.
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+// Put the actual definitions of the ACE_ATM_Request and
+// ACE_ATM_Request_Queue classes here to hide them from clients...
+
+ACE_ALLOC_HOOK_DEFINE(ACE_ATM_Acceptor)
+
+ACE_ATM_Acceptor::ACE_ATM_Acceptor (void)
+{
+ ACE_TRACE ("ACE_ATM_Acceptor::ACE_ATM_Acceptor");
+}
+
+ACE_ATM_Acceptor::~ACE_ATM_Acceptor (void)
+{
+ ACE_TRACE ("ACE_ATM_Acceptor::~ACE_ATM_Acceptor");
+}
+
+int
+ACE_ATM_Acceptor::get_local_addr (ACE_ATM_Addr &local_addr)
+{
+ ACE_TRACE ("ACE_ATM_Acceptor::get_local_addr");
+
+#if defined (ACE_HAS_FORE_ATM_WS2)
+ unsigned long ret = 0;
+ DWORD deviceID = 0;
+ ATM_ADDRESS addr;
+ struct sockaddr_atm *laddr;
+
+ if (::WSAIoctl ((int) ((ACE_SOCK_Acceptor *)this) -> get_handle (),
+ SIO_GET_ATM_ADDRESS,
+ (LPVOID) &deviceID,
+ sizeof (DWORD),
+ (LPVOID)&addr,
+ sizeof (ATM_ADDRESS),
+ &ret,
+ 0,
+ 0) == SOCKET_ERROR) {
+ ACE_OS::printf ("ATM_Acceptor (get_local_addr): WSIoctl: %d\n",
+ ::WSAGetLastError ());
+ return -1;
+ }
+
+ laddr = (struct sockaddr_atm *)local_addr.get_addr ();
+ ACE_OS::memcpy ((void *)& (laddr -> satm_number),
+ (void *)&addr,
+ ATM_ADDR_SIZE - 1);
+
+ return 0;
+#elif defined (ACE_HAS_FORE_ATM_XTI)
+ ACE_UNUSED_ARG (local_addr);
+
+ return 0;
+#elif defined (ACE_HAS_LINUX_ATM)
+ ATM_Addr *myaddr = (ATM_Addr *)local_addr.get_addr ();
+ int addrlen = sizeof (myaddr->sockaddratmsvc);
+
+ if (ACE_OS::getsockname (acceptor_.get_handle (),
+ (struct sockaddr *) & (myaddr->sockaddratmsvc),
+ &addrlen) < 0) {
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("ATM_Acceptor (get_local_addr): ioctl: %d\n"),
+ errno));
+ return -1;
+ }
+
+ return 0;
+#else
+ ACE_UNUSED_ARG (local_addr);
+
+ return 0;
+#endif /* ACE_HAS_FORE_ATM_WS2 && ACE_HAS_FORE_ATM_XTI */
+}
+
+ACE_HANDLE
+ACE_ATM_Acceptor::open (const ACE_Addr &remote_sap,
+ int backlog,
+ ACE_ATM_Params params)
+{
+ ACE_TRACE ("ACE_ATM_Acceptor::open");
+#if defined (ACE_HAS_FORE_ATM_XTI)
+ ACE_HANDLE handle = acceptor_.open (remote_sap,
+ params.get_reuse_addr (),
+ params.get_oflag (),
+ params.get_info (),
+ backlog,
+ params.get_device ());
+ return (handle == ACE_INVALID_HANDLE ? -1 : 0);
+#elif defined (ACE_HAS_FORE_ATM_WS2)
+ struct sockaddr_atm local_atm_addr;
+ ACE_HANDLE ret;
+ DWORD flags = 0;
+
+ /* Create a local endpoint of communication */
+
+ // Only leaves can listen.
+ flags = ACE_FLAG_MULTIPOINT_C_LEAF | ACE_FLAG_MULTIPOINT_D_LEAF;
+
+ if ((ret = ACE_OS::socket (AF_ATM,
+ SOCK_RAW,
+ ATMPROTO_AAL5,
+ 0,
+ 0,
+ flags))
+ == ACE_INVALID_HANDLE) {
+ ACE_OS::printf ("Acceptor (open): socket %d\n",
+ ::WSAGetLastError ());
+ return (ret);
+ }
+
+ ((ACE_SOCK_Acceptor *)this) -> set_handle (ret);
+
+ /* Set up the address information to become a server */
+ ACE_OS::memset ((void *) &local_atm_addr, 0, sizeof local_atm_addr);
+ local_atm_addr.satm_family = AF_ATM;
+ local_atm_addr.satm_number.AddressType = SAP_FIELD_ANY_AESA_REST;
+ local_atm_addr.satm_number.Addr[ ATM_ADDR_SIZE - 1 ]
+ = ((ACE_ATM_Addr *)&remote_sap) -> get_selector ();
+ local_atm_addr.satm_blli.Layer2Protocol = SAP_FIELD_ANY;
+ local_atm_addr.satm_blli.Layer3Protocol = SAP_FIELD_ABSENT;
+ local_atm_addr.satm_bhli.HighLayerInfoType = SAP_FIELD_ABSENT;
+
+ /* Associate address with endpoint */
+ if (ACE_OS::bind (((ACE_SOCK_Acceptor *)this) -> get_handle (),
+ reinterpret_cast (&local_atm_addr),
+ sizeof local_atm_addr) == -1) {
+ ACE_OS::printf ("Acceptor (open): bind %d\n", ::WSAGetLastError ());
+ return (ACE_INVALID_HANDLE);
+ }
+
+ /* Make endpoint listen for service requests */
+ if (ACE_OS::listen (( (ACE_SOCK_Acceptor *)this) -> get_handle (),
+ backlog)
+ == -1) {
+ ACE_OS::printf ("Acceptor (open): listen %d\n", ::WSAGetLastError ());
+ return (ACE_INVALID_HANDLE);
+ }
+
+ return 0;
+#elif defined (ACE_HAS_LINUX_ATM)
+ //we need to set the qos before binding to the socket
+ //use remote_sap as local_sap
+
+ ACE_ATM_Addr local_sap;
+ ATM_Addr *local_sap_addr = (ATM_Addr*)local_sap.get_addr ();
+ ACE_ATM_QoS def_qos;
+ ATM_QoS qos = def_qos.get_qos ();
+
+ ACE_HANDLE handle;
+ if ((handle = ACE_OS::socket (params.get_protocol_family (),
+ params.get_type (),
+ params.get_protocol (),
+ params.get_protocol_info (),
+ params.get_sock_group (),
+ params.get_flags ()
+ ))
+ == ACE_INVALID_HANDLE) {
+ ACE_DEBUG (LM_DEBUG,
+ ACE_TEXT ("Acceptor (socket): socket %d\n"),
+ errno);
+ return (ACE_INVALID_HANDLE);
+ }
+
+ ((ACE_SOCK_Acceptor *)this) -> set_handle (handle);
+ if (ACE_OS::setsockopt (handle,
+ SOL_ATM,
+ SO_ATMQOS,
+ reinterpret_cast (&qos),
+ sizeof (qos)) < 0) {
+ ACE_OS::printf ("Acceptor (setsockopt): setsockopt:%d\n",
+ errno);
+ }
+
+ struct atmif_sioc req;
+ struct sockaddr_atmsvc aux_addr[1024];
+
+ req.number = 0;
+ req.arg = aux_addr;
+ req.length = sizeof (aux_addr);
+ if (ACE_OS::ioctl (handle,
+ ATM_GETADDR,
+ &req) < 0) {
+ ACE_OS::perror ("Acceptor (setsockopt): ioctl:");
+ }
+ else {
+ local_sap_addr->sockaddratmsvc = aux_addr[0];
+ }
+ local_sap.set_selector (( (ACE_ATM_Addr*)&remote_sap)->get_selector ());
+
+ if (ACE_OS::bind (handle,
+ reinterpret_cast (
+ &(local_sap_addr->sockaddratmsvc)),
+ sizeof (local_sap_addr->sockaddratmsvc)
+ ) == -1) {
+ ACE_DEBUG (LM_DEBUG,
+ ACE_TEXT ("Acceptor (open): bind %d\n"),
+ errno);
+ return -1;
+ }
+ // Make endpoint listen for service requests
+ if (ACE_OS::listen (handle,
+ backlog)
+ == -1) {
+ ACE_DEBUG (LM_DEBUG,
+ ACE_TEXT ("Acceptor (listen): listen %d\n"),
+ errno);
+ return -1;
+ }
+
+ return 0;
+#else
+ ACE_UNUSED_ARG (remote_sap);
+ ACE_UNUSED_ARG (backlog);
+ ACE_UNUSED_ARG (params);
+#endif /* ACE_HAS_FORE_ATM_XTI/ACE_HAS_FORE_ATM_WS2/ACE_HAS_LINUX_ATM */
+}
+
+int
+ACE_ATM_Acceptor::accept (ACE_ATM_Stream &new_sap,
+ ACE_Addr *remote_addr,
+ ACE_Time_Value *timeout,
+ bool restart,
+ bool reset_new_handle,
+ ACE_ATM_Params params,
+ ACE_ATM_QoS qos)
+{
+ ACE_TRACE ("ACE_ATM_Acceptor::accept");
+#if defined (ACE_HAS_FORE_ATM_XTI)
+ ATM_QoS optbuf = qos.get_qos ();
+
+ return (acceptor_.accept (new_sap.get_stream (),
+ remote_addr,
+ timeout,
+ restart,
+ reset_new_handle,
+ params.get_rw_flag (),
+ params.get_user_data (),
+ &optbuf));
+#elif defined (ACE_HAS_FORE_ATM_WS2)
+ ACE_HANDLE n_handle;
+ ACE_HANDLE s_handle = ((ACE_SOCK_Acceptor *) this) -> get_handle ();
+ struct sockaddr_atm *cli_addr
+ = (struct sockaddr_atm *)remote_addr -> get_addr ();
+ int caddr_len = sizeof (struct sockaddr_atm);
+
+ do {
+ n_handle = ACE_OS::accept (s_handle,
+ reinterpret_cast (cli_addr),
+ &caddr_len);
+ } while (n_handle == ACE_INVALID_HANDLE && errno == EINTR);
+
+ ((ACE_ATM_Addr *)remote_addr) -> set (cli_addr,
+ ((ACE_ATM_Addr *)remote_addr) -> get_selector ());
+ ((ACE_IPC_SAP *)&new_sap) -> set_handle (n_handle);
+
+ return 0;
+#elif defined (ACE_HAS_LINUX_ATM)
+ ACE_UNUSED_ARG (params);
+
+ ACE_HANDLE s_handle = ((ACE_SOCK_Acceptor *) this) -> get_handle ();
+ struct atm_qos accept_qos = qos.get_qos ();
+
+ if (ACE_OS::setsockopt (s_handle,
+ SOL_ATM,
+ SO_ATMQOS,
+ reinterpret_cast (&accept_qos),
+ sizeof (accept_qos)) < 0) {
+ ACE_OS::printf ("Acceptor (accept): error setting Qos");
+ }
+
+ return (acceptor_.accept (new_sap.get_stream (),
+ remote_addr,
+ timeout,
+ restart,
+ reset_new_handle));
+#else
+ ACE_UNUSED_ARG (new_sap);
+ ACE_UNUSED_ARG (remote_addr);
+ ACE_UNUSED_ARG (timeout);
+ ACE_UNUSED_ARG (restart);
+ ACE_UNUSED_ARG (reset_new_handle);
+ ACE_UNUSED_ARG (params);
+ ACE_UNUSED_ARG (qos);
+ return 0;
+#endif /* ACE_HAS_FORE_ATM_XTI */
+}
+
+// Close versioned namespace, if enabled by the user.
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+
+#endif /* ACE_HAS_ATM */
diff --git a/externals/ace/ATM_Acceptor.h b/externals/ace/ATM_Acceptor.h
new file mode 100644
index 0000000..1241a22
--- /dev/null
+++ b/externals/ace/ATM_Acceptor.h
@@ -0,0 +1,123 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file ATM_Acceptor.h
+ *
+ * $Id: ATM_Acceptor.h 82723 2008-09-16 09:35:44Z johnnyw $
+ *
+ * @author Joe Hoffert
+ */
+//=============================================================================
+
+
+#ifndef ACE_ATM_ACCEPTOR_H
+#define ACE_ATM_ACCEPTOR_H
+#include /**/ "ace/pre.h"
+
+#include /**/ "ace/config-all.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#if defined (ACE_HAS_ATM)
+
+#include "ace/ATM_Stream.h"
+#include "ace/ATM_Params.h"
+#include "ace/ATM_QoS.h"
+
+#if defined (ACE_HAS_LINUX_ATM)
+#include /**/ "atm.h"
+#endif /* ACE_HAS_LINUX_ATM */
+
+#if defined (ACE_HAS_FORE_ATM_WS2) || defined (ACE_HAS_LINUX_ATM)
+#include "ace/SOCK_Acceptor.h"
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+typedef ACE_SOCK_Acceptor ATM_Acceptor;
+ACE_END_VERSIONED_NAMESPACE_DECL
+#elif defined (ACE_HAS_FORE_ATM_XTI)
+#include "ace/TLI_Acceptor.h"
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+typedef ACE_TLI_Acceptor ATM_Acceptor;
+ACE_END_VERSIONED_NAMESPACE_DECL
+#endif // ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM
+
+// Open versioned namespace, if enabled by the user.
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+// Forward declarations.
+class ACE_Time_Value;
+
+/**
+ * @class ACE_ATM_Acceptor
+ *
+ * @brief Defines the member functions for ACE_ATM_Acceptor abstraction.
+ *
+ * This class wraps up the ACE_SOCK_Acceptor and ACE_TLI_Acceptor
+ * to make the mechanism for the ATM protocol transparent.
+ */
+class ACE_Export ACE_ATM_Acceptor
+{
+
+public:
+ // = Initialization and termination methods.
+ /// Default constructor.
+ ACE_ATM_Acceptor (void);
+
+ ~ACE_ATM_Acceptor ();
+
+ /// Initiate a passive mode connection.
+ ACE_ATM_Acceptor (const ACE_Addr &remote_sap,
+ int backlog = ACE_DEFAULT_BACKLOG,
+ ACE_ATM_Params params = ACE_ATM_Params());
+
+ /// Initiate a passive mode socket.
+ ACE_HANDLE open (const ACE_Addr &remote_sap,
+ int backlog = ACE_DEFAULT_BACKLOG,
+ ACE_ATM_Params params = ACE_ATM_Params());
+
+ /// Close down the acceptor and release resources.
+ int close (void);
+
+ // = Passive connection acceptance method.
+
+ /// Accept a new data transfer connection. A @a timeout of 0 means
+ /// block forever, a @a timeout of {0, 0} means poll. @a restart == 1
+ /// means "restart if interrupted."
+ int accept (ACE_ATM_Stream &new_sap,
+ ACE_Addr *remote_addr = 0,
+ ACE_Time_Value *timeout = 0,
+ bool restart = true,
+ bool reset_new_handle = false,
+ ACE_ATM_Params params = ACE_ATM_Params(),
+ ACE_ATM_QoS qos = ACE_ATM_QoS());
+
+ /// Get the local address currently listening on
+ int get_local_addr( ACE_ATM_Addr &local_addr );
+
+ // = Meta-type info
+ typedef ACE_ATM_Addr PEER_ADDR;
+ typedef ACE_ATM_Stream PEER_STREAM;
+
+ /// Dump the state of an object.
+ void dump (void) const;
+
+ /// Declare the dynamic allocation hooks.
+ ACE_ALLOC_HOOK_DECLARE;
+
+private:
+ ATM_Acceptor acceptor_;
+};
+
+// Close versioned namespace, if enabled by the user.
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+
+#if defined (__ACE_INLINE__)
+#include "ace/ATM_Acceptor.inl"
+#endif /* __ACE_INLINE__ */
+
+#endif /* ACE_HAS_ATM */
+#include /**/ "ace/post.h"
+#endif /* ACE_ATM_ACCEPTOR_H */
diff --git a/externals/ace/ATM_Acceptor.inl b/externals/ace/ATM_Acceptor.inl
new file mode 100644
index 0000000..fa60c4a
--- /dev/null
+++ b/externals/ace/ATM_Acceptor.inl
@@ -0,0 +1,43 @@
+// -*- C++ -*-
+//
+// $Id: ATM_Acceptor.inl 80826 2008-03-04 14:51:23Z wotte $
+
+// Open versioned namespace, if enabled by the user.
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_INLINE void
+ACE_ATM_Acceptor::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_ATM_Acceptor::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_INLINE
+ACE_ATM_Acceptor::ACE_ATM_Acceptor (const ACE_Addr &remote_sap,
+ int backlog,
+ ACE_ATM_Params params)
+{
+ ACE_TRACE ("ACE_ATM_Acceptor::ACE_ATM_Acceptor");
+
+ //FUZZ: disable check_for_lack_ACE_OS
+ if (open (remote_sap, backlog, params) < 0)
+ //FUZZ: enable check_for_lack_ACE_OS
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_ATM_Acceptor::ACE_ATM_Acceptor")));
+}
+
+ACE_INLINE
+int
+ACE_ATM_Acceptor::close (void)
+{
+#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2) || defined (ACE_HAS_LINUX_ATM)
+ return (acceptor_.close());
+#else
+ return 0;
+#endif // ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM
+}
+
+// Close versioned namespace, if enabled by the user.
+ACE_END_VERSIONED_NAMESPACE_DECL
diff --git a/externals/ace/ATM_Addr.cpp b/externals/ace/ATM_Addr.cpp
new file mode 100644
index 0000000..991498d
--- /dev/null
+++ b/externals/ace/ATM_Addr.cpp
@@ -0,0 +1,522 @@
+// $Id: ATM_Addr.cpp 84565 2009-02-23 08:20:39Z johnnyw $
+
+// Defines the Internet domain address family address format.
+
+#include "ace/ATM_Addr.h"
+#if defined (ACE_HAS_ATM)
+
+#include "ace/Log_Msg.h"
+
+#if defined (ACE_HAS_FORE_ATM_WS2)
+#include /**/ "forews2.h"
+#endif /* ACE_HAS_FORE_ATM_WS2 */
+
+#if !defined (__ACE_INLINE__)
+#include "ace/ATM_Addr.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID(ace, ATM_Addr, "$Id: ATM_Addr.cpp 84565 2009-02-23 08:20:39Z johnnyw $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_ATM_Addr)
+
+#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2)
+#define BHLI_MAGIC "FORE_ATM"
+// This is line rate in cells/s for an OC-3 MM interface.
+const long ACE_ATM_Addr::LINE_RATE = 353207;
+const int ACE_ATM_Addr::OPT_FLAGS_CPID = 0x1;
+const int ACE_ATM_Addr::OPT_FLAGS_PMP = 0x2;
+const int ACE_ATM_Addr::DEFAULT_SELECTOR = 0x99;
+#elif defined (ACE_HAS_LINUX_ATM)
+//pbrandao:for Linux:
+//pbrandao:for now stick with current definitions
+//pbrandao:see if later need to change
+const long ACE_ATM_Addr::LINE_RATE = 353207;
+const int ACE_ATM_Addr::OPT_FLAGS_CPID = 0;
+const int ACE_ATM_Addr::OPT_FLAGS_PMP = 0;
+const int ACE_ATM_Addr::DEFAULT_SELECTOR = 0x99;
+#else
+const long ACE_ATM_Addr::LINE_RATE = 0L;
+const int ACE_ATM_Addr::OPT_FLAGS_CPID = 0;
+const int ACE_ATM_Addr::OPT_FLAGS_PMP = 0;
+const int ACE_ATM_Addr::DEFAULT_SELECTOR = 0x0;
+#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */
+
+// Default constructor
+
+ACE_ATM_Addr::ACE_ATM_Addr (u_char selector)
+#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2)
+ : ACE_Addr (AF_ATM,
+#elif defined (ACE_HAS_LINUX_ATM)
+ : ACE_Addr (PF_ATMSVC,
+#else
+ : ACE_Addr (AF_UNSPEC,
+#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */
+ sizeof this->atm_addr_)
+{
+ // ACE_TRACE ("ACE_ATM_Addr::ACE_ATM_Addr");
+ (void) ACE_OS::memset ((void *) &this->atm_addr_,
+ 0,
+ sizeof this->atm_addr_);
+ this->init (selector);
+}
+
+// Copy constructor.
+
+ACE_ATM_Addr::ACE_ATM_Addr (const ACE_ATM_Addr &sap,
+ u_char selector)
+#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2)
+ : ACE_Addr (AF_ATM,
+#elif defined (ACE_HAS_LINUX_ATM)
+ : ACE_Addr (PF_ATMSVC,
+#else
+ : ACE_Addr (AF_UNSPEC,
+#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */
+ sizeof this->atm_addr_)
+{
+ ACE_TRACE ("ACE_ATM_Addr::ACE_ATM_Addr");
+ this->set (sap, selector);
+#if defined (ACE_HAS_LINUX_ATM)
+ this->atm_addr_.sockaddratmsvc.sas_family = PF_ATMSVC;
+ this->atm_addr_.atmsap.blli[0].l3_proto = ATM_L3_NONE;
+ this->atm_addr_.atmsap.blli[0].l2_proto = ATM_L2_NONE;
+ this->atm_addr_.atmsap.bhli.hl_type = ATM_HL_NONE;
+#endif /* ACE_HAS_LINUX_ATM */
+}
+
+ACE_ATM_Addr::ACE_ATM_Addr (const ATM_Addr *sap,
+ u_char selector)
+#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2)
+ : ACE_Addr (AF_ATM,
+#elif defined (ACE_HAS_LINUX_ATM)
+ : ACE_Addr (PF_ATMSVC,
+#else
+ : ACE_Addr (AF_UNSPEC,
+#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */
+ sizeof this->atm_addr_)
+{
+ ACE_TRACE ("ACE_ATM_Addr::ACE_ATM_Addr");
+ this->set (sap, selector);
+}
+
+
+ACE_ATM_Addr::ACE_ATM_Addr (const ACE_TCHAR sap[],
+ u_char selector)
+#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2)
+ : ACE_Addr (AF_ATM,
+#elif defined (ACE_HAS_LINUX_ATM)
+ : ACE_Addr (PF_ATMSVC,
+#else
+ : ACE_Addr (AF_UNSPEC,
+#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */
+ sizeof this->atm_addr_)
+{
+ ACE_TRACE ("ACE_ATM_Addr::ACE_ATM_Addr");
+ this->set (sap, selector);
+}
+
+ACE_ATM_Addr::~ACE_ATM_Addr (void)
+{
+}
+
+// Return the address.
+
+void *
+ACE_ATM_Addr::get_addr (void) const
+{
+ ACE_TRACE ("ACE_ATM_Addr::get_addr");
+ return (void *) &this->atm_addr_;
+}
+
+void
+ACE_ATM_Addr::init (u_char selector)
+{
+#if defined (ACE_HAS_FORE_ATM_XTI)
+ // Note: this approach may be FORE implementation-specific. When we
+ // bind with tag_addr ABSENT and tag_selector PRESENT, only the
+ // selector (i.e. address[19]) is used by the TP. The rest of the
+ // local address is filled in by the TP and can be obtained via the
+ // 'ret' parameter or with t_getname ()/t_getprotaddr ().
+
+ atm_addr_.addressType = (u_int16_t) AF_ATM;
+
+ atm_addr_.sap.t_atm_sap_addr.SVE_tag_addr = (int8_t) T_ATM_ABSENT;
+ atm_addr_.sap.t_atm_sap_addr.SVE_tag_selector = (int8_t) T_ATM_PRESENT;
+
+ atm_addr_.sap.t_atm_sap_addr.address_format = (u_int8_t) T_ATM_ENDSYS_ADDR;
+ atm_addr_.sap.t_atm_sap_addr.address_length = ATMNSAP_ADDR_LEN;
+ atm_addr_.sap.t_atm_sap_addr.address[ATMNSAP_ADDR_LEN - 1] = selector;
+
+ atm_addr_.sap.t_atm_sap_layer2.SVE_tag = (int8_t) T_ATM_ABSENT;
+ atm_addr_.sap.t_atm_sap_layer3.SVE_tag = (int8_t) T_ATM_ABSENT;
+
+ atm_addr_.sap.t_atm_sap_appl.SVE_tag = (int8_t) T_ATM_PRESENT;
+ atm_addr_.sap.t_atm_sap_appl.ID_type = (u_int8_t) T_ATM_USER_APP_ID;
+
+ ACE_OS::memcpy (atm_addr_.sap.t_atm_sap_appl.ID.user_defined_ID,
+ BHLI_MAGIC,
+ sizeof atm_addr_.sap.t_atm_sap_appl.ID);
+#elif defined (ACE_HAS_FORE_ATM_WS2)
+ ACE_OS::memset ((void *)&atm_addr_, 0, sizeof atm_addr_);
+ atm_addr_.satm_number.Addr[ ATM_ADDR_SIZE - 1 ] = (char)selector;
+ atm_addr_.satm_family = AF_ATM;
+ atm_addr_.satm_number.AddressType = ATM_NSAP;
+ atm_addr_.satm_number.NumofDigits = ATM_ADDR_SIZE;
+ atm_addr_.satm_blli.Layer2Protocol = SAP_FIELD_ABSENT;
+ atm_addr_.satm_blli.Layer3Protocol = SAP_FIELD_ABSENT;
+ atm_addr_.satm_bhli.HighLayerInfoType = SAP_FIELD_ABSENT;
+
+ // Need to know the correspondence.
+ //atm_addr_.sap.t_atm_sap_appl.SVE_tag = (int8_t) T_ATM_PRESENT;
+ //atm_addr_.sap.t_atm_sap_appl.ID_type = (u_int8_t) T_ATM_USER_APP_ID;
+ //ACE_OS::memcpy (atm_addr_.sap.t_atm_sap_appl.ID.user_defined_ID,
+ // BHLI_MAGIC,
+ // sizeof atm_addr_.sap.t_atm_sap_appl.ID);
+#elif defined (ACE_HAS_LINUX_ATM)
+ atm_addr_.sockaddratmsvc.sas_family = AF_ATMSVC;
+ atm_addr_.sockaddratmsvc.sas_addr.prv[ATM_ESA_LEN - 1] = (char)selector;
+ atm_addr_.atmsap.blli[0].l3_proto = ATM_L3_NONE;
+ atm_addr_.atmsap.blli[0].l2_proto = ATM_L2_NONE;
+ atm_addr_.atmsap.bhli.hl_type = ATM_HL_NONE;
+#else
+ ACE_UNUSED_ARG (selector);
+#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */
+}
+
+int
+ACE_ATM_Addr::set (const ACE_ATM_Addr &sap,
+ u_char selector)
+{
+ ACE_TRACE ("ACE_ATM_Addr::set");
+
+ this->init (selector);
+
+ this->ACE_Addr::base_set (sap.get_type (),
+ sap.get_size ());
+
+#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2)
+ ACE_ASSERT (sap.get_type () == AF_ATM);
+#elif defined (ACE_HAS_LINUX_ATM)
+ ACE_ASSERT (sap.get_type () == PF_ATMSVC);
+#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 */
+
+ (void) ACE_OS::memcpy ((void *) &this->atm_addr_,
+ (void *) &sap.atm_addr_,
+ sizeof this->atm_addr_);
+ return 0;
+}
+
+int
+ACE_ATM_Addr::set (const ATM_Addr *sap,
+ u_char selector)
+{
+ ACE_TRACE ("ACE_ATM_Addr::set");
+
+ this->init (selector);
+
+#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2)
+ this->ACE_Addr::base_set (AF_ATM,
+#elif defined (ACE_HAS_LINUX_ATM)
+ this->ACE_Addr::base_set (PF_ATMSVC,
+#else
+ this->ACE_Addr::base_set (AF_UNSPEC,
+#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 */
+ sizeof (*sap));
+
+ (void) ACE_OS::memcpy ((void *) &this->atm_addr_,
+ (void *) sap,
+ sizeof this->atm_addr_);
+ return 0;
+}
+
+int
+ACE_ATM_Addr::set (const ACE_TCHAR address[],
+ u_char selector)
+{
+ ACE_TRACE ("ACE_ATM_Addr::set");
+ int ret;
+
+ this->init (selector);
+
+#if defined (ACE_HAS_FORE_ATM_XTI)
+ atm_addr_.sap.t_atm_sap_addr.SVE_tag_addr =
+ (int8_t) T_ATM_PRESENT;
+#endif /* ACE_HAS_FORE_ATM_XTI */
+
+ ret = this -> string_to_addr (address);
+ this -> set_selector (selector);
+ return ret;
+}
+
+// Transform the string into the current addressing format.
+
+int
+ACE_ATM_Addr::string_to_addr (const ACE_TCHAR sap[])
+{
+ ACE_TRACE ("ACE_ATM_Addr::string_to_addr");
+
+#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2)
+ this->ACE_Addr::base_set (AF_ATM,
+#elif defined (ACE_HAS_LINUX_ATM)
+ this->ACE_Addr::base_set (PF_ATMSVC,
+#else
+ this->ACE_Addr::base_set (AF_UNSPEC,
+#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */
+ sizeof this->atm_addr_);
+#if defined (ACE_HAS_FORE_ATM_XTI)
+ struct hostent *entry;
+ struct atmnsap_addr *nsap;
+
+ // Yow, someone gave us a NULL ATM address!
+ if (sap == 0)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+ else if ((entry = gethostbyname_atmnsap ((ACE_TCHAR *)sap)) != 0)
+ {
+ ACE_OS::memcpy (atm_addr_.sap.t_atm_sap_addr.address,
+ entry->h_addr_list[0],
+ ATMNSAP_ADDR_LEN - 1);
+ }
+ else if ((nsap = atmnsap_addr (sap)) != 0)
+ {
+ ACE_OS::memcpy (atm_addr_.sap.t_atm_sap_addr.address,
+ nsap->atmnsap,
+ ATMNSAP_ADDR_LEN);
+ }
+ else {
+ errno = EINVAL;
+ return -1;
+ }
+#elif defined (ACE_HAS_FORE_ATM_WS2)
+ DWORD dwValue;
+ HANDLE hLookup;
+ WSAQUERYSETW qsRestrictions;
+ CSADDR_INFO csaBuffer;
+ WCHAR tmpWStr[100];
+
+ MultiByteToWideChar (CP_ACP, MB_PRECOMPOSED, sap, -1, tmpWStr, 100);
+
+ csaBuffer.LocalAddr.iSockaddrLength = sizeof (struct sockaddr_atm);
+ csaBuffer.LocalAddr.lpSockaddr = (struct sockaddr *)&atm_addr_;
+ csaBuffer.RemoteAddr.iSockaddrLength = sizeof (struct sockaddr_atm);
+ csaBuffer.RemoteAddr.lpSockaddr = (struct sockaddr *)&atm_addr_;
+
+ qsRestrictions.dwSize = sizeof (WSAQUERYSETW);
+ qsRestrictions.lpszServiceInstanceName = 0;
+ qsRestrictions.lpServiceClassId = &FORE_NAME_CLASS;
+ qsRestrictions.lpVersion = 0;
+ qsRestrictions.lpszComment = 0;
+ qsRestrictions.dwNameSpace = FORE_NAME_SPACE;
+ qsRestrictions.lpNSProviderId = 0;
+ qsRestrictions.lpszContext = L"";
+ qsRestrictions.dwNumberOfProtocols = 0;
+ qsRestrictions.lpafpProtocols = 0;
+ qsRestrictions.lpszQueryString = tmpWStr;
+ qsRestrictions.dwNumberOfCsAddrs = 1;
+ qsRestrictions.lpcsaBuffer = &csaBuffer;
+ qsRestrictions.lpBlob = 0; //&blob;
+
+ if (::WSALookupServiceBeginW (&qsRestrictions, LUP_RETURN_ALL, &hLookup)
+ == SOCKET_ERROR) {
+ ACE_OS::printf ("Error: WSALookupServiceBeginW failed! %d\n",
+ ::WSAGetLastError ());
+ return -1;
+ }
+
+ dwValue = sizeof (WSAQUERYSETW);
+
+ if (::WSALookupServiceNextW (hLookup, 0, &dwValue, &qsRestrictions)
+ == SOCKET_ERROR) {
+ if (WSAGetLastError () != WSA_E_NO_MORE) {
+ ACE_OS::printf ("Error: WSALookupServiceNextW failed! %d\n",
+ ::WSAGetLastError ());
+ return -1;
+ }
+ }
+
+ if (WSALookupServiceEnd (hLookup) == SOCKET_ERROR) {
+ ACE_OS::printf ("Error : WSALookupServiceEnd failed! %d\n",
+ ::WSAGetLastError ());
+ errno = EINVAL;
+ return -1;
+ }
+#elif defined (ACE_HAS_LINUX_ATM)
+ if (sap == 0 || !ACE_OS::strcmp (sap,"")) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ if (text2atm ((ACE_TCHAR *)sap,
+ (struct sockaddr *)& (atm_addr_.sockaddratmsvc),
+ sizeof (atm_addr_.sockaddratmsvc),
+ T2A_SVC | T2A_NAME) < 0) {
+ ACE_DEBUG (LM_DEBUG,
+ "Error : text2atm failed!\n");
+ errno = EINVAL;
+ return -1;
+ }
+#else
+ ACE_UNUSED_ARG (sap);
+
+ return 0;
+#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */
+
+#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2) || defined (ACE_HAS_LINUX_ATM)
+ return 0;
+#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 */
+}
+
+// Transform the current address into string format.
+
+int
+ACE_ATM_Addr::addr_to_string (ACE_TCHAR addr[],
+ size_t addrlen) const
+{
+ ACE_TRACE ("ACE_ATM_Addr::addr_to_string");
+
+#if defined (ACE_HAS_FORE_ATM_XTI)
+ ACE_TCHAR buffer[MAXNAMELEN + 1];
+ struct atmnsap_addr nsap;
+ ACE_OS::memcpy (nsap.atmnsap,
+ atm_addr_.sap.t_atm_sap_addr.address,
+ ATMNSAP_ADDR_LEN);
+ ACE_OS::sprintf (buffer,
+ ACE_TEXT ("%s"),
+ atmnsap_ntoa (nsap));
+
+ size_t total_len = ACE_OS::strlen (buffer) + sizeof ('\0');
+
+ if (addrlen < total_len)
+ return -1;
+ else
+ ACE_OS::strcpy (addr, buffer);
+
+ return 0;
+#elif defined (ACE_HAS_FORE_ATM_WS2)
+ ACE_TCHAR buffer[MAXNAMELEN + 1];
+ int i;
+
+ if (addrlen < ATM_ADDR_SIZE + 1)
+ return -1;
+
+ for (i = 0; i < ATM_ADDR_SIZE; i++) {
+ buffer[ i * 3 ] = '\0';
+ ACE_OS::sprintf (buffer, ACE_TEXT ("%s%02x."),
+ buffer,
+ atm_addr_.satm_number.Addr[ i ]);
+ }
+
+ buffer[ ATM_ADDR_SIZE * 3 - 1 ] = '\0';
+ ACE_OS::strcpy (addr, buffer);
+
+ return 0;
+#elif defined (ACE_HAS_LINUX_ATM)
+ ACE_TCHAR buffer[MAX_ATM_ADDR_LEN + 1];
+ int total_len;
+ if ((total_len = atm2text (buffer,
+ sizeof buffer,
+ (struct sockaddr *)& (atm_addr_.sockaddratmsvc),
+ A2T_PRETTY)) < 0) {
+ ACE_DEBUG ((LM_DEBUG,"ACE_ATM_Addr (addr_to_string): atm2text failed\n"));
+ return -1;
+ }
+ if (addrlen < (size_t)total_len)
+ return -1;
+ else
+ ACE_OS::strcpy (addr,
+ buffer);
+
+ return 0;
+#else
+ ACE_UNUSED_ARG (addr);
+ ACE_UNUSED_ARG (addrlen);
+ return -1;
+#endif /* ACE_HAS_FORE_ATM_XTI && ACE_HAS_FORE_ATM_WS2 */
+}
+
+const ACE_TCHAR *
+ACE_ATM_Addr::addr_to_string (void) const
+{
+ ACE_TRACE ("ACE_ATM_Addr::addr_to_string");
+
+ static ACE_TCHAR addr[MAXHOSTNAMELEN + 1];
+ if (this->addr_to_string (addr,
+ MAXHOSTNAMELEN + 1) < 0)
+ return 0;
+
+ return addr;
+}
+
+// Set a pointer to the address.
+void
+ACE_ATM_Addr::set_addr (void *addr, int len)
+{
+ ACE_TRACE ("ACE_ATM_Addr::set_addr");
+
+#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2)
+ this->ACE_Addr::base_set (AF_ATM,
+#elif defined (ACE_HAS_LINUX_ATM)
+ this->ACE_Addr::base_set (PF_ATMSVC,
+#else
+ this->ACE_Addr::base_set (AF_UNSPEC,
+#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_WS2 */
+ len);
+ ACE_OS::memcpy ((void *) &this->atm_addr_,
+ (void *) addr, len);
+}
+
+// Compare two addresses for inequality.
+
+bool
+ACE_ATM_Addr::operator != (const ACE_ATM_Addr &sap) const
+{
+ ACE_TRACE ("ACE_ATM_Addr::operator !=");
+ return ! ((*this) == sap);
+}
+
+// Compare two addresses for equality.
+
+bool
+ACE_ATM_Addr::operator == (const ACE_ATM_Addr &sap) const
+{
+ ACE_TRACE ("ACE_ATM_Addr::operator ==");
+
+#if defined (ACE_HAS_LINUX_ATM)
+ return (atm_equal ((const struct sockaddr *)& (this->atm_addr_.sockaddratmsvc),
+ (const struct sockaddr *)& (sap.atm_addr_.sockaddratmsvc),
+ 0,
+ 0)
+ &&
+ sap_equal (& (this->atm_addr_.atmsap),
+ & (sap.atm_addr_.atmsap),
+ 0));
+#else
+ return ACE_OS::memcmp (&atm_addr_,
+ &sap.atm_addr_,
+ sizeof (ATM_Addr)) == 0;
+#endif /* ACE_HAS_LINUX_ATM */
+}
+
+void
+ACE_ATM_Addr::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_ATM_Addr::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+
+ ACE_TCHAR s[ACE_MAX_FULLY_QUALIFIED_NAME_LEN + 16];
+ ACE_OS::sprintf (s,
+ ACE_TEXT ("%s"),
+ this->addr_to_string ());
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("%s"), s));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_ATM */
diff --git a/externals/ace/ATM_Addr.h b/externals/ace/ATM_Addr.h
new file mode 100644
index 0000000..7fa93f1
--- /dev/null
+++ b/externals/ace/ATM_Addr.h
@@ -0,0 +1,197 @@
+// -*- C++ -*-
+
+//==========================================================================
+/**
+ * @file ATM_Addr.h
+ *
+ * $Id: ATM_Addr.h 80826 2008-03-04 14:51:23Z wotte $
+ *
+ * @author Joe Hoffert
+ */
+//==========================================================================
+
+#ifndef ACE_ATM_ADDR_H
+#define ACE_ATM_ADDR_H
+#include /**/ "ace/pre.h"
+
+#include /**/ "ace/config-all.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#if defined (ACE_HAS_ATM)
+
+#include /**/ "ace/ACE_export.h"
+#include "ace/Addr.h"
+
+#if defined (ACE_HAS_FORE_ATM_XTI)
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+typedef ATMSAPAddress ATM_Addr;
+ACE_END_VERSIONED_NAMESPACE_DECL
+#elif defined (ACE_HAS_FORE_ATM_WS2)
+#define FORE_NAME_SPACE NS_ALL
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+typedef struct sockaddr_atm ATM_Addr;
+ACE_END_VERSIONED_NAMESPACE_DECL
+#elif defined (ACE_HAS_LINUX_ATM)
+
+#include /**/ "atm.h"
+
+// Open versioned namespace, if enabled by the user.
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+//pbrandao:as Linux has this 2 structs separeted we "link it" here
+typedef struct _linux_atm_addr
+{
+ struct sockaddr_atmsvc sockaddratmsvc;
+ struct atm_sap atmsap;
+} ATM_Addr;
+#else
+typedef int ATM_Addr;
+#endif /* ACE_HAS_FORE_ATM_XTI/ACE_HAS_FORE_ATM_WS2/ACE_HAS_LINUX_ATM */
+
+/**
+ * @class ACE_ATM_Addr
+ *
+ * @brief Defines the ATM domain address family address format.
+ */
+class ACE_Export ACE_ATM_Addr : public ACE_Addr
+{
+public:
+ // Constants used for ATM options
+ static const long LINE_RATE;
+ static const int OPT_FLAGS_CPID;
+ static const int OPT_FLAGS_PMP;
+ static const int DEFAULT_SELECTOR;
+
+ // = Initialization methods.
+ /// Default constructor.
+ ACE_ATM_Addr (u_char selector = DEFAULT_SELECTOR);
+
+ /// Copy constructor.
+ ACE_ATM_Addr (const ACE_ATM_Addr &,
+ u_char selector = DEFAULT_SELECTOR);
+
+ /**
+ * Creates an ACE_ATM_Addr from an ATMSAPAddress structure. This
+ * is vendor specific (FORE systems). May need to change when other
+ * vendors are supported.
+ */
+ ACE_ATM_Addr (const ATM_Addr *,
+ u_char selector = DEFAULT_SELECTOR);
+
+ /**
+ * Initializes an ACE_ATM_Addr from the which can be
+ * "atm-address" (e.g.,
+ * "47.0005.80.ffe100.0000.f20f.2200.0020480694f9.00") or "hostname"
+ * (e.g., "frisbee.cs.wustl.edu").
+ */
+ ACE_ATM_Addr (const ACE_TCHAR sap[],
+ u_char selector = DEFAULT_SELECTOR);
+
+ /// Default dtor.
+ ~ACE_ATM_Addr (void);
+
+ // = Initialization methods (useful after object construction).
+ /// Default initialization for non-address values (e.g.,
+ /// t_atm_sap_addr.SVE_tag_addr, t_atm_sap_addr.SVE_tag_selector)
+ void init (u_char selector = DEFAULT_SELECTOR);
+
+ /// Initializes from another ACE_ATM_Addr.
+ int set (const ACE_ATM_Addr &,
+ u_char selector = DEFAULT_SELECTOR);
+
+ /**
+ * Initializes an ACE_ATM_Addr from an ATMSAPAddress/sockaddr_atm
+ * structure. This is vendor specific (FORE systems). May need to
+ * change when other vendors are supported.
+ */
+ int set (const ATM_Addr *,
+ u_char selector = DEFAULT_SELECTOR);
+
+ /**
+ * Initializes an ACE_ATM_Addr from the which can be
+ * "atm-address" (e.g.,
+ * "47.0005.80.ffe100.0000.f20f.2200.0020480694f9.00") or "hostname"
+ * (e.g., "frisbee.cs.wustl.edu").
+ */
+ int set (const ACE_TCHAR sap[],
+ u_char selector = DEFAULT_SELECTOR);
+
+ /**
+ * Initializes an ACE_ATM_Addr from the which can be
+ * "atm-address" (e.g.,
+ * "47.0005.80.ffe100.0000.f20f.2200.0020480694f9.00") or "hostname"
+ * (e.g., "frisbee.cs.wustl.edu").
+ */
+ virtual int string_to_addr (const ACE_TCHAR sap[]);
+
+ /**
+ * Return the character representation of the ATM address (e.g.,
+ * "47.0005.80.ffe100.0000.f20f.2200.0020480694f9.00") storing it in
+ * the @a addr (which is assumed to be bytes long). This
+ * version is reentrant. Returns -1 if the of the @a addr
+ * is too small, else 0.
+ */
+ virtual int addr_to_string (ACE_TCHAR addr[],
+ size_t addrlen) const;
+
+ /**
+ * Return the character representation of the ATM address (e.g.,
+ * "47.0005.80.ffe100.0000.f20f.2200.0020480694f9.00"). Returns -1
+ * if the of the is too small, else 0.(This version
+ * is non-reentrant since it returns a pointer to a static data
+ * area.)
+ */
+ const ACE_TCHAR *addr_to_string (void) const;
+
+ /// Return a pointer to the underlying network address.
+ virtual void *get_addr (void) const;
+
+ /// Set a pointer to the address.
+ virtual void set_addr (void *, int);
+
+ /// Return the selector for network address.
+ u_char get_selector (void) const;
+
+ /// Set the selector for the network address.
+ void set_selector (u_char selector);
+
+ /**
+ * Compare two addresses for equality. The addresses are considered
+ * equal if they contain the same ATM address. Q: Is there any
+ * other check for equality needed for ATM?
+ */
+ bool operator == (const ACE_ATM_Addr &SAP) const;
+
+ /// Compare two addresses for inequality.
+ bool operator != (const ACE_ATM_Addr &SAP) const;
+
+ /// Dump the state of an object.
+ void dump (void) const;
+
+ /// Declare the dynamic allocation hooks.
+ ACE_ALLOC_HOOK_DECLARE;
+
+// char *construct_options (ACE_HANDLE fd,
+// int qos_kb,
+// int flags,
+// long *optsize);
+// // Construct options for ATM connections
+
+private:
+ ATM_Addr atm_addr_;
+};
+
+// Close versioned namespace, if enabled by the user.
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+
+#if defined (__ACE_INLINE__)
+#include "ace/ATM_Addr.inl"
+#endif /* __ACE_INLINE__ */
+
+#endif /* ACE_HAS_ATM */
+#include /**/ "ace/post.h"
+#endif /* ACE_ATM_ADDR_H */
diff --git a/externals/ace/ATM_Addr.inl b/externals/ace/ATM_Addr.inl
new file mode 100644
index 0000000..55f43d6
--- /dev/null
+++ b/externals/ace/ATM_Addr.inl
@@ -0,0 +1,37 @@
+// -*- C++ -*-
+//
+// $Id: ATM_Addr.inl 80826 2008-03-04 14:51:23Z wotte $
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_INLINE u_char
+ACE_ATM_Addr::get_selector (void) const
+{
+ ACE_TRACE ("ACE_ATM_Addr::get_selector");
+#if defined (ACE_HAS_FORE_ATM_XTI)
+ return atm_addr_.sap.t_atm_sap_addr.address[ATMNSAP_ADDR_LEN - 1];
+#elif defined (ACE_HAS_FORE_ATM_WS2)
+ return atm_addr_.satm_number.Addr[ ATM_ADDR_SIZE - 1 ];
+#elif defined (ACE_HAS_LINUX_ATM)
+ return atm_addr_.sockaddratmsvc.sas_addr.prv[ATM_ESA_LEN - 1];
+#else
+ return 0;
+#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */
+}
+
+ACE_INLINE void
+ACE_ATM_Addr::set_selector (u_char selector)
+{
+ ACE_TRACE ("ACE_ATM_Addr::set_selector");
+#if defined (ACE_HAS_FORE_ATM_XTI)
+ atm_addr_.sap.t_atm_sap_addr.address[ATMNSAP_ADDR_LEN - 1] = selector;
+#elif defined (ACE_HAS_FORE_ATM_WS2)
+ atm_addr_.satm_number.Addr[ ATM_ADDR_SIZE - 1 ] = selector;
+#elif defined (ACE_HAS_LINUX_ATM)
+ atm_addr_.sockaddratmsvc.sas_addr.prv[ATM_ESA_LEN - 1] = selector;
+#else
+ ACE_UNUSED_ARG (selector);
+#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
diff --git a/externals/ace/ATM_Connector.cpp b/externals/ace/ATM_Connector.cpp
new file mode 100644
index 0000000..c1ce226
--- /dev/null
+++ b/externals/ace/ATM_Connector.cpp
@@ -0,0 +1,138 @@
+// ATM_Connector.cpp
+// $Id: ATM_Connector.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/ATM_Connector.h"
+#if defined (ACE_HAS_ATM)
+
+#include "ace/Handle_Set.h"
+
+ACE_RCSID(ace, ATM_Connector, "$Id: ATM_Connector.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#if !defined (__ACE_INLINE__)
+#include "ace/ATM_Connector.inl"
+#endif /* __ACE_INLINE__ */
+
+// Open versioned namespace, if enabled by the user.
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_ATM_Connector)
+
+ACE_ATM_Connector::ACE_ATM_Connector (void)
+{
+ ACE_TRACE ("ACE_ATM_Connector::ACE_ATM_Connector");
+}
+
+// Actively connect and produce a new ACE_ATM_Stream if things go well...
+// Connect the to the , waiting up to
+// amount of time if necessary.
+
+int
+ACE_ATM_Connector::connect (ACE_ATM_Stream &new_stream,
+ const ACE_ATM_Addr &remote_sap,
+ ACE_ATM_Params params,
+ ACE_ATM_QoS options,
+ ACE_Time_Value *timeout,
+ const ACE_ATM_Addr &local_sap,
+ int reuse_addr,
+ int flags,
+ int perms)
+{
+ ACE_TRACE ("ACE_ATM_Connector::connect");
+#if defined (ACE_HAS_FORE_ATM_XTI)
+ return connector_.connect(new_stream.get_stream(),
+ remote_sap,
+ timeout,
+ local_sap,
+ reuse_addr,
+ flags,
+ perms,
+ params.get_device(),
+ params.get_info(),
+ params.get_rw_flag(),
+ params.get_user_data(),
+ &options.get_qos());
+#elif defined (ACE_HAS_FORE_ATM_WS2)
+ ACE_DEBUG(LM_DEBUG,
+ ACE_TEXT ("ATM_Connector(connect): set QoS parameters\n" ));
+
+ ACE_HANDLE s = new_stream.get_handle();
+ struct sockaddr_atm *saddr = ( struct sockaddr_atm *)remote_sap.get_addr();
+ ACE_QoS cqos = options.get_qos();
+
+ ACE_QoS_Params qos_params = ACE_QoS_Params(0,
+ 0,
+ &cqos,
+ 0,
+ 0);
+
+ ACE_DEBUG(LM_DEBUG,
+ ACE_TEXT ("ATM_Connector(connect): connecting...\n"));
+
+ int result = ACE_OS::connect( s,
+ ( struct sockaddr *)saddr,
+ sizeof( struct sockaddr_atm ),
+ qos_params );
+
+ if ( result != 0 )
+ ACE_OS::printf( "ATM_Connector(connect): connection failed, %d\n",
+ ::WSAGetLastError());
+
+ return result;
+#elif defined (ACE_HAS_LINUX_ATM)
+ ACE_UNUSED_ARG (params);
+ ACE_UNUSED_ARG (timeout);
+ ACE_UNUSED_ARG (reuse_addr);
+ ACE_UNUSED_ARG (perms);
+ ACE_UNUSED_ARG (flags);
+
+ ACE_HANDLE handle = new_stream.get_handle();
+ ATM_QoS qos =options.get_qos();
+ ATM_Addr *local_addr=(ATM_Addr*)local_sap.get_addr(),
+ *remote_addr=(ATM_Addr*)remote_sap.get_addr();
+
+ if (ACE_OS::setsockopt(handle,
+ SOL_ATM,
+ SO_ATMSAP,
+ reinterpret_cast (&(local_addr->atmsap)),
+ sizeof(local_addr->atmsap)) < 0) {
+ ACE_OS::printf( "ATM_Connector(connect): unable to set atmsap %d\nContinuing...",
+ errno);
+ }
+ if (ACE_OS::setsockopt(handle,
+ SOL_ATM,
+ SO_ATMQOS,
+ reinterpret_cast (&qos),
+ sizeof(qos)) < 0) {
+ ACE_DEBUG((LM_DEBUG,ACE_TEXT ("ATM_Connector(connect): unable to set qos %d\n"),
+ errno));
+ return -1;
+ }
+
+ int result = ACE_OS::connect(handle,
+ (struct sockaddr *)&(remote_addr->sockaddratmsvc),
+ sizeof( remote_addr->sockaddratmsvc));
+
+ if ( result != 0 )
+ ACE_DEBUG(LM_DEBUG,
+ ACE_TEXT ("ATM_Connector(connect): connection failed, %d\n"),
+ errno);
+
+ return result;
+#else
+ ACE_UNUSED_ARG (new_stream);
+ ACE_UNUSED_ARG (remote_sap);
+ ACE_UNUSED_ARG (params);
+ ACE_UNUSED_ARG (options);
+ ACE_UNUSED_ARG (timeout);
+ ACE_UNUSED_ARG (local_sap);
+ ACE_UNUSED_ARG (reuse_addr);
+ ACE_UNUSED_ARG (flags);
+ ACE_UNUSED_ARG (perms);
+ return 0;
+#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */
+}
+
+// Close versioned namespace, if enabled by the user.
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_ATM */
diff --git a/externals/ace/ATM_Connector.h b/externals/ace/ATM_Connector.h
new file mode 100644
index 0000000..940fc5a
--- /dev/null
+++ b/externals/ace/ATM_Connector.h
@@ -0,0 +1,164 @@
+/* -*- C++ -*- */
+
+//=============================================================================
+/**
+ * @file ATM_Connector.h
+ *
+ * $Id: ATM_Connector.h 82723 2008-09-16 09:35:44Z johnnyw $
+ *
+ * @author Joe Hoffert
+ */
+//=============================================================================
+
+#ifndef ACE_ATM_CONNECTOR_H
+#define ACE_ATM_CONNECTOR_H
+#include /**/ "ace/pre.h"
+
+#include /**/ "ace/config-all.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#if defined (ACE_HAS_ATM)
+
+#include "ace/ATM_Stream.h"
+#include "ace/ATM_Params.h"
+#include "ace/ATM_QoS.h"
+
+#if defined (ACE_WIN32) || defined (ACE_HAS_LINUX_ATM)
+#include "ace/SOCK_Connector.h"
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+typedef ACE_SOCK_Connector ATM_Connector;
+ACE_END_VERSIONED_NAMESPACE_DECL
+#else
+#include "ace/XTI_ATM_Mcast.h"
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+typedef ACE_XTI_ATM_Mcast ATM_Connector;
+// Open versioned namespace, if enabled by the user.
+ACE_END_VERSIONED_NAMESPACE_DECL
+#endif
+
+// Open versioned namespace, if enabled by the user.
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+/**
+ * @class ACE_ATM_Connector
+ *
+ * @brief Defines an active connection factory for the ACE_ATM C++
+ * wrappers.
+ */
+class ACE_Export ACE_ATM_Connector
+{
+public:
+ // = Initialization methods.
+ /// Default constructor.
+ ACE_ATM_Connector (void);
+
+ /**
+ * Actively connect and produce a @a new_stream if things go well.
+ * The @a remote_sap is the address that we are trying to connect
+ * with. The are the parameters needed for either socket
+ * or XTI/ATM connections. The @a timeout is the amount of time to
+ * wait to connect. If it's 0 then we block indefinitely. If
+ * *timeout == {0, 0} then the connection is done using non-blocking
+ * mode. In this case, if the connection can't be made immediately
+ * the value of -1 is returned with @c errno == EWOULDBLOCK. If
+ * *timeout > {0, 0} then this is the maximum amount of time to wait before
+ * timing out. If the time expires before the connection is made
+ * @c errno == ETIME. The @a local_sap is the value of local address
+ * to bind to. If it's the default value of then
+ * the user is letting the OS do the binding. If @a reuse_addr == 1
+ * then the is reused, even if it hasn't been cleanedup yet.
+ */
+ ACE_ATM_Connector (ACE_ATM_Stream &new_stream,
+ const ACE_ATM_Addr &remote_sap,
+ ACE_ATM_Params params = ACE_ATM_Params(),
+ ACE_ATM_QoS options = ACE_ATM_QoS(),
+ ACE_Time_Value *timeout = 0,
+ const ACE_ATM_Addr &local_sap = ACE_ATM_Addr( "", 0 ),
+ int reuse_addr = 0,
+#if defined (ACE_WIN32)
+ int flags = 0,
+#else
+ int flags = O_RDWR,
+#endif /* ACE_WIN32 */
+ int perms = 0);
+
+ /**
+ * Actively connect and produce a @a new_stream if things go well.
+ * The @a remote_sap is the address that we are trying to connect
+ * with. The are the parameters needed for either socket
+ * or XTI/ATM connections. The @a timeout is the amount of time to
+ * wait to connect. If it's 0 then we block indefinitely. If
+ * *timeout == {0, 0} then the connection is done using non-blocking
+ * mode. In this case, if the connection can't be made immediately
+ * the value of -1 is returned with @c errno == EWOULDBLOCK. If
+ * *timeout > {0, 0} then this is the maximum amount of time to wait before
+ * timing out. If the time expires before the connection is made
+ * @c errno == ETIME. The @a local_sap is the value of local address
+ * to bind to. If it's the default value of then
+ * the user is letting the OS do the binding. If @a reuse_addr == 1
+ * then the is reused, even if it hasn't been cleanedup yet.
+ */
+ int connect (ACE_ATM_Stream &new_stream,
+ const ACE_ATM_Addr &remote_sap,
+ ACE_ATM_Params params = ACE_ATM_Params(),
+ ACE_ATM_QoS options = ACE_ATM_QoS(),
+ ACE_Time_Value *timeout = 0,
+ const ACE_ATM_Addr &local_sap = ACE_ATM_Addr( "",
+ 0 ),
+ int reuse_addr = 0,
+#if defined (ACE_WIN32)
+ int flags = 0,
+#else
+ int flags = O_RDWR,
+#endif /* ACE_WIN32 */
+ int perms = 0);
+
+ /**
+ * Try to complete a non-blocking connection.
+ * If connection completion is successful then @a new_stream contains
+ * the connected ACE_SOCK_Stream. If @a remote_sap is non-NULL then it
+ * will contain the address of the connected peer.
+ */
+ int complete (ACE_ATM_Stream &new_stream,
+ ACE_ATM_Addr *remote_sap,
+ ACE_Time_Value *tv);
+
+ /**
+ * Actively add a leaf to the root (i.e., point-to-multipoint). The
+ * @a remote_sap is the address of the leaf that we
+ * are trying to add.
+ */
+ int add_leaf (ACE_ATM_Stream ¤t_stream,
+ const ACE_Addr &remote_sap,
+ ACE_ATM_QoS &qos);
+
+ /// Resets any event associations on this handle
+ bool reset_new_handle (ACE_HANDLE handle);
+
+ // = Meta-type info
+ typedef ACE_ATM_Addr PEER_ADDR;
+ typedef ACE_ATM_Stream PEER_STREAM;
+
+ /// Dump the state of an object.
+ void dump (void) const;
+
+ /// Declare the dynamic allocation hooks.
+ ACE_ALLOC_HOOK_DECLARE;
+
+private:
+ ATM_Connector connector_;
+};
+
+// Open versioned namespace, if enabled by the user.
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#if defined (__ACE_INLINE__)
+#include "ace/ATM_Connector.inl"
+#endif /* __ACE_INLINE__ */
+
+#endif /* ACE_HAS_ATM */
+#include /**/ "ace/post.h"
+#endif /* ACE_ATM_CONNECTOR_H */
diff --git a/externals/ace/ATM_Connector.inl b/externals/ace/ATM_Connector.inl
new file mode 100644
index 0000000..10d1623
--- /dev/null
+++ b/externals/ace/ATM_Connector.inl
@@ -0,0 +1,132 @@
+// -*- C++ -*-
+//
+// $Id: ATM_Connector.inl 84565 2009-02-23 08:20:39Z johnnyw $
+
+// Open versioned namespace, if enabled by the user.
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_INLINE void
+ACE_ATM_Connector::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_ATM_Connector::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_INLINE
+ACE_ATM_Connector::ACE_ATM_Connector (ACE_ATM_Stream &new_stream,
+ const ACE_ATM_Addr &remote_sap,
+ ACE_ATM_Params params,
+ ACE_ATM_QoS options,
+ ACE_Time_Value *timeout,
+ const ACE_ATM_Addr &local_sap,
+ int reuse_addr,
+ int flags,
+ int perms)
+{
+ ACE_TRACE ("ACE_ATM_Connector::ACE_ATM_Connector");
+ if ((ACE_HANDLE)this->connect (new_stream,
+ remote_sap,
+ params,
+ options,
+ timeout,
+ local_sap,
+ reuse_addr,
+ flags,
+ perms) == ACE_INVALID_HANDLE
+ && timeout != 0 && !(errno == EWOULDBLOCK || errno == ETIME))
+ ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_ATM_Stream::ACE_ATM_Stream")));
+}
+
+// Try to complete a non-blocking connection.
+
+ACE_INLINE
+int
+ACE_ATM_Connector::complete (ACE_ATM_Stream &new_stream,
+ ACE_ATM_Addr *remote_sap,
+ ACE_Time_Value *tv)
+{
+ ACE_TRACE ("ACE_ATM_Connector::complete");
+#if defined (ACE_HAS_ATM)
+ return connector_.complete(new_stream.get_stream(),
+ remote_sap,
+ tv);
+#else
+ ACE_UNUSED_ARG(new_stream);
+ ACE_UNUSED_ARG(remote_sap);
+ ACE_UNUSED_ARG(tv);
+ return 0;
+#endif
+}
+
+ACE_INLINE
+int
+ACE_ATM_Connector::add_leaf (ACE_ATM_Stream ¤t_stream,
+ const ACE_Addr &remote_sap,
+ ACE_ATM_QoS &qos)
+{
+ ACE_TRACE ("ACE_ATM_Connector::add_leaf");
+#if defined (ACE_HAS_FORE_ATM_XTI)
+ return connector_.add_leaf(current_stream.get_stream(),
+ remote_sap,
+ leaf_id,
+ timeout);
+#elif defined (ACE_HAS_FORE_ATM_WS2)
+ struct sockaddr_atm *saddr = (struct sockaddr_atm *)remote_sap.get_addr();
+ ACE_QoS cqos = qos.get_qos();
+ int addr_len = sizeof( struct sockaddr_atm );
+
+ ACE_QoS_Params qos_params(0,
+ 0,
+ &cqos,
+ 0,
+ (JL_SENDER_ONLY));
+
+ ACE_OS::printf( "ATM_Connector::add_leaf: connecting...\n" );
+
+ ACE_HANDLE result = ACE_OS::join_leaf(current_stream.get_handle(),
+ (struct sockaddr *)saddr,
+ addr_len,
+ qos_params);
+
+ if ( result == ACE_INVALID_HANDLE )
+ ACE_OS::printf( "ATM_Connector(add_leaf): connection failed, %d\n",
+ ::WSAGetLastError());
+
+ return (result != ACE_INVALID_HANDLE);
+#elif defined (ACE_HAS_LINUX_ATM)
+ ACE_OS::printf("ATM_Connector(add_leaf): not yet implemented in Linux\n");
+
+ ACE_UNUSED_ARG(current_stream);
+ ACE_UNUSED_ARG(remote_sap);
+ ACE_UNUSED_ARG(leaf_id);
+ ACE_UNUSED_ARG(timeout);
+
+ return 0;
+#else
+ ACE_UNUSED_ARG(current_stream);
+ ACE_UNUSED_ARG(remote_sap);
+ ACE_UNUSED_ARG(leaf_id);
+ ACE_UNUSED_ARG(timeout);
+ return 0;
+#endif
+}
+
+ACE_INLINE
+bool
+ACE_ATM_Connector::reset_new_handle (ACE_HANDLE handle)
+{
+#if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
+ // Reset the event association
+ return ::WSAEventSelect ((SOCKET) handle,
+ 0,
+ 0);
+#else /* !defined ACE_HAS_WINSOCK2 */
+ ACE_UNUSED_ARG (handle);
+ return false;
+#endif /* ACE_WIN32 */
+}
+
+// Close versioned namespace, if enabled by the user.
+ACE_END_VERSIONED_NAMESPACE_DECL
diff --git a/externals/ace/ATM_Params.cpp b/externals/ace/ATM_Params.cpp
new file mode 100644
index 0000000..70a05f1
--- /dev/null
+++ b/externals/ace/ATM_Params.cpp
@@ -0,0 +1,20 @@
+// $Id: ATM_Params.cpp 80826 2008-03-04 14:51:23Z wotte $
+
+#include "ace/ATM_Params.h"
+
+#if defined (ACE_HAS_ATM)
+
+ACE_RCSID(ace, ATM_Params, "$Id: ATM_Params.cpp 80826 2008-03-04 14:51:23Z wotte $")
+
+#if !defined (__ACE_INLINE__)
+#include "ace/ATM_Params.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_ATM_Params)
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_ATM */
+
diff --git a/externals/ace/ATM_Params.h b/externals/ace/ATM_Params.h
new file mode 100644
index 0000000..d1e8c92
--- /dev/null
+++ b/externals/ace/ATM_Params.h
@@ -0,0 +1,214 @@
+// -*- C++ -*-
+
+//==========================================================================
+/**
+ * @file ATM_Params.h
+ *
+ * $Id: ATM_Params.h 80826 2008-03-04 14:51:23Z wotte $
+ *
+ * @author Joe Hoffert
+ */
+//==========================================================================
+
+
+#ifndef ACE_ATM_PARAMS_H
+#define ACE_ATM_PARAMS_H
+#include /**/ "ace/pre.h"
+
+#include /**/ "ace/config-all.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#if defined (ACE_HAS_ATM)
+
+#include /**/ "ace/ACE_export.h"
+
+#if defined (ACE_HAS_FORE_ATM_XTI)
+#include "ace/TLI.h"
+#define ATM_PROTOCOL_DEFAULT 0
+typedef struct t_info Param_Info;
+typedef struct netbuf Param_Udata;
+#elif defined (ACE_HAS_FORE_ATM_WS2)
+#include "ace/SOCK.h"
+#define ATM_PROTOCOL_DEFAULT ATMPROTO_AAL5
+#define ACE_XTI_ATM_DEVICE ""
+typedef int Param_Info;
+typedef int Param_Udata;
+#elif defined (ACE_HAS_LINUX_ATM)
+#include /**/ "atm.h"
+#define AF_ATM PF_ATMSVC
+#define ACE_XTI_ATM_DEVICE ""
+#define ATM_PROTOCOL_DEFAULT ATM_AAL5
+typedef int Param_Info;
+typedef int Param_Udata;
+#else
+#define ACE_XTI_ATM_DEVICE ""
+typedef int Param_Info;
+typedef int Param_Udata;
+#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+/**
+ * @class ACE_ATM_Params
+ *
+ * @brief Wrapper class that simplifies the information passed to the ATM
+ * enabled ACE_ATM_Connector class.
+ */
+class ACE_Export ACE_ATM_Params
+{
+public:
+ /**
+ * Initialize the data members. This class combines options from
+ * ACE_SOCK_Connector (@a protocol_family, @a protocol, ,
+ * @a protocol_info, , and @a flags) and
+ * ACE_TLI_Connector (, , , , and )
+ * so that either mechanism can be used transparently for ATM.
+ */
+ ACE_ATM_Params (int rw_flag = 1,
+ const char device[] = ACE_XTI_ATM_DEVICE,
+ Param_Info *info = 0,
+ Param_Udata *udata = 0,
+ int oflag = O_RDWR,
+ int protocol_family = AF_ATM,
+ int protocol = ATM_PROTOCOL_DEFAULT,
+ int type =
+#if defined (ACE_HAS_LINUX_ATM)
+ SOCK_DGRAM,
+#else
+ SOCK_RAW,
+#endif /* ACE_HAS_LINUX_ATM */
+ ACE_Protocol_Info *protocol_info = 0,
+ ACE_SOCK_GROUP g = 0,
+ u_long flags
+ = ACE_FLAG_MULTIPOINT_C_ROOT
+ | ACE_FLAG_MULTIPOINT_D_ROOT, // connector by default
+ int reuse_addr = 0);
+
+ /// Destructor.
+ ~ACE_ATM_Params ();
+
+ /// Get protocol family.
+ int get_protocol_family (void) const;
+
+ /// Set protocol family.
+ void set_protocol_family (int);
+
+ /// Get protocol.
+ int get_protocol (void) const;
+
+ /// Set protocol.
+ void set_protocol (int);
+
+ /// Get type.
+ int get_type (void) const;
+
+ /// Set type.
+ void set_type (int);
+
+ /// Get protocol info.
+ ACE_Protocol_Info *get_protocol_info( void );
+
+ /// Set protocol info.
+ void set_protocol_info( ACE_Protocol_Info *);
+
+ /// Get socket group.
+ ACE_SOCK_GROUP get_sock_group( void );
+
+ /// Set socket group.
+ void set_sock_group( ACE_SOCK_GROUP );
+
+ /// Get socket flags.
+ u_long get_flags( void );
+
+ /// Set socket flags.
+ void set_flags( u_long );
+
+ /// Get reuse_addr flag.
+ int get_reuse_addr (void) const;
+
+ /// Set reuse_addr flag.
+ void set_reuse_addr (int);
+
+ /// Get device.
+ const char* get_device (void) const;
+
+ /// Get info.
+ Param_Info* get_info (void) const;
+
+ /// Set info.
+ void set_info (Param_Info *);
+
+ /// Get r/w flag.
+ int get_rw_flag (void) const;
+
+ /// Set r/w flag.
+ void set_rw_flag (int);
+
+ /// Get user data.
+ Param_Udata* get_user_data (void) const;
+
+ /// Set user data.
+ void set_user_data (Param_Udata*);
+
+ /// Get open flag.
+ int get_oflag (void) const;
+
+ /// Set open flag.
+ void set_oflag (int);
+
+ /// Dump the state of an object.
+ void dump (void) const;
+
+ /// Declare the dynamic allocation hooks.
+ ACE_ALLOC_HOOK_DECLARE;
+
+private:
+ /// Protocol family for sockets connections.
+ int protocol_family_;
+
+ /// Protocol for sockets connections.
+ int protocol_;
+
+ /// Type for opening sockets.
+ int type_;
+
+ /// Information about the protocol.
+ ACE_Protocol_Info *protocol_info_;
+
+ /// Socket group used (for sockets only).
+ ACE_SOCK_GROUP group_;
+
+ /// Flags for sockets (for sockets only).
+ u_long flags_;
+
+ /// Flag for reusing address for opening sockets.
+ int reuse_addr_;
+
+ /// Device name for XTI/ATM connections.
+ const char *device_;
+
+ /// Info for XTI/ATM connections.
+ Param_Info *info_;
+
+ /// R/W flag for XTI/ATM connections.
+ int rw_flag_;
+
+ /// User data for XTI/ATM connections.
+ Param_Udata *udata_;
+
+ /// Open flag for XTI/ATM connections.
+ int oflag_;
+};
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#if defined (__ACE_INLINE__)
+#include "ace/ATM_Params.inl"
+#endif /* __ACE_INLINE__ */
+
+#endif /* ACE_HAS_ATM */
+#include /**/ "ace/post.h"
+#endif /* ACE_ATM_PARAMS_H */
diff --git a/externals/ace/ATM_Params.inl b/externals/ace/ATM_Params.inl
new file mode 100644
index 0000000..de2a4d4
--- /dev/null
+++ b/externals/ace/ATM_Params.inl
@@ -0,0 +1,235 @@
+// -*- C++ -*-
+//
+// $Id: ATM_Params.inl 80826 2008-03-04 14:51:23Z wotte $
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_INLINE void
+ACE_ATM_Params::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_ATM_Params::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_INLINE
+ACE_ATM_Params::ACE_ATM_Params (int rw_flag,
+ const char device[],
+ Param_Info *info,
+ Param_Udata *udata,
+ int oflag,
+ int protocol_family,
+ int protocol,
+ int type,
+ ACE_Protocol_Info *protocol_info,
+ ACE_SOCK_GROUP g,
+ u_long flags,
+ int reuse_addr)
+ : protocol_family_(protocol_family),
+ protocol_(protocol),
+ type_(type),
+ protocol_info_(protocol_info),
+ group_(g),
+ flags_(flags),
+ reuse_addr_(reuse_addr),
+ device_(device),
+ info_(info),
+ rw_flag_(rw_flag),
+ udata_(udata),
+ oflag_(oflag)
+{
+ ACE_TRACE ("ACE_ATM_Params::ACE_ATM_Params");
+}
+
+// Default dtor.
+ACE_INLINE
+ACE_ATM_Params::~ACE_ATM_Params (void)
+{
+ ACE_TRACE ("ACE_ATM_Params::~ACE_ATM_Params");
+}
+
+ACE_INLINE
+int
+ACE_ATM_Params::get_protocol_family (void) const
+{
+ ACE_TRACE ("ACE_ATM_Params::get_protocol_family");
+ return protocol_family_;
+}
+
+ACE_INLINE
+void
+ACE_ATM_Params::set_protocol_family (int family)
+{
+ ACE_TRACE ("ACE_ATM_Params::set_protocol_family");
+ protocol_family_ = family;
+}
+
+ACE_INLINE
+int
+ACE_ATM_Params::get_protocol (void) const
+{
+ ACE_TRACE ("ACE_ATM_Params::get_protocol");
+ return protocol_;
+}
+
+ACE_INLINE
+void
+ACE_ATM_Params::set_protocol (int protocol)
+{
+ ACE_TRACE ("ACE_ATM_Params::set_protocol");
+ protocol_ = protocol;
+}
+
+ACE_INLINE
+int
+ACE_ATM_Params::get_type (void) const
+{
+ ACE_TRACE ("ACE_ATM_Params::get_type");
+ return type_;
+}
+
+ACE_INLINE
+void
+ACE_ATM_Params::set_type (int type)
+{
+ ACE_TRACE ("ACE_ATM_Params::set_type");
+ type_ = type;
+}
+
+ACE_INLINE
+ACE_Protocol_Info*
+ACE_ATM_Params::get_protocol_info( void )
+{
+ ACE_TRACE ("ACE_ATM_Params::get_protocol_info");
+ return protocol_info_;
+}
+
+ACE_INLINE
+void
+ACE_ATM_Params::set_protocol_info( ACE_Protocol_Info *protocol_info )
+{
+ ACE_TRACE ("ACE_ATM_Params::set_protocol_info");
+ protocol_info_ = protocol_info;
+}
+
+ACE_INLINE
+ACE_SOCK_GROUP
+ACE_ATM_Params::get_sock_group( void )
+{
+ ACE_TRACE ("ACE_ATM_Params::get_sock_group");
+ return group_;
+}
+
+ACE_INLINE
+void
+ACE_ATM_Params::set_sock_group( ACE_SOCK_GROUP g )
+{
+ ACE_TRACE ("ACE_ATM_Params::set_sock_group");
+ group_ = g;
+}
+
+ACE_INLINE
+u_long
+ACE_ATM_Params::get_flags( void )
+{
+ ACE_TRACE ("ACE_ATM_Params::get_flags");
+ return flags_;
+}
+
+ACE_INLINE
+void
+ACE_ATM_Params::set_flags( u_long flags)
+{
+ ACE_TRACE ("ACE_ATM_Params::set_flags");
+ flags_ = flags;
+}
+
+ACE_INLINE
+int
+ACE_ATM_Params::get_reuse_addr (void) const
+{
+ ACE_TRACE ("ACE_ATM_Params::get_reuse_addr");
+ return reuse_addr_;
+}
+
+ACE_INLINE
+void
+ACE_ATM_Params::set_reuse_addr (int reuse_addr)
+{
+ ACE_TRACE ("ACE_ATM_Params::set_reuse_addr");
+ reuse_addr_ = reuse_addr;
+}
+
+ACE_INLINE
+const char*
+ACE_ATM_Params::get_device (void) const
+{
+ ACE_TRACE ("ACE_ATM_Params::get_device");
+ return device_;
+}
+
+ACE_INLINE
+Param_Info*
+ACE_ATM_Params::get_info (void) const
+{
+ ACE_TRACE ("ACE_ATM_Params::get_info");
+ return info_;
+}
+
+ACE_INLINE
+void
+ACE_ATM_Params::set_info (Param_Info* info)
+{
+ ACE_TRACE ("ACE_ATM_Params::set_info");
+ info_ = info;
+}
+
+ACE_INLINE
+int
+ACE_ATM_Params::get_rw_flag (void) const
+{
+ ACE_TRACE ("ACE_ATM_Params::get_rw_flag");
+ return rw_flag_;
+}
+
+ACE_INLINE
+void
+ACE_ATM_Params::set_rw_flag (int rw_flag)
+{
+ ACE_TRACE ("ACE_ATM_Params::set_rw_flag");
+ rw_flag_ = rw_flag;
+}
+
+ACE_INLINE
+Param_Udata*
+ACE_ATM_Params::get_user_data (void) const
+{
+ ACE_TRACE ("ACE_ATM_Params::get_user_data");
+ return udata_;
+}
+
+ACE_INLINE
+void
+ACE_ATM_Params::set_user_data (Param_Udata *udata)
+{
+ ACE_TRACE ("ACE_ATM_Params::set_user_data");
+ udata_ = udata;
+}
+
+ACE_INLINE
+int
+ACE_ATM_Params::get_oflag (void) const
+{
+ ACE_TRACE ("ACE_ATM_Params::get_oflag");
+ return oflag_;
+}
+
+ACE_INLINE
+void
+ACE_ATM_Params::set_oflag (int oflag)
+{
+ ACE_TRACE ("ACE_ATM_Params::set_oflag");
+ oflag_ = oflag;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
diff --git a/externals/ace/ATM_QoS.cpp b/externals/ace/ATM_QoS.cpp
new file mode 100644
index 0000000..5f83d3a
--- /dev/null
+++ b/externals/ace/ATM_QoS.cpp
@@ -0,0 +1,631 @@
+// $Id: ATM_QoS.cpp 84262 2009-01-29 10:34:33Z johnnyw $
+
+#include "ace/ATM_QoS.h"
+
+ACE_RCSID(ace, ATM_QoS, "$Id: ATM_QoS.cpp 84262 2009-01-29 10:34:33Z johnnyw $")
+
+#if defined (ACE_HAS_ATM)
+
+#if !defined (__ACE_INLINE__)
+#include "ace/ATM_QoS.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2)
+#define BHLI_MAGIC "FORE_ATM"
+// This is line rate in cells/s for an OC-3 MM interface.
+const long ACE_ATM_QoS::LINE_RATE = 353207;
+const int ACE_ATM_QoS::OPT_FLAGS_CPID = 0x1;
+const int ACE_ATM_QoS::OPT_FLAGS_PMP = 0x2;
+const int ACE_ATM_QoS::DEFAULT_SELECTOR = 0x99;
+const int ACE_ATM_QoS::DEFAULT_PKT_SIZE = 8192;
+#elif defined (ACE_HAS_LINUX_ATM)
+//pbrandao:for Linux:
+//pbrandao:for now stick with current definitions
+//pbrandao:see if later need to change
+const long ACE_ATM_QoS::LINE_RATE = 353207;
+const int ACE_ATM_QoS::OPT_FLAGS_CPID = 0x1;
+const int ACE_ATM_QoS::OPT_FLAGS_PMP = 0x2;
+const int ACE_ATM_QoS::DEFAULT_SELECTOR = 0x99;
+const int ACE_ATM_QoS::DEFAULT_PKT_SIZE = 8192;
+#else
+const long ACE_ATM_QoS::LINE_RATE = 0L;
+const int ACE_ATM_QoS::OPT_FLAGS_CPID = 0;
+const int ACE_ATM_QoS::OPT_FLAGS_PMP = 0;
+const int ACE_ATM_QoS::DEFAULT_SELECTOR = 0x0;
+const int ACE_ATM_QoS::DEFAULT_PKT_SIZE = 0;
+#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */
+
+ACE_ALLOC_HOOK_DEFINE(ACE_ATM_QoS)
+
+ACE_ATM_QoS::ACE_ATM_QoS (int pktSize)
+{
+ ACE_TRACE ("ACE_ATM_QoS::ACE_ATM_QoS");
+#if defined (ACE_HAS_LINUX_ATM)
+ ACE_OS::memset(&qos_, 0, sizeof(qos_));
+ qos_.aal = ATM_PROTOCOL_DEFAULT;
+ qos_.rxtp.traffic_class = ATM_ANYCLASS;
+ qos_.rxtp.max_sdu = pktSize;
+ qos_.txtp.traffic_class = ATM_ANYCLASS;
+ qos_.txtp.max_sdu = pktSize;
+#else
+ ACE_UNUSED_ARG (pktSize);
+#endif /* ACE_HAS_LINUX_ATM */
+}
+
+ACE_ATM_QoS::ACE_ATM_QoS(int rate,
+ int pktSize)
+{
+ ACE_TRACE( "ACE_ATM_QoS::ACE_ATM_QoS" );
+#if defined (ACE_HAS_FORE_ATM_WS2)
+ AAL_PARAMETERS_IE ie_aalparams;
+ ATM_TRAFFIC_DESCRIPTOR_IE ie_td;
+ ATM_BROADBAND_BEARER_CAPABILITY_IE ie_bbc;
+ ATM_QOS_CLASS_IE ie_qos;
+ Q2931_IE *ie_ptr;
+ int size;
+
+ // Setting up cbr parameters ...
+ ie_aalparams.AALType = AALTYPE_5;
+ ie_aalparams.AALSpecificParameters.AAL5Parameters.ForwardMaxCPCSSDUSize
+ = pktSize; // was 1516;
+ ie_aalparams.AALSpecificParameters.AAL5Parameters.BackwardMaxCPCSSDUSize
+ = pktSize; // was 1516;
+ ie_aalparams.AALSpecificParameters.AAL5Parameters.Mode = AAL5_MODE_MESSAGE;
+ ie_aalparams.AALSpecificParameters.AAL5Parameters.SSCSType = AAL5_SSCS_NULL;
+
+ size = sizeof(Q2931_IE_TYPE) + sizeof(ULONG) + sizeof(AAL_PARAMETERS_IE);
+
+ ie_td.Forward.PeakCellRate_CLP0 = SAP_FIELD_ABSENT;
+ ie_td.Forward.PeakCellRate_CLP01 = rate;
+ ie_td.Forward.SustainableCellRate_CLP0 = SAP_FIELD_ABSENT;
+ ie_td.Forward.SustainableCellRate_CLP01 = SAP_FIELD_ABSENT;
+ ie_td.Forward.MaxBurstSize_CLP0 = SAP_FIELD_ABSENT;
+ ie_td.Forward.MaxBurstSize_CLP01 = SAP_FIELD_ABSENT;
+ ie_td.Forward.Tagging = SAP_FIELD_ABSENT;
+
+ ie_td.Backward.PeakCellRate_CLP0 = SAP_FIELD_ABSENT;
+ ie_td.Backward.PeakCellRate_CLP01 = rate;
+ ie_td.Backward.SustainableCellRate_CLP0 = SAP_FIELD_ABSENT;
+ ie_td.Backward.SustainableCellRate_CLP01 = SAP_FIELD_ABSENT;
+ ie_td.Backward.MaxBurstSize_CLP0 = SAP_FIELD_ABSENT;
+ ie_td.Backward.MaxBurstSize_CLP01 = SAP_FIELD_ABSENT;
+ ie_td.Backward.Tagging = SAP_FIELD_ABSENT;
+
+ ie_td.BestEffort = 0; // Note: this must be set to zero for CBR.
+
+ size += sizeof( Q2931_IE_TYPE )
+ + sizeof( ULONG )
+ + sizeof( ATM_TRAFFIC_DESCRIPTOR_IE );
+
+ ie_bbc.BearerClass = BCOB_X;
+ ie_bbc.TrafficType = TT_CBR;
+ ie_bbc.TimingRequirements = TR_END_TO_END;
+ ie_bbc.ClippingSusceptability = CLIP_NOT;
+ ie_bbc.UserPlaneConnectionConfig = UP_P2P;
+
+ size += sizeof( Q2931_IE_TYPE )
+ + sizeof( ULONG )
+ + sizeof( ATM_BROADBAND_BEARER_CAPABILITY_IE );
+
+ ie_qos.QOSClassForward = QOS_CLASS1;
+ ie_qos.QOSClassBackward = QOS_CLASS1; // This may not be really used
+ // since we do only simplex data xfer.
+
+ size += sizeof(Q2931_IE_TYPE) + sizeof(ULONG) + sizeof(ATM_QOS_CLASS_IE);
+
+ qos_.ProviderSpecific.buf = (char *) ACE_OS::malloc(size);
+ if (qos_.ProviderSpecific.buf == 0) {
+ ACE_ERROR((LM_ERROR,
+ ACE_TEXT ("ACE_ATM_QoS::ACE_ATM_QoS: Unable to allocate %d bytes for qos_.ProviderSpecific.buf\n"),
+ size));
+ return;
+ }
+ qos_.ProviderSpecific.len = size;
+ ACE_OS::memset(qos_.ProviderSpecific.buf, 0, size);
+
+ ie_ptr = (Q2931_IE *) qos_.ProviderSpecific.buf;
+ ie_ptr->IEType = IE_AALParameters;
+ ie_ptr->IELength = sizeof( Q2931_IE_TYPE )
+ + sizeof( ULONG )
+ + sizeof( AAL_PARAMETERS_IE );
+ ACE_OS::memcpy(ie_ptr->IE, &ie_aalparams, sizeof(AAL_PARAMETERS_IE));
+
+ ie_ptr = (Q2931_IE *) ((char *)ie_ptr + ie_ptr->IELength);
+ ie_ptr->IEType = IE_TrafficDescriptor;
+ ie_ptr->IELength = sizeof( Q2931_IE_TYPE )
+ + sizeof( ULONG )
+ + sizeof( ATM_TRAFFIC_DESCRIPTOR_IE );
+ ACE_OS::memcpy(ie_ptr->IE, &ie_td, sizeof(ATM_TRAFFIC_DESCRIPTOR_IE));
+
+ ie_ptr = (Q2931_IE *) ((char *)ie_ptr + ie_ptr->IELength);
+ ie_ptr->IEType = IE_BroadbandBearerCapability;
+ ie_ptr->IELength = sizeof( Q2931_IE_TYPE )
+ + sizeof( ULONG )
+ + sizeof( ATM_BROADBAND_BEARER_CAPABILITY_IE );
+ ACE_OS::memcpy(ie_ptr->IE,
+ &ie_bbc,
+ sizeof(ATM_BROADBAND_BEARER_CAPABILITY_IE));
+
+ ie_ptr = (Q2931_IE *) ((char *)ie_ptr + ie_ptr->IELength);
+ ie_ptr->IEType = IE_QOSClass;
+ ie_ptr->IELength = sizeof( Q2931_IE_TYPE )
+ + sizeof( ULONG )
+ + sizeof( ATM_QOS_CLASS_IE );
+ ACE_OS::memcpy(ie_ptr->IE, &ie_qos, sizeof(ATM_QOS_CLASS_IE));
+
+ // qos_.SendingFlowspec.TokenRate = 0xffffffff;
+ // qos_.SendingFlowspec.TokenBucketSize = 0xffffffff;
+ // qos_.SendingFlowspec.PeakBandwidth = 0xffffffff;
+ // qos_.SendingFlowspec.Latency = 0xffffffff;
+ // qos_.SendingFlowspec.DelayVariation = 0xffffffff;
+ // qos_.SendingFlowspec.ServiceType = SERVICETYPE_BESTEFFORT;
+ // This will most probably be ignored by the service provider.
+ // qos_.SendingFlowspec.MaxSduSize = 0xffffffff;
+ // qos_.SendingFlowspec.MinimumPolicedSize = 0xffffffff;
+
+ // qos_.ReceivingFlowspec.TokenRate = 0xffffffff;
+ // qos_.ReceivingFlowspec.TokenBucketSize = 0xffffffff;
+ // qos_.ReceivingFlowspec.PeakBandwidth = 0xffffffff;
+ // qos_.ReceivingFlowspec.Latency = 0xffffffff;
+ // qos_.ReceivingFlowspec.DelayVariation = 0xffffffff;
+ // qos_.ReceivingFlowspec.ServiceType = SERVICETYPE_BESTEFFORT;
+ // This will most probably be ignored by the service provider.
+ // qos_.ReceivingFlowspec.MaxSduSize = 0xffffffff;
+ // qos_.ReceivingFlowspec.MinimumPolicedSize = 0;
+
+ ACE_Flow_Spec send_fspec( 0xffffffff,
+ 0xffffffff,
+ 0xffffffff,
+ 0xffffffff,
+ 0xffffffff,
+ SERVICETYPE_BESTEFFORT,
+ // This will most probably ignored by SP.
+ 0xffffffff,
+ 0xffffffff,
+ 15,
+ ACE_DEFAULT_THREAD_PRIORITY ),
+ recv_fspec( 0xffffffff,
+ 0xffffffff,
+ 0xffffffff,
+ 0xffffffff,
+ 0xffffffff,
+ SERVICETYPE_BESTEFFORT,
+ // This will most probably ignored by SP.
+ 0xffffffff,
+ 0,
+ 15,
+ ACE_DEFAULT_THREAD_PRIORITY );
+
+ qos_.sending_flowspec (send_fspec);
+ qos_.receiving_flowspec (recv_fspec);
+#elif defined (ACE_HAS_FORE_ATM_XTI)
+ ACE_UNUSED_ARG (rate);
+ ACE_UNUSED_ARG (pktSize);
+#elif defined (ACE_HAS_LINUX_ATM)
+ ACE_OS::memset(&qos_,
+ 0,
+ sizeof(qos_));
+ qos_.aal = ATM_PROTOCOL_DEFAULT;
+ qos_.rxtp.max_sdu = pktSize;
+
+ if (rate > 0) {
+ qos_.rxtp.pcr = rate;
+ qos_.rxtp.traffic_class = ATM_CBR;
+ qos_.txtp.traffic_class = ATM_CBR;
+ qos_.txtp.pcr = rate;
+ }
+ else {
+ qos_.rxtp.traffic_class = ATM_UBR;
+ qos_.txtp.traffic_class = ATM_UBR;
+ }
+
+ qos_.txtp.max_sdu = pktSize;
+#else
+ ACE_UNUSED_ARG (rate);
+#endif /* ACE_HAS_FORE_ATM_WS2 || ACE_HAS_FORE_ATM_XTI || ACE_HAS_LINUX_ATM */
+}
+
+void
+ACE_ATM_QoS::set_cbr_rate (int rate,
+ int pktSize)
+{
+ ACE_TRACE ("ACE_ATM_QoS::set_cbr_rate");
+#if defined (ACE_HAS_FORE_ATM_WS2)
+ /*
+ AAL_PARAMETERS_IE ie_aalparams;
+ ATM_TRAFFIC_DESCRIPTOR_IE ie_td;
+ ATM_BROADBAND_BEARER_CAPABILITY_IE ie_bbc;
+ ATM_QOS_CLASS_IE ie_qos;
+ Q2931_IE *ie_ptr;
+ int size;
+ */
+
+ ACE_OS::printf( "ATM_QoS(set_cbr_rate): set rate to %d c/s\n", rate );
+
+ // Setting up cbr parameters ...
+ /*
+ FORE has changed this - we no longer specify QoS this way
+ ie_aalparams.AALType = AALTYPE_5;
+ ie_aalparams.AALSpecificParameters.AAL5Parameters.ForwardMaxCPCSSDUSize
+ = pktSize; // was 1516;
+ ie_aalparams.AALSpecificParameters.AAL5Parameters.BackwardMaxCPCSSDUSize
+ = pktSize; // was 1516;
+ ie_aalparams.AALSpecificParameters.AAL5Parameters.Mode = AAL5_MODE_MESSAGE;
+ ie_aalparams.AALSpecificParameters.AAL5Parameters.SSCSType = AAL5_SSCS_NULL;
+
+ size = sizeof(Q2931_IE_TYPE) + sizeof(ULONG) + sizeof(AAL_PARAMETERS_IE);
+
+ ie_td.Forward.PeakCellRate_CLP0 = SAP_FIELD_ABSENT;
+ ie_td.Forward.PeakCellRate_CLP01 = rate;
+ ie_td.Forward.SustainableCellRate_CLP0 = SAP_FIELD_ABSENT;
+ ie_td.Forward.SustainableCellRate_CLP01 = SAP_FIELD_ABSENT;
+ ie_td.Forward.MaxBurstSize_CLP0 = SAP_FIELD_ABSENT;
+ ie_td.Forward.MaxBurstSize_CLP01 = SAP_FIELD_ABSENT;
+ ie_td.Forward.Tagging = SAP_FIELD_ABSENT;
+
+ ie_td.Backward.PeakCellRate_CLP0 = SAP_FIELD_ABSENT;
+ ie_td.Backward.PeakCellRate_CLP01 = rate;
+ ie_td.Backward.SustainableCellRate_CLP0 = SAP_FIELD_ABSENT;
+ ie_td.Backward.SustainableCellRate_CLP01 = SAP_FIELD_ABSENT;
+ ie_td.Backward.MaxBurstSize_CLP0 = SAP_FIELD_ABSENT;
+ ie_td.Backward.MaxBurstSize_CLP01 = SAP_FIELD_ABSENT;
+ ie_td.Backward.Tagging = SAP_FIELD_ABSENT;
+
+ ie_td.BestEffort = 0; // Note: this must be set to zero for CBR.
+
+ size += sizeof( Q2931_IE_TYPE ) +
+ sizeof( ULONG ) +
+ sizeof( ATM_TRAFFIC_DESCRIPTOR_IE );
+
+ ie_bbc.BearerClass = BCOB_X;
+ ie_bbc.TrafficType = TT_CBR;
+ ie_bbc.TimingRequirements = TR_END_TO_END;
+ ie_bbc.ClippingSusceptability = CLIP_NOT;
+ ie_bbc.UserPlaneConnectionConfig = UP_P2P;
+
+ size += sizeof(Q2931_IE_TYPE) +
+ sizeof(ULONG) +
+ sizeof(ATM_BROADBAND_BEARER_CAPABILITY_IE);
+
+ ie_qos.QOSClassForward = QOS_CLASS1;
+ ie_qos.QOSClassBackward = QOS_CLASS1; // This may not be really used
+ // since we only simplex data xfer.
+
+ size += sizeof(Q2931_IE_TYPE) + sizeof(ULONG) + sizeof(ATM_QOS_CLASS_IE);
+
+ qos_.ProviderSpecific.buf = (char *) ACE_OS::malloc(size);
+ if (qos_.ProviderSpecific.buf == 0) {
+ ACE_ERROR((LM_ERROR,
+ ACE_TEXT ("ACE_ATM_QoS::ACE_ATM_QoS: Unable to allocate %d bytes for qos_.ProviderSpecific.buf\n"),
+ size));
+ return;
+ }
+ qos_.ProviderSpecific.len = size;
+ ACE_OS::memset(qos_.ProviderSpecific.buf, 0, size);
+
+ ie_ptr = (Q2931_IE *) qos_.ProviderSpecific.buf;
+ ie_ptr->IEType = IE_AALParameters;
+ ie_ptr->IELength = sizeof( Q2931_IE_TYPE ) +
+ sizeof( ULONG ) +
+ sizeof( AAL_PARAMETERS_IE );
+ ACE_OS::memcpy(ie_ptr->IE, &ie_aalparams, sizeof(AAL_PARAMETERS_IE));
+
+ ie_ptr = (Q2931_IE *) ((char *)ie_ptr + ie_ptr->IELength);
+ ie_ptr->IEType = IE_TrafficDescriptor;
+ ie_ptr->IELength = sizeof( Q2931_IE_TYPE ) +
+ sizeof( ULONG ) +
+ sizeof( ATM_TRAFFIC_DESCRIPTOR_IE );
+ ACE_OS::memcpy(ie_ptr->IE, &ie_td, sizeof(ATM_TRAFFIC_DESCRIPTOR_IE));
+
+ ie_ptr = (Q2931_IE *) ((char *)ie_ptr + ie_ptr->IELength);
+ ie_ptr->IEType = IE_BroadbandBearerCapability;
+ ie_ptr->IELength = sizeof( Q2931_IE_TYPE ) +
+ sizeof( ULONG ) +
+ sizeof( ATM_BROADBAND_BEARER_CAPABILITY_IE );
+ ACE_OS::memcpy( ie_ptr->IE,
+ &ie_bbc,
+ sizeof( ATM_BROADBAND_BEARER_CAPABILITY_IE ));
+
+ ie_ptr = (Q2931_IE *) ((char *)ie_ptr + ie_ptr->IELength);
+ ie_ptr->IEType = IE_QOSClass;
+ ie_ptr->IELength = sizeof(Q2931_IE_TYPE) + sizeof(ULONG) +
+ sizeof(ATM_QOS_CLASS_IE);
+ ACE_OS::memcpy(ie_ptr->IE, &ie_qos, sizeof(ATM_QOS_CLASS_IE));
+ */
+
+ const int BYTES_PER_ATM_CELL = 53;
+ ACE_OS::memset(&qos_, 0, sizeof(ATM_QoS));
+ // Setting the token rate sets the minimum rate. 3 Mbits/sec seems too high.
+ // Certainly for Vaudeville audio, we only need about 1000 c/s which is
+ // 424000 bits/sec which is 53000 bytes/sec.
+ //qos_.SendingFlowspec.TokenRate = 3*(1024*128); // 3Mbits/sec
+ qos_.SendingFlowspec.TokenRate = 53000; // 1000 cells/sec
+ qos_.SendingFlowspec.TokenBucketSize = 32*1024; // our block size
+ //ourQos.SendingFlowspec.PeakBandwidth = ourQos.SendingFlowspec.TokenRate;
+ qos_.SendingFlowspec.ServiceType = SERVICETYPE_GUARANTEED;
+ // Peak bandwidth is in bytes/sec. The rate is specified in cells/sec so
+ // we need to convert from cells/sec to bytes/sec (i.e., multiply by 53).
+ qos_.SendingFlowspec.PeakBandwidth = rate * BYTES_PER_ATM_CELL;
+ qos_.SendingFlowspec.Latency = -1; // we don't care too much
+ qos_.SendingFlowspec.DelayVariation = -1; // we don't care too much
+ // no provider-specific data allowed on ATM
+ qos_.ProviderSpecific.buf=0;
+ qos_.ProviderSpecific.len=0;
+ // unidirectional P2MP; we don't need to setup the Receiving flowspec
+
+ //qos_.SendingFlowspec.TokenRate = 0xffffffff;
+ //qos_.SendingFlowspec.TokenBucketSize = 0xffffffff;
+ //qos_.SendingFlowspec.PeakBandwidth = 0xffffffff;
+ //qos_.SendingFlowspec.Latency = 0xffffffff;
+ //qos_.SendingFlowspec.DelayVariation = 0xffffffff;
+ //qos_.SendingFlowspec.ServiceType = SERVICETYPE_BESTEFFORT;
+ // This will most probably be ignored by the service provider.
+ //qos_.SendingFlowspec.MaxSduSize = 0xffffffff;
+ //qos_.SendingFlowspec.MinimumPolicedSize = 0xffffffff;
+
+ //qos_.ReceivingFlowspec.TokenRate = 0xffffffff;
+ //qos_.ReceivingFlowspec.TokenBucketSize = 0xffffffff;
+ //qos_.ReceivingFlowspec.PeakBandwidth = 0xffffffff;
+ //qos_.ReceivingFlowspec.Latency = 0xffffffff;
+ //qos_.ReceivingFlowspec.DelayVariation = 0xffffffff;
+ //qos_.ReceivingFlowspec.ServiceType = SERVICETYPE_BESTEFFORT;
+ // This will most probably be ignored by the service provider.
+ //qos_.ReceivingFlowspec.MaxSduSize = 0xffffffff;
+ //qos_.ReceivingFlowspec.MinimumPolicedSize = 0;
+
+ /*
+ ACE_Flow_Spec send_fspec( 0xffffffff,
+ 0xffffffff,
+ 0xffffffff,
+ 0xffffffff,
+ 0xffffffff,
+ SERVICETYPE_BESTEFFORT,
+ // This will most probably ignored by SP.
+ 0xffffffff,
+ 0xffffffff,
+ 15,
+ ACE_DEFAULT_THREAD_PRIORITY ),
+ recv_fspec( 0xffffffff,
+ 0xffffffff,
+ 0xffffffff,
+ 0xffffffff,
+ 0xffffffff,
+ SERVICETYPE_BESTEFFORT,
+ // This will most probably ignored by SP.
+ 0xffffffff,
+ 0,
+ 15,
+ ACE_DEFAULT_THREAD_PRIORITY );
+
+ qos_.sending_flowspec( send_fspec );
+ qos_.receiving_flowspec( recv_fspec );
+ */
+#elif defined (ACE_HAS_FORE_ATM_XTI)
+ ACE_UNUSED_ARG (rate);
+ ACE_UNUSED_ARG (pktSize);
+#elif defined (ACE_HAS_LINUX_ATM)
+ ACE_UNUSED_ARG (pktSize);
+
+ qos_.rxtp.traffic_class = ATM_CBR;
+ qos_.rxtp.pcr = rate;
+ qos_.txtp.traffic_class = ATM_CBR;
+ qos_.txtp.pcr = rate;
+#else
+ ACE_UNUSED_ARG (rate);
+#endif /* ACE_HAS_FORE_ATM_WS2 || ACE_HAS_FORE_ATM_XTI || ACE_HAS_LINUX_ATM */
+}
+
+void
+ACE_ATM_QoS::set_rate (ACE_HANDLE fd,
+ int rate,
+ int flags)
+{
+ ACE_TRACE ("ACE_ATM_QoS::set_rate");
+#if defined (ACE_HAS_FORE_ATM_WS2) || defined (ACE_HAS_LINUX_ATM)
+ set_cbr_rate( rate );
+
+ ACE_UNUSED_ARG( fd );
+ ACE_UNUSED_ARG( flags );
+#elif defined (ACE_HAS_FORE_ATM_XTI)
+ long optlen = 0;
+ qos_.buf = construct_options(fd,
+ rate,
+ flags,
+ &optlen);
+ qos_.len = optlen;
+#else
+ ACE_UNUSED_ARG (rate);
+#endif /* ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM || ACE_HAS_FORE_ATM_XTI */
+}
+
+char*
+ACE_ATM_QoS::construct_options (ACE_HANDLE fd,
+ int rate,
+ int flags,
+ long *len)
+{
+#if defined (ACE_HAS_FORE_ATM_WS2) || defined (ACE_HAS_LINUX_ATM)
+ ACE_UNUSED_ARG (fd);
+ ACE_UNUSED_ARG (rate);
+ ACE_UNUSED_ARG (flags);
+ ACE_UNUSED_ARG (len);
+ return 0;
+#elif defined (ACE_HAS_FORE_ATM_XTI)
+ struct t_opthdr *popt;
+ char *buf;
+ int qos_cells;
+ struct t_info info;
+
+ if (ACE_OS::t_getinfo (fd, &info) == -1)
+ {
+ ACE_OS::t_error ("t_getinfo");
+ return 0;
+ }
+
+ buf = (char *) ACE_OS::malloc (info.options);
+
+ if (buf == 0)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("Unable to allocate %d bytes for options\n"),
+ info.options),
+ 0);
+
+ popt = (struct t_opthdr *) buf;
+
+ if (flags & OPT_FLAGS_CPID)
+ {
+ // This constructs the T_ATM_ORIG_ADDR option, which is used to
+ // signal the UNI 3.1 Calling Party ID Information Element.
+ t_atm_addr *source_addr;
+
+ popt->len = sizeof (struct t_opthdr) + sizeof (t_atm_addr);
+ popt->level = T_ATM_SIGNALING;
+ popt->name = T_ATM_ORIG_ADDR;
+ popt->status = 0;
+
+ source_addr =
+ (t_atm_addr *)((char *) popt + sizeof (struct t_opthdr));
+
+ source_addr->address_format = T_ATM_ENDSYS_ADDR;
+ source_addr->address_length = ATMNSAP_ADDR_LEN;
+
+ ATMSAPAddress local_addr;
+ struct t_bind boundaddr;
+
+ boundaddr.addr.maxlen = sizeof(local_addr);
+ boundaddr.addr.buf = (char *) &local_addr;
+
+ //if (ACE_OS::t_getprotaddr(fd, &boundaddr, 0) < 0) {
+ if (ACE_OS::t_getname(fd,
+ &boundaddr.addr,
+ LOCALNAME) < 0)
+ {
+ ACE_OS::t_error("t_getname (local_address)");
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("Can't get local address!\n")));
+ ACE_OS::free (buf);
+ return 0;
+ }
+
+ ACE_OS::memcpy(source_addr->address,
+ local_addr.sap.t_atm_sap_addr.address,
+ ATMNSAP_ADDR_LEN);
+
+ popt = T_OPT_NEXTHDR (buf, info.options , popt);
+ }
+
+ // This constructs all options necessary (bearer cap., QoS, and
+ // Traffic Descriptor) to signal for a CBR connection with the
+ // specified QoS in kbit/sec., and/or specify a PMP connection.
+
+ // For FORE 200e cards, the adapter shapes traffic to CBR with rate
+ // equal to PCR CLP=0+1 (traffic.forward.PCR_all_traffic)
+
+ qos_cells = (rate * 1000) / (48*8);
+
+ if ((qos_cells > 0 && qos_cells < LINE_RATE)
+ || (ACE_BIT_ENABLED (flags, OPT_FLAGS_PMP)))
+ {
+ struct t_atm_bearer *bearer;
+ struct t_atm_traffic *traffic;
+
+ // T_ATM_BEARER_CAP: Broadband bearer capability
+ popt->len = sizeof (struct t_opthdr) + sizeof (struct t_atm_bearer);
+ popt->level = T_ATM_SIGNALING;
+ popt->name = T_ATM_BEARER_CAP;
+ popt->status = 0;
+
+ bearer = (struct t_atm_bearer *)((char *) popt +
+ sizeof (struct t_opthdr));
+ bearer->bearer_class = T_ATM_CLASS_X;
+
+ if (qos_cells)
+ {
+ bearer->traffic_type = T_ATM_CBR;
+ bearer->timing_requirements = T_ATM_END_TO_END;
+ }
+ else
+ {
+ bearer->traffic_type = 0; // UBR
+ bearer->timing_requirements = 0;
+ }
+ bearer->clipping_susceptibility = T_ATM_NULL;
+
+ if (ACE_BIT_ENABLED (flags, OPT_FLAGS_PMP))
+ bearer->connection_configuration = T_ATM_1_TO_MANY;
+ else
+ bearer->connection_configuration = T_ATM_1_TO_1;
+
+ popt = T_OPT_NEXTHDR (buf, info.options, popt);
+
+ // T_ATM_TRAFFIC: traffic descriptor
+ popt->len = sizeof (struct t_opthdr) + sizeof (struct t_atm_traffic);
+ popt->level = T_ATM_SIGNALING;
+ popt->name = T_ATM_TRAFFIC;
+ popt->status = 0;
+
+ traffic = (struct t_atm_traffic *)((char *) popt +
+ sizeof (struct t_opthdr));
+
+ traffic->forward.PCR_high_priority = T_ATM_ABSENT;
+ traffic->forward.PCR_all_traffic = qos_cells ? qos_cells : LINE_RATE;
+ traffic->forward.SCR_high_priority = T_ATM_ABSENT;
+ traffic->forward.SCR_all_traffic = T_ATM_ABSENT;
+ traffic->forward.MBS_high_priority = T_ATM_ABSENT;
+ traffic->forward.MBS_all_traffic = T_ATM_ABSENT;
+ traffic->forward.tagging = T_NO;
+
+ traffic->backward.PCR_high_priority = T_ATM_ABSENT;
+ traffic->backward.PCR_all_traffic =
+ (ACE_BIT_ENABLED (flags, OPT_FLAGS_PMP))
+ ? 0 : qos_cells ? qos_cells : LINE_RATE;
+ traffic->backward.SCR_high_priority = T_ATM_ABSENT;
+ traffic->backward.SCR_all_traffic = T_ATM_ABSENT;
+ traffic->backward.MBS_high_priority = T_ATM_ABSENT;
+ traffic->backward.MBS_all_traffic = T_ATM_ABSENT;
+ traffic->backward.tagging = T_NO;
+
+ traffic->best_effort = qos_cells ? T_NO : T_YES;
+
+ popt = T_OPT_NEXTHDR (buf,
+ info.options,
+ popt);
+ }
+
+ if (qos_cells > 0 && qos_cells < LINE_RATE)
+ {
+ struct t_atm_qos *qos;
+
+ // T_ATM_QOS: Quality of Service
+ popt->len = sizeof (struct t_opthdr) + sizeof (struct t_atm_qos);
+ popt->level = T_ATM_SIGNALING;
+ popt->name = T_ATM_QOS;
+ popt->status = 0;
+
+ qos = (struct t_atm_qos *)((char *) popt + sizeof (struct t_opthdr));
+ qos->coding_standard = T_ATM_ITU_CODING;
+ qos->forward.qos_class = T_ATM_QOS_CLASS_1;
+ qos->backward.qos_class = T_ATM_QOS_CLASS_1;
+
+ popt = T_OPT_NEXTHDR (buf, info.options, popt);
+ }
+
+ // Return actual size of options and option buffer to user.
+ *len = (char *) popt - buf;
+
+ return buf;
+#else
+ ACE_UNUSED_ARG (fd);
+ ACE_UNUSED_ARG (rate);
+ ACE_UNUSED_ARG (flag);
+ ACE_UNUSED_ARG (len);
+ return 0;
+#endif /* ACE_HAS_FORE_ATM_WS2 */
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_ATM */
+
diff --git a/externals/ace/ATM_QoS.h b/externals/ace/ATM_QoS.h
new file mode 100644
index 0000000..4e35f3f
--- /dev/null
+++ b/externals/ace/ATM_QoS.h
@@ -0,0 +1,115 @@
+// -*- C++ -*-
+
+//==========================================================================
+/**
+ * @file ATM_QoS.h
+ *
+ * $Id: ATM_QoS.h 80826 2008-03-04 14:51:23Z wotte $
+ *
+ * @author Joe Hoffert
+ */
+//==========================================================================
+
+
+#ifndef ACE_ATM_QoS_H
+#define ACE_ATM_QoS_H
+#include /**/ "ace/pre.h"
+
+#include /**/ "ace/config-all.h"
+
+#if !defined(ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#if defined (ACE_HAS_ATM)
+
+#if defined (ACE_HAS_FORE_ATM_WS2)
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+// just map to WS2 GQOS struct
+typedef ACE_QoS ATM_QoS;
+ACE_END_VERSIONED_NAMESPACE_DECL
+#elif defined (ACE_HAS_FORE_ATM_XTI)
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+typedef struct netbuf ATM_QoS;
+ACE_END_VERSIONED_NAMESPACE_DECL
+#elif defined (ACE_HAS_LINUX_ATM)
+#include /**/ "atm.h"
+#include "ace/ATM_Params.h"
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+typedef struct atm_qos ATM_QoS;
+ACE_END_VERSIONED_NAMESPACE_DECL
+#else
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+typedef int ATM_QoS;
+ACE_END_VERSIONED_NAMESPACE_DECL
+#endif /* ACE_HAS_FORE_ATM_WS2 || ACE_HAS_FORE_ATM_XTI || ACE_HAS_LINUX_ATM */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+/**
+ * @class ACE_ATM_QoS
+ *
+ * @brief Define the QoS parameters for ATM
+ *
+ * This class wraps up QoS parameters for both ATM/XTI and
+ * ATM/WinSock2 to make the mechanism for the ATM protocol
+ * transparent.
+ */
+class ACE_Export ACE_ATM_QoS
+{
+public:
+ // Constants used for ATM options
+ static const long LINE_RATE;
+ static const int OPT_FLAGS_CPID;
+ static const int OPT_FLAGS_PMP;
+ static const int DEFAULT_SELECTOR;
+ static const int DEFAULT_PKT_SIZE;
+
+ // = Initializattion and termination methods.
+ /// Default constructor.
+ ACE_ATM_QoS(int = DEFAULT_PKT_SIZE);
+
+ /// Constructor with a CBR rate.
+ ACE_ATM_QoS(int,
+ int = DEFAULT_PKT_SIZE);
+
+ ~ACE_ATM_QoS ();
+
+ /// Set the rate.
+ void set_rate (ACE_HANDLE,
+ int,
+ int);
+
+ /// Set CBR rate in cells per second.
+ void set_cbr_rate (int,
+ int = DEFAULT_PKT_SIZE);
+
+ /// Get ATM_QoS struct.
+ ATM_QoS get_qos (void);
+
+ /// Dump the state of an object.
+ void dump (void) const;
+
+ /// Declare the dynamic allocation hooks.
+ ACE_ALLOC_HOOK_DECLARE;
+
+protected:
+ /// Construct QoS options.
+ char* construct_options(ACE_HANDLE,
+ int,
+ int,
+ long*);
+
+private:
+ ATM_QoS qos_;
+};
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#if defined (__ACE_INLINE__)
+#include "ace/ATM_QoS.inl"
+#endif /* __ACE_INLINE__ */
+
+#endif /* ACE_HAS_ATM */
+#include /**/ "ace/post.h"
+#endif /* ACE_ATM_QoS_H */
diff --git a/externals/ace/ATM_QoS.inl b/externals/ace/ATM_QoS.inl
new file mode 100644
index 0000000..52b5211
--- /dev/null
+++ b/externals/ace/ATM_QoS.inl
@@ -0,0 +1,29 @@
+// -*- C++ -*-
+//
+// $Id: ATM_QoS.inl 80826 2008-03-04 14:51:23Z wotte $
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_INLINE void
+ACE_ATM_QoS::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_ATM_QoS::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_INLINE
+ACE_ATM_QoS::~ACE_ATM_QoS ()
+{
+ ACE_TRACE ("ACE_ATM_QoS::~ACE_ATM_QoS");
+}
+
+ACE_INLINE
+ATM_QoS
+ACE_ATM_QoS::get_qos (void)
+{
+ ACE_TRACE ("ACE_ATM_QoS::get_qos");
+ return qos_;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
diff --git a/externals/ace/ATM_Stream.cpp b/externals/ace/ATM_Stream.cpp
new file mode 100644
index 0000000..a9dc046
--- /dev/null
+++ b/externals/ace/ATM_Stream.cpp
@@ -0,0 +1,290 @@
+// $Id: ATM_Stream.cpp 84262 2009-01-29 10:34:33Z johnnyw $
+
+#include "ace/ATM_Stream.h"
+
+ACE_RCSID (ace, ATM_Stream, "$Id: ATM_Stream.cpp 84262 2009-01-29 10:34:33Z johnnyw $")
+
+#if defined (ACE_HAS_ATM)
+
+#if !defined (__ACE_INLINE__)
+#include "ace/ATM_Stream.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE (ACE_ATM_Stream)
+
+char*
+ACE_ATM_Stream::get_peer_name (void) const
+{
+ ACE_TRACE ("ACE_ATM_Stream::get_peer_name");
+#if defined (ACE_HAS_FORE_ATM_XTI)
+ // // Use t_getprotaddr for XTI/ATM
+ // struct t_bind *localaddr
+ // = (struct t_bind *) ACE_OS::t_alloc (get_handle (),
+ // T_BIND,
+ // T_ADDR);
+ // struct t_bind *peeraddr
+ // = (struct t_bind *) ACE_OS::t_alloc (get_handle (),
+ // T_BIND,
+ // T_ADDR);
+ // ::t_getprotaddr (get_handle (),
+ // localaddr,
+ // peeraddr);
+
+ // char* connected_name = (char*) ACE_OS::malloc (peeraddr->addr.len + 1);
+ // ACE_OS::strcpy (connected_name,
+ // peeraddr->addr.buf);
+ // ACE_OS::t_free ((char *) localaddr,
+ // T_BIND);
+ // ACE_OS::t_free ((char *) peeraddr,
+ // T_BIND);
+ // return (connected_name);
+
+#error "This doesn't seem to work. May need to jimmy-rig something with the"
+#error "/etc/xti_hosts file - Ugh!"
+
+ ACE_ATM_Addr sa;
+ struct netbuf name;
+ name.maxlen = sa.get_size ();
+ name.buf = (char *) sa.get_addr ();
+ ACE_OS::t_getname (this->get_handle (), &name, REMOTENAME);
+ // ACE_OS::ioctl (this->get_handle (),
+ // TI_GETPEERNAME,
+ // &name);
+ return (name.buf);
+
+#elif defined (ACE_HAS_FORE_ATM_WS2)
+ // Use getpeername for WinSock2.
+ struct sockaddr_atm name;
+ ACE_OS::memset (&name, 0, sizeof (name));
+ int nameSize = sizeof (name);
+
+ if (ACE_OS::getpeername (this->get_handle (),
+ (struct sockaddr *) &name,
+ &nameSize) != 0) {
+ return 0;
+ }
+
+ char buffer[256];
+ for (unsigned int index = 0; index < ATM_ADDR_SIZE - 1; index++) {
+ buffer[ index * 3 ] = '\0';
+ ACE_OS::sprintf (buffer, "%s%02x.", buffer, name.satm_number.Addr[ index ]);
+ }
+ buffer[ (ATM_ADDR_SIZE - 1) * 3 ] = '\0';
+ ACE_OS::sprintf (buffer, "%s%02x.", buffer, 0);
+ buffer[ ATM_ADDR_SIZE * 3 - 1 ] = '\0';
+ for (index = 0; index < ACE_OS::strlen (buffer); ++index)
+ buffer[index] = ACE_OS::ace_tolower (buffer[index]);
+
+ ifstream atm_hosts ("C:/WINNT/atmhosts");
+ assert (atm_hosts.is_open ());
+
+ // Find the host address in the ATM hosts file and return the
+ // host name
+ char line[256];
+ char *host_ptr, *host_name = 0;
+ ACE_NEW_RETURN (host_name, char[256], 0);
+ while (!atm_hosts.eof ()) {
+ atm_hosts.getline (line, 256);
+ // Convert the line to lower case to ease comparison
+ for (index = 0; index < ACE_OS::strlen (line); ++index)
+ line[index] = ACE_OS::ace_tolower (line[index]);
+ if (ACE_OS::strstr (line, buffer) != 0)
+ {
+ char *strtok_p;
+ // Grab the second token which is the host name
+ ACE_OS::strtok_r (line, " \t", &strtok_p);
+ host_ptr = ACE_OS::strtok (0, " \t", &strtok_p);
+ ACE_OS::strcpy (host_name, host_ptr);
+ break;
+ }
+ }
+
+ return host_name;
+#elif defined (ACE_HAS_LINUX_ATM)
+ ATM_Addr name;
+ int nameSize = sizeof (name.sockaddratmsvc);
+
+ if (ACE_OS::getpeername (this->get_handle (),
+ (struct sockaddr *) & (name.sockaddratmsvc),
+ &nameSize) < 0) {
+ ACE_OS::perror ("ACE_ATM_Stream (get_peer_name) : ");
+ return 0;
+ }
+
+ static ACE_TCHAR buffer[MAX_ATM_ADDR_LEN + 1];
+ int total_len;
+ if ((total_len = atm2text (buffer,sizeof buffer,
+ (struct sockaddr *) & (name.sockaddratmsvc),
+ A2T_PRETTY|A2T_NAME)) < 0) {
+ ACE_DEBUG ((LM_DEBUG,ACE_TEXT ("ACE_ATM_Stream (get_peer_name) :%d"),errno));
+ return 0;
+ }
+
+ return (char*) buffer;
+#else
+ return 0;
+#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */
+}
+
+ACE_HANDLE
+ACE_ATM_Stream::get_handle (void) const
+{
+ ACE_TRACE ("ACE_ATM_Stream::get_handle");
+#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2) || defined (ACE_HAS_LINUX_ATM)
+ return stream_.get_handle ();
+#else
+ return 0;
+#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */
+}
+
+int
+ACE_ATM_Stream::get_vpi_vci (ACE_UINT16 &vpi,
+ ACE_UINT16 &vci) const
+{
+ ACE_TRACE ("ACE_ATM_Stream::get_vpi_vci");
+#if defined (ACE_HAS_FORE_ATM_XTI)
+ struct t_atm_conn_prop conn_prop;
+ char* connect_opts = (char *) &conn_prop;
+ int opt_size = sizeof (t_atm_conn_prop);
+ struct t_info info;
+ struct t_optmgmt opt_req, opt_ret;
+
+ if (ACE_OS::t_getinfo (stream_.get_handle (),
+ &info) < 0)
+ {
+ ACE_OS::t_error ("t_getinfo");
+ return -1;
+ }
+
+ char *buf_req = (char *) ACE_OS::malloc (info.options);
+ if (buf_req == 0)
+ {
+ ACE_OS::fprintf (stderr,
+ "Unable to allocate %ld bytes for options\n",
+ info.options);
+ return -1;
+ }
+
+ char *buf_ret = (char *) ACE_OS::malloc (info.options);
+ if (buf_ret == 0)
+ {
+ ACE_OS::fprintf (stderr,
+ "Unable to allocate %ld bytes for options\n",
+ info.options);
+ return -1;
+ }
+
+ ACE_OS::memset (&opt_req, 0, sizeof (opt_req));
+ ACE_OS::memset (&opt_ret, 0, sizeof (opt_ret));
+
+ struct t_opthdr *popt = (struct t_opthdr *) buf_req;
+ struct t_opthdr *popt_ret = (struct t_opthdr *) buf_ret;
+
+ popt->len= sizeof (struct t_opthdr) + opt_size;
+
+ // We are only concerned with SVCs so no other check or values are needed
+ // here.
+ popt->level = T_ATM_SIGNALING;
+ popt->name = T_ATM_CONN_PROP;
+ popt->status = 0;
+
+ opt_req.opt.len = popt->len;
+ opt_req.opt.buf = (char *) popt;
+ opt_req.flags = T_CURRENT;
+
+ popt = T_OPT_NEXTHDR (buf_req,
+ info.options,
+ popt);
+ opt_ret.opt.maxlen = info.options;
+ opt_ret.opt.buf = (char *) popt_ret;
+
+ if (ACE_OS::t_optmgmt (stream_.get_handle (),
+ &opt_req,
+ &opt_ret) < 0) {
+ ACE_OS::t_error ("t_optmgmt");
+ return -1;
+ }
+
+ ACE_OS::memcpy (connect_opts,
+ (char *) popt_ret + sizeof (struct t_opthdr),
+ opt_size);
+
+ ACE_OS::free (buf_ret);
+ ACE_OS::free (buf_req);
+
+ vpi = conn_prop.vpi;
+ vci = conn_prop.vci;
+ return 0;
+#elif defined (ACE_HAS_FORE_ATM_WS2)
+ ATM_CONNECTION_ID connID;
+ DWORD bytes = 0;
+
+ if (::WSAIoctl ((int) this -> get_handle (),
+ SIO_GET_ATM_CONNECTION_ID,
+ 0,
+ 0,
+ (LPVOID) &connID,
+ sizeof (ATM_CONNECTION_ID),
+ &bytes,
+ 0,
+ 0)
+ == SOCKET_ERROR) {
+ ACE_OS::printf ("Error: WSAIoctl %d\n", WSAGetLastError ());
+ }
+
+ vpi = (ACE_UINT16) connID.VPI;
+ vci = (ACE_UINT16) connID.VCI;
+
+ return 0;
+#elif defined (ACE_HAS_LINUX_ATM)
+#if defined (SO_ATMPVC) /* atm version>=0.62 */
+ struct sockaddr_atmpvc mypvcaddr;
+ int addrpvclen = sizeof (mypvcaddr);
+ if (ACE_OS::getsockopt (stream_.get_handle (),
+ SOL_ATM,
+ SO_ATMPVC,
+ reinterpret_cast (&mypvcaddr),
+ &addrpvclen) < 0) {
+ ACE_DEBUG (LM_DEBUG,
+ ACE_TEXT ("ACE_ATM_Stream::get_vpi_vci: getsockopt %d\n"),
+ errno);
+ return -1;
+ }
+ vpi = (ACE_UINT16) mypvcaddr.sap_addr.vpi;
+ vci = (ACE_UINT16) mypvcaddr.sap_addr.vci;
+
+ return 0;
+#elif defined (SO_VCID) /* patch for atm version 0.59 */
+ struct atm_vcid mypvcid;
+ int pvcidlen = sizeof (mypvcid);
+ if (ACE_OS::getsockopt (stream_.get_handle (),
+ SOL_ATM,SO_VCID,
+ reinterpret_cast (&mypvcid),
+ &pvcidlen) < 0) {
+ ACE_DEBUG (LM_DEBUG,
+ ACE_TEXT ("ACE_ATM_Stream::get_vpi_vci: getsockopt %d\n"),
+ errno);
+ return -1;
+ }
+ vpi = (ACE_UINT16) mypvcid.vpi;
+ vci = (ACE_UINT16) mypvcid.vci;
+
+ return 0;
+#else
+ ACE_DEBUG (LM_DEBUG,
+ ACE_TEXT ("ACE_ATM_Stream::get_vpi_vci: Not implemented in this ATM version. Update to >= 0.62\n Or patch 0.59"));
+ ACE_UNUSED_ARG (vci);
+ ACE_UNUSED_ARG (vpi);
+
+ return -1;
+#endif /* SO_ATMPVC || SO_VCID */
+#else
+ return -1;
+#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_HAS_ATM */
diff --git a/externals/ace/ATM_Stream.h b/externals/ace/ATM_Stream.h
new file mode 100644
index 0000000..41ffb0d
--- /dev/null
+++ b/externals/ace/ATM_Stream.h
@@ -0,0 +1,107 @@
+/* -*- C++ -*- */
+
+//=============================================================================
+/**
+ * @file ATM_Stream.h
+ *
+ * $Id: ATM_Stream.h 80826 2008-03-04 14:51:23Z wotte $
+ *
+ * @author Joe Hoffert
+ */
+//=============================================================================
+
+
+#ifndef ACE_ATM_STREAM_H
+#define ACE_ATM_STREAM_H
+#include /**/ "ace/pre.h"
+
+#include /**/ "ace/config-all.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#if defined (ACE_HAS_ATM)
+
+#include "ace/ATM_Addr.h"
+#include "ace/ATM_Params.h"
+
+#if defined (ACE_WIN32)
+#include "ace/SOCK_Stream.h"
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+typedef ACE_SOCK_Stream ATM_Stream;
+ACE_END_VERSIONED_NAMESPACE_DECL
+#else
+#include "ace/TLI_Stream.h"
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+typedef ACE_TLI_Stream ATM_Stream;
+ACE_END_VERSIONED_NAMESPACE_DECL
+#endif
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+/**
+ * @class ACE_ATM_Stream
+ *
+ * @brief Defines the member functions for ACE_ATM_Stream abstraction.
+ */
+class ACE_Export ACE_ATM_Stream
+{
+public:
+ // = Initialization and termination methods.
+ /// Default constructor.
+ ACE_ATM_Stream (void);
+
+ // = ATM-specific open and shutdown operations.
+ /// open the stream.
+ int open (ACE_ATM_Params params = ACE_ATM_Params());
+
+ /// Close down and release resources.
+ int close (void);
+
+ /// Get the underlying handle.
+ ACE_HANDLE get_handle (void) const;
+
+ /// Get the underlying stream.
+ ATM_Stream& get_stream (void);
+
+ /// Get the name of the connected host.
+ char* get_peer_name (void) const;
+
+ /// Get the VPI and VCI of the stream.
+ int get_vpi_vci (ACE_UINT16 &vpi,
+ ACE_UINT16 &vci) const;
+
+ /// Recv an n byte buffer from the connected transport mechanism.
+ ssize_t recv (void *buf,
+ size_t n,
+ int *flags = 0) const;
+
+ /// Send exactly n bytes to the connected transport mechanism.
+ ssize_t send_n (const void *buf,
+ size_t n,
+ int flags) const;
+
+ // = Meta-type info
+ typedef ACE_ATM_Addr PEER_ADDR;
+
+ /// Dump the state of an object.
+ void dump (void) const;
+
+ /// Declare the dynamic allocation hooks.
+ ACE_ALLOC_HOOK_DECLARE;
+
+private:
+ /// Typedef'd to the appropriate stream mechanism above.
+ ATM_Stream stream_;
+};
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#if defined (__ACE_INLINE__)
+#include "ace/ATM_Stream.inl"
+#endif /* __ACE_INLINE__ */
+
+#endif /* ACE_HAS_ATM */
+#include /**/ "ace/post.h"
+#endif /* ACE_ATM_STREAM_H */
diff --git a/externals/ace/ATM_Stream.inl b/externals/ace/ATM_Stream.inl
new file mode 100644
index 0000000..007e258
--- /dev/null
+++ b/externals/ace/ATM_Stream.inl
@@ -0,0 +1,133 @@
+// -*- C++ -*-
+//
+// $Id: ATM_Stream.inl 84262 2009-01-29 10:34:33Z johnnyw $
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_INLINE void
+ACE_ATM_Stream::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_ATM_Stream::dump");
+#endif /* ACE_HAS_DUMP */
+}
+
+ACE_INLINE
+ACE_ATM_Stream::ACE_ATM_Stream (void)
+{
+ ACE_TRACE ("ACE_ATM_Stream::ACE_ATM_Stream");
+}
+
+ACE_INLINE
+int
+ACE_ATM_Stream::open (ACE_ATM_Params params)
+{
+ ACE_TRACE ("ACE_ATM_Stream::open");
+#if defined (ACE_HAS_FORE_ATM_XTI)
+ ACE_HANDLE handle = stream_.open (params.get_device(),
+ params.get_oflag(),
+ params.get_info());
+ return (handle == ACE_INVALID_HANDLE ? -1 : 0);
+#elif defined (ACE_HAS_FORE_ATM_WS2)
+ params.set_flags( ACE_FLAG_MULTIPOINT_C_ROOT | ACE_FLAG_MULTIPOINT_D_ROOT );
+
+ int retval = stream_.open (params.get_type(),
+ params.get_protocol_family(),
+ params.get_protocol(),
+ params.get_protocol_info(),
+ params.get_sock_group(),
+ params.get_flags(),
+ params.get_reuse_addr());
+ if (retval == -1)
+ return -1;
+
+ struct sockaddr_atm sock_addr;
+
+ ACE_OS::memset(&sock_addr, 0, sizeof(struct sockaddr_atm));
+ sock_addr.satm_family = AF_ATM;
+ sock_addr.satm_number.AddressType=ADDR_ANY;
+ sock_addr.satm_number.NumofDigits = ATM_ADDR_SIZE;
+ sock_addr.satm_blli.Layer2Protocol = SAP_FIELD_ABSENT;
+ sock_addr.satm_blli.Layer3Protocol = SAP_FIELD_ABSENT;
+ sock_addr.satm_bhli.HighLayerInfoType = SAP_FIELD_ABSENT;
+ if (ACE_OS::bind(get_handle(),
+ (struct sockaddr FAR *)&sock_addr,
+ sizeof(struct sockaddr_atm)) < 0)
+ {
+ ACE_OS::printf("Error binding local address: %d",WSAGetLastError());
+ return -1;
+ }
+
+ return 0;
+#else
+ ACE_UNUSED_ARG(params);
+ return 0;
+#endif /* ACE_HAS_FORE_ATM_XTI */
+}
+
+ACE_INLINE
+int
+ACE_ATM_Stream::close (void)
+{
+ ACE_TRACE ("ACE_ATM_Stream::close");
+#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2)
+ return stream_.close ();
+#else
+ return 0;
+#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 */
+}
+
+ACE_INLINE
+ATM_Stream&
+ACE_ATM_Stream::get_stream (void)
+{
+ ACE_TRACE ("ACE_ATM_Stream::get_stream");
+ return stream_;
+}
+
+ACE_INLINE
+ssize_t
+ACE_ATM_Stream::recv (void *buf,
+ size_t n,
+ int *flags) const
+{
+ ACE_TRACE ("ACE_ATM_Stream::recv");
+#if defined (ACE_HAS_FORE_ATM_XTI)
+ return stream_.recv (buf,
+ n,
+ flags);
+#elif defined (ACE_HAS_FORE_ATM_WS2)
+ return stream_.recv (buf,
+ n);
+#else
+ ACE_UNUSED_ARG(buf);
+ ACE_UNUSED_ARG(n);
+ ACE_UNUSED_ARG(flags);
+ return 0;
+#endif /* ACE_HAS_FORE_ATM_XTI */
+}
+
+ACE_INLINE
+ssize_t
+ACE_ATM_Stream::send_n (const void *buf,
+ size_t n,
+ int flags) const
+{
+ ACE_TRACE ("ACE_ATM_Stream::send_n");
+#if defined (ACE_HAS_FORE_ATM_XTI)
+ return stream_.send_n (buf,
+ n,
+ flags);
+#elif defined (ACE_HAS_FORE_ATM_WS2)
+ return stream_.send_n (buf,
+ n,
+ flags);
+#else
+ ACE_UNUSED_ARG(buf);
+ ACE_UNUSED_ARG(n);
+ ACE_UNUSED_ARG(flags);
+ return 0;
+#endif /* ACE_HAS_FORE_ATM_XTI */
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
diff --git a/externals/ace/Acceptor.cpp b/externals/ace/Acceptor.cpp
new file mode 100644
index 0000000..e2e1ad7
--- /dev/null
+++ b/externals/ace/Acceptor.cpp
@@ -0,0 +1,1246 @@
+#ifndef ACE_ACCEPTOR_CPP
+#define ACE_ACCEPTOR_CPP
+
+#include "ace/ACE.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ace/Acceptor.h"
+#include "ace/Handle_Set.h"
+#include "ace/Svc_Handler.h"
+#include "ace/WFMO_Reactor.h"
+#include "ace/OS_NS_stdio.h"
+#include "ace/OS_NS_string.h"
+#include "ace/OS_NS_sys_select.h"
+
+ACE_RCSID (ace,
+ Acceptor,
+ "$Id: Acceptor.cpp 84935 2009-03-22 19:21:58Z schmidt $")
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Acceptor)
+
+template void
+ACE_Acceptor::dump (void) const
+{
+#if defined (ACE_HAS_DUMP)
+ ACE_TRACE ("ACE_Acceptor::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ this->peer_acceptor_.dump ();
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+#endif /* ACE_HAS_DUMP */
+}
+
+template
+ACE_Acceptor::operator ACE_PEER_ACCEPTOR & () const
+{
+ ACE_TRACE ("ACE_Acceptor::operator ACE_PEER_ACCEPTOR &");
+ return (ACE_PEER_ACCEPTOR &) this->peer_acceptor_;
+}
+
+template ACE_PEER_ACCEPTOR &
+ACE_Acceptor::acceptor (void) const
+{
+ ACE_TRACE ("ACE_Acceptor::acceptor");
+ return const_cast (this->peer_acceptor_);
+}
+
+// Returns ACE_HANDLE of the underlying Acceptor_Strategy.
+
+template ACE_HANDLE
+ACE_Acceptor::get_handle (void) const
+{
+ ACE_TRACE ("ACE_Acceptor::get_handle");
+ return this->peer_acceptor_.get_handle ();
+}
+
+// Initialize the appropriate strategies for creation, passive
+// connection acceptance, and concurrency, and then register
+// with the Reactor and listen for connection requests at the
+// designated .
+
+template int
+ACE_Acceptor::open
+ (const ACE_PEER_ACCEPTOR_ADDR &local_addr,
+ ACE_Reactor *reactor,
+ int flags,
+ int use_select,
+ int reuse_addr)
+{
+ ACE_TRACE ("ACE_Acceptor::open");
+ this->flags_ = flags;
+ this->use_select_ = use_select;
+ this->reuse_addr_ = reuse_addr;
+ this->peer_acceptor_addr_ = local_addr;
+
+ // Must supply a valid Reactor to Acceptor::open()...
+
+ if (reactor == 0)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ if (this->peer_acceptor_.open (local_addr, reuse_addr) == -1)
+ return -1;
+
+ // Set the peer acceptor's handle into non-blocking mode. This is a
+ // safe-guard against the race condition that can otherwise occur
+ // between the time when