diff --git a/pvpgn/BUGS b/BUGS similarity index 100% rename from pvpgn/BUGS rename to BUGS diff --git a/pvpgn/CMakeLists.txt b/CMakeLists.txt similarity index 100% rename from pvpgn/CMakeLists.txt rename to CMakeLists.txt diff --git a/d2pack109/COPYING b/COPYING similarity index 100% rename from d2pack109/COPYING rename to COPYING diff --git a/pvpgn/CREDITS b/CREDITS similarity index 100% rename from pvpgn/CREDITS rename to CREDITS diff --git a/pvpgn/ConfigureChecks.cmake b/ConfigureChecks.cmake similarity index 100% rename from pvpgn/ConfigureChecks.cmake rename to ConfigureChecks.cmake diff --git a/pvpgn/IGNOREME b/IGNOREME similarity index 100% rename from pvpgn/IGNOREME rename to IGNOREME diff --git a/pvpgn/NEWS b/NEWS similarity index 100% rename from pvpgn/NEWS rename to NEWS diff --git a/pvpgn/README.ALPHA b/README.ALPHA similarity index 100% rename from pvpgn/README.ALPHA rename to README.ALPHA diff --git a/pvpgn/README.DEV b/README.DEV similarity index 100% rename from pvpgn/README.DEV rename to README.DEV diff --git a/pvpgn/README.cmake b/README.cmake similarity index 100% rename from pvpgn/README.cmake rename to README.cmake diff --git a/README.md b/README.md index 1bb012e..e84fd4b 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,6 @@ New commands * `/save` immediately save changes of accounts and clans from the cache to a storage (useful for testing) [commit](https://github.com/HarpyWar/pvpgn/commit/be8d65d16f910b2090b0db9e7eb2c043b816dae7) - Minor changes -- * add original MOTD files with UTF-8 encoding @@ -26,7 +25,8 @@ Minor changes * add ODBC support for CMake * add latest versioncheck.conf * skip_versioncheck, allow_bad_version are enabled by default in bnetd.conf - for easy start - +* source code is formatted for better reading +* unused files are removed, only pvpgn source here Build source code -- diff --git a/pvpgn/TODO b/TODO similarity index 100% rename from pvpgn/TODO rename to TODO diff --git a/pvpgn/UPDATE b/UPDATE similarity index 100% rename from pvpgn/UPDATE rename to UPDATE diff --git a/pvpgn/cmake/Modules/CheckIncludeFilesCXX.cmake b/cmake/Modules/CheckIncludeFilesCXX.cmake similarity index 100% rename from pvpgn/cmake/Modules/CheckIncludeFilesCXX.cmake rename to cmake/Modules/CheckIncludeFilesCXX.cmake diff --git a/pvpgn/cmake/Modules/CheckMkdirArgs.cmake b/cmake/Modules/CheckMkdirArgs.cmake similarity index 100% rename from pvpgn/cmake/Modules/CheckMkdirArgs.cmake rename to cmake/Modules/CheckMkdirArgs.cmake diff --git a/pvpgn/cmake/Modules/CheckTypeSizeCXX.cmake b/cmake/Modules/CheckTypeSizeCXX.cmake similarity index 100% rename from pvpgn/cmake/Modules/CheckTypeSizeCXX.cmake rename to cmake/Modules/CheckTypeSizeCXX.cmake diff --git a/pvpgn/cmake/Modules/CheckTypeSizeCXX.cxx.in b/cmake/Modules/CheckTypeSizeCXX.cxx.in similarity index 100% rename from pvpgn/cmake/Modules/CheckTypeSizeCXX.cxx.in rename to cmake/Modules/CheckTypeSizeCXX.cxx.in diff --git a/pvpgn/cmake/Modules/DefineInstallationPaths.cmake b/cmake/Modules/DefineInstallationPaths.cmake similarity index 100% rename from pvpgn/cmake/Modules/DefineInstallationPaths.cmake rename to cmake/Modules/DefineInstallationPaths.cmake diff --git a/pvpgn/cmake/Modules/FindMySQL.cmake b/cmake/Modules/FindMySQL.cmake similarity index 100% rename from pvpgn/cmake/Modules/FindMySQL.cmake rename to cmake/Modules/FindMySQL.cmake diff --git a/pvpgn/cmake/Modules/FindODBC.cmake b/cmake/Modules/FindODBC.cmake similarity index 100% rename from pvpgn/cmake/Modules/FindODBC.cmake rename to cmake/Modules/FindODBC.cmake diff --git a/pvpgn/cmake/Modules/FindPostgreSQL.cmake b/cmake/Modules/FindPostgreSQL.cmake similarity index 100% rename from pvpgn/cmake/Modules/FindPostgreSQL.cmake rename to cmake/Modules/FindPostgreSQL.cmake diff --git a/pvpgn/cmake/Modules/FindSQLite3.cmake b/cmake/Modules/FindSQLite3.cmake similarity index 100% rename from pvpgn/cmake/Modules/FindSQLite3.cmake rename to cmake/Modules/FindSQLite3.cmake diff --git a/pvpgn/cmake/Modules/FindZLIB.cmake b/cmake/Modules/FindZLIB.cmake similarity index 100% rename from pvpgn/cmake/Modules/FindZLIB.cmake rename to cmake/Modules/FindZLIB.cmake diff --git a/pvpgn/conf/CMakeLists.txt b/conf/CMakeLists.txt similarity index 100% rename from pvpgn/conf/CMakeLists.txt rename to conf/CMakeLists.txt diff --git a/pvpgn/conf/Makefile.am b/conf/Makefile.am similarity index 100% rename from pvpgn/conf/Makefile.am rename to conf/Makefile.am diff --git a/pvpgn/conf/ad.conf.in b/conf/ad.conf.in similarity index 100% rename from pvpgn/conf/ad.conf.in rename to conf/ad.conf.in diff --git a/pvpgn/conf/address_translation.conf.in b/conf/address_translation.conf.in similarity index 100% rename from pvpgn/conf/address_translation.conf.in rename to conf/address_translation.conf.in diff --git a/pvpgn/conf/anongame_infos.conf.in b/conf/anongame_infos.conf.in similarity index 100% rename from pvpgn/conf/anongame_infos.conf.in rename to conf/anongame_infos.conf.in diff --git a/pvpgn/conf/autoupdate.conf.in b/conf/autoupdate.conf.in similarity index 98% rename from pvpgn/conf/autoupdate.conf.in rename to conf/autoupdate.conf.in index 26953ac..a4fb468 100644 --- a/pvpgn/conf/autoupdate.conf.in +++ b/conf/autoupdate.conf.in @@ -1,518 +1,518 @@ -############################################################################## -# autoupdate.conf - Auto Update Configuration # -#----------------------------------------------------------------------------# -# # -# This is a list of client tags and their equivalent autoupdate files and # -# version information. # -# # -# This file will be ignored for certain clients if skip_versioncheck is # -# enabled in the bnetd.conf file. # -# # -# Only the first matching line is used. If no lines match then no upgrade # -# will be attempted and the client will remain at its current version. # -# # -# Note: if you want to use the autoupdate wildcard entries, you'll also need # -# to uncomment the corresponding wildcard entries in versioncheck.conf. # -# # -# Do not include "/" in any of the filenames. # -# # -# The versiontag is used to identify a particular version as specified in # -# the versioncheck configuration file. # -# # -# It works like this: versioncheck identifies a version by reported version # -# number, checksum, clienttag, etc. The autoupdate then uses the arch tag, # -# client tag and version tag to find the needed update file. # -# # -############################################################################## -# Battle.net related informations # -#----------------------------------------------------------------------------# -# War3 and War3x clients have different mpq files for the different game # -# languages. This is accounted for by the server, and the client will get # -# the correct file. Only one entry is needed per arch, client, and version # -# tag. # -# # -# Example: With the following line: # -# # -# IX86 W3XP W3XP_107A W3XP_IX86_1xx_111A.mpq # -# # -# war3x english clients will receive the file "W3XP_IX86_1xx_111A_enUS.mpq" # -# where russian clients will receive the file "W3XP_IX86_1xx_111A_ruRU.mpq" # -# and german clients will receive the file "W3XP_IX86_1xx_111A_deDE.mpq" # -# Make sure all the required mpq files are in the files directory or # -# autoupdate will not work. # -# # -# The avaliable language files are: # -# # -# enUS csCZ deDE esES frFR itIT jaJA koKR plPL ruRU zhCN zhTW # -# # -# The format of this file is as follows: # -# # -# archtag clienttag versiontag -----update file----- # -# # -############################################################################## -# Westwood Online related informations # -#----------------------------------------------------------------------------# -# For WOL autoupdate is used standart FTP protocol which is not included in # -# PvPGN. The default WOL autoupdate entryes are writed according to # -# westwood's autoupdate FTP server settings (username, password, filepath). # -# # -# WOLv2 using diferent rtp files for the diferent SKUs. This is accounted # -# for by the server, and the client will get the correct file. Only one # -# entry is needed per arch, client, and version tag. # -# # -# Example: With the following line: # -# IX86 TSUN 65536 131075_65536.rtp tibsun # -# # -# TibSun clients with SKU 4608 will receive the file "131075_65536_4608.rtp" # -# TibSun clients with SKU 4610 will receive the file "131075_65536_4610.rtp" # -# # -# The avaliable clients, theirs tags and SKUs are: # -# # -# Client name CTag SKUs # -# --------------------------------------------------- # -# Renegade RNGD 3072 3074 3075 3078 3081 3082 # -# Dune 2000 DN2K 3584 3586 3587 3589 3591 # -# Nox NOXX 4096 4098 4099 4101 4102 4105 # -# Tiberian Sun TSUN 4608 4610 4611 4615 # -# Red Alert 1v3 RALT 5376 5378 5379 # -# Lands of Lore 3 LOR3 6400 6401 6402 6403 6405 # -# Tiberian Sun XP TSXP 7168 7170 7171 7175 7424 7426 7427 7431 # -# Emperor: BFD EBFD 7936 7938 7939 7945 7946 # -# Red Alert 2 RAL2 8448 8450 8451 8457 8458 8960 8962 8963 8969 8970 # -# Nox Quest NOXQ 9472 9474 9475 9477 9478 9481 # -# Yuri's Revenge YURI 10496 10498 10499 10505 10506 # -# Renegade Server RFDS 12288 # -# WOL API WWOL 32512 # -# # -# Note: WOL update entry must including file path according to FTP server. # -# All WOL entries using archtag IX86. # -# # -# The format of this file is as follows: # -# # -# archtag clienttag versiontag -----update file----- file path # -# # -############################################################################## - -##### Intel (IX86) ########################################################### - -# =============== WarCraft III - FT (Expansion) =============== -#IX86 W3XP W3XP_107A W3XP_IX86_1xx_122a_2.mpq -#IX86 W3XP W3XP_110A W3XP_IX86_1xx_122a_2.mpq -#IX86 W3XP W3XP_111A W3XP_IX86_1xx_122a_2.mpq -#IX86 W3XP W3XP_112A W3XP_IX86_1xx_122a_2.mpq -#IX86 W3XP W3XP_113A W3XP_IX86_1xx_122a_2.mpq -#IX86 W3XP W3XP_113B W3XP_IX86_1xx_122a_2.mpq -#IX86 W3XP W3XP_114A W3XP_IX86_1xx_122a_2.mpq -#IX86 W3XP W3XP_114B W3XP_IX86_1xx_122a_2.mpq -#IX86 W3XP W3XP_115A W3XP_IX86_1xx_122a_2.mpq -#IX86 W3XP W3XP_116A W3XP_IX86_1xx_122a_2.mpq -#IX86 W3XP W3XP_117A W3XP_IX86_1xx_122a_2.mpq -#IX86 W3XP W3XP_118A W3XP_IX86_1xx_122a_2.mpq -#IX86 W3XP W3XP_119A W3XP_IX86_1xx_122a_2.mpq -#IX86 W3XP W3XP_119B W3XP_IX86_1xx_122a_2.mpq -#IX86 W3XP W3XP_120A W3XP_IX86_1xx_122a_2.mpq -#IX86 W3XP W3XP_120B W3XP_IX86_1xx_122a_2.mpq -#IX86 W3XP W3XP_120C W3XP_IX86_1xx_122a_2.mpq -#IX86 W3XP W3XP_120D W3XP_IX86_1xx_122a_2.mpq -#IX86 W3XP W3XP_120E W3XP_IX86_1xx_122a_2.mpq -#IX86 W3XP W3XP_121A W3XP_IX86_1xx_122a_2.mpq - -# Incremental update from version 1.21b -#IX86 W3XP W3XP_121B W3XP_IX86_121B_122a_2.mpq - -# The next one is a WarCraft III - FT wildcard entry. -#IX86 W3XP W3XP_1xx W3XP_IX86_1xx_122a_2.mpq - -# ==================== WarCraft III - RoC ===================== -#IX86 WAR3 WAR3_107A WAR3_IX86_1xx_122a_2.mpq -#IX86 WAR3 WAR3_110A WAR3_IX86_1xx_122a_2.mpq -#IX86 WAR3 WAR3_111A WAR3_IX86_1xx_122a_2.mpq -#IX86 WAR3 WAR3_112A WAR3_IX86_1xx_122a_2.mpq -#IX86 WAR3 WAR3_113A WAR3_IX86_1xx_122a_2.mpq -#IX86 WAR3 WAR3_113B WAR3_IX86_1xx_122a_2.mpq -#IX86 WAR3 WAR3_114A WAR3_IX86_1xx_122a_2.mpq -#IX86 WAR3 WAR3_114B WAR3_IX86_1xx_122a_2.mpq -#IX86 WAR3 WAR3_115A WAR3_IX86_1xx_122a_2.mpq -#IX86 WAR3 WAR3_116A WAR3_IX86_1xx_122a_2.mpq -#IX86 WAR3 WAR3_117A WAR3_IX86_1xx_122a_2.mpq -#IX86 WAR3 WAR3_118A WAR3_IX86_1xx_122a_2.mpq -#IX86 WAR3 WAR3_119A WAR3_IX86_1xx_122a_2.mpq -#IX86 WAR3 WAR3_119B WAR3_IX86_1xx_122a_2.mpq -#IX86 WAR3 WAR3_120A WAR3_IX86_1xx_122a_2.mpq -#IX86 WAR3 WAR3_120B WAR3_IX86_1xx_122a_2.mpq -#IX86 WAR3 WAR3_120C WAR3_IX86_1xx_122a_2.mpq -#IX86 WAR3 WAR3_120D WAR3_IX86_1xx_122a_2.mpq -#IX86 WAR3 WAR3_120E WAR3_IX86_1xx_122a_2.mpq -#IX86 WAR3 WAR3_121A WAR3_IX86_1xx_122a_2.mpq - -# Incremental update from version 1.21b -#IX86 WAR3 WAR3_121B WAR3_IX86_121B_122a_2.mpq - -# The next one is a WarCraft III - RoC wildcard entry. -#IX86 WAR3 WAR3_1xx WAR3_IX86_1xx_122a_2.mpq - -# ===================== Diablo II Expansion (LoD) =========================== -# Note: the following assumes that you want to upgrade all Diablo II clients -# to version 1.11b. If you are still running a 1.10 or 1.09d realm, you -# will need to modify these entries accordingly. - -#IX86 D2XP D2XP_107 D2XP_IX86_1xx_112A.mpq -#IX86 D2XP D2XP_108 D2XP_IX86_1xx_112A.mpq -#IX86 D2XP D2XP_109 D2XP_IX86_1xx_112A.mpq -#IX86 D2XP D2XP_109B D2XP_IX86_1xx_112A.mpq -#IX86 D2XP D2XP_109C D2XP_IX86_1xx_112A.mpq -#IX86 D2XP D2XP_109D D2XP_IX86_1xx_112A.mpq -#IX86 D2XP D2XP_110 D2XP_IX86_1xx_112A.mpq -#IX86 D2XP D2XP_111 D2XP_IX86_1xx_112A.mpq - -# Incremental update from version 1.11a --> 1.11b -#IX86 D2XP D2XP_111B D2XP_IX86_111B_112A.mpq - -# The next one is a Diablo II LoD wildcard entry. -#IX86 D2XP D2XP_1xx D2XP_IX86_1xx_112A.mpq - -# ========================== Diablo II (DV) ================================= -# Note: the following assumes that you want to upgrade all Diablo II clients -# to version 1.11b. If you are still running a 1.10 or 1.09d realm, you -# will need to modify these entries accordingly. - -#IX86 D2DV D2DV_100 D2DV_IX86_1xx_112A.mpq -#IX86 D2DV D2DV_101 D2DV_IX86_1xx_112A.mpq -#IX86 D2DV D2DV_103 D2DV_IX86_1xx_112A.mpq -#IX86 D2DV D2DV_104B D2DV_IX86_1xx_112A.mpq -#IX86 D2DV D2DV_104C D2DV_IX86_1xx_112A.mpq -#IX86 D2DV D2DV_105 D2DV_IX86_1xx_112A.mpq -#IX86 D2DV D2DV_105B D2DV_IX86_1xx_112A.mpq -#IX86 D2DV D2DV_106 D2DV_IX86_1xx_112A.mpq -#IX86 D2DV D2DV_106B D2DV_IX86_1xx_112A.mpq -#IX86 D2DV D2DV_108 D2DV_IX86_1xx_112A.mpq -#IX86 D2DV D2DV_109 D2DV_IX86_1xx_112A.mpq -#IX86 D2DV D2DV_109B D2DV_IX86_1xx_112A.mpq -#IX86 D2DV D2DV_109C D2DV_IX86_1xx_112A.mpq -#IX86 D2DV D2DV_109D D2DV_IX86_1xx_112A.mpq -#IX86 D2DV D2DV_110 D2DV_IX86_1xx_112A.mpq -#IX86 D2DV D2DV_111 D2DV_IX86_1xx_112A.mpq - -# Incremental update from version 1.11a --> 1.11b -#IX86 D2DV D2DV_111B D2DV_IX86_111B_112A.mpq - -# The next one is a Diablo II wildcard entry. -#IX86 D2DV D2DV_1xx D2DV_IX86_1xx_112A.mpq - -# ================ StarCraft Expansion (Brood War) ========================== -#IX86 SEXP SEXP_104 SEXP_IX86_1xx_1161.mpq -#IX86 STAR SEXP_104_STAR SEXP_IX86_1xx_1161.mpq -#IX86 SEXP SEXP_105 SEXP_IX86_1xx_1161.mpq -#IX86 STAR SEXP_105_STAR SEXP_IX86_1xx_1161.mpq -#IX86 SEXP SEXP_106 SEXP_IX86_1xx_1161.mpq -#IX86 STAR SEXP_106_STAR SEXP_IX86_1xx_1161.mpq -#IX86 SEXP SEXP_107 SEXP_IX86_1xx_1161.mpq -#IX86 STAR SEXP_107_STAR SEXP_IX86_1xx_1161.mpq -#IX86 SEXP SEXP_108 SEXP_IX86_1xx_1161.mpq -#IX86 STAR SEXP_108_STAR SEXP_IX86_1xx_1161.mpq -#IX86 SEXP SEXP_108B SEXP_IX86_1xx_1161.mpq -#IX86 STAR SEXP_108B_STAR SEXP_IX86_1xx_1161.mpq -#IX86 SEXP SEXP_109 SEXP_IX86_1xx_1161.mpq -#IX86 STAR SEXP_109_STAR SEXP_IX86_1xx_1161.mpq -#IX86 SEXP SEXP_110 SEXP_IX86_1xx_1161.mpq -#IX86 STAR SEXP_110_STAR SEXP_IX86_1xx_1161.mpq -#IX86 SEXP SEXP_111 SEXP_IX86_1xx_1161.mpq -#IX86 STAR SEXP_111_STAR SEXP_IX86_1xx_1161.mpq -#IX86 SEXP SEXP_111B SEXP_IX86_1xx_1161.mpq -#IX86 STAR SEXP_111B_STAR SEXP_IX86_1xx_1161.mpq -#IX86 SEXP SEXP_112 SEXP_IX86_1xx_1161.mpq -#IX86 STAR SEXP_112_STAR SEXP_IX86_1xx_1161.mpq -#IX86 SEXP SEXP_112B SEXP_IX86_1xx_1161.mpq -#IX86 STAR SEXP_112B_STAR SEXP_IX86_1xx_1161.mpq -#IX86 SEXP SEXP_113 SEXP_IX86_1xx_1161.mpq -# unfortunately we don't have a SEXP_113_STAR in versioncheck.conf -#IX86 SEXP SEXP_113B SEXP_IX86_1xx_1161.mpq -#IX86 STAR SEXP_113B_STAR SEXP_IX86_1xx_1161.mpq -#IX86 SEXP SEXP_113C SEXP_IX86_1xx_1161.mpq -#IX86 STAR SEXP_113C_STAR SEXP_IX86_1xx_1161.mpq -#IX86 SEXP SEXP_113D SEXP_IX86_1xx_1161.mpq -#IX86 STAR SEXP_113D_STAR SEXP_IX86_1xx_1161.mpq -#IX86 SEXP SEXP_113E SEXP_IX86_1xx_1161.mpq -#IX86 STAR SEXP_113E SEXP_IX86_1xx_1161.mpq -#IX86 SEXP SEXP_114 SEXP_IX86_1xx_1161.mpq -#IX86 STAR SEXP_114 SEXP_IX86_1xx_1161.mpq -#IX86 SEXP SEXP_115 SEXP_IX86_1xx_1161.mpq -#IX86 STAR SEXP_115 SEXP_IX86_1xx_1161.mpq -#IX86 SEXP SEXP_1151 SEXP_IX86_1xx_1161.mpq -#IX86 STAR SEXP_1151 SEXP_IX86_1xx_1161.mpq -#IX86 SEXP SEXP_1152 SEXP_IX86_1xx_1161.mpq -#IX86 STAR SEXP_1152 SEXP_IX86_1xx_1161.mpq -#IX86 SEXP SEXP_1153 SEXP_IX86_1xx_1161.mpq -#IX86 STAR SEXP_1153 SEXP_IX86_1xx_1161.mpq - -# Incremental update from version 1.15.3 -#IX86 SEXP SEXP_116 SEXP_IX86_116_1161.mpq -#IX86 STAR SEXP_116 SEXP_IX86_116_1161.mpq - -# The next one is a Brood War wildcard entry. -#IX86 SEXP SEXP_1xx SEXP_IX86_1xx_1161.mpq - -# ========================= StarCraft (original) ============================ -#IX86 STAR STAR_100 STAR_IX86_1xx_1161.mpq -#IX86 STAR STAR_101 STAR_IX86_1xx_1161.mpq -#IX86 STAR STAR_102 STAR_IX86_1xx_1161.mpq -#IX86 STAR STAR_103 STAR_IX86_1xx_1161.mpq -#IX86 STAR STAR_104 STAR_IX86_1xx_1161.mpq -#IX86 STAR STAR_105 STAR_IX86_1xx_1161.mpq -#IX86 STAR STAR_106 STAR_IX86_1xx_1161.mpq -#IX86 STAR STAR_107 STAR_IX86_1xx_1161.mpq -#IX86 STAR STAR_108 STAR_IX86_1xx_1161.mpq -#IX86 STAR STAR_108B STAR_IX86_1xx_1161.mpq -#IX86 STAR STAR_109 STAR_IX86_1xx_1161.mpq -#IX86 STAR STAR_109B STAR_IX86_1xx_1161.mpq -#IX86 STAR STAR_110 STAR_IX86_1xx_1161.mpq -#IX86 STAR STAR_111 STAR_IX86_1xx_1161.mpq -#IX86 STAR STAR_111B STAR_IX86_1xx_1161.mpq -#IX86 STAR STAR_112 STAR_IX86_1xx_1161.mpq -#IX86 STAR STAR_112B STAR_IX86_1xx_1161.mpq -#IX86 STAR STAR_113 STAR_IX86_1xx_1161.mpq -#IX86 STAR STAR_113B STAR_IX86_1xx_1161.mpq -#IX86 STAR STAR_113C STAR_IX86_1xx_1161.mpq -#IX86 STAR STAR_113D STAR_IX86_1xx_1161.mpq -#IX86 STAR STAR_113E STAR_IX86_1xx_1161.mpq -#IX86 STAR STAR_114 STAR_IX86_1xx_1161.mpq -#IX86 STAR STAR_115 STAR_IX86_1xx_1161.mpq -#IX86 STAR STAR_1151 STAR_IX86_1xx_1161.mpq -#IX86 STAR STAR_1152 STAR_IX86_1xx_1161.mpq -#IX86 STAR STAR_1153 SEXP_IX86_1xx_1161.mpq - -# Incremental update from version 1.15.3 -#IX86 STAR STAR_116 SEXP_IX86_116_1161.mpq - -# The next one is a Starcraft wildcard entry. -#IX86 STAR STAR_1xx STAR_IX86_1xx_1161.mpq - -# ========================= Diablo (original) ============================== -# note: Blizzard doesn't update client from 109 to 109b. -#IX86 DRTL DRTL_108 DRTL_IX86_108_109.mpq - -# The next one is a Diablo wildcard entry. -#IX86 DRTL DRTL_1xx DRTL_IX86_100_109.mpq - -# ========================= Warcraft II BNE =============================== -#IX86 W2BN W2BN_200 W2BN_IX86_200_202.mpq -#IX86 W2BN W2BN_201 W2BN_IX86_201_202.mpq - -##### Mac OS X (XMAC) ######################################################## - -# ===================== Diablo II Expansion (LoD) =========================== -# Note: the following assumes that you want to upgrade all Diablo II clients -# to version 1.11b. If you are still running a 1.10 or 1.09d realm, you -# will need to modify these entries accordingly. - -#XMAC D2XP D2XP_109D D2XP_XMAC_1xx_111B.mpq -#XMAC D2XP D2XP_110 D2XP_XMAC_1xx_111B.mpq - -# Incremental update from version 1.11a --> 1.11b -#XMAC D2XP D2XP_111 D2XP_XMAC_111A_111B.mpq - -# The next one is a Diablo II LoD wildcard entry. -#XMAC D2XP D2XP_1xx D2XP_XMAC_1xx_111B.mpq - -# ========================== Diablo II (DV) ================================= -# Note: the following assumes that you want to upgrade all Diablo II clients -# to version 1.11b. If you are still running a 1.10 or 1.09d realm, you -# will need to modify these entries accordingly. - -#XMAC D2DV D2DV_109D D2DV_XMAC_1xx_111B.mpq -#XMAC D2DV D2DV_110 D2DV_XMAC_1xx_111B.mpq - -# Incremental update from version 1.11a --> 1.11b -#XMAC D2DV D2DV_111 D2DV_XMAC_111A_111B.mpq - -# The next one is a Diablo II LoD wildcard entry. -#XMAC D2DV D2DV_1xx D2DV_XMAC_1xx_111B.mpq - -# ================ StarCraft Expansion (Brood War) ========================== - -#XMAC SEXP SEXP_109B SEXP_XMAC_1xx_113E.mpq -#XMAC SEXP SEXP_110 SEXP_XMAC_1xx_113E.mpq -#XMAC STAR SEXP_110_STAR SEXP_XMAC_1xx_113E.mpq -#XMAC SEXP SEXP_111 SEXP_XMAC_1xx_113E.mpq -#XMAC STAR SEXP_111_STAR SEXP_XMAC_1xx_113E.mpq -#XMAC SEXP SEXP_111B SEXP_XMAC_1xx_113E.mpq -#XMAC STAR SEXP_111B_STAR SEXP_XMAC_1xx_113E.mpq -#XMAC SEXP SEXP_112 SEXP_XMAC_1xx_113E.mpq -#XMAC STAR SEXP_112_STAR SEXP_XMAC_1xx_113E.mpq -#XMAC SEXP SEXP_113 SEXP_XMAC_1xx_113E.mpq -#XMAC STAR SEXP_113_STAR SEXP_XMAC_1xx_113E.mpq -#XMAC SEXP SEXP_113C SEXP_XMAC_1xx_113E.mpq -#XMAC STAR SEXP_113C_STAR SEXP_XMAC_1xx_113E.mpq -# Unfortunately versioncheck.conf does not contain entries for 1.13{a|b|d} - -# The next one is a Brood War wildcard entry. -#XMAC SEXP SEXP_1xx SEXP_XMAC_1xx_113E.mpq - -# ========================= StarCraft (original) ============================ - -#XMAC STAR STAR_109B STAR_XMAC_1xx_113E.mpq -#XMAC STAR STAR_110 STAR_XMAC_1xx_113E.mpq -#XMAC STAR STAR_111 STAR_XMAC_1xx_113E.mpq -#XMAC STAR STAR_111B STAR_XMAC_1xx_113E.mpq -#XMAC STAR STAR_112 STAR_XMAC_1xx_113E.mpq -# Unfortunately versioncheck.conf does not contain entries for 1.13{a-d} - -# The next one is a Starcraft wildcard entry. -#XMAC STAR STAR_1xx STAR_XMAC_1xx_113E.mpq - -##### Mac OS Classic (PMAC) ################################################## - -# ===================== Diablo II Expansion (LoD) =========================== -# Note: the following assumes that you want to upgrade all Diablo II clients -# to version 1.11b. If you are still running a 1.10 or 1.09d realm, you -# will need to modify these entries accordingly. - -#PMAC D2XP D2XP_1xx D2XP_PMAC_1xx_111B.mpq - -# ========================== Diablo II (DV) ================================= -# Note: the following assumes that you want to upgrade all Diablo II clients -# to version 1.11b. If you are still running a 1.10 or 1.09d realm, you -# will need to modify these entries accordingly. - -#PMAC D2DV D2DV_109D D2DV_PMAC_1xx_111B.mpq -#PMAC D2DV D2DV_1xx D2DV_PMAC_1xx_111B.mpq - -# ================ StarCraft Expansion (Brood War) ========================== - -#PMAC SEXP SEXP_109B SEXP_PMAC_1xx_113E.mpq -#PMAC SEXP SEXP_110 SEXP_PMAC_1xx_113E.mpq -#PMAC STAR SEXP_110_STAR SEXP_PMAC_1xx_113E.mpq -#PMAC SEXP SEXP_111 SEXP_PMAC_1xx_113E.mpq -#PMAC STAR SEXP_111_STAR SEXP_PMAC_1xx_113E.mpq -#PMAC SEXP SEXP_111B SEXP_PMAC_1xx_113E.mpq -#PMAC STAR SEXP_111B_STAR SEXP_PMAC_1xx_113E.mpq -#PMAC SEXP SEXP_112 SEXP_PMAC_1xx_113E.mpq -#PMAC STAR SEXP_112_STAR SEXP_PMAC_1xx_113E.mpq - -# The next one is a Brood War wildcard entry. -#PMAC SEXP SEXP_1xx SEXP_PMAC_1xx_113E.mpq - -# ========================= StarCraft (original) ============================ - -#PMAC STAR STAR_109B STAR_PMAC_1xx_113E.mpq -#PMAC STAR STAR_110 STAR_PMAC_1xx_113E.mpq -#PMAC STAR STAR_111 STAR_PMAC_1xx_113E.mpq -#PMAC STAR STAR_111B STAR_PMAC_1xx_113E.mpq -#PMAC STAR STAR_112 STAR_PMAC_1xx_113E.mpq - -# The next one is a Brood War wildcard entry. -#PMAC STAR STAR_1xx STAR_PMAC_1xx_113E.mpq - -##### Westwood Online update entries ######################################### - -# ========================== Westwood Online API ============================ - -#IX86 WWOL 65536 65551_65536.rtp wolapi -#IX86 WWOL 65537 65551_65537.rtp wolapi -#IX86 WWOL 65538 65551_65538.rtp wolapi -#IX86 WWOL 65539 65551_65539.rtp wolapi -#IX86 WWOL 65540 65551_65540.rtp wolapi -#IX86 WWOL 65541 65551_65541.rtp wolapi -#IX86 WWOL 65542 65551_65542.rtp wolapi -#IX86 WWOL 65543 65551_65543.rtp wolapi -#IX86 WWOL 65544 65551_65544.rtp wolapi -#IX86 WWOL 65545 65551_65545.rtp wolapi -#IX86 WWOL 65546 65551_65546.rtp wolapi -#IX86 WWOL 65547 65551_65547.rtp wolapi -#IX86 WWOL 65548 65551_65548.rtp wolapi -#IX86 WWOL 65549 65551_65549.rtp wolapi -#IX86 WWOL 65550 65551_65550.rtp wolapi -#IX86 WWOL 65555 65556_65555.rtp wolapi - -# =============================== Renegade ================================== - -#IX86 RNGD 65538 65573_65538.rtp renegade -#IX86 RNGD 65550 65573_65538.rtp renegade -#IX86 RNGD 65551 65573_65538.rtp renegade -#IX86 RNGD 65566 65573_65538.rtp renegade -#IX86 RNGD 65567 65573_65538.rtp renegade -#IX86 RNGD 65568 65573_65538.rtp renegade -#IX86 RNGD 65570 65573_65570.rtp renegade -#IX86 RNGD 65571 65573_65571.rtp renegade -#IX86 RNGD 65572 65573_65572.rtp renegade - -# ==================== Renegade Free Dedicated Server ======================= - -#IX86 RFDS 65538 65572_65538.rtp renegade -#IX86 RFDS 65550 65572_65550.rtp renegade -#IX86 RFDS 65551 65572_65551.rtp renegade -#IX86 RFDS 65553 65572_65553.rtp renegade -#IX86 RFDS 65554 65572_65554.rtp renegade -#IX86 RFDS 65566 65572_65566.rtp renegade -#IX86 RFDS 65568 65572_65568.rtp renegade -#IX86 RFDS 65570 65572_65570.rtp renegade -#IX86 RFDS 65571 65572_65571.rtp renegade -#IX86 RFDS 65572 65573_65572.rtp renegade - -# ============================= Tiberian Sun ================================ - -#IX86 TSUN 65536 131075_65536.rtp tibsun -#IX86 TSUN 65541 131075_65536.rtp tibsun -#IX86 TSUN 65542 131075_65536.rtp tibsun -#IX86 TSUN 65543 131075_65536.rtp tibsun -#IX86 TSUN 65544 131075_65536.rtp tibsun -#IX86 TSUN 65545 131075_65536.rtp tibsun -#IX86 TSUN 65546 131075_65536.rtp tibsun -#IX86 TSUN 65547 131075_65536.rtp tibsun -#IX86 TSUN 65548 131075_65548.rtp tibsun -#IX86 TSUN 131072 131075_65548.rtp tibsun -#IX86 TSUN 131074 131075_131074.rtp tibsun - -# ======================= Tiberian Sun: FireStorm =========================== - -#IX86 TSXP 131072 131074_131072.rtp tibsun -#IX86 TSXP 131074 131075_131074.rtp tibsun - -# =============================== Dune 2000 ================================= - -#IX86 DN2K 65536 65542.rtp dune2k/1.006/1.000 -#IX86 DN2K 65537 65542_65537.rtp dune2k/1.006/1.001 - -# ================================== NOX ==================================== - -#IX86 NOXX 65536 65538_65536.rtp nox -#IX86 NOXX 65537 65538_65537.rtp nox - -# =============================== NOX: Quest ================================ - -#IX86 NOXQ 65536 65538_65536.rtp nox -#IX86 NOXQ 65537 65538_65537.rtp nox -#IX86 NOXQ 65538 65540_65538.rtp nox -#IX86 NOXQ 65539 65540_65539.rtp nox - -# ======================= Emperor: Battle for Dune ========================== - -#IX86 EBFD 1 65545_1.rtp emperor -#IX86 EBFD 65536 65545_65536.rtp emperor -#IX86 EBFD 65537 65545_65537.rtp emperor -#IX86 EBFD 65538 65545_65538.rtp emperor -#IX86 EBFD 65539 65545_65539.rtp emperor -#IX86 EBFD 65540 65545_65540.rtp emperor -#IX86 EBFD 65541 65545_65541.rtp emperor -#IX86 EBFD 65542 65545_65542.rtp emperor -#IX86 EBFD 65543 65545_65543.rtp emperor -#IX86 EBFD 65544 65545_65544.rtp emperor - -# ============================= Red Alert 2 ================================= - -#IX86 RAL2 65536 65542_65536.rtp ra2 -#IX86 RAL2 65537 65542_65537.rtp ra2 -#IX86 RAL2 65538 65542_65538.rtp ra2 -#IX86 RAL2 65539 65542_65539.rtp ra2 -#IX86 RAL2 65540 65542_65540.rtp ra2 -#IX86 RAL2 65541 65542_65541.rtp ra2 - -# ============================= Yuri's Revenge ============================== - -#IX86 YURI 65536 65537_65536.rtp yuri - -# ============================= Lands of Lore 3 ============================= - -#IX86 LOR3 65536 65539_65536.rtp lore3/1.003 -#IX86 LOR3 65537 65539_65537.rtp lore3/1.003 -#IX86 LOR3 65538 65539_65538.rtp lore3/1.003 +############################################################################## +# autoupdate.conf - Auto Update Configuration # +#----------------------------------------------------------------------------# +# # +# This is a list of client tags and their equivalent autoupdate files and # +# version information. # +# # +# This file will be ignored for certain clients if skip_versioncheck is # +# enabled in the bnetd.conf file. # +# # +# Only the first matching line is used. If no lines match then no upgrade # +# will be attempted and the client will remain at its current version. # +# # +# Note: if you want to use the autoupdate wildcard entries, you'll also need # +# to uncomment the corresponding wildcard entries in versioncheck.conf. # +# # +# Do not include "/" in any of the filenames. # +# # +# The versiontag is used to identify a particular version as specified in # +# the versioncheck configuration file. # +# # +# It works like this: versioncheck identifies a version by reported version # +# number, checksum, clienttag, etc. The autoupdate then uses the arch tag, # +# client tag and version tag to find the needed update file. # +# # +############################################################################## +# Battle.net related informations # +#----------------------------------------------------------------------------# +# War3 and War3x clients have different mpq files for the different game # +# languages. This is accounted for by the server, and the client will get # +# the correct file. Only one entry is needed per arch, client, and version # +# tag. # +# # +# Example: With the following line: # +# # +# IX86 W3XP W3XP_107A W3XP_IX86_1xx_111A.mpq # +# # +# war3x english clients will receive the file "W3XP_IX86_1xx_111A_enUS.mpq" # +# where russian clients will receive the file "W3XP_IX86_1xx_111A_ruRU.mpq" # +# and german clients will receive the file "W3XP_IX86_1xx_111A_deDE.mpq" # +# Make sure all the required mpq files are in the files directory or # +# autoupdate will not work. # +# # +# The avaliable language files are: # +# # +# enUS csCZ deDE esES frFR itIT jaJA koKR plPL ruRU zhCN zhTW # +# # +# The format of this file is as follows: # +# # +# archtag clienttag versiontag -----update file----- # +# # +############################################################################## +# Westwood Online related informations # +#----------------------------------------------------------------------------# +# For WOL autoupdate is used standart FTP protocol which is not included in # +# PvPGN. The default WOL autoupdate entryes are writed according to # +# westwood's autoupdate FTP server settings (username, password, filepath). # +# # +# WOLv2 using diferent rtp files for the diferent SKUs. This is accounted # +# for by the server, and the client will get the correct file. Only one # +# entry is needed per arch, client, and version tag. # +# # +# Example: With the following line: # +# IX86 TSUN 65536 131075_65536.rtp tibsun # +# # +# TibSun clients with SKU 4608 will receive the file "131075_65536_4608.rtp" # +# TibSun clients with SKU 4610 will receive the file "131075_65536_4610.rtp" # +# # +# The avaliable clients, theirs tags and SKUs are: # +# # +# Client name CTag SKUs # +# --------------------------------------------------- # +# Renegade RNGD 3072 3074 3075 3078 3081 3082 # +# Dune 2000 DN2K 3584 3586 3587 3589 3591 # +# Nox NOXX 4096 4098 4099 4101 4102 4105 # +# Tiberian Sun TSUN 4608 4610 4611 4615 # +# Red Alert 1v3 RALT 5376 5378 5379 # +# Lands of Lore 3 LOR3 6400 6401 6402 6403 6405 # +# Tiberian Sun XP TSXP 7168 7170 7171 7175 7424 7426 7427 7431 # +# Emperor: BFD EBFD 7936 7938 7939 7945 7946 # +# Red Alert 2 RAL2 8448 8450 8451 8457 8458 8960 8962 8963 8969 8970 # +# Nox Quest NOXQ 9472 9474 9475 9477 9478 9481 # +# Yuri's Revenge YURI 10496 10498 10499 10505 10506 # +# Renegade Server RFDS 12288 # +# WOL API WWOL 32512 # +# # +# Note: WOL update entry must including file path according to FTP server. # +# All WOL entries using archtag IX86. # +# # +# The format of this file is as follows: # +# # +# archtag clienttag versiontag -----update file----- file path # +# # +############################################################################## + +##### Intel (IX86) ########################################################### + +# =============== WarCraft III - FT (Expansion) =============== +#IX86 W3XP W3XP_107A W3XP_IX86_1xx_122a_2.mpq +#IX86 W3XP W3XP_110A W3XP_IX86_1xx_122a_2.mpq +#IX86 W3XP W3XP_111A W3XP_IX86_1xx_122a_2.mpq +#IX86 W3XP W3XP_112A W3XP_IX86_1xx_122a_2.mpq +#IX86 W3XP W3XP_113A W3XP_IX86_1xx_122a_2.mpq +#IX86 W3XP W3XP_113B W3XP_IX86_1xx_122a_2.mpq +#IX86 W3XP W3XP_114A W3XP_IX86_1xx_122a_2.mpq +#IX86 W3XP W3XP_114B W3XP_IX86_1xx_122a_2.mpq +#IX86 W3XP W3XP_115A W3XP_IX86_1xx_122a_2.mpq +#IX86 W3XP W3XP_116A W3XP_IX86_1xx_122a_2.mpq +#IX86 W3XP W3XP_117A W3XP_IX86_1xx_122a_2.mpq +#IX86 W3XP W3XP_118A W3XP_IX86_1xx_122a_2.mpq +#IX86 W3XP W3XP_119A W3XP_IX86_1xx_122a_2.mpq +#IX86 W3XP W3XP_119B W3XP_IX86_1xx_122a_2.mpq +#IX86 W3XP W3XP_120A W3XP_IX86_1xx_122a_2.mpq +#IX86 W3XP W3XP_120B W3XP_IX86_1xx_122a_2.mpq +#IX86 W3XP W3XP_120C W3XP_IX86_1xx_122a_2.mpq +#IX86 W3XP W3XP_120D W3XP_IX86_1xx_122a_2.mpq +#IX86 W3XP W3XP_120E W3XP_IX86_1xx_122a_2.mpq +#IX86 W3XP W3XP_121A W3XP_IX86_1xx_122a_2.mpq + +# Incremental update from version 1.21b +#IX86 W3XP W3XP_121B W3XP_IX86_121B_122a_2.mpq + +# The next one is a WarCraft III - FT wildcard entry. +#IX86 W3XP W3XP_1xx W3XP_IX86_1xx_122a_2.mpq + +# ==================== WarCraft III - RoC ===================== +#IX86 WAR3 WAR3_107A WAR3_IX86_1xx_122a_2.mpq +#IX86 WAR3 WAR3_110A WAR3_IX86_1xx_122a_2.mpq +#IX86 WAR3 WAR3_111A WAR3_IX86_1xx_122a_2.mpq +#IX86 WAR3 WAR3_112A WAR3_IX86_1xx_122a_2.mpq +#IX86 WAR3 WAR3_113A WAR3_IX86_1xx_122a_2.mpq +#IX86 WAR3 WAR3_113B WAR3_IX86_1xx_122a_2.mpq +#IX86 WAR3 WAR3_114A WAR3_IX86_1xx_122a_2.mpq +#IX86 WAR3 WAR3_114B WAR3_IX86_1xx_122a_2.mpq +#IX86 WAR3 WAR3_115A WAR3_IX86_1xx_122a_2.mpq +#IX86 WAR3 WAR3_116A WAR3_IX86_1xx_122a_2.mpq +#IX86 WAR3 WAR3_117A WAR3_IX86_1xx_122a_2.mpq +#IX86 WAR3 WAR3_118A WAR3_IX86_1xx_122a_2.mpq +#IX86 WAR3 WAR3_119A WAR3_IX86_1xx_122a_2.mpq +#IX86 WAR3 WAR3_119B WAR3_IX86_1xx_122a_2.mpq +#IX86 WAR3 WAR3_120A WAR3_IX86_1xx_122a_2.mpq +#IX86 WAR3 WAR3_120B WAR3_IX86_1xx_122a_2.mpq +#IX86 WAR3 WAR3_120C WAR3_IX86_1xx_122a_2.mpq +#IX86 WAR3 WAR3_120D WAR3_IX86_1xx_122a_2.mpq +#IX86 WAR3 WAR3_120E WAR3_IX86_1xx_122a_2.mpq +#IX86 WAR3 WAR3_121A WAR3_IX86_1xx_122a_2.mpq + +# Incremental update from version 1.21b +#IX86 WAR3 WAR3_121B WAR3_IX86_121B_122a_2.mpq + +# The next one is a WarCraft III - RoC wildcard entry. +#IX86 WAR3 WAR3_1xx WAR3_IX86_1xx_122a_2.mpq + +# ===================== Diablo II Expansion (LoD) =========================== +# Note: the following assumes that you want to upgrade all Diablo II clients +# to version 1.11b. If you are still running a 1.10 or 1.09d realm, you +# will need to modify these entries accordingly. + +#IX86 D2XP D2XP_107 D2XP_IX86_1xx_112A.mpq +#IX86 D2XP D2XP_108 D2XP_IX86_1xx_112A.mpq +#IX86 D2XP D2XP_109 D2XP_IX86_1xx_112A.mpq +#IX86 D2XP D2XP_109B D2XP_IX86_1xx_112A.mpq +#IX86 D2XP D2XP_109C D2XP_IX86_1xx_112A.mpq +#IX86 D2XP D2XP_109D D2XP_IX86_1xx_112A.mpq +#IX86 D2XP D2XP_110 D2XP_IX86_1xx_112A.mpq +#IX86 D2XP D2XP_111 D2XP_IX86_1xx_112A.mpq + +# Incremental update from version 1.11a --> 1.11b +#IX86 D2XP D2XP_111B D2XP_IX86_111B_112A.mpq + +# The next one is a Diablo II LoD wildcard entry. +#IX86 D2XP D2XP_1xx D2XP_IX86_1xx_112A.mpq + +# ========================== Diablo II (DV) ================================= +# Note: the following assumes that you want to upgrade all Diablo II clients +# to version 1.11b. If you are still running a 1.10 or 1.09d realm, you +# will need to modify these entries accordingly. + +#IX86 D2DV D2DV_100 D2DV_IX86_1xx_112A.mpq +#IX86 D2DV D2DV_101 D2DV_IX86_1xx_112A.mpq +#IX86 D2DV D2DV_103 D2DV_IX86_1xx_112A.mpq +#IX86 D2DV D2DV_104B D2DV_IX86_1xx_112A.mpq +#IX86 D2DV D2DV_104C D2DV_IX86_1xx_112A.mpq +#IX86 D2DV D2DV_105 D2DV_IX86_1xx_112A.mpq +#IX86 D2DV D2DV_105B D2DV_IX86_1xx_112A.mpq +#IX86 D2DV D2DV_106 D2DV_IX86_1xx_112A.mpq +#IX86 D2DV D2DV_106B D2DV_IX86_1xx_112A.mpq +#IX86 D2DV D2DV_108 D2DV_IX86_1xx_112A.mpq +#IX86 D2DV D2DV_109 D2DV_IX86_1xx_112A.mpq +#IX86 D2DV D2DV_109B D2DV_IX86_1xx_112A.mpq +#IX86 D2DV D2DV_109C D2DV_IX86_1xx_112A.mpq +#IX86 D2DV D2DV_109D D2DV_IX86_1xx_112A.mpq +#IX86 D2DV D2DV_110 D2DV_IX86_1xx_112A.mpq +#IX86 D2DV D2DV_111 D2DV_IX86_1xx_112A.mpq + +# Incremental update from version 1.11a --> 1.11b +#IX86 D2DV D2DV_111B D2DV_IX86_111B_112A.mpq + +# The next one is a Diablo II wildcard entry. +#IX86 D2DV D2DV_1xx D2DV_IX86_1xx_112A.mpq + +# ================ StarCraft Expansion (Brood War) ========================== +#IX86 SEXP SEXP_104 SEXP_IX86_1xx_1161.mpq +#IX86 STAR SEXP_104_STAR SEXP_IX86_1xx_1161.mpq +#IX86 SEXP SEXP_105 SEXP_IX86_1xx_1161.mpq +#IX86 STAR SEXP_105_STAR SEXP_IX86_1xx_1161.mpq +#IX86 SEXP SEXP_106 SEXP_IX86_1xx_1161.mpq +#IX86 STAR SEXP_106_STAR SEXP_IX86_1xx_1161.mpq +#IX86 SEXP SEXP_107 SEXP_IX86_1xx_1161.mpq +#IX86 STAR SEXP_107_STAR SEXP_IX86_1xx_1161.mpq +#IX86 SEXP SEXP_108 SEXP_IX86_1xx_1161.mpq +#IX86 STAR SEXP_108_STAR SEXP_IX86_1xx_1161.mpq +#IX86 SEXP SEXP_108B SEXP_IX86_1xx_1161.mpq +#IX86 STAR SEXP_108B_STAR SEXP_IX86_1xx_1161.mpq +#IX86 SEXP SEXP_109 SEXP_IX86_1xx_1161.mpq +#IX86 STAR SEXP_109_STAR SEXP_IX86_1xx_1161.mpq +#IX86 SEXP SEXP_110 SEXP_IX86_1xx_1161.mpq +#IX86 STAR SEXP_110_STAR SEXP_IX86_1xx_1161.mpq +#IX86 SEXP SEXP_111 SEXP_IX86_1xx_1161.mpq +#IX86 STAR SEXP_111_STAR SEXP_IX86_1xx_1161.mpq +#IX86 SEXP SEXP_111B SEXP_IX86_1xx_1161.mpq +#IX86 STAR SEXP_111B_STAR SEXP_IX86_1xx_1161.mpq +#IX86 SEXP SEXP_112 SEXP_IX86_1xx_1161.mpq +#IX86 STAR SEXP_112_STAR SEXP_IX86_1xx_1161.mpq +#IX86 SEXP SEXP_112B SEXP_IX86_1xx_1161.mpq +#IX86 STAR SEXP_112B_STAR SEXP_IX86_1xx_1161.mpq +#IX86 SEXP SEXP_113 SEXP_IX86_1xx_1161.mpq +# unfortunately we don't have a SEXP_113_STAR in versioncheck.conf +#IX86 SEXP SEXP_113B SEXP_IX86_1xx_1161.mpq +#IX86 STAR SEXP_113B_STAR SEXP_IX86_1xx_1161.mpq +#IX86 SEXP SEXP_113C SEXP_IX86_1xx_1161.mpq +#IX86 STAR SEXP_113C_STAR SEXP_IX86_1xx_1161.mpq +#IX86 SEXP SEXP_113D SEXP_IX86_1xx_1161.mpq +#IX86 STAR SEXP_113D_STAR SEXP_IX86_1xx_1161.mpq +#IX86 SEXP SEXP_113E SEXP_IX86_1xx_1161.mpq +#IX86 STAR SEXP_113E SEXP_IX86_1xx_1161.mpq +#IX86 SEXP SEXP_114 SEXP_IX86_1xx_1161.mpq +#IX86 STAR SEXP_114 SEXP_IX86_1xx_1161.mpq +#IX86 SEXP SEXP_115 SEXP_IX86_1xx_1161.mpq +#IX86 STAR SEXP_115 SEXP_IX86_1xx_1161.mpq +#IX86 SEXP SEXP_1151 SEXP_IX86_1xx_1161.mpq +#IX86 STAR SEXP_1151 SEXP_IX86_1xx_1161.mpq +#IX86 SEXP SEXP_1152 SEXP_IX86_1xx_1161.mpq +#IX86 STAR SEXP_1152 SEXP_IX86_1xx_1161.mpq +#IX86 SEXP SEXP_1153 SEXP_IX86_1xx_1161.mpq +#IX86 STAR SEXP_1153 SEXP_IX86_1xx_1161.mpq + +# Incremental update from version 1.15.3 +#IX86 SEXP SEXP_116 SEXP_IX86_116_1161.mpq +#IX86 STAR SEXP_116 SEXP_IX86_116_1161.mpq + +# The next one is a Brood War wildcard entry. +#IX86 SEXP SEXP_1xx SEXP_IX86_1xx_1161.mpq + +# ========================= StarCraft (original) ============================ +#IX86 STAR STAR_100 STAR_IX86_1xx_1161.mpq +#IX86 STAR STAR_101 STAR_IX86_1xx_1161.mpq +#IX86 STAR STAR_102 STAR_IX86_1xx_1161.mpq +#IX86 STAR STAR_103 STAR_IX86_1xx_1161.mpq +#IX86 STAR STAR_104 STAR_IX86_1xx_1161.mpq +#IX86 STAR STAR_105 STAR_IX86_1xx_1161.mpq +#IX86 STAR STAR_106 STAR_IX86_1xx_1161.mpq +#IX86 STAR STAR_107 STAR_IX86_1xx_1161.mpq +#IX86 STAR STAR_108 STAR_IX86_1xx_1161.mpq +#IX86 STAR STAR_108B STAR_IX86_1xx_1161.mpq +#IX86 STAR STAR_109 STAR_IX86_1xx_1161.mpq +#IX86 STAR STAR_109B STAR_IX86_1xx_1161.mpq +#IX86 STAR STAR_110 STAR_IX86_1xx_1161.mpq +#IX86 STAR STAR_111 STAR_IX86_1xx_1161.mpq +#IX86 STAR STAR_111B STAR_IX86_1xx_1161.mpq +#IX86 STAR STAR_112 STAR_IX86_1xx_1161.mpq +#IX86 STAR STAR_112B STAR_IX86_1xx_1161.mpq +#IX86 STAR STAR_113 STAR_IX86_1xx_1161.mpq +#IX86 STAR STAR_113B STAR_IX86_1xx_1161.mpq +#IX86 STAR STAR_113C STAR_IX86_1xx_1161.mpq +#IX86 STAR STAR_113D STAR_IX86_1xx_1161.mpq +#IX86 STAR STAR_113E STAR_IX86_1xx_1161.mpq +#IX86 STAR STAR_114 STAR_IX86_1xx_1161.mpq +#IX86 STAR STAR_115 STAR_IX86_1xx_1161.mpq +#IX86 STAR STAR_1151 STAR_IX86_1xx_1161.mpq +#IX86 STAR STAR_1152 STAR_IX86_1xx_1161.mpq +#IX86 STAR STAR_1153 SEXP_IX86_1xx_1161.mpq + +# Incremental update from version 1.15.3 +#IX86 STAR STAR_116 SEXP_IX86_116_1161.mpq + +# The next one is a Starcraft wildcard entry. +#IX86 STAR STAR_1xx STAR_IX86_1xx_1161.mpq + +# ========================= Diablo (original) ============================== +# note: Blizzard doesn't update client from 109 to 109b. +#IX86 DRTL DRTL_108 DRTL_IX86_108_109.mpq + +# The next one is a Diablo wildcard entry. +#IX86 DRTL DRTL_1xx DRTL_IX86_100_109.mpq + +# ========================= Warcraft II BNE =============================== +#IX86 W2BN W2BN_200 W2BN_IX86_200_202.mpq +#IX86 W2BN W2BN_201 W2BN_IX86_201_202.mpq + +##### Mac OS X (XMAC) ######################################################## + +# ===================== Diablo II Expansion (LoD) =========================== +# Note: the following assumes that you want to upgrade all Diablo II clients +# to version 1.11b. If you are still running a 1.10 or 1.09d realm, you +# will need to modify these entries accordingly. + +#XMAC D2XP D2XP_109D D2XP_XMAC_1xx_111B.mpq +#XMAC D2XP D2XP_110 D2XP_XMAC_1xx_111B.mpq + +# Incremental update from version 1.11a --> 1.11b +#XMAC D2XP D2XP_111 D2XP_XMAC_111A_111B.mpq + +# The next one is a Diablo II LoD wildcard entry. +#XMAC D2XP D2XP_1xx D2XP_XMAC_1xx_111B.mpq + +# ========================== Diablo II (DV) ================================= +# Note: the following assumes that you want to upgrade all Diablo II clients +# to version 1.11b. If you are still running a 1.10 or 1.09d realm, you +# will need to modify these entries accordingly. + +#XMAC D2DV D2DV_109D D2DV_XMAC_1xx_111B.mpq +#XMAC D2DV D2DV_110 D2DV_XMAC_1xx_111B.mpq + +# Incremental update from version 1.11a --> 1.11b +#XMAC D2DV D2DV_111 D2DV_XMAC_111A_111B.mpq + +# The next one is a Diablo II LoD wildcard entry. +#XMAC D2DV D2DV_1xx D2DV_XMAC_1xx_111B.mpq + +# ================ StarCraft Expansion (Brood War) ========================== + +#XMAC SEXP SEXP_109B SEXP_XMAC_1xx_113E.mpq +#XMAC SEXP SEXP_110 SEXP_XMAC_1xx_113E.mpq +#XMAC STAR SEXP_110_STAR SEXP_XMAC_1xx_113E.mpq +#XMAC SEXP SEXP_111 SEXP_XMAC_1xx_113E.mpq +#XMAC STAR SEXP_111_STAR SEXP_XMAC_1xx_113E.mpq +#XMAC SEXP SEXP_111B SEXP_XMAC_1xx_113E.mpq +#XMAC STAR SEXP_111B_STAR SEXP_XMAC_1xx_113E.mpq +#XMAC SEXP SEXP_112 SEXP_XMAC_1xx_113E.mpq +#XMAC STAR SEXP_112_STAR SEXP_XMAC_1xx_113E.mpq +#XMAC SEXP SEXP_113 SEXP_XMAC_1xx_113E.mpq +#XMAC STAR SEXP_113_STAR SEXP_XMAC_1xx_113E.mpq +#XMAC SEXP SEXP_113C SEXP_XMAC_1xx_113E.mpq +#XMAC STAR SEXP_113C_STAR SEXP_XMAC_1xx_113E.mpq +# Unfortunately versioncheck.conf does not contain entries for 1.13{a|b|d} + +# The next one is a Brood War wildcard entry. +#XMAC SEXP SEXP_1xx SEXP_XMAC_1xx_113E.mpq + +# ========================= StarCraft (original) ============================ + +#XMAC STAR STAR_109B STAR_XMAC_1xx_113E.mpq +#XMAC STAR STAR_110 STAR_XMAC_1xx_113E.mpq +#XMAC STAR STAR_111 STAR_XMAC_1xx_113E.mpq +#XMAC STAR STAR_111B STAR_XMAC_1xx_113E.mpq +#XMAC STAR STAR_112 STAR_XMAC_1xx_113E.mpq +# Unfortunately versioncheck.conf does not contain entries for 1.13{a-d} + +# The next one is a Starcraft wildcard entry. +#XMAC STAR STAR_1xx STAR_XMAC_1xx_113E.mpq + +##### Mac OS Classic (PMAC) ################################################## + +# ===================== Diablo II Expansion (LoD) =========================== +# Note: the following assumes that you want to upgrade all Diablo II clients +# to version 1.11b. If you are still running a 1.10 or 1.09d realm, you +# will need to modify these entries accordingly. + +#PMAC D2XP D2XP_1xx D2XP_PMAC_1xx_111B.mpq + +# ========================== Diablo II (DV) ================================= +# Note: the following assumes that you want to upgrade all Diablo II clients +# to version 1.11b. If you are still running a 1.10 or 1.09d realm, you +# will need to modify these entries accordingly. + +#PMAC D2DV D2DV_109D D2DV_PMAC_1xx_111B.mpq +#PMAC D2DV D2DV_1xx D2DV_PMAC_1xx_111B.mpq + +# ================ StarCraft Expansion (Brood War) ========================== + +#PMAC SEXP SEXP_109B SEXP_PMAC_1xx_113E.mpq +#PMAC SEXP SEXP_110 SEXP_PMAC_1xx_113E.mpq +#PMAC STAR SEXP_110_STAR SEXP_PMAC_1xx_113E.mpq +#PMAC SEXP SEXP_111 SEXP_PMAC_1xx_113E.mpq +#PMAC STAR SEXP_111_STAR SEXP_PMAC_1xx_113E.mpq +#PMAC SEXP SEXP_111B SEXP_PMAC_1xx_113E.mpq +#PMAC STAR SEXP_111B_STAR SEXP_PMAC_1xx_113E.mpq +#PMAC SEXP SEXP_112 SEXP_PMAC_1xx_113E.mpq +#PMAC STAR SEXP_112_STAR SEXP_PMAC_1xx_113E.mpq + +# The next one is a Brood War wildcard entry. +#PMAC SEXP SEXP_1xx SEXP_PMAC_1xx_113E.mpq + +# ========================= StarCraft (original) ============================ + +#PMAC STAR STAR_109B STAR_PMAC_1xx_113E.mpq +#PMAC STAR STAR_110 STAR_PMAC_1xx_113E.mpq +#PMAC STAR STAR_111 STAR_PMAC_1xx_113E.mpq +#PMAC STAR STAR_111B STAR_PMAC_1xx_113E.mpq +#PMAC STAR STAR_112 STAR_PMAC_1xx_113E.mpq + +# The next one is a Brood War wildcard entry. +#PMAC STAR STAR_1xx STAR_PMAC_1xx_113E.mpq + +##### Westwood Online update entries ######################################### + +# ========================== Westwood Online API ============================ + +#IX86 WWOL 65536 65551_65536.rtp wolapi +#IX86 WWOL 65537 65551_65537.rtp wolapi +#IX86 WWOL 65538 65551_65538.rtp wolapi +#IX86 WWOL 65539 65551_65539.rtp wolapi +#IX86 WWOL 65540 65551_65540.rtp wolapi +#IX86 WWOL 65541 65551_65541.rtp wolapi +#IX86 WWOL 65542 65551_65542.rtp wolapi +#IX86 WWOL 65543 65551_65543.rtp wolapi +#IX86 WWOL 65544 65551_65544.rtp wolapi +#IX86 WWOL 65545 65551_65545.rtp wolapi +#IX86 WWOL 65546 65551_65546.rtp wolapi +#IX86 WWOL 65547 65551_65547.rtp wolapi +#IX86 WWOL 65548 65551_65548.rtp wolapi +#IX86 WWOL 65549 65551_65549.rtp wolapi +#IX86 WWOL 65550 65551_65550.rtp wolapi +#IX86 WWOL 65555 65556_65555.rtp wolapi + +# =============================== Renegade ================================== + +#IX86 RNGD 65538 65573_65538.rtp renegade +#IX86 RNGD 65550 65573_65538.rtp renegade +#IX86 RNGD 65551 65573_65538.rtp renegade +#IX86 RNGD 65566 65573_65538.rtp renegade +#IX86 RNGD 65567 65573_65538.rtp renegade +#IX86 RNGD 65568 65573_65538.rtp renegade +#IX86 RNGD 65570 65573_65570.rtp renegade +#IX86 RNGD 65571 65573_65571.rtp renegade +#IX86 RNGD 65572 65573_65572.rtp renegade + +# ==================== Renegade Free Dedicated Server ======================= + +#IX86 RFDS 65538 65572_65538.rtp renegade +#IX86 RFDS 65550 65572_65550.rtp renegade +#IX86 RFDS 65551 65572_65551.rtp renegade +#IX86 RFDS 65553 65572_65553.rtp renegade +#IX86 RFDS 65554 65572_65554.rtp renegade +#IX86 RFDS 65566 65572_65566.rtp renegade +#IX86 RFDS 65568 65572_65568.rtp renegade +#IX86 RFDS 65570 65572_65570.rtp renegade +#IX86 RFDS 65571 65572_65571.rtp renegade +#IX86 RFDS 65572 65573_65572.rtp renegade + +# ============================= Tiberian Sun ================================ + +#IX86 TSUN 65536 131075_65536.rtp tibsun +#IX86 TSUN 65541 131075_65536.rtp tibsun +#IX86 TSUN 65542 131075_65536.rtp tibsun +#IX86 TSUN 65543 131075_65536.rtp tibsun +#IX86 TSUN 65544 131075_65536.rtp tibsun +#IX86 TSUN 65545 131075_65536.rtp tibsun +#IX86 TSUN 65546 131075_65536.rtp tibsun +#IX86 TSUN 65547 131075_65536.rtp tibsun +#IX86 TSUN 65548 131075_65548.rtp tibsun +#IX86 TSUN 131072 131075_65548.rtp tibsun +#IX86 TSUN 131074 131075_131074.rtp tibsun + +# ======================= Tiberian Sun: FireStorm =========================== + +#IX86 TSXP 131072 131074_131072.rtp tibsun +#IX86 TSXP 131074 131075_131074.rtp tibsun + +# =============================== Dune 2000 ================================= + +#IX86 DN2K 65536 65542.rtp dune2k/1.006/1.000 +#IX86 DN2K 65537 65542_65537.rtp dune2k/1.006/1.001 + +# ================================== NOX ==================================== + +#IX86 NOXX 65536 65538_65536.rtp nox +#IX86 NOXX 65537 65538_65537.rtp nox + +# =============================== NOX: Quest ================================ + +#IX86 NOXQ 65536 65538_65536.rtp nox +#IX86 NOXQ 65537 65538_65537.rtp nox +#IX86 NOXQ 65538 65540_65538.rtp nox +#IX86 NOXQ 65539 65540_65539.rtp nox + +# ======================= Emperor: Battle for Dune ========================== + +#IX86 EBFD 1 65545_1.rtp emperor +#IX86 EBFD 65536 65545_65536.rtp emperor +#IX86 EBFD 65537 65545_65537.rtp emperor +#IX86 EBFD 65538 65545_65538.rtp emperor +#IX86 EBFD 65539 65545_65539.rtp emperor +#IX86 EBFD 65540 65545_65540.rtp emperor +#IX86 EBFD 65541 65545_65541.rtp emperor +#IX86 EBFD 65542 65545_65542.rtp emperor +#IX86 EBFD 65543 65545_65543.rtp emperor +#IX86 EBFD 65544 65545_65544.rtp emperor + +# ============================= Red Alert 2 ================================= + +#IX86 RAL2 65536 65542_65536.rtp ra2 +#IX86 RAL2 65537 65542_65537.rtp ra2 +#IX86 RAL2 65538 65542_65538.rtp ra2 +#IX86 RAL2 65539 65542_65539.rtp ra2 +#IX86 RAL2 65540 65542_65540.rtp ra2 +#IX86 RAL2 65541 65542_65541.rtp ra2 + +# ============================= Yuri's Revenge ============================== + +#IX86 YURI 65536 65537_65536.rtp yuri + +# ============================= Lands of Lore 3 ============================= + +#IX86 LOR3 65536 65539_65536.rtp lore3/1.003 +#IX86 LOR3 65537 65539_65537.rtp lore3/1.003 +#IX86 LOR3 65538 65539_65538.rtp lore3/1.003 diff --git a/pvpgn/conf/bnalias.conf.in b/conf/bnalias.conf.in similarity index 100% rename from pvpgn/conf/bnalias.conf.in rename to conf/bnalias.conf.in diff --git a/pvpgn/conf/bnban.conf.in b/conf/bnban.conf.in similarity index 100% rename from pvpgn/conf/bnban.conf.in rename to conf/bnban.conf.in diff --git a/pvpgn/conf/bnetd.conf.in b/conf/bnetd.conf.in similarity index 100% rename from pvpgn/conf/bnetd.conf.in rename to conf/bnetd.conf.in diff --git a/pvpgn/conf/bnetd.conf.win32 b/conf/bnetd.conf.win32 similarity index 100% rename from pvpgn/conf/bnetd.conf.win32 rename to conf/bnetd.conf.win32 diff --git a/pvpgn/conf/bnetd_default_user.cdb b/conf/bnetd_default_user.cdb similarity index 100% rename from pvpgn/conf/bnetd_default_user.cdb rename to conf/bnetd_default_user.cdb diff --git a/pvpgn/conf/bnetd_default_user.plain.in b/conf/bnetd_default_user.plain.in similarity index 100% rename from pvpgn/conf/bnetd_default_user.plain.in rename to conf/bnetd_default_user.plain.in diff --git a/pvpgn/conf/bnhelp.conf.in b/conf/bnhelp.conf.in similarity index 100% rename from pvpgn/conf/bnhelp.conf.in rename to conf/bnhelp.conf.in diff --git a/pvpgn/conf/bnissue.txt.in b/conf/bnissue.txt.in similarity index 100% rename from pvpgn/conf/bnissue.txt.in rename to conf/bnissue.txt.in diff --git a/pvpgn/conf/bnmaps.conf.in b/conf/bnmaps.conf.in similarity index 100% rename from pvpgn/conf/bnmaps.conf.in rename to conf/bnmaps.conf.in diff --git a/pvpgn/conf/bnmotd-bgBG.txt.in b/conf/bnmotd-bgBG.txt.in similarity index 100% rename from pvpgn/conf/bnmotd-bgBG.txt.in rename to conf/bnmotd-bgBG.txt.in diff --git a/pvpgn/conf/bnmotd-csCZ.txt.in b/conf/bnmotd-csCZ.txt.in similarity index 100% rename from pvpgn/conf/bnmotd-csCZ.txt.in rename to conf/bnmotd-csCZ.txt.in diff --git a/pvpgn/conf/bnmotd-deDE.txt.in b/conf/bnmotd-deDE.txt.in similarity index 100% rename from pvpgn/conf/bnmotd-deDE.txt.in rename to conf/bnmotd-deDE.txt.in diff --git a/pvpgn/conf/bnmotd-enUS.txt.in b/conf/bnmotd-enUS.txt.in similarity index 100% rename from pvpgn/conf/bnmotd-enUS.txt.in rename to conf/bnmotd-enUS.txt.in diff --git a/pvpgn/conf/bnmotd-esES.txt.in b/conf/bnmotd-esES.txt.in similarity index 100% rename from pvpgn/conf/bnmotd-esES.txt.in rename to conf/bnmotd-esES.txt.in diff --git a/pvpgn/conf/bnmotd-frFR.txt.in b/conf/bnmotd-frFR.txt.in similarity index 100% rename from pvpgn/conf/bnmotd-frFR.txt.in rename to conf/bnmotd-frFR.txt.in diff --git a/pvpgn/conf/bnmotd-jpJA.txt.in b/conf/bnmotd-jpJA.txt.in similarity index 100% rename from pvpgn/conf/bnmotd-jpJA.txt.in rename to conf/bnmotd-jpJA.txt.in diff --git a/pvpgn/conf/bnmotd-koKR.txt.in b/conf/bnmotd-koKR.txt.in similarity index 100% rename from pvpgn/conf/bnmotd-koKR.txt.in rename to conf/bnmotd-koKR.txt.in diff --git a/pvpgn/conf/bnmotd-nlNL.txt.in b/conf/bnmotd-nlNL.txt.in similarity index 100% rename from pvpgn/conf/bnmotd-nlNL.txt.in rename to conf/bnmotd-nlNL.txt.in diff --git a/pvpgn/conf/bnmotd-plPL.txt.in b/conf/bnmotd-plPL.txt.in similarity index 100% rename from pvpgn/conf/bnmotd-plPL.txt.in rename to conf/bnmotd-plPL.txt.in diff --git a/pvpgn/conf/bnmotd-ptBR.txt.in b/conf/bnmotd-ptBR.txt.in similarity index 100% rename from pvpgn/conf/bnmotd-ptBR.txt.in rename to conf/bnmotd-ptBR.txt.in diff --git a/pvpgn/conf/bnmotd-ruRU.txt.in b/conf/bnmotd-ruRU.txt.in similarity index 100% rename from pvpgn/conf/bnmotd-ruRU.txt.in rename to conf/bnmotd-ruRU.txt.in diff --git a/pvpgn/conf/bnmotd-svSE.txt.in b/conf/bnmotd-svSE.txt.in similarity index 100% rename from pvpgn/conf/bnmotd-svSE.txt.in rename to conf/bnmotd-svSE.txt.in diff --git a/pvpgn/conf/bnmotd-zhCN.txt.in b/conf/bnmotd-zhCN.txt.in similarity index 100% rename from pvpgn/conf/bnmotd-zhCN.txt.in rename to conf/bnmotd-zhCN.txt.in diff --git a/pvpgn/conf/bnmotd-zhTW.txt.in b/conf/bnmotd-zhTW.txt.in similarity index 100% rename from pvpgn/conf/bnmotd-zhTW.txt.in rename to conf/bnmotd-zhTW.txt.in diff --git a/pvpgn/conf/bnxpcalc.conf.in b/conf/bnxpcalc.conf.in similarity index 100% rename from pvpgn/conf/bnxpcalc.conf.in rename to conf/bnxpcalc.conf.in diff --git a/pvpgn/conf/bnxplevel.conf.in b/conf/bnxplevel.conf.in similarity index 100% rename from pvpgn/conf/bnxplevel.conf.in rename to conf/bnxplevel.conf.in diff --git a/pvpgn/conf/channel.conf.in b/conf/channel.conf.in similarity index 100% rename from pvpgn/conf/channel.conf.in rename to conf/channel.conf.in diff --git a/pvpgn/conf/command_groups.conf.in b/conf/command_groups.conf.in similarity index 100% rename from pvpgn/conf/command_groups.conf.in rename to conf/command_groups.conf.in diff --git a/pvpgn/conf/d2cs.conf.in b/conf/d2cs.conf.in similarity index 100% rename from pvpgn/conf/d2cs.conf.in rename to conf/d2cs.conf.in diff --git a/pvpgn/conf/d2cs.conf.win32 b/conf/d2cs.conf.win32 similarity index 100% rename from pvpgn/conf/d2cs.conf.win32 rename to conf/d2cs.conf.win32 diff --git a/pvpgn/conf/d2dbs.conf.in b/conf/d2dbs.conf.in similarity index 100% rename from pvpgn/conf/d2dbs.conf.in rename to conf/d2dbs.conf.in diff --git a/pvpgn/conf/d2dbs.conf.win32 b/conf/d2dbs.conf.win32 similarity index 100% rename from pvpgn/conf/d2dbs.conf.win32 rename to conf/d2dbs.conf.win32 diff --git a/pvpgn/conf/d2server.ini b/conf/d2server.ini similarity index 100% rename from pvpgn/conf/d2server.ini rename to conf/d2server.ini diff --git a/pvpgn/conf/news.txt.in b/conf/news.txt.in similarity index 100% rename from pvpgn/conf/news.txt.in rename to conf/news.txt.in diff --git a/pvpgn/conf/realm.conf.in b/conf/realm.conf.in similarity index 100% rename from pvpgn/conf/realm.conf.in rename to conf/realm.conf.in diff --git a/pvpgn/conf/sql_DB_layout.conf.in b/conf/sql_DB_layout.conf.in similarity index 100% rename from pvpgn/conf/sql_DB_layout.conf.in rename to conf/sql_DB_layout.conf.in diff --git a/pvpgn/conf/sql_DB_layout2.conf.in b/conf/sql_DB_layout2.conf.in similarity index 100% rename from pvpgn/conf/sql_DB_layout2.conf.in rename to conf/sql_DB_layout2.conf.in diff --git a/pvpgn/conf/supportfile.conf.in b/conf/supportfile.conf.in similarity index 100% rename from pvpgn/conf/supportfile.conf.in rename to conf/supportfile.conf.in diff --git a/pvpgn/conf/topics.conf.in b/conf/topics.conf.in similarity index 100% rename from pvpgn/conf/topics.conf.in rename to conf/topics.conf.in diff --git a/pvpgn/conf/tournament.conf.in b/conf/tournament.conf.in similarity index 100% rename from pvpgn/conf/tournament.conf.in rename to conf/tournament.conf.in diff --git a/pvpgn/conf/versioncheck.conf.in b/conf/versioncheck.conf.in similarity index 100% rename from pvpgn/conf/versioncheck.conf.in rename to conf/versioncheck.conf.in diff --git a/pvpgn/config.h.cmake b/config.h.cmake similarity index 100% rename from pvpgn/config.h.cmake rename to config.h.cmake diff --git a/pvpgn/conversion-changelog b/conversion-changelog similarity index 100% rename from pvpgn/conversion-changelog rename to conversion-changelog diff --git a/d2pack109/CREDITS b/d2pack109/CREDITS deleted file mode 100644 index bbbaeb9..0000000 --- a/d2pack109/CREDITS +++ /dev/null @@ -1,245 +0,0 @@ -PvPGN CREDITS (also please see the original BNETD credits bellow): --------------------------------------------------------------------- - -CREDITS - This file contains the names of people who have contributed to the - development of the PvPGN BNETD mod in some way. This file is not - complete and we would like to thank everyone who helped us in any way. - -PROGRAMMING CONTRIBUTORS - Zzzoom (servers@3dgames.com.ar) - For persistent SQL connections patch, password brute force attacks - protection and various bug reports. - - Lots of other people who do not whish to be mentioned here. - -BINARY PACKAGES: -- Birzan George Cristian (Debian packages) -- Dorin Lazar (RPMs) -- Mihai Maties (RPMs & src.rpm snapshot script) -- Radu Radoveneanu (Slackware packages) - -ORIGINAL BNETD CREDITS: -------------------------------- - -CREDITS - - This file contains the names of people who have contributed to the - development of the BNETD server in some way. This project has made an - enormous amount of progress since the development has become public, - and this is one place where members of the community can be thanked. - - -PROGRAMMING CONTRIBUTORS - - The following people have contributed code, code ideas, bug fixes, and - debugging work: - - Mark Baysinger (mbaysing@ucsd.edu) - For the original idea, original implementation, documentation of the - protocol, starhack.ml.org, the tracking server, etc. - - Ross Combs (rocombs@cs.nmsu.edu) - Various cleanups, release coordination, / commands, config files, etc. - - Rob Crittenden (rcrit@greyoak.com) - For many bug fixes, protocol work, file downloads, man pages, user - icons, better channel handling, autoconf, ladder, etc. as well as - working on the FAQ and user support. - - Descolada (dyn1-tnt9-237.chicago.il.ameritech.net) - For the hashing algorithm complete with a sample C implementation. - - Gediminas (gediminas_lt@mailexcite.com) - For work on the client command "readline" code, the initial help - system, and a better /conn command. - - Oleg Drokin (green@ccssu.crimea.ua) - For patches to fix bnchat and bnstat. - - Damien Clermonte (clermond@esiee.fr) - For portability (to cygnus B20.1 on win32) work, testing, and helpful - observations, and the TCP keepalive patch. - - Denis Moreaux (vapula@endor.be) - For working out the correct ladder equations. - - Philippe Dubois (pdubois@matrox.com) - For working on the Win32 port, UDP stuff, auto-update, and the - bnettime code. - - Typhoon [Marco Ziech] (mmz@gmx.net) - For lots of good work on the BNI utilities, BITS (server inter- - connectivity) support, and his bnetmasq.sh script. He also - answers a lot of user questions and put together most of the - web site. - - Dizzy (dizzy@roedu.net) - For help with NAT issues, a much improved help system, channel - flooding prevention, new /-commands, a mail system, and more. - - Razvan Jianu (roger@hell.gameover.ro) - For many useful coredumps :) Also for the /addacct command. - - Qlex (qlex@eoliss.com) - For kick starting the Diablo II stuff, testing thousands quick - changes, moral support, and digging up all the information. - - Kenshin (kenshin_@hotmail.com) - For helping Qlex with the character stuff, fixing some major - bugs in the Diablo II code, and starting work on saving - characters. - - Hakan Tandogan (hakan@gurkensalat.com) - For always making RPMs for bnetd and the tracker and some patches to - correct startup/shutdown issues. Also for continuing Diablo II work. - - Jung-woo Sohn (logout@aeroguy.snu.ac.kr) - For /watch feedback, dobae flooding disconnect, better disconnect - game result handling, and generally for lots of good ideas. And - also for spotting the failed account creation crashing bug. - - YobGuls (yobguls@yobguls.2ndmail.com) - Actually contributed to the DSBot code, but see next entry. - - Eurijk! (wc2@zefga.net) - For pointing out how the new cdkey hashing works and also how - version checking is performed. This was some really ugly but - important stuff! He figured this out working on DSBot but - kindly explained it to us and showed us example code. He's - also working on the Prolix bot project and has provided lots - of useful bug reports and other commentary. - - Fred Wittekind (rom@twister.dyndns.org) - For autoupdate version range support. For pointing out all the - update MPQ files we didn't know about. Also for the message - force-command patch. - - Mathieu Legare (Mathieu_Legare@uqtr.uquebec.ca) - For picking up bnetdStats and making it report all kinds of - statistics. - - Onlyer (onlyer@users.sourceforge.net) - For new commands, Diablo II protocol work, Diablo II closed server - work, FSGS account conversion, etc. - - faster (lqx@cic.tsinghua.edu.cn) - For Diablo II closed communication (S2S) and for finding that - check_alloc bug. - - sousou (liupeng.cs@263.net) - For Diablo II closed database server and ladder. - - esper (esperpale@263.net) - Diablo II closed server gui and ladder. - - sherpya (sherpya@netfarm.it) - For lots of help with adbanners, the d2close merge, reporting - bugs (like the 100% poll() CPU usage bug), and lots of good - suggestions. Also for work on channel list reloads. - - Yoss (bartek@milc.com.pl) - For helpful suggestions for the mail code and for patching - the emote flooding hole. Also for the /admin command and for - the patch to fix the "operator can ban admins" bug. A big - thanks for much improved kill and ban commands and the new - dynamic ipban with better address matching and timeouts. - - Roland Stahn (blue@cs.tu-berlin.de) - For all the work tracking down the versioncheck information - for revision of the STAR and SEXP clients. For information about - Blizzard's numbering scheme. For helpful packet information. - Also for the bug reports and simple patches which probably should - have been fixed a long time ago but he was the only person with - enough patience to figure out what was happening. Specifically, - the "all countries in one channel" feature, the empty game pass - bug, the multiple game with same name bug, and the memory - corruption after autoupdates. For updated version information. - For diagnosing the autoupdate crash (bug in server.c handling - closed sockets). - - KWS (vizi@csucs.net) - For the nice bug reports on gameinfo parsing on game join, win32 - socket and file portability problems. Also for patches to update - versioncheck info, implement IP storage, the patch for better - eventlogs, and Makefile improvements. - - Jack (jack@takeovertheworld.org) - For Diablo II open game difficulty patch. - - forester (laterk@inbox.lv) - Working on the Win32 port, bnetd GUI for Win32, small patches. - -TESTING AND DEBUGGING CONTRIBUTORS - - The following people have sent in ideas, bug reports, and minor - patches. - - 187 (187@infoceptor.com) - For bug reports and the idea for the /news command. - - Shin DongJun (djshin@oslab.snu.ac.kr) - For some bug reports and patches. - - Jeffery Jones (jeffery_jones@mtlusa.com) - For the game address translation idea. - - Maxim Tereshenkov (max@ostin.ru) - For the stack trace which found the 8-bit account.c bug. - - Yanoch (yanoch@loginnovation.com) - For suggesting the /kill improvement. - - stacker (stacker@mail.ee.ntou.edu.tw) - For lots of bug reports and also the sbnetd front end. - - Mike Hindman (mhindman@bnetd.nmsu.edu) - David Fitzpatrick (dfitzpat@bnetd.nmsu.edu) - For lots of ideas and all the help with Diablo. - - Homer (homer@ogn.de) - For the helpful info on game info strings and ladder maps. - - Alvin Sim (elflord@faerie.cx) - For lots of testing and figuring out that Diablo II open gameplay was - actually not too hard to implement. - - AsmodeusB - For finding annoying the gameinfo bug in connection.c :) - - forester (http://forester.yo.lv) - For pointing out what gameresult 5 means. - - jerome (imeepmeep@mac.com) - For the MacOS X package. - - acbcdde (acbcdde@hotmail.com) - For Win32 Makefile and config.h fixes. - - mojohead ( Andrey Ilyin ) - For d2dbs/d2ladder.c fixes. - - -OTHER CONTRIBUTORS - - The following people have contributed their time, talent, and other - resources to the project: - - Josh (josh@bnetd.org) - For a wonderful web site, quick mirroring of new releases, testing, - organization, documentation, and user support. - - Tim Jung (tjung@igateway.net) - For kindly hosting our mailing lists, domain, web pages, etc. as well - as regular feedback and testing. - - Allan Clark (allanc@sco.com) - For putting together some nice RPMs. - - -NOTE - - This list is not complete. I have lost track of the names of some - people who have contributed, and likely forgotten about others. If you - think you should be listed here but aren't, please contact the - bnetd-dev mailing list and we will take care of it right away. diff --git a/d2pack109/README b/d2pack109/README deleted file mode 100644 index 8b77ba5..0000000 --- a/d2pack109/README +++ /dev/null @@ -1,44 +0,0 @@ - Readme for Player vs. Player Gaming Network - --------------------------------------------- - D2Pack 1.09 - ------------- - - PvPGN is a BNETD mod which aims to provide support for all Blizzard -clients (thus it supports all BNETD supported clients plus the most recent -ones). - This release only includes d2cs/d2dbs as needed to host a Diablo II 1.09 -closed realm. It only supports d2gs 1.09d. This package NEEDS a "bnetd" server -configured to work (for example use a "bnetd" from a PvPGN release). - -The list of supported clients and their minimum verion required is: -- Diablo 2 v1.09 -- Diablo 2 LOD v1.09 ------------- - - The documentation is located in the docs directory. Please read docs/INDEX -for a list of files and what they contain. - If you are updating from a previous PvPGN version check the file UPDATE -first. - - ------ - -We're always looking for good coders (C coders) or -anyone who can contribute to our project in any way. - -Project homepages/distribution sites: -- project home and main distribution site: http://pvpgn.berlios.de -- alternate project home: http://www.pvpgn.org -- alternate distribution site: http://www.pvpgn.de - -Support channels: - -1. BugTracker (preffered support method): -http://developer.berlios.de/bugs/?group_id=2291 - -2. Mailing List: pvpgn-users@lists.berlios.de ( to subscribe go here -https://lists.berlios.de/mailman/listinfo/pvpgn-users ) - -3. Forums: http://forums.pvpgn.org - -4. IRC live support: #pvpgn on irc.pvpgn.org diff --git a/d2pack109/Win32-Projects/Makefile.mingw b/d2pack109/Win32-Projects/Makefile.mingw deleted file mode 100644 index a626bc8..0000000 --- a/d2pack109/Win32-Projects/Makefile.mingw +++ /dev/null @@ -1,493 +0,0 @@ -# Project: d2pack109 Package -# Makefile: MinGW (http://www.mingw.org) -# -# Copyright (C) 2005 CreepLord (creeplord@pvpgn.org) -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# - -##################################################################### - -ifndef DEST -DEST = ./win32-builds -endif - -VERSION = 0.7 -RELEASE = CVS -PACKAGE = $(DEST)/D2Pack109-$(VERSION)-$(RELEASE)-Win32$(TYPE).zip - -ifndef prefix - prefix = ./d2pack109 - installdir = $(prefix)-$(VERSION) -else - installdir = $(prefix) -endif - -confdir = $(installdir)/conf -docsdir = $(installdir)/docs -filesdir = $(installdir)/files -sharedir = $(installdir)/var -bakdir = $(sharedir)/bak -bakcharsavedir = $(sharedir)/bak/charsave -bakcharinfodir = $(sharedir)/bak/charinfo -charsavedir = $(sharedir)/charinfo -charinfodir = $(sharedir)/charsave -laddersdir = $(sharedir)/ladders -reportsdir = $(sharedir)/reports - -##################################################################### - -TOP_DIR = ./.. - -SRC_CONFDIR = $(TOP_DIR)/conf -SRC_DOCSDIR = $(TOP_DIR)/docs -SRC_FILESDIR = $(TOP_DIR)/files -SRC_SBINDIR = $(TOP_DIR)/sbin -SRC_SRCDIR = $(TOP_DIR)/src -SRC_COMMONDIR = $(SRC_SRCDIR)/common -SRC_COMPATDIR = $(SRC_SRCDIR)/compat -SRC_D2CSDIR = $(SRC_SRCDIR)/d2cs -SRC_D2DBSDIR = $(SRC_SRCDIR)/d2dbs -SRC_WIN32DIR = $(SRC_SRCDIR)/win32 - -##################################################################### - -CC = gcc -INSTALL = install -INSTALL_DIR = install -d -RMF = rm -f -STRIP = strip -WINDRES = windres -ZIP = zip -rm9q -ECHO = echo - -ifdef CROSS_BUILD -PCC = /usr/bin/gcc -ENV = -WFLAGS = -W -Wall -Wno-unused -#WFLAGS = -UNIX2DOS = ./u2d -else -PCC = $(CC) -ENV = -e -WFLAGS = -UNIX2DOS = u2d.exe -endif - -##################################################################### - -CFLAGS = $(WFLAGS) -I$(SRC_SRCDIR) -I$(SRC_SRCDIR)/include -LDFLAGS = -lws2_32 -L$(SRC_SRCDIR)/lib - -ifdef WITH_MYSQL -CFLAGS += -DWITH_SQL_MYSQL -LDFLAGS += -lmysql -endif - -ifdef WITH_PGSQL -CFLAGS += -DWITH_SQL_PGSQL -LDFLAGS += -lpq -endif - -ifdef WITH_SQLITE3 -CFLAGS += -DWITH_SQL_SQLITE3 -DHAVE_SQLITE3_H -LDFLAGS += -lsqlite3 -endif - -ifdef WITH_ODBC -CFLAGS += -DWITH_SQL_ODBC -LDFLAGS += -lodbc32 -endif - -ifdef WITH_GUI -CFLAGS += -DWIN32_GUI -LDFLAGS += -mwindows -endif - -##################################################################### -# EXECUTABLES -##################################################################### - -ifdef WITH_GUI - d2cs_SBIN = $(SRC_SBINDIR)/d2cs109.exe - d2dbs_SBIN = $(SRC_SBINDIR)/d2dbs109.exe -else - d2cs_SBIN = $(SRC_SBINDIR)/d2cs109Console.exe - d2dbs_SBIN = $(SRC_SBINDIR)/d2dbs109Console.exe -endif - -##################################################################### -# RESOURCES -##################################################################### - -ifdef WITH_GUI -d2cs_RES = $(SRC_WIN32DIR)/d2cs_resource.res -d2dbs_RES = $(SRC_WIN32DIR)/d2dbs_resource.res -else -d2cs_RES = $(SRC_WIN32DIR)/console_resource.res -d2dbs_RES = $(SRC_WIN32DIR)/console_resource.res -endif - -##################################################################### -# SOURCE -##################################################################### - -d2cs_SOURCE = \ - $(SRC_D2CSDIR)/main.c \ - $(SRC_D2CSDIR)/d2gs.c \ - $(SRC_D2CSDIR)/handle_d2gs.c \ - $(SRC_D2CSDIR)/serverqueue.c \ - $(SRC_D2CSDIR)/connection.c \ - $(SRC_D2CSDIR)/game.c \ - $(SRC_D2CSDIR)/server.c \ - $(SRC_D2CSDIR)/handle_init.c \ - $(SRC_D2CSDIR)/handle_d2cs.c \ - $(SRC_D2CSDIR)/d2charfile.c \ - $(SRC_D2CSDIR)/d2charlist.c \ - $(SRC_D2CSDIR)/xstring.c \ - $(SRC_D2CSDIR)/gamequeue.c \ - $(SRC_D2CSDIR)/prefs.c \ - $(SRC_D2CSDIR)/conf.c \ - $(SRC_D2CSDIR)/cmdline_parse.c \ - $(SRC_D2CSDIR)/bnetd.c \ - $(SRC_D2CSDIR)/handle_bnetd.c \ - $(SRC_D2CSDIR)/s2s.c \ - $(SRC_D2CSDIR)/net.c \ - $(SRC_D2CSDIR)/d2ladder.c \ - $(SRC_D2CSDIR)/handle_signal.c \ - $(SRC_COMMONDIR)/eventlog.c \ - $(SRC_COMMONDIR)/hashtable.c \ - $(SRC_COMMONDIR)/hexdump.c \ - $(SRC_COMMONDIR)/list.c \ - $(SRC_COMMONDIR)/packet.c \ - $(SRC_COMMONDIR)/bn_type.c \ - $(SRC_COMMONDIR)/addr.c \ - $(SRC_COMMONDIR)/util.c \ - $(SRC_COMMONDIR)/queue.c \ - $(SRC_COMMONDIR)/network.c \ - $(SRC_COMMONDIR)/fdwatch.c\ - $(SRC_COMMONDIR)/fdwatch_select.c\ - $(SRC_COMMONDIR)/fdwatch_poll.c\ - $(SRC_COMMONDIR)/fdwatch_kqueue.c\ - $(SRC_COMMONDIR)/fdwatch_epoll.c\ - $(SRC_COMMONDIR)/trans.c \ - $(SRC_COMMONDIR)/xalloc.c \ - $(SRC_COMMONDIR)/rlimit.c \ - $(SRC_COMMONDIR)/tag.c \ - $(SRC_COMPATDIR)/inet_aton.c \ - $(SRC_COMPATDIR)/inet_ntoa.c \ - $(SRC_COMPATDIR)/strdup.c \ - $(SRC_COMPATDIR)/strerror.c \ - $(SRC_COMPATDIR)/strtoul.c \ - $(SRC_COMPATDIR)/strftime.c \ - $(SRC_COMPATDIR)/strcasecmp.c \ - $(SRC_COMPATDIR)/strncasecmp.c \ - $(SRC_COMPATDIR)/strsep.c \ - $(SRC_COMPATDIR)/psock.c \ - $(SRC_COMPATDIR)/uname.c \ - $(SRC_COMPATDIR)/gettimeofday.c \ - $(SRC_COMPATDIR)/difftime.c \ - $(SRC_COMPATDIR)/pdir.c \ - $(SRC_COMPATDIR)/memset.c \ - $(SRC_COMPATDIR)/memcpy.c \ - $(SRC_COMPATDIR)/memmove.c \ - $(SRC_WIN32DIR)/service.c \ - $(SRC_WIN32DIR)/d2cs_winmain.c - -d2dbs_SOURCE = \ - $(SRC_D2DBSDIR)/main.c \ - $(SRC_D2DBSDIR)/charlock.c \ - $(SRC_D2DBSDIR)/d2ladder.c \ - $(SRC_D2DBSDIR)/dbserver.c \ - $(SRC_D2DBSDIR)/dbspacket.c \ - $(SRC_D2DBSDIR)/prefs.c \ - $(SRC_D2DBSDIR)/handle_signal.c \ - $(SRC_D2DBSDIR)/dbsdupecheck.c \ - $(SRC_D2DBSDIR)/cmdline_parse.c \ - $(SRC_D2CSDIR)/conf.c \ - $(SRC_D2CSDIR)/xstring.c \ - $(SRC_COMMONDIR)/eventlog.c \ - $(SRC_COMMONDIR)/list.c \ - $(SRC_COMMONDIR)/bn_type.c \ - $(SRC_COMMONDIR)/util.c \ - $(SRC_COMMONDIR)/addr.c \ - $(SRC_COMMONDIR)/xalloc.c \ - $(SRC_COMMONDIR)/fdwatch.c \ - $(SRC_COMMONDIR)/fdwatch_select.c \ - $(SRC_COMMONDIR)/fdwatch_poll.c \ - $(SRC_COMMONDIR)/fdwatch_epoll.c \ - $(SRC_COMMONDIR)/fdwatch_kqueue.c \ - $(SRC_COMMONDIR)/tag.c \ - $(SRC_COMMONDIR)/rlimit.c \ - $(SRC_COMPATDIR)/inet_aton.c \ - $(SRC_COMPATDIR)/psock.c \ - $(SRC_COMPATDIR)/strerror.c \ - $(SRC_COMPATDIR)/strsep.c \ - $(SRC_WIN32DIR)/service.c \ - $(SRC_WIN32DIR)/d2dbs_winmain.c - -##################################################################### -# OBJECTS -##################################################################### - -d2cs_OBJECTS = $(d2cs_SOURCE:.c=.o) -d2dbs_OBJECTS = $(d2dbs_SOURCE:.c=.o) - -d2server_OBJECTS = $(d2cs_OBJECTS) $(d2dbs_OBJECTS) - -##################################################################### -# Targets -##################################################################### - -.PHONY: all -all: - @$(ECHO) =============================================================================== - @$(ECHO) = = - @$(ECHO) = Targets: = - @$(ECHO) = = - @$(ECHO) = make_mingw gui Build GUI Programs = -# @$(ECHO) = make_mingw gui-mysql Build GUI Programs with mySQL Support = -# @$(ECHO) = make_mingw gui-pgsql Build GUI Programs with pgSQL Support = -# @$(ECHO) = make_mingw gui-sqlite3 Build GUI Programs with SQLite3 Support = -# @$(ECHO) = make_mingw gui-odbc Build GUI Programs with ODBC Support = -# @$(ECHO) = = - @$(ECHO) = make_mingw console Build Console Programs = -# @$(ECHO) = make_mingw console-mysql Build Console Programs with mySQL Support = -# @$(ECHO) = make_mingw console-pgsql Build Console Programs with pgSQL Support = -# @$(ECHO) = make_mingw console-sqlite3 Build Console Programs with SQLite3 Support = -# @$(ECHO) = make_mingw console-odbc Build Console Programs with ODBC Support = - @$(ECHO) = = - @$(ECHO) = make_mingw clean Remove All Objects, Resources, Executables = - @$(ECHO) = = - @$(ECHO) = make_mingw install [InstallPath] Installs the D2Pack109 Package = - @$(ECHO) = = - @$(ECHO) =============================================================================== - @pause - -##################################################################### -# COMPILING TARGETS -##################################################################### - -.PHONY: gui -gui: clean - @$(MAKE) -s -fMakefile.mingw servers $(ENV) WITH_GUI=1 - -.PHONY: gui-mysql -gui-mysql: clean - @$(MAKE) -s -fMakefile.mingw servers $(ENV) WITH_GUI=1 $(ENV) WITH_MYSQL=1 - -.PHONY: gui-pgsql -gui-pgsql: clean - @$(MAKE) -s -fMakefile.mingw servers $(ENV) WITH_GUI=1 $(ENV) WITH_PGSQL=1 - -.PHONY: gui-sqlite3 -gui-sqlite3: clean - @$(MAKE) -s -fMakefile.mingw servers $(ENV) WITH_GUI=1 $(ENV) WITH_SQLITE3=1 - -.PHONY: gui-odbc -gui-odbc: clean - @$(MAKE) -s -fMakefile.mingw servers $(ENV) WITH_GUI=1 $(ENV) WITH_ODBC=1 - -.PHONY: console -console: clean servers - -.PHONY: console-mysql -console-mysql: clean - @$(MAKE) -s -fMakefile.mingw servers $(ENV) WITH_MYSQL=1 - -.PHONY: console-pgsql -console-pgsql: clean - @$(MAKE) -s -fMakefile.mingw servers $(ENV) WITH_PGSQL=1 - -.PHONY: console-sqlite3 -console-sqlite3: clean - @$(MAKE) -s -fMakefile.mingw servers $(ENV) WITH_SQLITE3=1 - -.PHONY: console-odbc -console-odbc: clean - @$(MAKE) -s -fMakefile.mingw servers $(ENV) WITH_ODBC=1 - -##################################################################### - -.PHONY: servers -servers: $(d2cs_SBIN) $(d2dbs_SBIN) - -##################################################################### -# CLEANING -##################################################################### - -.PHONY: clean -clean: clean-obj clean-res clean-exe - -.PHONY: clean-obj -clean-obj: - @$(ECHO) Removing Objects - @-$(RMF) $(SRC_COMMONDIR)/*.o - @-$(RMF) $(SRC_COMPATDIR)/*.o - @-$(RMF) $(SRC_D2CSDIR)/*.o - @-$(RMF) $(SRC_D2DBSDIR)/*.o - @-$(RMF) $(SRC_WIN32DIR)/*.o - -.PHONY: clean-res -clean-res: - @$(ECHO) Removing Resourses - @-$(RMF) $(SRC_WIN32DIR)/*.res - -.PHONY: clean-exe -clean-exe: - @$(ECHO) Removing Executables - @-$(RMF) $(SRC_SBINDIR)/*.exe - -##################################################################### -# PACKAGING -##################################################################### - -.PHONY: gui-package -gui-package: - @$(MAKE) -s -fMakefile.mingw gui - @$(MAKE) -s -fMakefile.mingw package $(ENV) TYPE=-GUI $(ENV) - -.PHONY: console-package -console-package: - @$(MAKE) -s -fMakefile.mingw console - @$(MAKE) -s -fMakefile.mingw package $(ENV) TYPE=-Console $(ENV) NAME_TYPE=Console - -.PHONY: releases -releases: console-package gui-package - -.PHONY: package -package: $(DEST) install - @$(ECHO) Making PvPGN$(TYPE) Package - @$(ECHO) @echo off > $(installdir)/install.bat - @$(ECHO) d2cs109$(NAME_TYPE).exe -s install >> $(installdir)/install.bat - @$(ECHO) d2dbs109$(NAME_TYPE).exe -s install >> $(installdir)/install.bat - @$(ECHO) @echo off > $(installdir)/uninstall.bat - @$(ECHO) d2cs109$(NAME_TYPE).exe -s uninstall >> $(installdir)/uninstall.bat - @$(ECHO) d2dbs109$(NAME_TYPE).exe -s uninstall >> $(installdir)/uninstall.bat - @-$(RMF) $(PACKAGE) - @$(ZIP) $(PACKAGE) $(installdir) - -##################################################################### -# INSTALLING -##################################################################### - -.PHONY: install -install: install-dirs install-confs install-docs install-files install-exes install-misc install-u2d - -.PHONY: install-dirs -install-dirs: - @$(ECHO) Creating Directorys - @-$(INSTALL_DIR) $(installdir) - @-$(INSTALL_DIR) $(confdir) - @-$(INSTALL_DIR) $(docsdir) - @-$(INSTALL_DIR) $(filesdir) - @-$(INSTALL_DIR) $(sharedir) - @-$(INSTALL_DIR) $(bakdir) - @-$(INSTALL_DIR) $(bakcharsavedir) - @-$(INSTALL_DIR) $(bakcharinfodir) - @-$(INSTALL_DIR) $(charsavedir) - @-$(INSTALL_DIR) $(charinfodir) - @-$(INSTALL_DIR) $(laddersdir) - -.PHONY: install-confs -install-confs: - @$(ECHO) Installing Configuration Files - @-$(INSTALL) $(SRC_CONFDIR)/d2cs.conf.win32 $(confdir)/d2cs.conf - @-$(INSTALL) $(SRC_CONFDIR)/d2dbs.conf.win32 $(confdir)/d2dbs.conf - @-$(INSTALL) $(SRC_CONFDIR)/address_translation.conf $(confdir) - -.PHONY: install-docs -install-docs: - @$(ECHO) Installing Docs - @-$(INSTALL) $(SRC_DOCSDIR)/Service.Win32.txt $(docsdir) - @-$(INSTALL) $(SRC_DOCSDIR)/INSTALL.unix $(docsdir)/INSTALL.unix.txt - -.PHONY: install-files -install-files: - @$(ECHO) Installing Server Files - @-$(INSTALL) $(SRC_FILESDIR)/newbie.save $(filesdir) - -.PHONY: install-exes -install-exes: - @$(ECHO) Installing Executables - @-$(INSTALL) $(SRC_SBINDIR)/*.exe $(installdir) -# @-$(INSTALL) $(SRC_SBINDIR)/*.dll $(installdir) - -.PHONY: install-misc -install-misc: - @$(ECHO) Installing Misc Files - @-$(INSTALL) $(TOP_DIR)/COPYING $(installdir)/COPYING.txt - @-$(INSTALL) $(TOP_DIR)/CREDITS $(installdir)/CREDITS.txt - @-$(INSTALL) $(TOP_DIR)/README $(installdir)/README.txt - -.PHONY: install-u2d -install-u2d: - @$(ECHO) Converting Unix Style Text Files to Dos Format - @$(PCC) $(SRC_WIN32DIR)/u2d.c -o $(UNIX2DOS) - @-$(UNIX2DOS) $(confdir)/*.conf - @-$(UNIX2DOS) $(docsdir)/*.txt - @-$(UNIX2DOS) $(installdir)/*.txt - @-$(RMF) $(UNIX2DOS) - -##################################################################### -# DIRECTORYS -##################################################################### - -$(SRC_SBINDIR): - $(INSTALL_DIR) $(SRC_SBINDIR) - -$(DEST): - $(INSTALL_DIR) $(DEST) - -##################################################################### -# HEADER -##################################################################### - -.PHONY: SHOWHEADER -SHOWHEADER: - @$(ECHO) ============================================================ - @$(ECHO) CFLAGS..= $(CFLAGS) - @$(ECHO) LDFLAGS.= $(LDFLAGS) - @$(ECHO) ============================================================ - -##################################################################### -# SERVER BINS -##################################################################### - -$(d2cs_SBIN): SHOWHEADER $(d2cs_OBJECTS) $(d2cs_RES) $(SRC_SBINDIR) - @$(ECHO) Linking $@ - @$(CC) $(d2cs_OBJECTS) $(d2cs_RES) $(LDFLAGS) -o $@ - @$(STRIP) $@ - -$(d2dbs_SBIN): SHOWHEADER $(d2dbs_OBJECTS) $(d2dbs_RES) $(SRC_SBINDIR) - @$(ECHO) Linking $@ - @$(CC) $(d2dbs_OBJECTS) $(d2dbs_RES) $(LDFLAGS) -o $@ - @$(STRIP) $@ - -##################################################################### -# Object Files -##################################################################### - -%.o: %.c - @$(ECHO) Compiling $*.c - @$(CC) $(CFLAGS) -c $< -o $@ - -##################################################################### -# Resource Files -##################################################################### - -%.res: %.rc - @$(ECHO) Compiling $*.rc - @$(WINDRES) -i $< -o $@ -O coff --include-dir $(SRC_SRCDIR) diff --git a/d2pack109/Win32-Projects/make_mingw.bat b/d2pack109/Win32-Projects/make_mingw.bat deleted file mode 100644 index 9d2b171..0000000 --- a/d2pack109/Win32-Projects/make_mingw.bat +++ /dev/null @@ -1,24 +0,0 @@ -@echo off -path = C:\MinGW\bin - -if %1X == installX goto install - -mingw32-make -fMakefile.mingw %1 -goto end - -:install -if %2X == X goto error - -mingw32-make -fMakefile.mingw %1 -e prefix=%2 -goto end - -:error -echo: -echo You didn't supply the Install Path! -echo: -echo example: make_mingw install C:\d2pack109 -echo: -pause -goto end - -:end diff --git a/d2pack109/Win32-Projects/make_mingw.sh b/d2pack109/Win32-Projects/make_mingw.sh deleted file mode 100755 index b08b309..0000000 --- a/d2pack109/Win32-Projects/make_mingw.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh - -PREFIX=/usr/local/cross-tools -TARGET=i386-mingw32msvc -export PATH="$PREFIX/bin:$PREFIX/$TARGET/bin:$PATH" -export CROSS_BUILD=1 -export DEST="./win32-builds" -exec make -fMakefile.mingw $* diff --git a/d2pack109/conf/address_translation.conf b/d2pack109/conf/address_translation.conf deleted file mode 100644 index 50cbfea..0000000 --- a/d2pack109/conf/address_translation.conf +++ /dev/null @@ -1,94 +0,0 @@ -######################################################################################################## -#------------------------------------------------------------------------------------------------------# -# Address Translation table # -#------------------------------------------------------------------------------------------------------# -# # -# This is a list of ip:port addresses that get translated # -# # -# The entries are broken into four parts: # -# # -# * the IP address w/port to be translated # -# * the output IP address w/port # -# * comma delimited list of networks to be excluded from translation # -# * comma delimited list of networks to be included in translation # -# # -# Each line must contain all four parts or the entire entry will be rejected # -# There are no default ports, make sure input and output includes the port number # -# # -# The entries are searched in the order listed in this file # -# Exclude networks are searched before include networks # -# Only the first matching line is used # -# Lines begining with '#' are ignored # -# # -# If no match is found, the input ip will be returned. # -# # -# NONE = There are no neworks to exclude/include (just a place holder, no entries will be added) # -# ANY = All networks will be excluded/included (same as 0.0.0.0/0) # -# # -######################################################################################################## - -######################################################################################################## -# w3route server ip (removed from w3trans.conf) (Port 6200) # -# # -# Set input address the same as the w3routeaddr setting in the bnetd.conf # -# Set output address to the address to be sent to war3 clients # -# Set exclude to the range of clients you want to recieve the input address # -# instead of the output address # -# Set include to the range of clients you want to recieve the output address # -# # -# input (ip:port) output (ip:port) exclude (ip/netmask) include (ip/netmask) # -#--------------------- ---------------------- ---------------------------- -------------------------# - -#0.0.0.0:6200 192.168.1.100:6200 NONE 192.168.1.0/24 -#0.0.0.0:6200 internetip:6200 NONE ANY - - - -######################################################################################################## -# Game Translations for clients (removed from gametrans.conf) (client data ports) # -# # -# Set input address to the client to be translated # -# Set output address to the address to be sent to the other clients # -# Set exclude to the range of clients you want to recieve the input address # -# instead of the output address # -# Set include to the range of clients you want to recieve the output address # -# # -# input (ip:port) output (ip:port) exclude (ip/netmask) include (ip/netmask) # -#--------------------- ---------------------- ---------------------------- -------------------------# - -#192.168.1.1:6119 internetip:6119 192.168.1.0/24,10.0.0.0/8 ANY -#192.168.1.2:6118 internetip:6118 192.168.1.0/24 ANY - - - -######################################################################################################## -# Diablo II Charactar Server (d2cs) - (removed from realm.conf) (Port 6113) # -# # -# Set input address to the ip of d2cs (same as the ip in the realm.conf) # -# Set output address to the address to be sent to the clients # -# Set exclude to the range of clients you want to recieve the input address # -# instead of the output address # -# Set include to the range of client you want to recieve the output address # -# # -# input (ip:port) output (ip:port) exclude (ip/netmask) include (ip/netmask) # -#--------------------- ---------------------- ---------------------------- -------------------------# - -#192.168.1.100:6113 internetip:6113 192.168.1.0/24 ANY - - - -######################################################################################################## -# Diablo II Game Server (d2gs) - (removed from d2gstrans.conf) (Port 4000) # -# # -# Set input address to the ip of d2gs (same as the gameservlist in d2cs.conf) # -# Set output address to the address to be sent to the clients # -# Set exclude to the range of clients you want to recieve the input address # -# instead of the output address # -# Set include to the range of client you want to recieve the output address # -# # -# input (ip:port) output (ip:port) exclude (ip/netmask) include (ip/netmask) # -#--------------------- ---------------------- ---------------------------- -------------------------# - -#192.168.1.100:4000 internetip:4000 192.168.1.0/24 ANY - - diff --git a/d2pack109/conf/d2cs.conf.in b/d2pack109/conf/d2cs.conf.in deleted file mode 100644 index 844c563..0000000 --- a/d2pack109/conf/d2cs.conf.in +++ /dev/null @@ -1,201 +0,0 @@ -################################################################################# -# d2cs.conf - Configuration file for the diablo2 game control server # -#-------------------------------------------------------------------------------# -# # -# This file is an example configuration and may require modification to # -# suit your needs or your site. Blank lines and lines starting with a "#" # -# are ignored. Use quotes around values that contain spaces. # -# # -################################################################################# - - -################################################################################# -# Server Major Settings # -#-------------------------------------------------------------------------------# -# # -# Your realm server name # -realmname = D2CS - -# This is a comma delimited list of hostnames that the server should -# listen on. It might be useful to make an internal-only server on a -# gateway machine for example. If the list is not set or if it has a -# entry with no host component, the server will bind to that port on all -# interfaces. -# d2cs default listening port is 6113 -servaddrs = 0.0.0.0:6113 - -# This is a comma delimited list of game servers -#gameservlist = your.gameserver,another.gameserver - -# This is bnetd server address with port -# bnetd default listening port is 6112 -#bnetdaddr = xxx.xxx.xxx.xxx:6112 - -# Set this to the maximum number of concurrent connections allowed on -# this server. -max_connections = 1000 - -# This sets the realm to Classic or LOD or Both -# Classic = 0 -# LOD = 1 -# Both = 2 (default) -lod_realm = 2 - -# This sets whether you can convert a clasic char to -# an expansion char. -# Allow Convert = 1 -# Don't allow Convert = 0 -allow_convert = 0 - -# here u can enter the symbols allowed in accountnames (additional to -# alphanumerical symbals which are always accepted). please note that -# it is absolutly mandatory that u set up the same symbols here as in -# bnetd.conf or else u wont be able to play D2 with some characters -# (those whose symbols are allowed in bnetd.conf but not here) -# same warnings as in bnetd.conf apply here - be warned - and just -# change something if you know what you are doing -#default setting is "-_[]" -account_allowed_symbols = "-_[]" - -# # -################################################################################# - -################################################################################# -# Message logs # -#-------------------------------------------------------------------------------# -# Multiple log levels can be defined by connecting them with a comma (,) -# Available loglevels are: -# none -# trace -# debug -# info -# warn -# error -# fatal -#loglevels = fatal,error,warn,info -loglevels = fatal,error,warn,info,debug,trace - -# # -################################################################################# - -################################################################################# -# File and Path section # -# Use absolute paths in these lines to avoid problems! # -#-------------------------------------------------------------------------------# -# # -logfile = /usr/local/var/d2cs.log -charsavedir = /usr/local/var/charsave -charinfodir = /usr/local/var/charinfo -bak_charsavedir = /usr/local/var/bak/charsave -bak_charinfodir = /usr/local/var/bak/charinfo -ladderdir = /usr/local/var/ladders -newbiefile = /usr/local/var/files/newbie.save -transfile = /usr/local/etc/address_translation.conf -# # -################################################################################# - -################################################################################# -# Misc # -#-------------------------------------------------------------------------------# -# # -# Message Of The Day, support hexcode -motd = "Tips: How to use color in your profile(Right click on your portrait to open pr ofile editing). Use \\\\xffc as Prefix (\\\\xff means ascii code 0xff,but you should use copy/paste trick to in put it, c means character 'c'. Color also works in game chat,but have input limit). Then append the Color chara cter list below: \\xffc0White '0' \\xffc1Red '1' \\xffc2Green '2' \\xffc3Blue '3' \\xffc4Gold '4' \\xffc5Gray '5' Black '6' \\xffc7DarkYellow '7' \\xffc8Orange '8' \\xffc9Yellow '9' \\xffc:DarkGreen ':' \\xffc;Purple ';' \\xffc/src) and run configure. You will need to provide configure with -your custom options, ex. - -./configure --prefix= - -It will configure the source distribution to compile and install in the -location. - -Check using ./configure --help for all available options. - -3. Compile and install PvPGN using - -$ make -$ make install - -WARNING !! make install it will also overwrite the configuration files. Make a -backup of them before doing "make install" (read more about this in the UPDATE -file). - -Now you just need to edit the config files and adjust them acording to your -system. Have fun! - -4. (only for binary PvPGN distributions) -Depending on the type of package you have obtained (ex RPM, deb, tgz) you will -have to install the package using the right package tool. - -Examples: - -$ rpm -ivh pvpgn-.rpm - -or - -$ installpkg pvpgn-.tgz - -or - -$ dpkg -i pvpgn-.deb - -After you install the binary package you will need to adjust PvPGN configuration -files (usually installed in /etc/pvpgn dir). Have fun! diff --git a/d2pack109/docs/Service.Win32.txt b/d2pack109/docs/Service.Win32.txt deleted file mode 100644 index cbb0a14..0000000 --- a/d2pack109/docs/Service.Win32.txt +++ /dev/null @@ -1,5 +0,0 @@ -To Install: -run the install.bat in the main dir - -To Uninstall: -run the uninstall.bat in the main dir \ No newline at end of file diff --git a/d2pack109/src/Makefile.in b/d2pack109/src/Makefile.in deleted file mode 100644 index d83fddb..0000000 --- a/d2pack109/src/Makefile.in +++ /dev/null @@ -1,348 +0,0 @@ -# -# Copyright (C) 1999 Rob Crittenden (rcrit@greyoak.com) -# Copyright (C) 1999,2000 Ross Combs (rocombs@cs.nmsu.edu) -# -# 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. -# - -prefix = @prefix@ -exec_prefix = @exec_prefix@ - -bindir = @bindir@ -sbindir = @sbindir@ -mandir = @mandir@ -confdir = @sysconfdir@ -sharedir = @localstatedir@ -filesdir = @localstatedir@/files -charinfodir = @localstatedir@/charinfo -charsavedir = @localstatedir@/charsave -ladderdir = @localstatedir@/ladders -statusdir = @localstatedir@/status -bak_charsavedir = @localstatedir@/bak/charsave -bak_charinfodir = @localstatedir@/bak/charinfo - -SRC_SRCDIR = @srcdir@ -SRC_SBINDIR = @srcdir@/../sbin -SRC_MANDIR = @srcdir@/../man -SRC_CONFDIR = @srcdir@/../conf -SRC_SHAREDIR = @srcdir@/../files -SRC_SCRIPTDIR = @srcdir@/../scripts - -SRC_ACDIR = ${SRC_SRCDIR}/autoconf -SRC_D2CSDIR = ${SRC_SRCDIR}/d2cs -SRC_D2DBSDIR = ${SRC_SRCDIR}/d2dbs -SRC_COMMONDIR = ${SRC_SRCDIR}/common -SRC_COMPATDIR = ${SRC_SRCDIR}/compat - -RMF = rm -f - -RMDIR = rmdir - -ECHO = echo - -SED = sed - -INSTALL = @INSTALL@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_DIRS = @INSTALL@ -d -m 755 - -# CC set by configure -# CFLAGS set by configure -CPPFLAGS = @DEFS@ @DEFINES@ -DD2CS_DEFAULT_CONF_FILE=\"${confdir}/d2cs.conf\" -DD2DBS_DEFAULT_CONF_FILE=\"${confdir}/d2dbs.conf\" -I"${SRC_SRCDIR}" @CPPFLAGS@ -COMPILE = @CC@ @CFLAGS@ ${CPPFLAGS} -fno-strict-aliasing -c -#PREPROCESS = @CPP@ ${CPPFLAGS} -LINK = @CC@ @CFLAGS@ @LDFLAGS@ -LINK_LIBS = @LIBS@ - -PARTS = common compat d2cs d2dbs - -d2cs_SBIN = ${SRC_SBINDIR}/d2cs -d2cs_CONFS = d2cs.conf address_translation.conf -d2cs_OBJECTS = ${SRC_D2CSDIR}/main.o \ -${SRC_D2CSDIR}/d2gs.o \ -${SRC_D2CSDIR}/handle_d2gs.o \ -${SRC_D2CSDIR}/serverqueue.o \ -${SRC_D2CSDIR}/connection.o \ -${SRC_D2CSDIR}/game.o \ -${SRC_D2CSDIR}/server.o \ -${SRC_D2CSDIR}/handle_init.o \ -${SRC_D2CSDIR}/handle_d2cs.o \ -${SRC_D2CSDIR}/d2charfile.o \ -${SRC_D2CSDIR}/d2charlist.o \ -${SRC_D2CSDIR}/xstring.o \ -${SRC_D2CSDIR}/gamequeue.o \ -${SRC_D2CSDIR}/conf.o \ -${SRC_D2CSDIR}/prefs.o \ -${SRC_D2CSDIR}/cmdline_parse.o \ -${SRC_D2CSDIR}/bnetd.o \ -${SRC_D2CSDIR}/handle_bnetd.o \ -${SRC_D2CSDIR}/s2s.o \ -${SRC_D2CSDIR}/net.o \ -${SRC_D2CSDIR}/d2ladder.o \ -${SRC_D2CSDIR}/handle_signal.o \ -${SRC_COMMONDIR}/hashtable.o \ -${SRC_COMMONDIR}/hexdump.o \ -${SRC_COMMONDIR}/eventlog.o \ -${SRC_COMMONDIR}/list.o \ -${SRC_COMMONDIR}/packet.o \ -${SRC_COMMONDIR}/bn_type.o \ -${SRC_COMMONDIR}/addr.o \ -${SRC_COMMONDIR}/util.o \ -${SRC_COMMONDIR}/queue.o \ -${SRC_COMMONDIR}/network.o \ -${SRC_COMMONDIR}/fdwatch.o \ -${SRC_COMMONDIR}/fdwatch_select.o \ -${SRC_COMMONDIR}/fdwatch_poll.o \ -${SRC_COMMONDIR}/fdwatch_epoll.o \ -${SRC_COMMONDIR}/fdwatch_kqueue.o \ -${SRC_COMMONDIR}/rlimit.o \ -${SRC_COMMONDIR}/trans.o \ -${SRC_COMMONDIR}/tag.o \ -${SRC_COMMONDIR}/xalloc.o \ -${SRC_COMPATDIR}/inet_aton.o \ -${SRC_COMPATDIR}/inet_ntoa.o \ -${SRC_COMPATDIR}/strdup.o \ -${SRC_COMPATDIR}/strerror.o \ -${SRC_COMPATDIR}/strtoul.o \ -${SRC_COMPATDIR}/strftime.o \ -${SRC_COMPATDIR}/strcasecmp.o \ -${SRC_COMPATDIR}/strncasecmp.o \ -${SRC_COMPATDIR}/strsep.o \ -${SRC_COMPATDIR}/psock.o \ -${SRC_COMPATDIR}/uname.o \ -${SRC_COMPATDIR}/gettimeofday.o \ -${SRC_COMPATDIR}/difftime.o \ -${SRC_COMPATDIR}/pdir.o \ -${SRC_COMPATDIR}/memset.o \ -${SRC_COMPATDIR}/memcpy.o \ -${SRC_COMPATDIR}/memmove.o - -d2dbs_SBIN = ${SRC_SBINDIR}/d2dbs -d2dbs_CONFS = d2dbs.conf -d2dbs_OBJECTS = ${SRC_D2DBSDIR}/main.o \ -${SRC_D2DBSDIR}/charlock.o \ -${SRC_D2DBSDIR}/d2ladder.o \ -${SRC_D2DBSDIR}/dbserver.o \ -${SRC_D2DBSDIR}/dbspacket.o \ -${SRC_D2DBSDIR}/cmdline_parse.o \ -${SRC_D2DBSDIR}/prefs.o \ -${SRC_D2DBSDIR}/handle_signal.o \ -${SRC_D2DBSDIR}/dbsdupecheck.o \ -${SRC_D2CSDIR}/conf.o \ -${SRC_D2CSDIR}/xstring.o \ -${SRC_COMMONDIR}/list.o \ -${SRC_COMMONDIR}/eventlog.o \ -${SRC_COMMONDIR}/bn_type.o \ -${SRC_COMMONDIR}/util.o \ -${SRC_COMMONDIR}/addr.o \ -${SRC_COMMONDIR}/fdwatch.o \ -${SRC_COMMONDIR}/fdwatch_select.o \ -${SRC_COMMONDIR}/fdwatch_poll.o \ -${SRC_COMMONDIR}/fdwatch_epoll.o \ -${SRC_COMMONDIR}/fdwatch_kqueue.o \ -${SRC_COMMONDIR}/rlimit.o \ -${SRC_COMMONDIR}/tag.o \ -${SRC_COMMONDIR}/xalloc.o \ -${SRC_COMPATDIR}/psock.o \ -${SRC_COMPATDIR}/strerror.o \ -${SRC_COMPATDIR}/strsep.o - -OBJECTS = ${d2cs_OBJECTS} ${d2dbs_OBJECTS} -SBINS = ${d2cs_SBIN} ${d2dbs_SBIN} - -CONFS = ${d2cs_CONFS} ${d2dbs_CONFS} - -SHARES = newbie.save - -OTHERRM = ${SRC_ACDIR}/ansi2knr ${SRC_ACDIR}/ansi2knr.o @ANSI2KNR_TMP@ -DIRS = ${SRC_SBINDIR} - -.PHONY: all -all: .dep @ANSI2KNR_DEP@ config ${SBINS} ${SRC_CONFDIR}/d2cs.conf ${SRC_CONFDIR}/d2dbs.conf - -.PHONY: clean -clean: - -${RMF} core - -${RMF} ${OBJECTS} - -${RMF} ${SBINS} - -${RMF} ${OTHERRM} - -.PHONY: distclean -distclean: clean - -${RMF} ${SRC_CONFDIR}/d2cs.conf - -${RMF} ${SRC_CONFDIR}/d2dbs.conf - -${RMF} ${SRC_SRCDIR}/config.cache ${SRC_SRCDIR}/config.log - -${RMF} ${SRC_SRCDIR}/config.status - -${RMF} ${SRC_SRCDIR}/Makefile ${SRC_SRCDIR}/config.h - -${RMDIR} ${DIRS} - -.PHONY: cvsclean -cvsclean: distclean - -${RMF} ${SRC_SRCDIR}/configure ${SRC_SRCDIR}/config.h.in - -.PHONY: clean-compile -clean-compile: clean all - -.PHONY: config -config: .dep ${SRC_SRCDIR}/Makefile ${SRC_SRCDIR}/config.h - -${SRC_SRCDIR}/configure: ${SRC_SRCDIR}/configure.in - @${ECHO} "The configure script is out of date; rebuilding..." - cd ${SRC_SRCDIR} && autoconf - @${ECHO} >> ${SRC_SRCDIR}/config.h.in - @${ECHO} >> $@ - -${SRC_SRCDIR}/config.h.in: ${SRC_SRCDIR}/configure.in - @${ECHO} "The config.h.in header is out of date; rebuilding..." - cd ${SRC_SRCDIR} && autoheader - @${ECHO} >> $@ - @${ECHO} >> ${SRC_SRCDIR}/configure - -${SRC_SRCDIR}/config.status: ${SRC_SRCDIR}/configure - @${ECHO} "The config.status script is out of date; rechecking..." - ${SRC_SRCDIR}/config.status --recheck - @${ECHO} >> $@ - -${SRC_SRCDIR}/config.h: ${SRC_SRCDIR}/config.h.in ${SRC_SRCDIR}/config.status - @${ECHO} "The config.h header is out of date; rewriting..." - ${SRC_SRCDIR}/config.status - @${ECHO} >> ${SRC_SRCDIR}/Makefile - @${ECHO} >> $@ - -${SRC_SRCDIR}/Makefile: ${SRC_SRCDIR}/Makefile.in ${SRC_SRCDIR}/config.status - @${ECHO} "The Makefile is out of date; rewriting..." - ${SRC_SRCDIR}/config.status - @${ECHO} >> ${SRC_SRCDIR}/config.h - @${ECHO} >> $@ - -${SRC_SBINDIR}: - ${INSTALL_DIRS} $@ - -.PHONY: install -install: .dep install-sbin install-conf install-share - -.PHONY: install-sbin -install-sbin: ${SBINS} - ${INSTALL_DIRS} ${DESTDIR}/${sbindir} - @list='${SBINS}'; for p in $$list; do \ - if test -f $$p; then \ - ${ECHO} " ${INSTALL_PROGRAM} $$p ${DESTDIR}/${sbindir}"; \ - ${INSTALL_PROGRAM} $$p ${DESTDIR}/${sbindir}; \ - else :; fi; \ - done - -.PHONY: install-conf -install-conf: ${SRC_CONFDIR}/d2cs.conf ${SRC_CONFDIR}/d2dbs.conf - ${INSTALL_DIRS} ${DESTDIR}/${confdir} - @list='${CONFS}'; for p in $$list; do \ - if test -f ${SRC_CONFDIR}/$$p; then \ - ${ECHO} " ${INSTALL_DATA} ${SRC_CONFDIR}/$$p ${DESTDIR}/${confdir}"; \ - ${INSTALL_DATA} ${SRC_CONFDIR}/$$p ${DESTDIR}/${confdir}; \ - else :; fi; \ - done - -.PHONY: install-share -install-share: - ${INSTALL_DIRS} ${DESTDIR}/${sharedir} ${DESTDIR}/${filesdir} \ - ${DESTDIR}/${charinfodir} ${DESTDIR}/${charsavedir} ${DESTDIR}/${bak_charsavedir} \ - ${DESTDIR}/${bak_charinfodir} ${DESTDIR}/${ladderdir} ${DESTDIR}/${statusdir} - @list='${SHARES}'; for p in $$list; do \ - if test -f ${SRC_SHAREDIR}/$$p; then \ - ${ECHO} " ${INSTALL_DATA} ${SRC_SHAREDIR}/$$p ${DESTDIR}/${filesdir}"; \ - ${INSTALL_DATA} ${SRC_SHAREDIR}/$$p ${DESTDIR}/${filesdir}; \ - else :; fi; \ - done - -.PHONY: uninstall -uninstall: uninstall-sbin uninstall-conf uninstall-share - -.PHONY: uninstall-sbin -uninstall-sbin: - @list='${SBINS}'; for p in $$list; do \ - ${ECHO} " ${RMF} ${sbindir}/$$p"; \ - ${RMF} ${sbindir}/$$p; \ - done - -.PHONY: uninstall-conf -uninstall-conf: - @list='${CONFS}'; for p in $$list; do \ - ${ECHO} " ${RMF} ${confdir}/$$p"; \ - ${RMF} ${confdir}/$$p; \ - done - -.PHONY: uninstall-share -uninstall-share: - @list='${SHARES}'; for p in $$list; do \ - ${ECHO} " ${RMF} ${sharedir}/$$p"; \ - ${RMF} ${sharedir}/$$p; \ - done - -${SRC_CONFDIR}/d2cs.conf: ${SRC_CONFDIR}/d2cs.conf.in ${SRC_SRCDIR}/config.status - @${RMF} $@ - ${SED} -e "s@/usr/local/var/@${sharedir}/@g" -e "s@/usr/local/etc/@${confdir}/@g" ${SRC_CONFDIR}/d2cs.conf.in > $@ - -${SRC_CONFDIR}/d2dbs.conf: ${SRC_CONFDIR}/d2dbs.conf.in ${SRC_SRCDIR}/config.status - @${RMF} $@ - ${SED} -e "s@/usr/local/var/@${sharedir}/@g" -e "s@/usr/local/etc/@${confdir}/@g" ${SRC_CONFDIR}/d2dbs.conf.in > $@ - -${SRC_ACDIR}/ansi2knr: ${SRC_ACDIR}/ansi2knr.o - @${RMF} $@ - ${LINK} ${SRC_ACDIR}/ansi2knr.o ${LINK_LIBS} -o $@ - -${SRC_ACDIR}/ansi2knr.o: ${SRC_ACDIR}/ansi2knr.c - @${RMF} $@ - ${COMPILE} ${SRC_ACDIR}/ansi2knr.c -o $@ - -SHOWHEADER: - @echo - @echo "Using compile command: ${COMPILE}" - @echo - -.c.o: SHOWHEADER - @${RMF} $@ - @echo "Compiling $*.c" - @@COMPILEANSI1@ - @@COMPILEANSI2@ - @@COMPILEANSI3@ - -.dep: - ${MAKE} dep - -dep: - @${RMF} .dep - @for a in ${PARTS}; do \ - echo Dependency check: $$a; \ - ${COMPILE} -MM `ls $$a/*.c` | sed -e "s@\(.*\)\.o:\(.*\)@$$a\/\1\.o:\2@g" 1>>.dep; \ - done - -${d2cs_SBIN}: SHOWHEADER ${d2cs_OBJECTS} - @${INSTALL_DIRS} ${SRC_SBINDIR} - @${RMF} $@ - ${LINK} ${d2cs_OBJECTS} ${LINK_LIBS} -o $@ - -${d2dbs_SBIN}: SHOWHEADER ${d2dbs_OBJECTS} - @${INSTALL_DIRS} ${SRC_SBINDIR} - @${RMF} $@ - ${LINK} ${d2dbs_OBJECTS} ${LINK_LIBS} -o $@ - -ifneq ($(wildcard .dep),) -include .dep -endif - -# Tell versions (3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/d2pack109/src/autoconf/ansi2knr.c b/d2pack109/src/autoconf/ansi2knr.c deleted file mode 100644 index 1ef66bf..0000000 --- a/d2pack109/src/autoconf/ansi2knr.c +++ /dev/null @@ -1,637 +0,0 @@ -/* Copyright (C) 1989, 1997, 1998 Aladdin Enterprises. All rights reserved. */ - -/*$Id: ansi2knr.c,v 1.1.1.1 2004/03/11 18:57:30 dizzy Exp $*/ -/* Convert ANSI C function definitions to K&R ("traditional C") syntax */ - -/* -ansi2knr is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY. No author or distributor accepts responsibility to anyone for the -consequences of using it or for whether it serves any particular purpose or -works at all, unless he says so in writing. Refer to the GNU General Public -License (the "GPL") for full details. - -Everyone is granted permission to copy, modify and redistribute ansi2knr, -but only under the conditions described in the GPL. A copy of this license -is supposed to have been given to you along with ansi2knr so you can know -your rights and responsibilities. It should be in a file named COPYLEFT, -or, if there is no file named COPYLEFT, a file named COPYING. Among other -things, the copyright notice and this notice must be preserved on all -copies. - -We explicitly state here what we believe is already implied by the GPL: if -the ansi2knr program is distributed as a separate set of sources and a -separate executable file which are aggregated on a storage medium together -with another program, this in itself does not bring the other program under -the GPL, nor does the mere fact that such a program or the procedures for -constructing it invoke the ansi2knr executable bring any other part of the -program under the GPL. -*/ - -/* - * Usage: - ansi2knr [--filename FILENAME] [INPUT_FILE [OUTPUT_FILE]] - * --filename provides the file name for the #line directive in the output, - * overriding input_file (if present). - * If no input_file is supplied, input is read from stdin. - * If no output_file is supplied, output goes to stdout. - * There are no error messages. - * - * ansi2knr recognizes function definitions by seeing one or more - * identifiers at the left margin, possibly including function pointer - * types, eventually followed by a left parenthesis with a right - * parenthesis after that and with a left brace as the first token on - * the next line. ansi2knr will recognize a multi-line header provided - * that no intervening line ends with a left or right brace or a - * semicolon. These algorithms ignore whitespace and comments. - * The following constructs will confuse it: - * - Any other construct that starts at the left margin and - * follows the above syntax (such as a macro or function call). - * - Some macros that tinker with the syntax of the function header. - */ - -/* - * The original and principal author of ansi2knr is L. Peter Deutsch - * . Other authors are noted in the change history - * that follows (in reverse chronological order): - rac 2000-08-02 modified to not force the return values to be - on the preceding line, to transform prototypes, to - remove the "void" single parameter restriction, and to - handle function pointers with ANSI style parameters. - lpd 1998-11-09 added further hack to recognize identifier(void) - as being a procedure - lpd 1998-10-23 added hack to recognize lines consisting of - identifier1(identifier2) as *not* being procedures - lpd 1997-12-08 made input_file optional; only closes input and/or - output file if not stdin or stdout respectively; prints - usage message on stderr rather than stdout; adds - --filename switch (changes suggested by - ) - lpd 1996-01-21 added code to cope with not HAVE_CONFIG_H and with - compilers that don't understand void, as suggested by - Tom Lane - lpd 1996-01-15 changed to require that the first non-comment token - on the line following a function header be a left brace, - to reduce sensitivity to macros, as suggested by Tom Lane - - lpd 1995-06-22 removed #ifndefs whose sole purpose was to define - undefined preprocessor symbols as 0; changed all #ifdefs - for configuration symbols to #ifs - lpd 1995-04-05 changed copyright notice to make it clear that - including ansi2knr in a program does not bring the entire - program under the GPL - lpd 1994-12-18 added conditionals for systems where ctype macros - don't handle 8-bit characters properly, suggested by - Francois Pinard ; - removed --varargs switch (this is now the default) - lpd 1994-10-10 removed CONFIG_BROKETS conditional - lpd 1994-07-16 added some conditionals to help GNU `configure', - suggested by Francois Pinard ; - properly erase prototype args in function parameters, - contributed by Jim Avera ; - correct error in writeblanks (it shouldn't erase EOLs) - lpd 1989-xx-xx original version - */ - -/* Most of the conditionals here are to make ansi2knr work with */ -/* or without the GNU configure machinery. */ - -#if HAVE_CONFIG_H -# include -#endif - -#include -#include - -#if HAVE_CONFIG_H - -/* - For properly autoconfiguring ansi2knr, use AC_CONFIG_HEADER(config.h). - This will define HAVE_CONFIG_H and so, activate the following lines. - */ - -# if STDC_HEADERS || HAVE_STRING_H -# include -# else -# include -# endif - -#else /* not HAVE_CONFIG_H */ - -/* Otherwise do it the hard way */ - -# ifdef BSD -# include -# else -# ifdef VMS - extern int strlen(), strncmp(); -# else -# include -# endif -# endif - -#endif /* not HAVE_CONFIG_H */ - -#if STDC_HEADERS -# include -#else -/* - malloc and free should be declared in stdlib.h, - but if you've got a K&R compiler, they probably aren't. - */ -# ifdef MSDOS -# include -# else -# ifdef VMS - extern char *malloc(); - extern void free(); -# else - extern char *malloc(); - extern int free(); -# endif -# endif - -#endif - -/* - * The ctype macros don't always handle 8-bit characters correctly. - * Compensate for this here. - */ -#ifdef isascii -# undef HAVE_ISASCII /* just in case */ -# define HAVE_ISASCII 1 -#else -#endif -#if STDC_HEADERS || !HAVE_ISASCII -# define is_ascii(c) 1 -#else -# define is_ascii(c) isascii(c) -#endif - -#define is_space(c) (is_ascii(c) && isspace(c)) -#define is_alpha(c) (is_ascii(c) && isalpha(c)) -#define is_alnum(c) (is_ascii(c) && isalnum(c)) - -/* Scanning macros */ -#define isidchar(ch) (is_alnum(ch) || (ch) == '_') -#define isidfirstchar(ch) (is_alpha(ch) || (ch) == '_') - -/* Forward references */ -static char *skipspace(); -static int writeblanks(); -static int test1(); -static int convert1(); - -static char *startfn; -static char *endfn; - -/* The main program */ -int -main(argc, argv) - int argc; - char *argv[]; -{ FILE *in = stdin; - FILE *out = stdout; - char *filename = 0; -#define bufsize 5000 /* arbitrary size */ - char *buf; - char *line; - char *more; - char *usage = - "Usage: ansi2knr [--filename FILENAME] [INPUT_FILE [OUTPUT_FILE]]\n"; - /* - * In previous versions, ansi2knr recognized a --varargs switch. - * If this switch was supplied, ansi2knr would attempt to convert - * a ... argument to va_alist and va_dcl; if this switch was not - * supplied, ansi2knr would simply drop any such arguments. - * Now, ansi2knr always does this conversion, and we only - * check for this switch for backward compatibility. - */ - int convert_varargs = 1; - - while ( argc > 1 && argv[1][0] == '-' ) { - if ( !strcmp(argv[1], "--varargs") ) { - convert_varargs = 1; - argc--; - argv++; - continue; - } - if ( !strcmp(argv[1], "--filename") && argc > 2 ) { - filename = argv[2]; - argc -= 2; - argv += 2; - continue; - } - fprintf(stderr, "Unrecognized switch: %s\n", argv[1]); - fprintf(stderr, usage); - exit(1); - } - switch ( argc ) - { - default: - fprintf(stderr, usage); - exit(0); - case 3: - out = fopen(argv[2], "w"); - if ( out == NULL ) { - fprintf(stderr, "Cannot open output file %s\n", argv[2]); - exit(1); - } - /* falls through */ - case 2: - in = fopen(argv[1], "r"); - if ( in == NULL ) { - fprintf(stderr, "Cannot open input file %s\n", argv[1]); - exit(1); - } - if ( filename == 0 ) - filename = argv[1]; - /* falls through */ - case 1: - break; - } - if ( filename ) - fprintf(out, "#line 1 \"%s\"\n", filename); - buf = malloc(bufsize); - line = buf; - while ( fgets(line, (unsigned)(buf + bufsize - line), in) != NULL ) - { -test: line += strlen(line); - switch ( test1(buf) ) - { - case 3: /* a function pointer */ - case 2: /* a function prototype */ - convert1(buf, out, 1, convert_varargs); - break; - case 1: /* a function */ - /* Check for a { at the start of the next line. */ - more = ++line; -f: if ( line >= buf + (bufsize - 1) ) /* overflow check */ - goto wl; - if ( fgets(line, (unsigned)(buf + bufsize - line), in) == NULL ) - goto wl; - switch ( *skipspace(more, 1) ) - { - case '{': - /* Definitely a function */ - convert1(buf, out, 0, convert_varargs); - fputs(more, out); - break; - case 0: - /* The next line was blank or a comment: */ - /* keep scanning for a non-comment. */ - line += strlen(line); - goto f; - default: - /* buf isn't a function header, but */ - /* more might be. */ - fputs(buf, out); - strcpy(buf, more); - line = buf; - goto test; - } - break; - case -1: /* maybe the start of a function */ - if ( line != buf + (bufsize - 1) ) /* overflow check */ - continue; - /* falls through */ - default: /* not a function */ -wl: fputs(buf, out); - break; - } - line = buf; - } - if ( line != buf ) - fputs(buf, out); - free(buf); - if ( out != stdout ) - fclose(out); - if ( in != stdin ) - fclose(in); - return 0; -} - - -/* Skip over space and comments, in either direction. */ -static char * -skipspace(p, dir) - char *p; - int dir; /* 1 for forward, -1 for backward */ -{ if (*p=='\0') return p; - for ( ; ; ) - { while ( is_space(*p) ) - p += dir; - if ( !(*p == '/' && p[dir] == '*') ) - break; - p += dir; p += dir; - while ( !(*p == '*' && p[dir] == '/') ) - { if ( *p == 0 ) - return p; /* multi-line comment?? */ - p += dir; - } - p += dir; p += dir; - } - return p; -} - -/* - * Write blanks over part of a string. - * Don't overwrite end-of-line characters. - */ -static int -writeblanks(start, end) - char *start; - char *end; -{ char *p; - for ( p = start; p < end; p++ ) - if ( *p != '\r' && *p != '\n' ) - *p = ' '; - return 0; -} - -/* - * Test whether the string in buf is a function definition. - * The string may contain and/or end with a newline. - * Return as follows: - * 0 - definitely not a function definition; - * 1 - definitely a function definition; - * 2 - definitely a function prototype; - * 3 - definitely a function pointer; - * -1 - may be the beginning of a function definition, - * append another line and look again. - */ -static int -test1(buf) - char *buf; -{ char *p; - char *bend; - int contin; - - if ( !isalpha(*buf) ) - return 0; /* no name at left margin */ - bend = skipspace(buf + strlen(buf) - 1, -1); - switch ( *bend ) - { - case ';': contin = 2; break; - case ')': contin = 1; break; - case '{': - case '}': - return 0; /* not a function */ - default: contin = -1; - } - - /* find start and end of function name */ - startfn=buf; - while (*startfn!='\0' && *startfn!='(') - { - startfn++; - startfn = skipspace(startfn, 1); - } - if (*startfn=='\0') - return 0; /* not a function */ - startfn--; - p = startfn; - startfn = skipspace(startfn,-1); - endfn = startfn+1; - while (isidchar(*startfn)) startfn--; - startfn++; - if (startfn>=endfn) - return 0; - - p = skipspace(endfn, 1); -#if 0 -/* v v */ -/* typedef __ssize_t __io_read_ */ -fprintf(stderr,"found %s\n",buf); -fprintf(stderr,"func="); -{ int i; for (i=0; i 0) { - int level = 0; - - for (p = endfn; *p; p = skipspace(p + 1, 1)) - level += (*p == '(' ? 1 : *p == ')' ? -1 : 0); - if (level > 0) - contin = -1; - } - return contin; -} - -/* Convert a recognized function definition or header to K&R syntax. */ -static int -convert1(buf, out, header, convert_varargs) - char *buf; - FILE *out; - int header; /* Boolean */ - int convert_varargs; /* Boolean */ -{ - char *p; - /* - * The breaks table contains pointers to the beginning and end - * of each argument. - */ - char **breaks; - unsigned num_breaks = 2; /* for testing */ - char **btop; - char **bp; - char **ap; - char *vararg = 0; - - for (p=buf; p= btop ) - { /* Filled up break table. */ - /* Allocate a bigger one and start over. */ - free((char *)breaks); - num_breaks <<= 1; - goto top; - } - *bp++ = p; - /* Find the end of the argument */ - for ( ; end == NULL; p++ ) - { switch(*p) - { - case ',': - if ( !level ) end = p; - break; - case '(': - if ( !level ) lp = p; - level++; - break; - case ')': - if ( --level < 0 ) end = p; - else rp = p; - break; - case '/': - p = skipspace(p, 1) - 1; - break; - default: - ; - } - } - /* Erase any embedded function pointer parameters. */ - if ( lp ) - writeblanks(lp + 1, rp); - p--; /* back up over terminator */ - /* Find the name being declared. */ - /* This is complicated because of procedure and */ - /* array modifiers. */ - for ( ; ; ) - { p = skipspace(p - 1, -1); - switch ( *p ) - { - case ']': /* skip array dimension(s) */ - case ')': /* skip procedure args OR name */ - { int level = 1; - while ( level ) - switch ( *--p ) - { - case ']': case ')': level++; break; - case '[': case '(': level--; break; - case '/': p = skipspace(p, -1) + 1; break; - default: ; - } - } - if ( *p == '(' && *skipspace(p + 1, 1) == '*' ) - { /* We found the name of the function pointer */ - while ( !isidfirstchar(*p) ) - p = skipspace(p, 1) + 1; - goto found; - } - break; - default: - goto found; - } - } -found: if ( *p == '.' && p[-1] == '.' && p[-2] == '.' ) - { if ( convert_varargs ) - { *bp++ = "va_alist"; - vararg = p-2; - } - else - { p++; - if ( bp == breaks + 1 ) /* sole argument */ - writeblanks(breaks[0], p); - else - writeblanks(bp[-1] - 1, p); - bp--; - } - } - else - { while ( isidchar(*p) ) p--; - *bp++ = p+1; - } - p = end; - } - while ( *p++ == ',' ); - *bp = p; - /* Make a special check for 'void' arglist */ - if ( bp == breaks+2 ) - { p = skipspace(breaks[0], 1); - if ( !strncmp(p, "void", 4) ) - { p = skipspace(p+4, 1); - if ( p == breaks[2] - 1 ) - { bp = breaks; /* yup, pretend arglist is empty */ - writeblanks(breaks[0], p + 1); - } - } - } - /* Put out the function name and left parenthesis. */ - for (p=startfn; p != endfn; p++) putc(*p, out); - /* Put out the declaration. */ - if ( header ) - { fputs(");", out); - for ( p = breaks[0]; *p; p++ ) - if ( *p == '\r' || *p == '\n' ) - putc(*p, out); - } - else - { for ( ap = breaks+1; ap < bp; ap += 2 ) - { p = *ap; - while ( isidchar(*p) ) - putc(*p, out), p++; - if ( ap < bp - 1 ) - fputs(", ", out); - } - fputs(") ", out); - /* Put out the argument declarations */ - for ( ap = breaks+2; ap <= bp; ap += 2 ) - (*ap)[-1] = ';'; - if ( vararg != 0 ) - { *vararg = 0; - fputs(breaks[0], out); /* any prior args */ - fputs("va_dcl", out); /* the final arg */ - fputs(bp[0], out); - } - else - fputs(breaks[0], out); - } - free((char *)breaks); - return 0; -} diff --git a/d2pack109/src/autoconf/ccstdc.m4 b/d2pack109/src/autoconf/ccstdc.m4 deleted file mode 100644 index dfe01fb..0000000 --- a/d2pack109/src/autoconf/ccstdc.m4 +++ /dev/null @@ -1,91 +0,0 @@ -## ----------------------------------------- ## -## ANSIfy the C compiler whenever possible. ## -## From Franc,ois Pinard ## -## ----------------------------------------- ## - -# serial 1 - -# @defmac AC_PROG_CC_STDC -# @maindex PROG_CC_STDC -# @ovindex CC -# If the C compiler in not in ANSI C mode by default, try to add an option -# to output variable @code{CC} to make it so. This macro tries various -# options that select ANSI C on some system or another. It considers the -# compiler to be in ANSI C mode if it handles function prototypes correctly. -# -# If you use this macro, you should check after calling it whether the C -# compiler has been set to accept ANSI C; if not, the shell variable -# @code{am_cv_prog_cc_stdc} is set to @samp{no}. If you wrote your source -# code in ANSI C, you can make an un-ANSIfied copy of it by using the -# program @code{ansi2knr}, which comes with Ghostscript. -# @end defmac - -AC_DEFUN(AM_PROG_CC_STDC, -[AC_REQUIRE([AC_PROG_CC]) -AC_BEFORE([$0], [AC_C_INLINE]) -AC_BEFORE([$0], [AC_C_CONST]) -dnl Force this before AC_PROG_CPP. Some cpp's, eg on HPUX, require -dnl a magic option to avoid problems with ANSI preprocessor commands -dnl like #elif. -dnl FIXME: can't do this because then AC_AIX won't work due to a -dnl circular dependency. -dnl AC_BEFORE([$0], [AC_PROG_CPP]) -AC_MSG_CHECKING(for ${CC-cc} option to accept ANSI C) -AC_CACHE_VAL(am_cv_prog_cc_stdc, -[am_cv_prog_cc_stdc=no -ac_save_CC="$CC" -# Don't try gcc -ansi; that turns off useful extensions and -# breaks some systems' header files. -# AIX -qlanglvl=ansi -# Ultrix and OSF/1 -std1 -# HP-UX -Aa -D_HPUX_SOURCE -# SVR4 -Xc -D__EXTENSIONS__ -for ac_arg in "" -qlanglvl=ansi -std1 "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" -do - CC="$ac_save_CC $ac_arg" - AC_TRY_COMPILE( -[#include -#include -#include -#include -/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ -struct buf { int x; }; -FILE * (*rcsopen) (struct buf *, struct stat *, int); -static char *e (p, i) - char **p; - int i; -{ - return p[i]; -} -static char *f (char * (*g) (char **, int), char **p, ...) -{ - char *s; - va_list v; - va_start (v,p); - s = g (p, va_arg (v,int)); - va_end (v); - return s; -} -int test (int i, double x); -struct s1 {int (*f) (int a);}; -struct s2 {int (*f) (double a);}; -int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); -int argc; -char **argv; -], [ -return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; -], -[am_cv_prog_cc_stdc="$ac_arg"; break]) -done -CC="$ac_save_CC" -]) -if test -z "$am_cv_prog_cc_stdc"; then - AC_MSG_RESULT([none needed]) -else - AC_MSG_RESULT($am_cv_prog_cc_stdc) -fi -case "x$am_cv_prog_cc_stdc" in - x|xno) ;; - *) CC="$CC $am_cv_prog_cc_stdc" ;; -esac -]) diff --git a/d2pack109/src/autoconf/config.guess b/d2pack109/src/autoconf/config.guess deleted file mode 100644 index d56c46d..0000000 --- a/d2pack109/src/autoconf/config.guess +++ /dev/null @@ -1,1410 +0,0 @@ -#! /bin/sh -# Attempt to guess a canonical system name. -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -# 2000, 2001, 2002, 2003 Free Software Foundation, Inc. - -timestamp='2003-08-18' - -# This file 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. -# -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# Originally written by Per Bothner . -# Please send patches to . Submit a context -# diff and a properly formatted ChangeLog entry. -# -# This script attempts to guess a canonical system name similar to -# config.sub. If it succeeds, it prints the system name on stdout, and -# exits with 0. Otherwise, it exits with 1. -# -# The plan is that this can be called by configure scripts if you -# don't specify an explicit build system type. - -me=`echo "$0" | sed -e 's,.*/,,'` - -usage="\ -Usage: $0 [OPTION] - -Output the configuration name of the system \`$me' is run on. - -Operation modes: - -h, --help print this help, then exit - -t, --time-stamp print date of last modification, then exit - -v, --version print version number, then exit - -Report bugs and patches to ." - -version="\ -GNU config.guess ($timestamp) - -Originally written by Per Bothner. -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 -Free Software Foundation, Inc. - -This is free software; see the source for copying conditions. There is NO -warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." - -help=" -Try \`$me --help' for more information." - -# Parse command line -while test $# -gt 0 ; do - case $1 in - --time-stamp | --time* | -t ) - echo "$timestamp" ; exit 0 ;; - --version | -v ) - echo "$version" ; exit 0 ;; - --help | --h* | -h ) - echo "$usage"; exit 0 ;; - -- ) # Stop option processing - shift; break ;; - - ) # Use stdin as input. - break ;; - -* ) - echo "$me: invalid option $1$help" >&2 - exit 1 ;; - * ) - break ;; - esac -done - -if test $# != 0; then - echo "$me: too many arguments$help" >&2 - exit 1 -fi - -trap 'exit 1' 1 2 15 - -# CC_FOR_BUILD -- compiler used by this script. Note that the use of a -# compiler to aid in system detection is discouraged as it requires -# temporary files to be created and, as you can see below, it is a -# headache to deal with in a portable fashion. - -# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still -# use `HOST_CC' if defined, but it is deprecated. - -# Portable tmp directory creation inspired by the Autoconf team. - -set_cc_for_build=' -trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; -trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; -: ${TMPDIR=/tmp} ; - { tmp=`(umask 077 && mktemp -d -q "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || - { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || - { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || - { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; -dummy=$tmp/dummy ; -tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; -case $CC_FOR_BUILD,$HOST_CC,$CC in - ,,) echo "int x;" > $dummy.c ; - for c in cc gcc c89 c99 ; do - if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then - CC_FOR_BUILD="$c"; break ; - fi ; - done ; - if test x"$CC_FOR_BUILD" = x ; then - CC_FOR_BUILD=no_compiler_found ; - fi - ;; - ,,*) CC_FOR_BUILD=$CC ;; - ,*,*) CC_FOR_BUILD=$HOST_CC ;; -esac ;' - -# This is needed to find uname on a Pyramid OSx when run in the BSD universe. -# (ghazi@noc.rutgers.edu 1994-08-24) -if (test -f /.attbin/uname) >/dev/null 2>&1 ; then - PATH=$PATH:/.attbin ; export PATH -fi - -UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown -UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown -UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown -UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown - -# Note: order is significant - the case branches are not exclusive. - -case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in - *:NetBSD:*:*) - # NetBSD (nbsd) targets should (where applicable) match one or - # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, - # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently - # switched to ELF, *-*-netbsd* would select the old - # object file format. This provides both forward - # compatibility and a consistent mechanism for selecting the - # object file format. - # - # Note: NetBSD doesn't particularly care about the vendor - # portion of the name. We always set it to "unknown". - sysctl="sysctl -n hw.machine_arch" - UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ - /usr/sbin/$sysctl 2>/dev/null || echo unknown)` - case "${UNAME_MACHINE_ARCH}" in - armeb) machine=armeb-unknown ;; - arm*) machine=arm-unknown ;; - sh3el) machine=shl-unknown ;; - sh3eb) machine=sh-unknown ;; - *) machine=${UNAME_MACHINE_ARCH}-unknown ;; - esac - # The Operating System including object format, if it has switched - # to ELF recently, or will in the future. - case "${UNAME_MACHINE_ARCH}" in - arm*|i386|m68k|ns32k|sh3*|sparc|vax) - eval $set_cc_for_build - if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ - | grep __ELF__ >/dev/null - then - # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). - # Return netbsd for either. FIX? - os=netbsd - else - os=netbsdelf - fi - ;; - *) - os=netbsd - ;; - esac - # The OS release - # Debian GNU/NetBSD machines have a different userland, and - # thus, need a distinct triplet. However, they do not need - # kernel version information, so it can be replaced with a - # suitable tag, in the style of linux-gnu. - case "${UNAME_VERSION}" in - Debian*) - release='-gnu' - ;; - *) - release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` - ;; - esac - # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: - # contains redundant information, the shorter form: - # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. - echo "${machine}-${os}${release}" - exit 0 ;; - amiga:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - arc:OpenBSD:*:*) - echo mipsel-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - hp300:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - mac68k:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - macppc:OpenBSD:*:*) - echo powerpc-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - mvme68k:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - mvme88k:OpenBSD:*:*) - echo m88k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - mvmeppc:OpenBSD:*:*) - echo powerpc-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - pmax:OpenBSD:*:*) - echo mipsel-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - sgi:OpenBSD:*:*) - echo mipseb-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - sun3:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - wgrisc:OpenBSD:*:*) - echo mipsel-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - *:OpenBSD:*:*) - echo ${UNAME_MACHINE}-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - alpha:OSF1:*:*) - if test $UNAME_RELEASE = "V4.0"; then - UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` - fi - # According to Compaq, /usr/sbin/psrinfo has been available on - # OSF/1 and Tru64 systems produced since 1995. I hope that - # covers most systems running today. This code pipes the CPU - # types through head -n 1, so we only detect the type of CPU 0. - ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` - case "$ALPHA_CPU_TYPE" in - "EV4 (21064)") - UNAME_MACHINE="alpha" ;; - "EV4.5 (21064)") - UNAME_MACHINE="alpha" ;; - "LCA4 (21066/21068)") - UNAME_MACHINE="alpha" ;; - "EV5 (21164)") - UNAME_MACHINE="alphaev5" ;; - "EV5.6 (21164A)") - UNAME_MACHINE="alphaev56" ;; - "EV5.6 (21164PC)") - UNAME_MACHINE="alphapca56" ;; - "EV5.7 (21164PC)") - UNAME_MACHINE="alphapca57" ;; - "EV6 (21264)") - UNAME_MACHINE="alphaev6" ;; - "EV6.7 (21264A)") - UNAME_MACHINE="alphaev67" ;; - "EV6.8CB (21264C)") - UNAME_MACHINE="alphaev68" ;; - "EV6.8AL (21264B)") - UNAME_MACHINE="alphaev68" ;; - "EV6.8CX (21264D)") - UNAME_MACHINE="alphaev68" ;; - "EV6.9A (21264/EV69A)") - UNAME_MACHINE="alphaev69" ;; - "EV7 (21364)") - UNAME_MACHINE="alphaev7" ;; - "EV7.9 (21364A)") - UNAME_MACHINE="alphaev79" ;; - esac - # A Vn.n version is a released version. - # A Tn.n version is a released field test version. - # A Xn.n version is an unreleased experimental baselevel. - # 1.2 uses "1.2" for uname -r. - echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - exit 0 ;; - Alpha*:OpenVMS:*:*) - echo alpha-hp-vms - exit 0 ;; - Alpha\ *:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # Should we change UNAME_MACHINE based on the output of uname instead - # of the specific Alpha model? - echo alpha-pc-interix - exit 0 ;; - 21064:Windows_NT:50:3) - echo alpha-dec-winnt3.5 - exit 0 ;; - Amiga*:UNIX_System_V:4.0:*) - echo m68k-unknown-sysv4 - exit 0;; - *:[Aa]miga[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-amigaos - exit 0 ;; - *:[Mm]orph[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-morphos - exit 0 ;; - *:OS/390:*:*) - echo i370-ibm-openedition - exit 0 ;; - arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) - echo arm-acorn-riscix${UNAME_RELEASE} - exit 0;; - SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) - echo hppa1.1-hitachi-hiuxmpp - exit 0;; - Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) - # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. - if test "`(/bin/universe) 2>/dev/null`" = att ; then - echo pyramid-pyramid-sysv3 - else - echo pyramid-pyramid-bsd - fi - exit 0 ;; - NILE*:*:*:dcosx) - echo pyramid-pyramid-svr4 - exit 0 ;; - DRS?6000:unix:4.0:6*) - echo sparc-icl-nx6 - exit 0 ;; - DRS?6000:UNIX_SV:4.2*:7*) - case `/usr/bin/uname -p` in - sparc) echo sparc-icl-nx7 && exit 0 ;; - esac ;; - sun4H:SunOS:5.*:*) - echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; - sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) - echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; - i86pc:SunOS:5.*:*) - echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; - sun4*:SunOS:6*:*) - # According to config.sub, this is the proper way to canonicalize - # SunOS6. Hard to guess exactly what SunOS6 will be like, but - # it's likely to be more like Solaris than SunOS4. - echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; - sun4*:SunOS:*:*) - case "`/usr/bin/arch -k`" in - Series*|S4*) - UNAME_RELEASE=`uname -v` - ;; - esac - # Japanese Language versions have a version number like `4.1.3-JL'. - echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` - exit 0 ;; - sun3*:SunOS:*:*) - echo m68k-sun-sunos${UNAME_RELEASE} - exit 0 ;; - sun*:*:4.2BSD:*) - UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` - test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 - case "`/bin/arch`" in - sun3) - echo m68k-sun-sunos${UNAME_RELEASE} - ;; - sun4) - echo sparc-sun-sunos${UNAME_RELEASE} - ;; - esac - exit 0 ;; - aushp:SunOS:*:*) - echo sparc-auspex-sunos${UNAME_RELEASE} - exit 0 ;; - # The situation for MiNT is a little confusing. The machine name - # can be virtually everything (everything which is not - # "atarist" or "atariste" at least should have a processor - # > m68000). The system name ranges from "MiNT" over "FreeMiNT" - # to the lowercase version "mint" (or "freemint"). Finally - # the system name "TOS" denotes a system which is actually not - # MiNT. But MiNT is downward compatible to TOS, so this should - # be no problem. - atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit 0 ;; - atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit 0 ;; - *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit 0 ;; - milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) - echo m68k-milan-mint${UNAME_RELEASE} - exit 0 ;; - hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) - echo m68k-hades-mint${UNAME_RELEASE} - exit 0 ;; - *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) - echo m68k-unknown-mint${UNAME_RELEASE} - exit 0 ;; - powerpc:machten:*:*) - echo powerpc-apple-machten${UNAME_RELEASE} - exit 0 ;; - RISC*:Mach:*:*) - echo mips-dec-mach_bsd4.3 - exit 0 ;; - RISC*:ULTRIX:*:*) - echo mips-dec-ultrix${UNAME_RELEASE} - exit 0 ;; - VAX*:ULTRIX*:*:*) - echo vax-dec-ultrix${UNAME_RELEASE} - exit 0 ;; - 2020:CLIX:*:* | 2430:CLIX:*:*) - echo clipper-intergraph-clix${UNAME_RELEASE} - exit 0 ;; - mips:*:*:UMIPS | mips:*:*:RISCos) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c -#ifdef __cplusplus -#include /* for printf() prototype */ - int main (int argc, char *argv[]) { -#else - int main (argc, argv) int argc; char *argv[]; { -#endif - #if defined (host_mips) && defined (MIPSEB) - #if defined (SYSTYPE_SYSV) - printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); - #endif - #if defined (SYSTYPE_SVR4) - printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); - #endif - #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) - printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); - #endif - #endif - exit (-1); - } -EOF - $CC_FOR_BUILD -o $dummy $dummy.c \ - && $dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \ - && exit 0 - echo mips-mips-riscos${UNAME_RELEASE} - exit 0 ;; - Motorola:PowerMAX_OS:*:*) - echo powerpc-motorola-powermax - exit 0 ;; - Motorola:*:4.3:PL8-*) - echo powerpc-harris-powermax - exit 0 ;; - Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) - echo powerpc-harris-powermax - exit 0 ;; - Night_Hawk:Power_UNIX:*:*) - echo powerpc-harris-powerunix - exit 0 ;; - m88k:CX/UX:7*:*) - echo m88k-harris-cxux7 - exit 0 ;; - m88k:*:4*:R4*) - echo m88k-motorola-sysv4 - exit 0 ;; - m88k:*:3*:R3*) - echo m88k-motorola-sysv3 - exit 0 ;; - AViiON:dgux:*:*) - # DG/UX returns AViiON for all architectures - UNAME_PROCESSOR=`/usr/bin/uname -p` - if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] - then - if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ - [ ${TARGET_BINARY_INTERFACE}x = x ] - then - echo m88k-dg-dgux${UNAME_RELEASE} - else - echo m88k-dg-dguxbcs${UNAME_RELEASE} - fi - else - echo i586-dg-dgux${UNAME_RELEASE} - fi - exit 0 ;; - M88*:DolphinOS:*:*) # DolphinOS (SVR3) - echo m88k-dolphin-sysv3 - exit 0 ;; - M88*:*:R3*:*) - # Delta 88k system running SVR3 - echo m88k-motorola-sysv3 - exit 0 ;; - XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) - echo m88k-tektronix-sysv3 - exit 0 ;; - Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) - echo m68k-tektronix-bsd - exit 0 ;; - *:IRIX*:*:*) - echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` - exit 0 ;; - ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. - echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id - exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX ' - i*86:AIX:*:*) - echo i386-ibm-aix - exit 0 ;; - ia64:AIX:*:*) - if [ -x /usr/bin/oslevel ] ; then - IBM_REV=`/usr/bin/oslevel` - else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} - fi - echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} - exit 0 ;; - *:AIX:2:3) - if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #include - - main() - { - if (!__power_pc()) - exit(1); - puts("powerpc-ibm-aix3.2.5"); - exit(0); - } -EOF - $CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0 - echo rs6000-ibm-aix3.2.5 - elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then - echo rs6000-ibm-aix3.2.4 - else - echo rs6000-ibm-aix3.2 - fi - exit 0 ;; - *:AIX:*:[45]) - IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` - if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then - IBM_ARCH=rs6000 - else - IBM_ARCH=powerpc - fi - if [ -x /usr/bin/oslevel ] ; then - IBM_REV=`/usr/bin/oslevel` - else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} - fi - echo ${IBM_ARCH}-ibm-aix${IBM_REV} - exit 0 ;; - *:AIX:*:*) - echo rs6000-ibm-aix - exit 0 ;; - ibmrt:4.4BSD:*|romp-ibm:BSD:*) - echo romp-ibm-bsd4.4 - exit 0 ;; - ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and - echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to - exit 0 ;; # report: romp-ibm BSD 4.3 - *:BOSX:*:*) - echo rs6000-bull-bosx - exit 0 ;; - DPX/2?00:B.O.S.:*:*) - echo m68k-bull-sysv3 - exit 0 ;; - 9000/[34]??:4.3bsd:1.*:*) - echo m68k-hp-bsd - exit 0 ;; - hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) - echo m68k-hp-bsd4.4 - exit 0 ;; - 9000/[34678]??:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - case "${UNAME_MACHINE}" in - 9000/31? ) HP_ARCH=m68000 ;; - 9000/[34]?? ) HP_ARCH=m68k ;; - 9000/[678][0-9][0-9]) - if [ -x /usr/bin/getconf ]; then - sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` - sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` - case "${sc_cpu_version}" in - 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 - 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 - 532) # CPU_PA_RISC2_0 - case "${sc_kernel_bits}" in - 32) HP_ARCH="hppa2.0n" ;; - 64) HP_ARCH="hppa2.0w" ;; - '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 - esac ;; - esac - fi - if [ "${HP_ARCH}" = "" ]; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - - #define _HPUX_SOURCE - #include - #include - - int main () - { - #if defined(_SC_KERNEL_BITS) - long bits = sysconf(_SC_KERNEL_BITS); - #endif - long cpu = sysconf (_SC_CPU_VERSION); - - switch (cpu) - { - case CPU_PA_RISC1_0: puts ("hppa1.0"); break; - case CPU_PA_RISC1_1: puts ("hppa1.1"); break; - case CPU_PA_RISC2_0: - #if defined(_SC_KERNEL_BITS) - switch (bits) - { - case 64: puts ("hppa2.0w"); break; - case 32: puts ("hppa2.0n"); break; - default: puts ("hppa2.0"); break; - } break; - #else /* !defined(_SC_KERNEL_BITS) */ - puts ("hppa2.0"); break; - #endif - default: puts ("hppa1.0"); break; - } - exit (0); - } -EOF - (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` - test -z "$HP_ARCH" && HP_ARCH=hppa - fi ;; - esac - if [ ${HP_ARCH} = "hppa2.0w" ] - then - # avoid double evaluation of $set_cc_for_build - test -n "$CC_FOR_BUILD" || eval $set_cc_for_build - if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E -) | grep __LP64__ >/dev/null - then - HP_ARCH="hppa2.0w" - else - HP_ARCH="hppa64" - fi - fi - echo ${HP_ARCH}-hp-hpux${HPUX_REV} - exit 0 ;; - ia64:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - echo ia64-hp-hpux${HPUX_REV} - exit 0 ;; - 3050*:HI-UX:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #include - int - main () - { - long cpu = sysconf (_SC_CPU_VERSION); - /* The order matters, because CPU_IS_HP_MC68K erroneously returns - true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct - results, however. */ - if (CPU_IS_PA_RISC (cpu)) - { - switch (cpu) - { - case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; - case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; - case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; - default: puts ("hppa-hitachi-hiuxwe2"); break; - } - } - else if (CPU_IS_HP_MC68K (cpu)) - puts ("m68k-hitachi-hiuxwe2"); - else puts ("unknown-hitachi-hiuxwe2"); - exit (0); - } -EOF - $CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0 - echo unknown-hitachi-hiuxwe2 - exit 0 ;; - 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) - echo hppa1.1-hp-bsd - exit 0 ;; - 9000/8??:4.3bsd:*:*) - echo hppa1.0-hp-bsd - exit 0 ;; - *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) - echo hppa1.0-hp-mpeix - exit 0 ;; - hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) - echo hppa1.1-hp-osf - exit 0 ;; - hp8??:OSF1:*:*) - echo hppa1.0-hp-osf - exit 0 ;; - i*86:OSF1:*:*) - if [ -x /usr/sbin/sysversion ] ; then - echo ${UNAME_MACHINE}-unknown-osf1mk - else - echo ${UNAME_MACHINE}-unknown-osf1 - fi - exit 0 ;; - parisc*:Lites*:*:*) - echo hppa1.1-hp-lites - exit 0 ;; - C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) - echo c1-convex-bsd - exit 0 ;; - C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) - if getsysinfo -f scalar_acc - then echo c32-convex-bsd - else echo c2-convex-bsd - fi - exit 0 ;; - C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) - echo c34-convex-bsd - exit 0 ;; - C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) - echo c38-convex-bsd - exit 0 ;; - C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) - echo c4-convex-bsd - exit 0 ;; - CRAY*Y-MP:*:*:*) - echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit 0 ;; - CRAY*[A-Z]90:*:*:*) - echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ - | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ - -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ - -e 's/\.[^.]*$/.X/' - exit 0 ;; - CRAY*TS:*:*:*) - echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit 0 ;; - CRAY*T3E:*:*:*) - echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit 0 ;; - CRAY*SV1:*:*:*) - echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit 0 ;; - *:UNICOS/mp:*:*) - echo nv1-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit 0 ;; - F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) - FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` - echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit 0 ;; - i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) - echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} - exit 0 ;; - sparc*:BSD/OS:*:*) - echo sparc-unknown-bsdi${UNAME_RELEASE} - exit 0 ;; - *:BSD/OS:*:*) - echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} - exit 0 ;; - *:FreeBSD:*:*|*:GNU/FreeBSD:*:*) - # Determine whether the default compiler uses glibc. - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #include - #if __GLIBC__ >= 2 - LIBC=gnu - #else - LIBC= - #endif -EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=` - # GNU/FreeBSD systems have a "k" prefix to indicate we are using - # FreeBSD's kernel, but not the complete OS. - case ${LIBC} in gnu) kernel_only='k' ;; esac - echo ${UNAME_MACHINE}-unknown-${kernel_only}freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`${LIBC:+-$LIBC} - exit 0 ;; - i*:CYGWIN*:*) - echo ${UNAME_MACHINE}-pc-cygwin - exit 0 ;; - i*:MINGW*:*) - echo ${UNAME_MACHINE}-pc-mingw32 - exit 0 ;; - i*:PW*:*) - echo ${UNAME_MACHINE}-pc-pw32 - exit 0 ;; - x86:Interix*:[34]*) - echo i586-pc-interix${UNAME_RELEASE}|sed -e 's/\..*//' - exit 0 ;; - [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) - echo i${UNAME_MACHINE}-pc-mks - exit 0 ;; - i*:Windows_NT*:* | Pentium*:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we - # UNAME_MACHINE based on the output of uname instead of i386? - echo i586-pc-interix - exit 0 ;; - i*:UWIN*:*) - echo ${UNAME_MACHINE}-pc-uwin - exit 0 ;; - p*:CYGWIN*:*) - echo powerpcle-unknown-cygwin - exit 0 ;; - prep*:SunOS:5.*:*) - echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; - *:GNU:*:*) - echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` - exit 0 ;; - i*86:Minix:*:*) - echo ${UNAME_MACHINE}-pc-minix - exit 0 ;; - arm*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; - cris:Linux:*:*) - echo cris-axis-linux-gnu - exit 0 ;; - ia64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; - m68*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; - mips:Linux:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #undef CPU - #undef mips - #undef mipsel - #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) - CPU=mipsel - #else - #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) - CPU=mips - #else - CPU= - #endif - #endif -EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` - test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0 - ;; - mips64:Linux:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #undef CPU - #undef mips64 - #undef mips64el - #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) - CPU=mips64el - #else - #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) - CPU=mips64 - #else - CPU= - #endif - #endif -EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` - test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0 - ;; - ppc:Linux:*:*) - echo powerpc-unknown-linux-gnu - exit 0 ;; - ppc64:Linux:*:*) - echo powerpc64-unknown-linux-gnu - exit 0 ;; - alpha:Linux:*:*) - case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in - EV5) UNAME_MACHINE=alphaev5 ;; - EV56) UNAME_MACHINE=alphaev56 ;; - PCA56) UNAME_MACHINE=alphapca56 ;; - PCA57) UNAME_MACHINE=alphapca56 ;; - EV6) UNAME_MACHINE=alphaev6 ;; - EV67) UNAME_MACHINE=alphaev67 ;; - EV68*) UNAME_MACHINE=alphaev68 ;; - esac - objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null - if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi - echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} - exit 0 ;; - parisc:Linux:*:* | hppa:Linux:*:*) - # Look for CPU level - case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in - PA7*) echo hppa1.1-unknown-linux-gnu ;; - PA8*) echo hppa2.0-unknown-linux-gnu ;; - *) echo hppa-unknown-linux-gnu ;; - esac - exit 0 ;; - parisc64:Linux:*:* | hppa64:Linux:*:*) - echo hppa64-unknown-linux-gnu - exit 0 ;; - s390:Linux:*:* | s390x:Linux:*:*) - echo ${UNAME_MACHINE}-ibm-linux - exit 0 ;; - sh64*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; - sh*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; - sparc:Linux:*:* | sparc64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; - x86_64:Linux:*:*) - echo x86_64-unknown-linux-gnu - exit 0 ;; - i*86:Linux:*:*) - # The BFD linker knows what the default object file format is, so - # first see if it will tell us. cd to the root directory to prevent - # problems with other programs or directories called `ld' in the path. - # Set LC_ALL=C to ensure ld outputs messages in English. - ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \ - | sed -ne '/supported targets:/!d - s/[ ][ ]*/ /g - s/.*supported targets: *// - s/ .*// - p'` - case "$ld_supported_targets" in - elf32-i386) - TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu" - ;; - a.out-i386-linux) - echo "${UNAME_MACHINE}-pc-linux-gnuaout" - exit 0 ;; - coff-i386) - echo "${UNAME_MACHINE}-pc-linux-gnucoff" - exit 0 ;; - "") - # Either a pre-BFD a.out linker (linux-gnuoldld) or - # one that does not give us useful --help. - echo "${UNAME_MACHINE}-pc-linux-gnuoldld" - exit 0 ;; - esac - # Determine whether the default compiler is a.out or elf - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #include - #ifdef __ELF__ - # ifdef __GLIBC__ - # if __GLIBC__ >= 2 - LIBC=gnu - # else - LIBC=gnulibc1 - # endif - # else - LIBC=gnulibc1 - # endif - #else - #ifdef __INTEL_COMPILER - LIBC=gnu - #else - LIBC=gnuaout - #endif - #endif - #ifdef __dietlibc__ - LIBC=dietlibc - #endif -EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=` - test x"${LIBC}" != x && echo "${UNAME_MACHINE}-pc-linux-${LIBC}" && exit 0 - test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0 - ;; - i*86:DYNIX/ptx:4*:*) - # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. - # earlier versions are messed up and put the nodename in both - # sysname and nodename. - echo i386-sequent-sysv4 - exit 0 ;; - i*86:UNIX_SV:4.2MP:2.*) - # Unixware is an offshoot of SVR4, but it has its own version - # number series starting with 2... - # I am not positive that other SVR4 systems won't match this, - # I just have to hope. -- rms. - # Use sysv4.2uw... so that sysv4* matches it. - echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} - exit 0 ;; - i*86:OS/2:*:*) - # If we were able to find `uname', then EMX Unix compatibility - # is probably installed. - echo ${UNAME_MACHINE}-pc-os2-emx - exit 0 ;; - i*86:XTS-300:*:STOP) - echo ${UNAME_MACHINE}-unknown-stop - exit 0 ;; - i*86:atheos:*:*) - echo ${UNAME_MACHINE}-unknown-atheos - exit 0 ;; - i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) - echo i386-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; - i*86:*DOS:*:*) - echo ${UNAME_MACHINE}-pc-msdosdjgpp - exit 0 ;; - i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) - UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` - if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then - echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} - else - echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} - fi - exit 0 ;; - i*86:*:5:[78]*) - case `/bin/uname -X | grep "^Machine"` in - *486*) UNAME_MACHINE=i486 ;; - *Pentium) UNAME_MACHINE=i586 ;; - *Pent*|*Celeron) UNAME_MACHINE=i686 ;; - esac - echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} - exit 0 ;; - i*86:*:3.2:*) - if test -f /usr/options/cb.name; then - UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then - UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` - (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 - (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ - && UNAME_MACHINE=i586 - (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ - && UNAME_MACHINE=i686 - (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ - && UNAME_MACHINE=i686 - echo ${UNAME_MACHINE}-pc-sco$UNAME_REL - else - echo ${UNAME_MACHINE}-pc-sysv32 - fi - exit 0 ;; - pc:*:*:*) - # Left here for compatibility: - # uname -m prints for DJGPP always 'pc', but it prints nothing about - # the processor, so we play safe by assuming i386. - echo i386-pc-msdosdjgpp - exit 0 ;; - Intel:Mach:3*:*) - echo i386-pc-mach3 - exit 0 ;; - paragon:*:*:*) - echo i860-intel-osf1 - exit 0 ;; - i860:*:4.*:*) # i860-SVR4 - if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then - echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 - else # Add other i860-SVR4 vendors below as they are discovered. - echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 - fi - exit 0 ;; - mini*:CTIX:SYS*5:*) - # "miniframe" - echo m68010-convergent-sysv - exit 0 ;; - mc68k:UNIX:SYSTEM5:3.51m) - echo m68k-convergent-sysv - exit 0 ;; - M680?0:D-NIX:5.3:*) - echo m68k-diab-dnix - exit 0 ;; - M68*:*:R3V[567]*:*) - test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;; - 3[34]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0) - OS_REL='' - test -r /etc/.relid \ - && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && echo i486-ncr-sysv4.3${OS_REL} && exit 0 - /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;; - 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && echo i486-ncr-sysv4 && exit 0 ;; - m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) - echo m68k-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; - mc68030:UNIX_System_V:4.*:*) - echo m68k-atari-sysv4 - exit 0 ;; - TSUNAMI:LynxOS:2.*:*) - echo sparc-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; - rs6000:LynxOS:2.*:*) - echo rs6000-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; - PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) - echo powerpc-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; - SM[BE]S:UNIX_SV:*:*) - echo mips-dde-sysv${UNAME_RELEASE} - exit 0 ;; - RM*:ReliantUNIX-*:*:*) - echo mips-sni-sysv4 - exit 0 ;; - RM*:SINIX-*:*:*) - echo mips-sni-sysv4 - exit 0 ;; - *:SINIX-*:*:*) - if uname -p 2>/dev/null >/dev/null ; then - UNAME_MACHINE=`(uname -p) 2>/dev/null` - echo ${UNAME_MACHINE}-sni-sysv4 - else - echo ns32k-sni-sysv - fi - exit 0 ;; - PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort - # says - echo i586-unisys-sysv4 - exit 0 ;; - *:UNIX_System_V:4*:FTX*) - # From Gerald Hewes . - # How about differentiating between stratus architectures? -djm - echo hppa1.1-stratus-sysv4 - exit 0 ;; - *:*:*:FTX*) - # From seanf@swdc.stratus.com. - echo i860-stratus-sysv4 - exit 0 ;; - *:VOS:*:*) - # From Paul.Green@stratus.com. - echo hppa1.1-stratus-vos - exit 0 ;; - mc68*:A/UX:*:*) - echo m68k-apple-aux${UNAME_RELEASE} - exit 0 ;; - news*:NEWS-OS:6*:*) - echo mips-sony-newsos6 - exit 0 ;; - R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) - if [ -d /usr/nec ]; then - echo mips-nec-sysv${UNAME_RELEASE} - else - echo mips-unknown-sysv${UNAME_RELEASE} - fi - exit 0 ;; - BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. - echo powerpc-be-beos - exit 0 ;; - BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. - echo powerpc-apple-beos - exit 0 ;; - BePC:BeOS:*:*) # BeOS running on Intel PC compatible. - echo i586-pc-beos - exit 0 ;; - SX-4:SUPER-UX:*:*) - echo sx4-nec-superux${UNAME_RELEASE} - exit 0 ;; - SX-5:SUPER-UX:*:*) - echo sx5-nec-superux${UNAME_RELEASE} - exit 0 ;; - SX-6:SUPER-UX:*:*) - echo sx6-nec-superux${UNAME_RELEASE} - exit 0 ;; - Power*:Rhapsody:*:*) - echo powerpc-apple-rhapsody${UNAME_RELEASE} - exit 0 ;; - *:Rhapsody:*:*) - echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} - exit 0 ;; - *:Darwin:*:*) - case `uname -p` in - *86) UNAME_PROCESSOR=i686 ;; - powerpc) UNAME_PROCESSOR=powerpc ;; - esac - echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} - exit 0 ;; - *:procnto*:*:* | *:QNX:[0123456789]*:*) - UNAME_PROCESSOR=`uname -p` - if test "$UNAME_PROCESSOR" = "x86"; then - UNAME_PROCESSOR=i386 - UNAME_MACHINE=pc - fi - echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} - exit 0 ;; - *:QNX:*:4*) - echo i386-pc-qnx - exit 0 ;; - NSR-[DGKLNPTVW]:NONSTOP_KERNEL:*:*) - echo nsr-tandem-nsk${UNAME_RELEASE} - exit 0 ;; - *:NonStop-UX:*:*) - echo mips-compaq-nonstopux - exit 0 ;; - BS2000:POSIX*:*:*) - echo bs2000-siemens-sysv - exit 0 ;; - DS/*:UNIX_System_V:*:*) - echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} - exit 0 ;; - *:Plan9:*:*) - # "uname -m" is not consistent, so use $cputype instead. 386 - # is converted to i386 for consistency with other x86 - # operating systems. - if test "$cputype" = "386"; then - UNAME_MACHINE=i386 - else - UNAME_MACHINE="$cputype" - fi - echo ${UNAME_MACHINE}-unknown-plan9 - exit 0 ;; - *:TOPS-10:*:*) - echo pdp10-unknown-tops10 - exit 0 ;; - *:TENEX:*:*) - echo pdp10-unknown-tenex - exit 0 ;; - KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) - echo pdp10-dec-tops20 - exit 0 ;; - XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) - echo pdp10-xkl-tops20 - exit 0 ;; - *:TOPS-20:*:*) - echo pdp10-unknown-tops20 - exit 0 ;; - *:ITS:*:*) - echo pdp10-unknown-its - exit 0 ;; - SEI:*:*:SEIUX) - echo mips-sei-seiux${UNAME_RELEASE} - exit 0 ;; -esac - -#echo '(No uname command or uname output not recognized.)' 1>&2 -#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 - -eval $set_cc_for_build -cat >$dummy.c < -# include -#endif -main () -{ -#if defined (sony) -#if defined (MIPSEB) - /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, - I don't know.... */ - printf ("mips-sony-bsd\n"); exit (0); -#else -#include - printf ("m68k-sony-newsos%s\n", -#ifdef NEWSOS4 - "4" -#else - "" -#endif - ); exit (0); -#endif -#endif - -#if defined (__arm) && defined (__acorn) && defined (__unix) - printf ("arm-acorn-riscix"); exit (0); -#endif - -#if defined (hp300) && !defined (hpux) - printf ("m68k-hp-bsd\n"); exit (0); -#endif - -#if defined (NeXT) -#if !defined (__ARCHITECTURE__) -#define __ARCHITECTURE__ "m68k" -#endif - int version; - version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; - if (version < 4) - printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); - else - printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); - exit (0); -#endif - -#if defined (MULTIMAX) || defined (n16) -#if defined (UMAXV) - printf ("ns32k-encore-sysv\n"); exit (0); -#else -#if defined (CMU) - printf ("ns32k-encore-mach\n"); exit (0); -#else - printf ("ns32k-encore-bsd\n"); exit (0); -#endif -#endif -#endif - -#if defined (__386BSD__) - printf ("i386-pc-bsd\n"); exit (0); -#endif - -#if defined (sequent) -#if defined (i386) - printf ("i386-sequent-dynix\n"); exit (0); -#endif -#if defined (ns32000) - printf ("ns32k-sequent-dynix\n"); exit (0); -#endif -#endif - -#if defined (_SEQUENT_) - struct utsname un; - - uname(&un); - - if (strncmp(un.version, "V2", 2) == 0) { - printf ("i386-sequent-ptx2\n"); exit (0); - } - if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ - printf ("i386-sequent-ptx1\n"); exit (0); - } - printf ("i386-sequent-ptx\n"); exit (0); - -#endif - -#if defined (vax) -# if !defined (ultrix) -# include -# if defined (BSD) -# if BSD == 43 - printf ("vax-dec-bsd4.3\n"); exit (0); -# else -# if BSD == 199006 - printf ("vax-dec-bsd4.3reno\n"); exit (0); -# else - printf ("vax-dec-bsd\n"); exit (0); -# endif -# endif -# else - printf ("vax-dec-bsd\n"); exit (0); -# endif -# else - printf ("vax-dec-ultrix\n"); exit (0); -# endif -#endif - -#if defined (alliant) && defined (i860) - printf ("i860-alliant-bsd\n"); exit (0); -#endif - - exit (1); -} -EOF - -$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && $dummy && exit 0 - -# Apollos put the system type in the environment. - -test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; } - -# Convex versions that predate uname can use getsysinfo(1) - -if [ -x /usr/convex/getsysinfo ] -then - case `getsysinfo -f cpu_type` in - c1*) - echo c1-convex-bsd - exit 0 ;; - c2*) - if getsysinfo -f scalar_acc - then echo c32-convex-bsd - else echo c2-convex-bsd - fi - exit 0 ;; - c34*) - echo c34-convex-bsd - exit 0 ;; - c38*) - echo c38-convex-bsd - exit 0 ;; - c4*) - echo c4-convex-bsd - exit 0 ;; - esac -fi - -cat >&2 < in order to provide the needed -information to handle your system. - -config.guess timestamp = $timestamp - -uname -m = `(uname -m) 2>/dev/null || echo unknown` -uname -r = `(uname -r) 2>/dev/null || echo unknown` -uname -s = `(uname -s) 2>/dev/null || echo unknown` -uname -v = `(uname -v) 2>/dev/null || echo unknown` - -/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` -/bin/uname -X = `(/bin/uname -X) 2>/dev/null` - -hostinfo = `(hostinfo) 2>/dev/null` -/bin/universe = `(/bin/universe) 2>/dev/null` -/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` -/bin/arch = `(/bin/arch) 2>/dev/null` -/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` -/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` - -UNAME_MACHINE = ${UNAME_MACHINE} -UNAME_RELEASE = ${UNAME_RELEASE} -UNAME_SYSTEM = ${UNAME_SYSTEM} -UNAME_VERSION = ${UNAME_VERSION} -EOF - -exit 1 - -# Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "timestamp='" -# time-stamp-format: "%:y-%02m-%02d" -# time-stamp-end: "'" -# End: diff --git a/d2pack109/src/autoconf/config.sub b/d2pack109/src/autoconf/config.sub deleted file mode 100644 index 6890099..0000000 --- a/d2pack109/src/autoconf/config.sub +++ /dev/null @@ -1,1508 +0,0 @@ -#! /bin/sh -# Configuration validation subroutine script. -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -# 2000, 2001, 2002, 2003 Free Software Foundation, Inc. - -timestamp='2003-08-18' - -# This file is (in principle) common to ALL GNU software. -# The presence of a machine in this file suggests that SOME GNU software -# can handle that machine. It does not imply ALL GNU software can. -# -# This file 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. - -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# Please send patches to . Submit a context -# diff and a properly formatted ChangeLog entry. -# -# Configuration subroutine to validate and canonicalize a configuration type. -# Supply the specified configuration type as an argument. -# If it is invalid, we print an error message on stderr and exit with code 1. -# Otherwise, we print the canonical config type on stdout and succeed. - -# This file is supposed to be the same for all GNU packages -# and recognize all the CPU types, system types and aliases -# that are meaningful with *any* GNU software. -# Each package is responsible for reporting which valid configurations -# it does not support. The user should be able to distinguish -# a failure to support a valid configuration from a meaningless -# configuration. - -# The goal of this file is to map all the various variations of a given -# machine specification into a single specification in the form: -# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM -# or in some cases, the newer four-part form: -# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM -# It is wrong to echo any other type of specification. - -me=`echo "$0" | sed -e 's,.*/,,'` - -usage="\ -Usage: $0 [OPTION] CPU-MFR-OPSYS - $0 [OPTION] ALIAS - -Canonicalize a configuration name. - -Operation modes: - -h, --help print this help, then exit - -t, --time-stamp print date of last modification, then exit - -v, --version print version number, then exit - -Report bugs and patches to ." - -version="\ -GNU config.sub ($timestamp) - -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 -Free Software Foundation, Inc. - -This is free software; see the source for copying conditions. There is NO -warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." - -help=" -Try \`$me --help' for more information." - -# Parse command line -while test $# -gt 0 ; do - case $1 in - --time-stamp | --time* | -t ) - echo "$timestamp" ; exit 0 ;; - --version | -v ) - echo "$version" ; exit 0 ;; - --help | --h* | -h ) - echo "$usage"; exit 0 ;; - -- ) # Stop option processing - shift; break ;; - - ) # Use stdin as input. - break ;; - -* ) - echo "$me: invalid option $1$help" - exit 1 ;; - - *local*) - # First pass through any local machine types. - echo $1 - exit 0;; - - * ) - break ;; - esac -done - -case $# in - 0) echo "$me: missing argument$help" >&2 - exit 1;; - 1) ;; - *) echo "$me: too many arguments$help" >&2 - exit 1;; -esac - -# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). -# Here we must recognize all the valid KERNEL-OS combinations. -maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` -case $maybe_os in - nto-qnx* | linux-gnu* | linux-dietlibc | kfreebsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*) - os=-$maybe_os - basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` - ;; - *) - basic_machine=`echo $1 | sed 's/-[^-]*$//'` - if [ $basic_machine != $1 ] - then os=`echo $1 | sed 's/.*-/-/'` - else os=; fi - ;; -esac - -### Let's recognize common machines as not being operating systems so -### that things like config.sub decstation-3100 work. We also -### recognize some manufacturers as not being operating systems, so we -### can provide default operating systems below. -case $os in - -sun*os*) - # Prevent following clause from handling this invalid input. - ;; - -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ - -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ - -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ - -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ - -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ - -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ - -apple | -axis) - os= - basic_machine=$1 - ;; - -sim | -cisco | -oki | -wec | -winbond) - os= - basic_machine=$1 - ;; - -scout) - ;; - -wrs) - os=-vxworks - basic_machine=$1 - ;; - -chorusos*) - os=-chorusos - basic_machine=$1 - ;; - -chorusrdb) - os=-chorusrdb - basic_machine=$1 - ;; - -hiux*) - os=-hiuxwe2 - ;; - -sco5) - os=-sco3.2v5 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco4) - os=-sco3.2v4 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco3.2.[4-9]*) - os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco3.2v[4-9]*) - # Don't forget version if it is 3.2v4 or newer. - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco*) - os=-sco3.2v2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -udk*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -isc) - os=-isc2.2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -clix*) - basic_machine=clipper-intergraph - ;; - -isc*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -lynx*) - os=-lynxos - ;; - -ptx*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` - ;; - -windowsnt*) - os=`echo $os | sed -e 's/windowsnt/winnt/'` - ;; - -psos*) - os=-psos - ;; - -mint | -mint[0-9]*) - basic_machine=m68k-atari - os=-mint - ;; -esac - -# Decode aliases for certain CPU-COMPANY combinations. -case $basic_machine in - # Recognize the basic CPU types without company name. - # Some are omitted here because they have special meanings below. - 1750a | 580 \ - | a29k \ - | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ - | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ - | am33_2.0 \ - | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \ - | c4x | clipper \ - | d10v | d30v | dlx | dsp16xx \ - | fr30 | frv \ - | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ - | i370 | i860 | i960 | ia64 \ - | ip2k | iq2000 \ - | m32r | m68000 | m68k | m88k | mcore \ - | mips | mipsbe | mipseb | mipsel | mipsle \ - | mips16 \ - | mips64 | mips64el \ - | mips64vr | mips64vrel \ - | mips64orion | mips64orionel \ - | mips64vr4100 | mips64vr4100el \ - | mips64vr4300 | mips64vr4300el \ - | mips64vr5000 | mips64vr5000el \ - | mipsisa32 | mipsisa32el \ - | mipsisa32r2 | mipsisa32r2el \ - | mipsisa64 | mipsisa64el \ - | mipsisa64sb1 | mipsisa64sb1el \ - | mipsisa64sr71k | mipsisa64sr71kel \ - | mipstx39 | mipstx39el \ - | mn10200 | mn10300 \ - | msp430 \ - | ns16k | ns32k \ - | openrisc | or32 \ - | pdp10 | pdp11 | pj | pjl \ - | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ - | pyramid \ - | sh | sh[1234] | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \ - | sh64 | sh64le \ - | sparc | sparc64 | sparc86x | sparclet | sparclite | sparcv9 | sparcv9b \ - | strongarm \ - | tahoe | thumb | tic4x | tic80 | tron \ - | v850 | v850e \ - | we32k \ - | x86 | xscale | xstormy16 | xtensa \ - | z8k) - basic_machine=$basic_machine-unknown - ;; - m6811 | m68hc11 | m6812 | m68hc12) - # Motorola 68HC11/12. - basic_machine=$basic_machine-unknown - os=-none - ;; - m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) - ;; - - # We use `pc' rather than `unknown' - # because (1) that's what they normally are, and - # (2) the word "unknown" tends to confuse beginning users. - i*86 | x86_64) - basic_machine=$basic_machine-pc - ;; - # Object if more than one company name word. - *-*-*) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 - exit 1 - ;; - # Recognize the basic CPU types with company name. - 580-* \ - | a29k-* \ - | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ - | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ - | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ - | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ - | avr-* \ - | bs2000-* \ - | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ - | clipper-* | cydra-* \ - | d10v-* | d30v-* | dlx-* \ - | elxsi-* \ - | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \ - | h8300-* | h8500-* \ - | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ - | i*86-* | i860-* | i960-* | ia64-* \ - | ip2k-* | iq2000-* \ - | m32r-* \ - | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ - | m88110-* | m88k-* | mcore-* \ - | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ - | mips16-* \ - | mips64-* | mips64el-* \ - | mips64vr-* | mips64vrel-* \ - | mips64orion-* | mips64orionel-* \ - | mips64vr4100-* | mips64vr4100el-* \ - | mips64vr4300-* | mips64vr4300el-* \ - | mips64vr5000-* | mips64vr5000el-* \ - | mipsisa32-* | mipsisa32el-* \ - | mipsisa32r2-* | mipsisa32r2el-* \ - | mipsisa64-* | mipsisa64el-* \ - | mipsisa64sb1-* | mipsisa64sb1el-* \ - | mipsisa64sr71k-* | mipsisa64sr71kel-* \ - | mipstx39-* | mipstx39el-* \ - | msp430-* \ - | none-* | np1-* | nv1-* | ns16k-* | ns32k-* \ - | orion-* \ - | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ - | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ - | pyramid-* \ - | romp-* | rs6000-* \ - | sh-* | sh[1234]-* | sh[23]e-* | sh[34]eb-* | shbe-* \ - | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ - | sparc-* | sparc64-* | sparc86x-* | sparclet-* | sparclite-* \ - | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \ - | tahoe-* | thumb-* \ - | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ - | tron-* \ - | v850-* | v850e-* | vax-* \ - | we32k-* \ - | x86-* | x86_64-* | xps100-* | xscale-* | xstormy16-* \ - | xtensa-* \ - | ymp-* \ - | z8k-*) - ;; - # Recognize the various machine names and aliases which stand - # for a CPU type and a company and sometimes even an OS. - 386bsd) - basic_machine=i386-unknown - os=-bsd - ;; - 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) - basic_machine=m68000-att - ;; - 3b*) - basic_machine=we32k-att - ;; - a29khif) - basic_machine=a29k-amd - os=-udi - ;; - adobe68k) - basic_machine=m68010-adobe - os=-scout - ;; - alliant | fx80) - basic_machine=fx80-alliant - ;; - altos | altos3068) - basic_machine=m68k-altos - ;; - am29k) - basic_machine=a29k-none - os=-bsd - ;; - amd64) - basic_machine=x86_64-pc - ;; - amdahl) - basic_machine=580-amdahl - os=-sysv - ;; - amiga | amiga-*) - basic_machine=m68k-unknown - ;; - amigaos | amigados) - basic_machine=m68k-unknown - os=-amigaos - ;; - amigaunix | amix) - basic_machine=m68k-unknown - os=-sysv4 - ;; - apollo68) - basic_machine=m68k-apollo - os=-sysv - ;; - apollo68bsd) - basic_machine=m68k-apollo - os=-bsd - ;; - aux) - basic_machine=m68k-apple - os=-aux - ;; - balance) - basic_machine=ns32k-sequent - os=-dynix - ;; - c90) - basic_machine=c90-cray - os=-unicos - ;; - convex-c1) - basic_machine=c1-convex - os=-bsd - ;; - convex-c2) - basic_machine=c2-convex - os=-bsd - ;; - convex-c32) - basic_machine=c32-convex - os=-bsd - ;; - convex-c34) - basic_machine=c34-convex - os=-bsd - ;; - convex-c38) - basic_machine=c38-convex - os=-bsd - ;; - cray | j90) - basic_machine=j90-cray - os=-unicos - ;; - crds | unos) - basic_machine=m68k-crds - ;; - cris | cris-* | etrax*) - basic_machine=cris-axis - ;; - da30 | da30-*) - basic_machine=m68k-da30 - ;; - decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) - basic_machine=mips-dec - ;; - decsystem10* | dec10*) - basic_machine=pdp10-dec - os=-tops10 - ;; - decsystem20* | dec20*) - basic_machine=pdp10-dec - os=-tops20 - ;; - delta | 3300 | motorola-3300 | motorola-delta \ - | 3300-motorola | delta-motorola) - basic_machine=m68k-motorola - ;; - delta88) - basic_machine=m88k-motorola - os=-sysv3 - ;; - dpx20 | dpx20-*) - basic_machine=rs6000-bull - os=-bosx - ;; - dpx2* | dpx2*-bull) - basic_machine=m68k-bull - os=-sysv3 - ;; - ebmon29k) - basic_machine=a29k-amd - os=-ebmon - ;; - elxsi) - basic_machine=elxsi-elxsi - os=-bsd - ;; - encore | umax | mmax) - basic_machine=ns32k-encore - ;; - es1800 | OSE68k | ose68k | ose | OSE) - basic_machine=m68k-ericsson - os=-ose - ;; - fx2800) - basic_machine=i860-alliant - ;; - genix) - basic_machine=ns32k-ns - ;; - gmicro) - basic_machine=tron-gmicro - os=-sysv - ;; - go32) - basic_machine=i386-pc - os=-go32 - ;; - h3050r* | hiux*) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - h8300hms) - basic_machine=h8300-hitachi - os=-hms - ;; - h8300xray) - basic_machine=h8300-hitachi - os=-xray - ;; - h8500hms) - basic_machine=h8500-hitachi - os=-hms - ;; - harris) - basic_machine=m88k-harris - os=-sysv3 - ;; - hp300-*) - basic_machine=m68k-hp - ;; - hp300bsd) - basic_machine=m68k-hp - os=-bsd - ;; - hp300hpux) - basic_machine=m68k-hp - os=-hpux - ;; - hp3k9[0-9][0-9] | hp9[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hp9k2[0-9][0-9] | hp9k31[0-9]) - basic_machine=m68000-hp - ;; - hp9k3[2-9][0-9]) - basic_machine=m68k-hp - ;; - hp9k6[0-9][0-9] | hp6[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hp9k7[0-79][0-9] | hp7[0-79][0-9]) - basic_machine=hppa1.1-hp - ;; - hp9k78[0-9] | hp78[0-9]) - # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp - ;; - hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) - # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp - ;; - hp9k8[0-9][13679] | hp8[0-9][13679]) - basic_machine=hppa1.1-hp - ;; - hp9k8[0-9][0-9] | hp8[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hppa-next) - os=-nextstep3 - ;; - hppaosf) - basic_machine=hppa1.1-hp - os=-osf - ;; - hppro) - basic_machine=hppa1.1-hp - os=-proelf - ;; - i370-ibm* | ibm*) - basic_machine=i370-ibm - ;; -# I'm not sure what "Sysv32" means. Should this be sysv3.2? - i*86v32) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv32 - ;; - i*86v4*) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv4 - ;; - i*86v) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv - ;; - i*86sol2) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-solaris2 - ;; - i386mach) - basic_machine=i386-mach - os=-mach - ;; - i386-vsta | vsta) - basic_machine=i386-unknown - os=-vsta - ;; - iris | iris4d) - basic_machine=mips-sgi - case $os in - -irix*) - ;; - *) - os=-irix4 - ;; - esac - ;; - isi68 | isi) - basic_machine=m68k-isi - os=-sysv - ;; - m88k-omron*) - basic_machine=m88k-omron - ;; - magnum | m3230) - basic_machine=mips-mips - os=-sysv - ;; - merlin) - basic_machine=ns32k-utek - os=-sysv - ;; - mingw32) - basic_machine=i386-pc - os=-mingw32 - ;; - miniframe) - basic_machine=m68000-convergent - ;; - *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) - basic_machine=m68k-atari - os=-mint - ;; - mips3*-*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` - ;; - mips3*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown - ;; - mmix*) - basic_machine=mmix-knuth - os=-mmixware - ;; - monitor) - basic_machine=m68k-rom68k - os=-coff - ;; - morphos) - basic_machine=powerpc-unknown - os=-morphos - ;; - msdos) - basic_machine=i386-pc - os=-msdos - ;; - mvs) - basic_machine=i370-ibm - os=-mvs - ;; - ncr3000) - basic_machine=i486-ncr - os=-sysv4 - ;; - netbsd386) - basic_machine=i386-unknown - os=-netbsd - ;; - netwinder) - basic_machine=armv4l-rebel - os=-linux - ;; - news | news700 | news800 | news900) - basic_machine=m68k-sony - os=-newsos - ;; - news1000) - basic_machine=m68030-sony - os=-newsos - ;; - news-3600 | risc-news) - basic_machine=mips-sony - os=-newsos - ;; - necv70) - basic_machine=v70-nec - os=-sysv - ;; - next | m*-next ) - basic_machine=m68k-next - case $os in - -nextstep* ) - ;; - -ns2*) - os=-nextstep2 - ;; - *) - os=-nextstep3 - ;; - esac - ;; - nh3000) - basic_machine=m68k-harris - os=-cxux - ;; - nh[45]000) - basic_machine=m88k-harris - os=-cxux - ;; - nindy960) - basic_machine=i960-intel - os=-nindy - ;; - mon960) - basic_machine=i960-intel - os=-mon960 - ;; - nonstopux) - basic_machine=mips-compaq - os=-nonstopux - ;; - np1) - basic_machine=np1-gould - ;; - nv1) - basic_machine=nv1-cray - os=-unicosmp - ;; - nsr-tandem) - basic_machine=nsr-tandem - ;; - op50n-* | op60c-*) - basic_machine=hppa1.1-oki - os=-proelf - ;; - or32 | or32-*) - basic_machine=or32-unknown - os=-coff - ;; - OSE68000 | ose68000) - basic_machine=m68000-ericsson - os=-ose - ;; - os68k) - basic_machine=m68k-none - os=-os68k - ;; - pa-hitachi) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - paragon) - basic_machine=i860-intel - os=-osf - ;; - pbd) - basic_machine=sparc-tti - ;; - pbb) - basic_machine=m68k-tti - ;; - pc532 | pc532-*) - basic_machine=ns32k-pc532 - ;; - pentium | p5 | k5 | k6 | nexgen | viac3) - basic_machine=i586-pc - ;; - pentiumpro | p6 | 6x86 | athlon | athlon_*) - basic_machine=i686-pc - ;; - pentiumii | pentium2 | pentiumiii | pentium3) - basic_machine=i686-pc - ;; - pentium4) - basic_machine=i786-pc - ;; - pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) - basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentiumpro-* | p6-* | 6x86-* | athlon-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentium4-*) - basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pn) - basic_machine=pn-gould - ;; - power) basic_machine=power-ibm - ;; - ppc) basic_machine=powerpc-unknown - ;; - ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppcle | powerpclittle | ppc-le | powerpc-little) - basic_machine=powerpcle-unknown - ;; - ppcle-* | powerpclittle-*) - basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppc64) basic_machine=powerpc64-unknown - ;; - ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppc64le | powerpc64little | ppc64-le | powerpc64-little) - basic_machine=powerpc64le-unknown - ;; - ppc64le-* | powerpc64little-*) - basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ps2) - basic_machine=i386-ibm - ;; - pw32) - basic_machine=i586-unknown - os=-pw32 - ;; - rom68k) - basic_machine=m68k-rom68k - os=-coff - ;; - rm[46]00) - basic_machine=mips-siemens - ;; - rtpc | rtpc-*) - basic_machine=romp-ibm - ;; - s390 | s390-*) - basic_machine=s390-ibm - ;; - s390x | s390x-*) - basic_machine=s390x-ibm - ;; - sa29200) - basic_machine=a29k-amd - os=-udi - ;; - sb1) - basic_machine=mipsisa64sb1-unknown - ;; - sb1el) - basic_machine=mipsisa64sb1el-unknown - ;; - sei) - basic_machine=mips-sei - os=-seiux - ;; - sequent) - basic_machine=i386-sequent - ;; - sh) - basic_machine=sh-hitachi - os=-hms - ;; - sh64) - basic_machine=sh64-unknown - ;; - sparclite-wrs | simso-wrs) - basic_machine=sparclite-wrs - os=-vxworks - ;; - sps7) - basic_machine=m68k-bull - os=-sysv2 - ;; - spur) - basic_machine=spur-unknown - ;; - st2000) - basic_machine=m68k-tandem - ;; - stratus) - basic_machine=i860-stratus - os=-sysv4 - ;; - sun2) - basic_machine=m68000-sun - ;; - sun2os3) - basic_machine=m68000-sun - os=-sunos3 - ;; - sun2os4) - basic_machine=m68000-sun - os=-sunos4 - ;; - sun3os3) - basic_machine=m68k-sun - os=-sunos3 - ;; - sun3os4) - basic_machine=m68k-sun - os=-sunos4 - ;; - sun4os3) - basic_machine=sparc-sun - os=-sunos3 - ;; - sun4os4) - basic_machine=sparc-sun - os=-sunos4 - ;; - sun4sol2) - basic_machine=sparc-sun - os=-solaris2 - ;; - sun3 | sun3-*) - basic_machine=m68k-sun - ;; - sun4) - basic_machine=sparc-sun - ;; - sun386 | sun386i | roadrunner) - basic_machine=i386-sun - ;; - sv1) - basic_machine=sv1-cray - os=-unicos - ;; - symmetry) - basic_machine=i386-sequent - os=-dynix - ;; - t3e) - basic_machine=alphaev5-cray - os=-unicos - ;; - t90) - basic_machine=t90-cray - os=-unicos - ;; - tic54x | c54x*) - basic_machine=tic54x-unknown - os=-coff - ;; - tic55x | c55x*) - basic_machine=tic55x-unknown - os=-coff - ;; - tic6x | c6x*) - basic_machine=tic6x-unknown - os=-coff - ;; - tx39) - basic_machine=mipstx39-unknown - ;; - tx39el) - basic_machine=mipstx39el-unknown - ;; - toad1) - basic_machine=pdp10-xkl - os=-tops20 - ;; - tower | tower-32) - basic_machine=m68k-ncr - ;; - udi29k) - basic_machine=a29k-amd - os=-udi - ;; - ultra3) - basic_machine=a29k-nyu - os=-sym1 - ;; - v810 | necv810) - basic_machine=v810-nec - os=-none - ;; - vaxv) - basic_machine=vax-dec - os=-sysv - ;; - vms) - basic_machine=vax-dec - os=-vms - ;; - vpp*|vx|vx-*) - basic_machine=f301-fujitsu - ;; - vxworks960) - basic_machine=i960-wrs - os=-vxworks - ;; - vxworks68) - basic_machine=m68k-wrs - os=-vxworks - ;; - vxworks29k) - basic_machine=a29k-wrs - os=-vxworks - ;; - w65*) - basic_machine=w65-wdc - os=-none - ;; - w89k-*) - basic_machine=hppa1.1-winbond - os=-proelf - ;; - xps | xps100) - basic_machine=xps100-honeywell - ;; - ymp) - basic_machine=ymp-cray - os=-unicos - ;; - z8k-*-coff) - basic_machine=z8k-unknown - os=-sim - ;; - none) - basic_machine=none-none - os=-none - ;; - -# Here we handle the default manufacturer of certain CPU types. It is in -# some cases the only manufacturer, in others, it is the most popular. - w89k) - basic_machine=hppa1.1-winbond - ;; - op50n) - basic_machine=hppa1.1-oki - ;; - op60c) - basic_machine=hppa1.1-oki - ;; - romp) - basic_machine=romp-ibm - ;; - rs6000) - basic_machine=rs6000-ibm - ;; - vax) - basic_machine=vax-dec - ;; - pdp10) - # there are many clones, so DEC is not a safe bet - basic_machine=pdp10-unknown - ;; - pdp11) - basic_machine=pdp11-dec - ;; - we32k) - basic_machine=we32k-att - ;; - sh3 | sh4 | sh[34]eb | sh[1234]le | sh[23]ele) - basic_machine=sh-unknown - ;; - sh64) - basic_machine=sh64-unknown - ;; - sparc | sparcv9 | sparcv9b) - basic_machine=sparc-sun - ;; - cydra) - basic_machine=cydra-cydrome - ;; - orion) - basic_machine=orion-highlevel - ;; - orion105) - basic_machine=clipper-highlevel - ;; - mac | mpw | mac-mpw) - basic_machine=m68k-apple - ;; - pmac | pmac-mpw) - basic_machine=powerpc-apple - ;; - *-unknown) - # Make sure to match an already-canonicalized machine name. - ;; - *) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 - exit 1 - ;; -esac - -# Here we canonicalize certain aliases for manufacturers. -case $basic_machine in - *-digital*) - basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` - ;; - *-commodore*) - basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` - ;; - *) - ;; -esac - -# Decode manufacturer-specific aliases for certain operating systems. - -if [ x"$os" != x"" ] -then -case $os in - # First match some system type aliases - # that might get confused with valid system types. - # -solaris* is a basic system type, with this one exception. - -solaris1 | -solaris1.*) - os=`echo $os | sed -e 's|solaris1|sunos4|'` - ;; - -solaris) - os=-solaris2 - ;; - -svr4*) - os=-sysv4 - ;; - -unixware*) - os=-sysv4.2uw - ;; - -gnu/linux*) - os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` - ;; - # First accept the basic system types. - # The portable systems comes first. - # Each alternative MUST END IN A *, to match a version number. - # -sysv* is not here because it comes later, after sysvr4. - -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ - | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ - | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ - | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ - | -aos* \ - | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ - | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ - | -hiux* | -386bsd* | -netbsd* | -openbsd* | -kfreebsd* | -freebsd* | -riscix* \ - | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ - | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ - | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ - | -chorusos* | -chorusrdb* \ - | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ - | -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \ - | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ - | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ - | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ - | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ - | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ - | -powermax* | -dnix* | -nx6 | -nx7 | -sei*) - # Remember, each alternative MUST END IN *, to match a version number. - ;; - -qnx*) - case $basic_machine in - x86-* | i*86-*) - ;; - *) - os=-nto$os - ;; - esac - ;; - -nto-qnx*) - ;; - -nto*) - os=`echo $os | sed -e 's|nto|nto-qnx|'` - ;; - -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ - | -windows* | -osx | -abug | -netware* | -os9* | -beos* \ - | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) - ;; - -mac*) - os=`echo $os | sed -e 's|mac|macos|'` - ;; - -linux-dietlibc) - os=-linux-dietlibc - ;; - -linux*) - os=`echo $os | sed -e 's|linux|linux-gnu|'` - ;; - -sunos5*) - os=`echo $os | sed -e 's|sunos5|solaris2|'` - ;; - -sunos6*) - os=`echo $os | sed -e 's|sunos6|solaris3|'` - ;; - -opened*) - os=-openedition - ;; - -wince*) - os=-wince - ;; - -osfrose*) - os=-osfrose - ;; - -osf*) - os=-osf - ;; - -utek*) - os=-bsd - ;; - -dynix*) - os=-bsd - ;; - -acis*) - os=-aos - ;; - -atheos*) - os=-atheos - ;; - -386bsd) - os=-bsd - ;; - -ctix* | -uts*) - os=-sysv - ;; - -nova*) - os=-rtmk-nova - ;; - -ns2 ) - os=-nextstep2 - ;; - -nsk*) - os=-nsk - ;; - # Preserve the version number of sinix5. - -sinix5.*) - os=`echo $os | sed -e 's|sinix|sysv|'` - ;; - -sinix*) - os=-sysv4 - ;; - -triton*) - os=-sysv3 - ;; - -oss*) - os=-sysv3 - ;; - -svr4) - os=-sysv4 - ;; - -svr3) - os=-sysv3 - ;; - -sysvr4) - os=-sysv4 - ;; - # This must come after -sysvr4. - -sysv*) - ;; - -ose*) - os=-ose - ;; - -es1800*) - os=-ose - ;; - -xenix) - os=-xenix - ;; - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) - os=-mint - ;; - -aros*) - os=-aros - ;; - -kaos*) - os=-kaos - ;; - -none) - ;; - *) - # Get rid of the `-' at the beginning of $os. - os=`echo $os | sed 's/[^-]*-//'` - echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 - exit 1 - ;; -esac -else - -# Here we handle the default operating systems that come with various machines. -# The value should be what the vendor currently ships out the door with their -# machine or put another way, the most popular os provided with the machine. - -# Note that if you're going to try to match "-MANUFACTURER" here (say, -# "-sun"), then you have to tell the case statement up towards the top -# that MANUFACTURER isn't an operating system. Otherwise, code above -# will signal an error saying that MANUFACTURER isn't an operating -# system, and we'll never get to this point. - -case $basic_machine in - *-acorn) - os=-riscix1.2 - ;; - arm*-rebel) - os=-linux - ;; - arm*-semi) - os=-aout - ;; - c4x-* | tic4x-*) - os=-coff - ;; - # This must come before the *-dec entry. - pdp10-*) - os=-tops20 - ;; - pdp11-*) - os=-none - ;; - *-dec | vax-*) - os=-ultrix4.2 - ;; - m68*-apollo) - os=-domain - ;; - i386-sun) - os=-sunos4.0.2 - ;; - m68000-sun) - os=-sunos3 - # This also exists in the configure program, but was not the - # default. - # os=-sunos4 - ;; - m68*-cisco) - os=-aout - ;; - mips*-cisco) - os=-elf - ;; - mips*-*) - os=-elf - ;; - or32-*) - os=-coff - ;; - *-tti) # must be before sparc entry or we get the wrong os. - os=-sysv3 - ;; - sparc-* | *-sun) - os=-sunos4.1.1 - ;; - *-be) - os=-beos - ;; - *-ibm) - os=-aix - ;; - *-wec) - os=-proelf - ;; - *-winbond) - os=-proelf - ;; - *-oki) - os=-proelf - ;; - *-hp) - os=-hpux - ;; - *-hitachi) - os=-hiux - ;; - i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) - os=-sysv - ;; - *-cbm) - os=-amigaos - ;; - *-dg) - os=-dgux - ;; - *-dolphin) - os=-sysv3 - ;; - m68k-ccur) - os=-rtu - ;; - m88k-omron*) - os=-luna - ;; - *-next ) - os=-nextstep - ;; - *-sequent) - os=-ptx - ;; - *-crds) - os=-unos - ;; - *-ns) - os=-genix - ;; - i370-*) - os=-mvs - ;; - *-next) - os=-nextstep3 - ;; - *-gould) - os=-sysv - ;; - *-highlevel) - os=-bsd - ;; - *-encore) - os=-bsd - ;; - *-sgi) - os=-irix - ;; - *-siemens) - os=-sysv4 - ;; - *-masscomp) - os=-rtu - ;; - f30[01]-fujitsu | f700-fujitsu) - os=-uxpv - ;; - *-rom68k) - os=-coff - ;; - *-*bug) - os=-coff - ;; - *-apple) - os=-macos - ;; - *-atari*) - os=-mint - ;; - *) - os=-none - ;; -esac -fi - -# Here we handle the case where we know the os, and the CPU type, but not the -# manufacturer. We pick the logical manufacturer. -vendor=unknown -case $basic_machine in - *-unknown) - case $os in - -riscix*) - vendor=acorn - ;; - -sunos*) - vendor=sun - ;; - -aix*) - vendor=ibm - ;; - -beos*) - vendor=be - ;; - -hpux*) - vendor=hp - ;; - -mpeix*) - vendor=hp - ;; - -hiux*) - vendor=hitachi - ;; - -unos*) - vendor=crds - ;; - -dgux*) - vendor=dg - ;; - -luna*) - vendor=omron - ;; - -genix*) - vendor=ns - ;; - -mvs* | -opened*) - vendor=ibm - ;; - -ptx*) - vendor=sequent - ;; - -vxsim* | -vxworks* | -windiss*) - vendor=wrs - ;; - -aux*) - vendor=apple - ;; - -hms*) - vendor=hitachi - ;; - -mpw* | -macos*) - vendor=apple - ;; - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) - vendor=atari - ;; - -vos*) - vendor=stratus - ;; - esac - basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` - ;; -esac - -echo $basic_machine$os -exit 0 - -# Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "timestamp='" -# time-stamp-format: "%:y-%02m-%02d" -# time-stamp-end: "'" -# End: diff --git a/d2pack109/src/autoconf/termios.m4 b/d2pack109/src/autoconf/termios.m4 deleted file mode 100644 index 1eb31d1..0000000 --- a/d2pack109/src/autoconf/termios.m4 +++ /dev/null @@ -1,14 +0,0 @@ -dnl From Jim Meyering. - -# serial 1 - -AC_DEFUN(AM_SYS_POSIX_TERMIOS, -[AC_CACHE_CHECK([POSIX termios], am_cv_sys_posix_termios, - [AC_TRY_LINK([#include -#include -#include ], - [/* SunOS 4.0.3 has termios.h but not the library calls. */ - tcgetattr(0, 0);], - am_cv_sys_posix_termios=yes, - am_cv_sys_posix_termios=no)]) -]) diff --git a/d2pack109/src/autoconf/winsz.m4 b/d2pack109/src/autoconf/winsz.m4 deleted file mode 100644 index fa81c9d..0000000 --- a/d2pack109/src/autoconf/winsz.m4 +++ /dev/null @@ -1,36 +0,0 @@ -dnl From Jim Meyering. - -# serial 1 - -AC_DEFUN(AM_HEADER_TIOCGWINSZ_NEEDS_SYS_IOCTL, -[AC_REQUIRE([AM_SYS_POSIX_TERMIOS]) - AC_CACHE_CHECK([whether use of TIOCGWINSZ requires sys/ioctl.h], - am_cv_sys_tiocgwinsz_needs_sys_ioctl_h, - [am_cv_sys_tiocgwinsz_needs_sys_ioctl_h=no - - gwinsz_in_termios_h=no - if test $am_cv_sys_posix_termios = yes; then - AC_EGREP_CPP([yes], - [#include -# include -# ifdef TIOCGWINSZ - yes -# endif - ], gwinsz_in_termios_h=yes) - fi - - if test $gwinsz_in_termios_h = no; then - AC_EGREP_CPP([yes], - [#include -# include -# ifdef TIOCGWINSZ - yes -# endif - ], am_cv_sys_tiocgwinsz_needs_sys_ioctl_h=yes) - fi - ]) - if test $am_cv_sys_tiocgwinsz_needs_sys_ioctl_h = yes; then - AC_DEFINE(GWINSZ_IN_SYS_IOCTL,1, - [Define if TIOCGWINSZ requires sys/ioctl.h]) - fi -]) diff --git a/d2pack109/src/autogen.sh b/d2pack109/src/autogen.sh deleted file mode 100755 index 7fe1d2d..0000000 --- a/d2pack109/src/autogen.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -autoconf -autoheader diff --git a/d2pack109/src/common/addr.c b/d2pack109/src/common/addr.c deleted file mode 100644 index b906f3a..0000000 --- a/d2pack109/src/common/addr.c +++ /dev/null @@ -1,626 +0,0 @@ -/* - * Copyright (C) 1999,2000,2001 Ross Combs (rocombs@cs.nmsu.edu) - * - * 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. - */ -#define ADDR_INTERNAL_ACCESS -#include "common/setup_before.h" -#ifdef HAVE_STDDEF_H -# include -#else -# ifndef NULL -# define NULL ((void *)0) -# endif -#endif -#ifdef STDC_HEADERS -# include -#else -# ifdef HAVE_MALLOC_H -# include -# endif -#endif -#ifdef HAVE_STRING_H -# include -#else -# ifdef HAVE_STRINGS_H -# include -# endif -#endif -#ifdef HAVE_MEMORY_H -# include -#endif -#include "compat/memset.h" -#include "compat/memcpy.h" -#include "compat/strrchr.h" -#include "compat/strdup.h" -#ifdef HAVE_SYS_TYPES_H -# include -#endif -#ifdef HAVE_SYS_SOCKET_H -# include -#endif -#include "compat/socket.h" -#ifdef HAVE_SYS_PARAM_H -# include -#endif -#ifdef HAVE_NETINET_IN_H -# include -#endif -#include "compat/netinet_in.h" -#ifdef HAVE_ARPA_INET_H -# include -#endif -#include "compat/inet_aton.h" -#include "compat/inet_ntoa.h" -#ifdef HAVE_NETDB_H -# include -#endif -#ifdef HAVE_ASSERT_H -# include -#endif -#include "compat/psock.h" -#include "common/eventlog.h" -#include "common/list.h" -#include "common/util.h" -#include "common/xalloc.h" -#include "common/addr.h" -#include "common/setup_after.h" - - -static char const * netaddr_num_to_addr_str(unsigned int netipaddr, unsigned int netmask); - - -#define HACK_SIZE 4 - -/* both arguments are in host byte order */ -extern char const * addr_num_to_addr_str(unsigned int ipaddr, unsigned short port) -{ - static unsigned int curr=0; - static char temp[HACK_SIZE][64]; - struct sockaddr_in tsa; - - curr = (curr+1)%HACK_SIZE; - - memset(&tsa,0,sizeof(tsa)); - tsa.sin_family = PSOCK_AF_INET; - tsa.sin_port = htons((unsigned short)0); - tsa.sin_addr.s_addr = htonl(ipaddr); - sprintf(temp[curr],"%.32s:%hu",inet_ntoa(tsa.sin_addr),port); - - return temp[curr]; -} - - -/* ipaddr is in host byte order */ -extern char const * addr_num_to_ip_str(unsigned int ipaddr) -{ - static unsigned int curr=0; - static char temp[HACK_SIZE][64]; - struct sockaddr_in tsa; - - curr = (curr+1)%HACK_SIZE; - - memset(&tsa,0,sizeof(tsa)); - tsa.sin_family = PSOCK_AF_INET; - tsa.sin_port = htons((unsigned short)0); - tsa.sin_addr.s_addr = htonl(ipaddr); - sprintf(temp[curr],"%.32s",inet_ntoa(tsa.sin_addr)); - - return temp[curr]; -} - - -static char const * netaddr_num_to_addr_str(unsigned int netipaddr, unsigned int netmask) -{ - static unsigned int curr=0; - static char temp[HACK_SIZE][64]; - struct sockaddr_in tsa; - - curr = (curr+1)%HACK_SIZE; - - memset(&tsa,0,sizeof(tsa)); - tsa.sin_family = PSOCK_AF_INET; - tsa.sin_port = htons((unsigned short)0); - tsa.sin_addr.s_addr = htonl(netipaddr); - sprintf(temp[curr],"%.32s/0x%08x",inet_ntoa(tsa.sin_addr),netmask); - - return temp[curr]; -} - - - -extern char const * host_lookup(char const * hoststr, unsigned int * ipaddr) -{ - struct sockaddr_in tsa; -#ifdef HAVE_GETHOSTBYNAME - struct hostent * hp; -#endif - - if (!hoststr) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL hoststr"); - return NULL; - } - if (!ipaddr) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL ipaddr"); - return NULL; - } - - memset(&tsa,0,sizeof(tsa)); - tsa.sin_family = PSOCK_AF_INET; - tsa.sin_port = htons(0); - -#ifdef HAVE_GETHOSTBYNAME -#ifdef WIN32 - psock_init(); -#endif - hp = gethostbyname(hoststr); - if (!hp || !hp->h_addr_list) -#endif - { - if (inet_aton(hoststr,&tsa.sin_addr)) - { - *ipaddr = ntohl(tsa.sin_addr.s_addr); - return hoststr; /* We could call gethostbyaddr() on tsa to try and get the - official hostname but most systems would have already found - it when sending a dotted-quad to gethostbyname(). This is - good enough when that fails. */ - } - eventlog(eventlog_level_error,__FUNCTION__,"could not lookup host \"%s\"",hoststr); - return NULL; - } - -#ifdef HAVE_GETHOSTBYNAME - memcpy(&tsa.sin_addr,(void *)hp->h_addr_list[0],sizeof(struct in_addr)); /* avoid warning */ - *ipaddr = ntohl(tsa.sin_addr.s_addr); - if (hp->h_name) - return hp->h_name; - return hoststr; -#endif -} - - -extern t_addr * addr_create_num(unsigned int ipaddr, unsigned short port) -{ - t_addr * temp; - - temp = xmalloc(sizeof(t_addr)); - temp->str = xstrdup(addr_num_to_addr_str(ipaddr,port)); - temp->str = NULL; - temp->ip = ipaddr; - temp->port = port; - temp->data.p = NULL; - - return temp; -} - - -extern t_addr * addr_create_str(char const * str, unsigned int defipaddr, unsigned short defport) -{ - char * tstr; - t_addr * temp; - unsigned int ipaddr; - unsigned short port; - char const * hoststr; - char * portstr; - char const * hostname; - - if (!str) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL str"); - return NULL; - } - - tstr = xstrdup(str); - - if ((portstr = strrchr(tstr,':'))) - { - char * protstr; - - *portstr = '\0'; - portstr++; - - if ((protstr = strrchr(portstr,'/'))) - { - *protstr = '\0'; - protstr++; - } - - if (portstr[0]!='\0') - { - if (str_to_ushort(portstr,&port)<0) - { -#ifdef HAVE_GETSERVBYNAME - struct servent * sp; - - if (!(sp = getservbyname(portstr,protstr?protstr:"tcp"))) -#endif - { - eventlog(eventlog_level_error,__FUNCTION__,"could not convert \"%s\" to a port number",portstr); - xfree(tstr); - return NULL; - } -#ifdef HAVE_GETSERVBYNAME - port = ntohs(sp->s_port); -#endif - } - } - else - port = defport; - } - else - port = defport; - - if (tstr[0]!='\0') - hoststr = tstr; - else - { - struct sockaddr_in tsa; - - tsa.sin_addr.s_addr = htonl(defipaddr); - hoststr = inet_ntoa(tsa.sin_addr); - } - - if (!(hostname = host_lookup(hoststr,&ipaddr))) - { - eventlog(eventlog_level_error,__FUNCTION__,"could not lookup host \"%s\"",hoststr); - xfree(tstr); - return NULL; - } - - temp = xmalloc(sizeof(t_addr)); - temp->str = xstrdup(hostname); - xfree(tstr); - - temp->ip = ipaddr; - temp->port = port; - temp->data.p = NULL; - - return temp; -} - - -extern int addr_destroy(t_addr const * addr) -{ - if (!addr) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL addr"); - return -1; - } - - if (addr->str) - xfree((void *)addr->str); /* avoid warning */ - xfree((void *)addr); /* avoid warning */ - - return 0; -} - - -/* hostname or IP */ -extern char * addr_get_host_str(t_addr const * addr, char * str, unsigned int len) -{ - if (!addr) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL addr"); - return NULL; - } - if (!str) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL str"); - return NULL; - } - if (len<2) - { - eventlog(eventlog_level_error,__FUNCTION__,"str too short"); - return NULL; - } - - if (!addr->str) - { - eventlog(eventlog_level_error,__FUNCTION__,"addr has NULL str"); - return NULL; - } - - strncpy(str,addr->str,len-1); - str[len-1] = '\0'; - - return str; -} - - -/* IP:port */ -extern char * addr_get_addr_str(t_addr const * addr, char * str, unsigned int len) -{ - if (!addr) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL addr"); - return NULL; - } - if (!str) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL str"); - return NULL; - } - if (len<2) - { - eventlog(eventlog_level_error,__FUNCTION__,"str too short"); - return NULL; - } - - strncpy(str,addr_num_to_addr_str(addr->ip,addr->port),len-1); - str[len-1] = '\0'; - - return str; -} - - -extern unsigned int addr_get_ip(t_addr const * addr) -{ - if (!addr) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL addr"); - return 0; - } - - return addr->ip; -} - - -extern unsigned short addr_get_port(t_addr const * addr) -{ - if (!addr) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL addr"); - return 0; - } - - return addr->port; -} - - -extern int addr_set_data(t_addr * addr, t_addr_data data) -{ - if (!addr) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL addr"); - return -1; - } - - addr->data = data; - return 0; -} - - -extern t_addr_data addr_get_data(t_addr const * addr) -{ - t_addr_data tdata; - - if (!addr) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL addr"); - tdata.p = NULL; - return tdata; - } - - return addr->data; -} - - -extern t_netaddr * netaddr_create_str(char const * netstr) -{ - t_netaddr * netaddr; - char * temp; - char const * netipstr; - char const * netmaskstr; - unsigned int netip; - unsigned int netmask; - - if (!netstr) - { - eventlog(eventlog_level_error,__FUNCTION__,"unable to allocate memory for netaddr"); - return NULL; - } - - temp = xstrdup(netstr); - if (!(netipstr = strtok(temp,"/"))) - { - xfree(temp); - return NULL; - } - if (!(netmaskstr = strtok(NULL,"/"))) - { - xfree(temp); - return NULL; - } - - netaddr = xmalloc(sizeof(t_netaddr)); - - /* FIXME: call getnetbyname() first, then host_lookup() */ - if (!host_lookup(netipstr,&netip)) - { - eventlog(eventlog_level_error,__FUNCTION__,"could not lookup net"); - xfree(netaddr); - xfree(temp); - return NULL; - } - netaddr->ip = netip; - - if (str_to_uint(netmaskstr,&netmask)<0) - { - struct sockaddr_in tsa; - - if (inet_aton(netmaskstr,&tsa.sin_addr)) - netmask = ntohl(tsa.sin_addr.s_addr); - else - { - eventlog(eventlog_level_error,__FUNCTION__,"could not convert mask"); - xfree(netaddr); - xfree(temp); - return NULL; - } - } - else - { - if (netmask>32) - { - eventlog(eventlog_level_error,__FUNCTION__,"network bits must be less than or equal to 32 (%u)",netmask); - xfree(netaddr); - xfree(temp); - return NULL; - } - /* for example, 8 -> 11111111000000000000000000000000 */ - if (netmask!=0) - netmask = ~((1<<(32-netmask))-1); - } - netaddr->mask = netmask; - - xfree(temp); // [zap-zero] 20020731 - (hopefully) fixed memory leak - - return netaddr; -} - - -extern int netaddr_destroy(t_netaddr const * netaddr) -{ - if (!netaddr) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL netaddr"); - return -1; - } - - xfree((void *)netaddr); /* avoid warning */ - - return 0; -} - - -extern char * netaddr_get_addr_str(t_netaddr const * netaddr, char * str, unsigned int len) -{ - if (!netaddr) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL netaddr"); - return NULL; - } - if (!str) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL str"); - return NULL; - } - if (len<2) - { - eventlog(eventlog_level_error,__FUNCTION__,"str too short"); - return NULL; - } - - strncpy(str,netaddr_num_to_addr_str(netaddr->ip,netaddr->mask),len-1); /* FIXME: format nicely with x.x.x.x/bitcount */ - str[len-1] = '\0'; - - return str; -} - - -extern int netaddr_contains_addr_num(t_netaddr const * netaddr, unsigned int ipaddr) -{ - if (!netaddr) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL netaddr"); - return -1; - } - - return (ipaddr&netaddr->mask)==netaddr->ip; -} - - -extern int addrlist_append(t_addrlist * addrlist, char const * str, unsigned int defipaddr, unsigned short defport) -{ - t_addr * addr; - char * tstr; - char * tok; - - assert(addrlist != NULL); - - if (!str) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL str"); - return -1; - } - - tstr = xstrdup(str); - for (tok=strtok(tstr,","); tok; tok=strtok(NULL,",")) /* strtok modifies the string it is passed */ - { - if (!(addr = addr_create_str(tok,defipaddr,defport))) - { - eventlog(eventlog_level_error,__FUNCTION__,"could not create addr"); - xfree(tstr); - return -1; - } - list_append_data(addrlist,addr); - } - - xfree(tstr); - - return 0; -} - -extern t_addrlist * addrlist_create(char const * str, unsigned int defipaddr, unsigned short defport) -{ - t_addrlist * addrlist; - - if (!str) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL str"); - return NULL; - } - - addrlist = list_create(); - - if (addrlist_append(addrlist,str,defipaddr,defport)<0) { - eventlog(eventlog_level_error,__FUNCTION__,"could not append to newly created addrlist"); - list_destroy(addrlist); - return NULL; - } - - return addrlist; -} - -extern int addrlist_destroy(t_addrlist * addrlist) -{ - t_elem * curr; - t_addr * addr; - - if (!addrlist) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL addrlist"); - return -1; - } - - LIST_TRAVERSE(addrlist,curr) - { - if (!(addr = elem_get_data(curr))) - eventlog(eventlog_level_error,__FUNCTION__,"found NULL addr in list"); - else - addr_destroy(addr); - list_remove_elem(addrlist,&curr); - } - - return list_destroy(addrlist); -} - - -extern int addrlist_get_length(t_addrlist const * addrlist) -{ - return list_get_length(addrlist); -} diff --git a/d2pack109/src/common/addr.h b/d2pack109/src/common/addr.h deleted file mode 100644 index da5f69e..0000000 --- a/d2pack109/src/common/addr.h +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (C) 1999,2000,2001 Ross Combs (rocombs@cs.nmsu.edu) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_ADDR_TYPES -#define INCLUDED_ADDR_TYPES - -#ifdef JUST_NEED_TYPES -# include "common/list.h" -#else -# define JUST_NEED_TYPES -# include "common/list.h" -# undef JUST_NEED_TYPES -#endif - -typedef union -{ - unsigned long n; - int i; - void * p; -} t_addr_data; - -typedef struct addr_struct -#ifdef ADDR_INTERNAL_ACCESS -{ - char const * str; /* hostname or ip */ - unsigned int ip; - unsigned int port; - t_addr_data data; /* data argument */ -} -#endif -t_addr; - -typedef struct netaddr_struct -#ifdef ADDR_INTERNAL_ACCESS -{ - unsigned int ip; - unsigned int mask; -} -#endif -t_netaddr; - -typedef t_list t_addrlist; - -#endif - - -/*****/ -#ifndef JUST_NEED_TYPES -#ifndef INCLUDED_ADDR_PROTOS -#define INCLUDED_ADDR_PROTOS - -/* ipaddr and port are in host byte order */ -extern char const * addr_num_to_addr_str(unsigned int ipaddr, unsigned short port); -/* ipaddr is in host byte order */ -extern char const * addr_num_to_ip_str(unsigned int ipaddr); - -extern char const * host_lookup(char const * hoststr, unsigned int * ipaddr); - -/* ipaddr and port are in host byte order */ -extern t_addr * addr_create_num(unsigned int ipaddr, unsigned short port) ; - -/* defipaddr and defport are in host byte order */ -extern t_addr * addr_create_str(char const * str, unsigned int defipaddr, unsigned short defport) ; - -extern int addr_destroy(t_addr const * addr); -extern char * addr_get_host_str(t_addr const * addr, char * str, unsigned int len); -extern char * addr_get_addr_str(t_addr const * addr, char * str, unsigned int len); -/* returned in host byte order */ -extern unsigned int addr_get_ip(t_addr const * addr); -/* returned in host byte order */ -extern unsigned short addr_get_port(t_addr const * addr); -extern int addr_set_data(t_addr * addr, t_addr_data data); -extern t_addr_data addr_get_data(t_addr const * addr); -extern t_netaddr * netaddr_create_str(char const * str) ; -extern int netaddr_destroy(t_netaddr const * netaddr); -extern char * netaddr_get_addr_str(t_netaddr const * netaddr, char * str, unsigned int len); -extern int netaddr_contains_addr_num(t_netaddr const * netaddr, unsigned int ipaddr); - -/* defipaddr and defport are in host byte order */ -extern int addrlist_append(t_addrlist * addrlist, char const * str, unsigned int defipaddr, unsigned short defport); -extern t_addrlist * addrlist_create(char const * str, unsigned int defipaddr, unsigned short defport) ; -extern int addrlist_destroy(t_addrlist * addrlist); -extern int addrlist_get_length(t_addrlist const * addrlist); - -#endif -#endif diff --git a/d2pack109/src/common/bn_type.c b/d2pack109/src/common/bn_type.c deleted file mode 100644 index 59fab41..0000000 --- a/d2pack109/src/common/bn_type.c +++ /dev/null @@ -1,665 +0,0 @@ -/* - * Copyright (C) 1998,1999,2001 Ross Combs (rocombs@cs.nmsu.edu) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#include "common/setup_before.h" -#ifdef HAVE_STRING_H -# include -#endif -#ifdef HAVE_MEMORY_H -# include -#endif -#include "compat/memcpy.h" -#include "common/eventlog.h" -#include "common/bn_type.h" -#include "common/setup_after.h" - - -/************************************************************/ - - -extern int bn_byte_tag_get(bn_byte const * src, char * dst, unsigned int len) -{ - unsigned int i; - - if (!dst) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL dst"); - return -1; - } - if (!src) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL src"); - return -1; - } - if (len<1) - { - eventlog(eventlog_level_error,__FUNCTION__,"got zero len"); - return -1; - } - - for (i=0; i> 8) ); - return 0; -} - - -extern int bn_short_nset(bn_short * dst, t_uint16 src) -{ - if (!dst) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL dst"); - return -1; - } - - (*dst)[0] = (unsigned char)((src>> 8) ); - (*dst)[1] = (unsigned char)((src )&0xff); - return 0; -} - - -extern int bn_int_set(bn_int * dst, t_uint32 src) -{ - if (!dst) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL dst"); - return -1; - } - - (*dst)[0] = (unsigned char)((src )&0xff); - (*dst)[1] = (unsigned char)((src>> 8)&0xff); - (*dst)[2] = (unsigned char)((src>>16)&0xff); - (*dst)[3] = (unsigned char)((src>>24) ); - return 0; -} - - -extern int bn_int_nset(bn_int * dst, t_uint32 src) -{ - if (!dst) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL dst"); - return -1; - } - - (*dst)[0] = (unsigned char)((src>>24) ); - (*dst)[1] = (unsigned char)((src>>16)&0xff); - (*dst)[2] = (unsigned char)((src>> 8)&0xff); - (*dst)[3] = (unsigned char)((src )&0xff); - return 0; -} - - -#ifdef HAVE_T_LONG -extern int bn_long_set(bn_long * dst, t_uint64 src) -{ - if (!dst) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL dst"); - return -1; - } - - (*dst)[0] = (unsigned char)((src )&0xff); - (*dst)[1] = (unsigned char)((src>> 8)&0xff); - (*dst)[2] = (unsigned char)((src>>16)&0xff); - (*dst)[3] = (unsigned char)((src>>24)&0xff); - (*dst)[4] = (unsigned char)((src>>32)&0xff); - (*dst)[5] = (unsigned char)((src>>40)&0xff); - (*dst)[6] = (unsigned char)((src>>48)&0xff); - (*dst)[7] = (unsigned char)((src>>56) ); - return 0; -} - - -extern int bn_long_nset(bn_long * dst, t_uint64 src) -{ - if (!dst) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL dst"); - return -1; - } - - (*dst)[0] = (unsigned char)((src>>56) ); - (*dst)[1] = (unsigned char)((src>>48)&0xff); - (*dst)[2] = (unsigned char)((src>>40)&0xff); - (*dst)[3] = (unsigned char)((src>>32)&0xff); - (*dst)[4] = (unsigned char)((src>>24)&0xff); - (*dst)[5] = (unsigned char)((src>>16)&0xff); - (*dst)[6] = (unsigned char)((src>> 8)&0xff); - (*dst)[7] = (unsigned char)((src )&0xff); - return 0; -} -#endif - - -extern int bn_long_set_a_b(bn_long * dst, t_uint32 srca, t_uint32 srcb) -{ - if (!dst) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL dst"); - return -1; - } - - (*dst)[0] = (unsigned char)((srcb )&0xff); - (*dst)[1] = (unsigned char)((srcb>> 8)&0xff); - (*dst)[2] = (unsigned char)((srcb>>16)&0xff); - (*dst)[3] = (unsigned char)((srcb>>24)&0xff); - (*dst)[4] = (unsigned char)((srca )&0xff); - (*dst)[5] = (unsigned char)((srca>> 8)&0xff); - (*dst)[6] = (unsigned char)((srca>>16)&0xff); - (*dst)[7] = (unsigned char)((srca>>24) ); - return 0; -} - - -extern int bn_long_nset_a_b(bn_long * dst, t_uint32 srca, t_uint32 srcb) -{ - if (!dst) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL dst"); - return -1; - } - - (*dst)[0] = (unsigned char)((srca>>24) ); - (*dst)[1] = (unsigned char)((srca>>16)&0xff); - (*dst)[2] = (unsigned char)((srca>> 8)&0xff); - (*dst)[3] = (unsigned char)((srca )&0xff); - (*dst)[4] = (unsigned char)((srcb>>24)&0xff); - (*dst)[5] = (unsigned char)((srcb>>16)&0xff); - (*dst)[6] = (unsigned char)((srcb>> 8)&0xff); - (*dst)[7] = (unsigned char)((srcb )&0xff); - return 0; -} - - -/************************************************************/ - - -extern int bn_raw_set(void * dst, void const * src, unsigned int len) -{ - if (!dst) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL dst"); - return -1; - } - if (!src) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL src"); - return -1; - } - - memcpy(dst,src,len); - return 0; -} - - -/************************************************************/ - - -extern int bn_byte_tag_eq(bn_byte const src, char const * tag) -{ - bn_byte temp; - - if (!src) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL src"); - return -1; - } - if (!tag) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL tag"); - return -1; - } - - if (bn_byte_tag_set(&temp,tag)<0) - return -1; - if (bn_byte_get(src)==bn_byte_get(temp)) - return 0; - - return -1; -} - - -extern int bn_short_tag_eq(bn_short const src, char const * tag) -{ - bn_short temp; - - if (!src) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL src"); - return -1; - } - if (!tag) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL tag"); - return -1; - } - - if (bn_short_tag_set(&temp,tag)<0) - return -1; - if (bn_short_get(src)==bn_short_get(temp)) - return 0; - - return -1; -} - - -extern int bn_int_tag_eq(bn_int const src, char const * tag) -{ - bn_int temp; - - if (!src) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL src"); - return -1; - } - if (!tag) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL tag"); - return -1; - } - - if (bn_int_tag_set(&temp,tag)<0) - return -1; - if (bn_int_get(src)==bn_int_get(temp)) - return 0; - - return -1; -} - - -extern int bn_long_tag_eq(bn_long const src, char const * tag) -{ - bn_long temp; - - if (!src) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL src"); - return -1; - } - if (!tag) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL tag"); - return -1; - } - - if (bn_long_tag_set(&temp,tag)<0) - return -1; - if (bn_long_get_a(src)==bn_long_get_a(temp) && - bn_long_get_b(src)==bn_long_get_b(temp)) - return 0; - - return -1; -} - - -/************************************************************/ - - -extern int uint32_to_int(t_uint32 num) -{ - if (num<(1UL<<30)) - return (int)num; - return (-(int)((~(num))+1)); -} diff --git a/d2pack109/src/common/bn_type.h b/d2pack109/src/common/bn_type.h deleted file mode 100644 index c706dca..0000000 --- a/d2pack109/src/common/bn_type.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (C) 1998,1999 Ross Combs (rocombs@cs.nmsu.edu) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_BN_TYPE_TYPES -#define INCLUDED_BN_TYPE_TYPES - -#ifdef JUST_NEED_TYPES -# include "compat/uint.h" -#else -# define JUST_NEED_TYPES -# include "compat/uint.h" -# undef JUST_NEED_TYPES -#endif - -typedef t_uint8 bn_basic; -typedef bn_basic bn_byte[1]; -typedef bn_basic bn_short[2]; -typedef bn_basic bn_int[4]; -typedef bn_basic bn_long[8]; - -#endif - - -/*****/ -#ifndef JUST_NEED_TYPES -#ifndef INCLUDED_BN_TYPE_PROTOS -#define INCLUDED_BN_TYPE_PROTOS - -#define JUST_NEED_TYPES -# include "compat/uint.h" -#undef JUST_NEED_TYPES - -extern int bn_byte_tag_get(bn_byte const * src, char * dst, unsigned int len); -extern int bn_short_tag_get(bn_short const * src, char * dst, unsigned int len); -extern int bn_int_tag_get(bn_int const * src, char * dst, unsigned int len); -extern int bn_long_tag_get(bn_long const * src, char * dst, unsigned int len); - -extern int bn_byte_tag_set(bn_byte * dst, char const * tag); -extern int bn_short_tag_set(bn_short * dst, char const * tag); -extern int bn_int_tag_set(bn_int * dst, char const * tag); -extern int bn_long_tag_set(bn_long * dst, char const * tag); - -extern t_uint8 bn_byte_get(bn_byte const src) ; -extern t_uint16 bn_short_get(bn_short const src) ; -extern t_uint16 bn_short_nget(bn_short const src) ; -extern t_uint32 bn_int_get(bn_int const src) ; -extern t_uint32 bn_int_nget(bn_int const src) ; -#ifdef HAVE_T_UINT64 -extern t_uint64 bn_long_get(bn_long const src) ; -#endif -extern t_uint32 bn_long_get_a(bn_long const src) ; -extern t_uint32 bn_long_get_b(bn_long const src) ; - -extern int bn_byte_set(bn_byte * dst, t_uint8 src); -extern int bn_short_set(bn_short * dst, t_uint16 src); -extern int bn_short_nset(bn_short * dst, t_uint16 src); -extern int bn_int_set(bn_int * dst, t_uint32 src); -extern int bn_int_nset(bn_int * dst, t_uint32 src); -#ifdef HAVE_T_UINT64 -extern int bn_long_set(bn_long * dst, t_uint64 src); -extern int bn_long_nset(bn_long * dst, t_uint64 src); -#endif -extern int bn_long_set_a_b(bn_long * dst, t_uint32 srca, t_uint32 srcb); -extern int bn_long_nset_a_b(bn_long * dst, t_uint32 srca, t_uint32 srcb); - -extern int bn_raw_set(void * dst, void const * src, unsigned int len); - -extern int bn_byte_tag_eq(bn_byte const src, char const * tag) ; -extern int bn_short_tag_eq(bn_short const src, char const * tag) ; -extern int bn_int_tag_eq(bn_int const src, char const * tag) ; -extern int bn_long_tag_eq(bn_long const src, char const * tag) ; - -extern int uint32_to_int(t_uint32 num); - -#endif -#endif diff --git a/d2pack109/src/common/d2game_protocol.h b/d2pack109/src/common/d2game_protocol.h deleted file mode 100644 index 7092f08..0000000 --- a/d2pack109/src/common/d2game_protocol.h +++ /dev/null @@ -1,551 +0,0 @@ -/* - * Copyright (C) 2000 Otto Chan (kenshin_@hotmail.com) - * Copyright (C) 2000 Ross Combs (rocombs@cs.nmsu.edu) - * Copyright (C) 2000 Onlyer (onlyer@263.net) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_D2GAME_PROTOCOL_TYPES -#define INCLUDED_D2GAME_PROTOCOL_TYPES - -#ifdef JUST_NEED_TYPES -# include "bn_type.h" -#else -# define JUST_NEED_TYPES -# include "bn_type.h" -# undef JUST_NEED_TYPES -#endif - - -/* - * The protocol for communicating between a Diablo II client - * and game server. - * FIXME: put the #define's into the PROTO section - */ - - -/******************************************************/ -typedef struct -{ -#ifdef NOTONLYER - bn_short magic; - bn_short size; - bn_byte type; -/* FIXME: the two sets of packets don't jive... did the beta have a different - game protocol or am I just confused (could easily be the later). */ -#else - bn_byte type; -#endif -} t_d2game_header; -/******************************************************/ - - -/******************************************************/ -typedef struct -{ - t_d2game_header h; -} t_d2game_generic; -/******************************************************/ - - -/******************************************************/ -/* -D2 00 05 00 00 -*/ -#define SERVER_00 0x00 /* beta-only? */ -typedef struct -{ - t_d2game_header h; - bn_byte unknown1; /* data request #? */ -} PACKED_ATTR() t_server_00_req; -#define SERVER_00 0x00 -/******************************************************/ - - -/******************************************************/ -/* -D2 00 20 00 01 E2 5E 13 BE 4C 02 04 CA 00 00 00 .........L...... -6C 69 6C 6A 6F 65 00 00 64 25 42 00 1C E9 50 00 liljoe..d.B...P. -*/ -#define CLIENT_01 0x01 /* beta-only? */ -typedef struct /* game select? */ -{ - t_d2game_header h; - bn_byte unknown1; /* data reply #? */ - bn_int gameid1; /* same as in auth 04 reply */ - bn_short gameid2; /* same as in auth 04 reply */ - bn_byte unknown2[5]; - /* character name */ - /* 00 64 25 42 00 1C E9 50 00 unknown... string or numeric? */ -} PACKED_ATTR() t_client_01; -/******************************************************/ - - -/******************************************************/ -/* -0030 22 38 32 5D 00 00 97 20 20 20 20 20 "82]........ -*/ -#define D2GAME_SERVER_WELCOME 0x97 -typedef struct -{ - t_d2game_header h; -} t_d2game_server_welcome; - - -/* -0000: 60 00 27 04 18 79 27 04 A8 00 00 00 07 02 00 00 `.'..y'......... -0010: B0 01 01 00 00 6F 6E 6C 79 65 72 00 B8 6A F7 BF .....onlyer..j.. -0020: 00 00 00 00 34 00 00 04 00 00 00 00 00 ....4........ - -0000: 60 00 27 04 18 79 27 04 30 0D 00 00 07 02 00 00 `.'..y'.0....... -0010: B0 01 04 00 01 41 4C 42 45 52 54 00 B8 6A F7 BF .....ALBERT..j.. -0020: 00 00 00 00 34 00 00 04 00 00 00 00 00 ....4........ - -0000: 60 00 27 04 18 79 27 04 A0 0A 00 00 07 02 00 00 `.'..y'......... -0010: B0 01 04 00 02 41 4C 42 45 52 54 00 B8 6A F7 BF .....ALBERT..j.. -0020: 00 00 00 00 34 00 00 04 00 00 00 00 00 ....4........ - -0000: 60 00 AB 04 18 79 AB 04 DE 00 9F 00 0C 02 00 00 `....y.......... -0010: 60 01 04 00 00 62 62 62 00 71 DF 77 A6 C0 E6 77 `....bbb.q.w...w -0020: A6 C0 E6 77 34 05 00 04 00 00 00 00 00 ...w4........ - -*/ - - -#define D2GAME_CLIENT_CREATEGAMEREQ 0x60 - -typedef bn_basic bn_charname[16]; - -typedef struct -{ - t_d2game_header h; - char gamename[16]; - bn_byte servertype; /* servertype=0, data not send to client and have no host */ - /* creator changed to newbie data saved in server machine*/ - /* servertype=1, data send to client and have host */ - /* servertype=2, data send to client and have no host */ - /* servertype=3, client all newbie,seems to be wrong */ - /* data is saved in server machine */ - /* client is loaded from server machine */ - bn_byte class; - bn_byte template; /* character template */ - /* affect the reply in 0x01 */ - /* should less than the lines of excel/CharTemplate.txt */ - bn_byte difficulty; - bn_charname charname; - bn_short arena; - bn_int gameflag; - bn_byte unknownb2; /* unused */ - bn_byte unknownb3; /* unused */ -} t_d2game_client_creategamereq; - - -typedef struct -{ - bn_byte flag1; /* "test gameflag,06" should not be zero,or will be bad gameflag */ - /* flag1 should be set with bit 0x04 or will fail or crash */ - /* bit 0x10,0x20,0x08 is ignored in reply */ - - bn_byte flag2; /* hardcore and softcore */ - /* 0x0 means softcore,0x1 template mode,0x8 means hardcore */ - /* bit 0x02,0x04,0xF0 is ignored in reply */ - /* have sth to do with char template */ - /* opengame */ - - bn_byte flag3; /* guild data (not in reply) */ - /* 0x01 means have guild */ - /* others bits seems all unused */ - - bn_byte flag4; /* seems to be unused */ - -} t_d2game_gameflag; - - - -/* -0030 22 37 86 D7 00 00 61 65 00 00 00 00 00 01 03 00 "7....ae........ -0040 00 00 6F 6E 6C 79 65 72 2D 63 6E 61 61 00 24 E0 ..onlyer-cnaa.$. -0050 7B 05 {. -*/ - -#define D2GAME_CLIENT_JOINGAMEREQ 0x61 -typedef struct -{ - t_d2game_header h; - bn_int token; - bn_short gameid; - bn_byte charclass; /* 00=Amazon 01=Sor 02=Nec 03=Pal 04=Bar */ - bn_int version; - bn_charname charname; - /* 16 bytes playe name (including 0x0 ending) */ -} t_d2game_client_joingamereq; - - -/* -0030 22 1C C9 65 00 00 20 20 20 20 20 20 "..e........ -*/ - -#define D2GAME_SERVER_NOOP 0x20 -typedef struct -{ - t_d2game_header h; - /* 5 \x20 noop */ -} t_d2game_server_noop; - - - -/* -0030 22 37 17 07 00 00 66 91 4B A1 00 00 00 00 00 "7....f.K...... -*/ -#define D2GAME_CLIENT_UNKNOWN_66 0x66 /* echo message? */ -typedef struct -{ - t_d2game_header h; - bn_int unknown1; - bn_int unknown2; -} t_d2game_client_unknown_66; - -/* -0000: 8F 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ -0010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ -0020: 00 . -*/ - -#define D2GAME_SERVER_UNKNOWN_8F 0x8f /* echo reply? */ -typedef struct -{ - t_d2game_header h; - bn_int unknown1; - bn_int unknown2; - bn_int unknown3; - bn_int unknown4; - bn_int unknown5; - bn_int unknown6; - bn_int unknown7; /* all here for open char is zero */ -} t_d2game_server_unknown_8f; - - - -/* -0030 22 1C C4 53 00 00 01 00 04 00 00 00 00 02 "..S.......... -*/ -#define D2GAME_SERVER_JOINOK 0x01 -/* this message will appear after - * 1. CLIENT_CREATEGAEM valid - * 2. CLIENT_JOINGAME valid - */ -typedef struct -{ - t_d2game_header h; - bn_byte difficulty; - bn_short gameflag; - bn_byte template; - bn_short unknown1; - bn_short unknown2; -} t_d2game_server_joinok; - - -/* -0030 22 2F 65 38 00 00 64 "/e8..d -*/ - -#define D2GAME_CLIENT_JOINACTREQ 0x64 -typedef struct -{ - t_d2game_header h; - /* none */ -} t_d2game_client_joinactreq; - - -#define D2GAME_SERVER_UNKNOWN_59 0x59 -typedef struct -{ - t_d2game_header h; -} t_d2game_server_unknown_59; - - -/* -0030 22 0E 0C 01 00 00 65 82 82 00 00 00 55 AA 55 AA ".....e.....U.U. -0040 47 00 00 00 6F 6E 6C 79 65 72 2D 63 6E 61 00 00 G...onlyer-cna.. -0050 00 00 00 00 01 00 00 00 DD 00 10 00 82 00 01 00 ................ -0060 01 00 01 01 01 01 01 FF FF FF 01 01 FF FF FF FF ................ -0070 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF ................ -0080 FF FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ -0090 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ -00A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ -00B0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FC ............... -*/ - - -#define D2GAME_CLIENT_PLAYERSAVE 0x65 -typedef struct -{ - t_d2game_header h; - bn_byte size; - bn_int total_size; - /* player save file */ - /* an append */ -} t_d2game_client_playersave; - - -#define D2GAME_SERVER_ERROR 0x9c -typedef struct -{ - t_d2game_header h; - bn_int errorno; -} t_d2game_server_error; - -#define D2GAME_SERVER_ERROR_UNKNOWN_FAILURE 0 /* error biger than 22 is also unknown */ -#define D2GAME_SERVER_ERROR_CHAR_VER 1 -#define D2GAME_SERVER_ERROR_QUEST_DATA 2 -#define D2GAME_SERVER_ERROR_WP_DATA 3 -#define D2GAME_SERVER_ERROR_STAT_DATA 4 -#define D2GAME_SERVER_ERROR_SKILL_DATA 5 -#define D2GAME_SERVER_ERROR_UNABLE_ENTER 6 -#define D2GAME_SERVER_ERROR_INVENTORY_DATA 7 -#define D2GAME_SERVER_ERROR_DEAD_BODY 8 -#define D2GAME_SERVER_ERROR_HEADER 9 -#define D2GAME_SERVER_ERROR_HIREABLES 10 -#define D2GAME_SERVER_ERROR_INTRO_DATA 11 -#define D2GAME_SERVER_ERROR_ITEM 12 -#define D2GAME_SERVER_ERROR_DEAD_BODY_ITEM 13 -#define D2GAME_SERVER_ERROR_GENERIC_BAD_FILE 14 -#define D2GAME_SERVER_ERROR_GAME_FULL 15 -#define D2GAME_SERVER_ERROR_GAME_VER 16 -#define D2GAME_SERVER_ERROR_NIGHTMARE 17 -#define D2GAME_SERVER_ERROR_HELL 18 -#define D2GAME_SERVER_ERROR_NORMAL_HARDCORE 19 -#define D2GAME_SERVER_ERROR_HARDCORE_NORMAL 20 -#define D2GAME_SERVER_ERROR_DEAD_HARDCORE 21 -/* -0000: 15 01 00 69 20 77 69 6C 6C 20 67 6F 00 00 00 ...i will go... - -0000: 15 01 00 74 68 61 6E 6B 73 20 66 6F 72 20 79 6F ...thanks for yo -0010: 75 72 20 68 65 6C 70 00 00 00 ur help... - -0000: 15 01 00 73 65 65 20 75 00 00 00 ...see u... - - -*/ - -#define D2GAME_CLIENT_CHAT_MESSAGE 0x15 -typedef struct -{ - t_d2game_header h; - bn_short unknown1; - /* chat message */ -} t_d2game_client_chat_message; - - -/* -0000: 26 01 00 02 00 00 00 00 00 01 6F 6E 6C 79 65 72 &.........onlyer -0010: 2D 63 6E 61 61 00 69 20 77 69 6C 6C 20 67 6F 00 -cnaa.i will go. - -0000: 26 01 00 02 00 00 00 00 00 01 6F 6E 6C 79 65 72 &.........onlyer -0010: 2D 63 6E 61 61 00 74 68 61 6E 6B 73 20 66 6F 72 -cnaa.thanks for -0020: 20 79 6F 75 72 20 68 65 6C 70 00 your help. - -0000: 26 01 00 02 00 00 00 00 00 01 6F 6E 6C 79 65 72 &.........onlyer -0010: 2D 63 6E 61 61 00 73 65 65 20 75 00 -cnaa.see u. - -0000: 26 01 00 02 00 00 00 00 00 17 63 63 00 62 79 65 &.........cc.bye -0010: 00 67 49 00 00 00 01 86 17 32 12 01 00 07 00 05 .gI......2...... - -*/ - -#define D2GAME_SERVER_CHAT_MESSAGE 0x26 -typedef struct -{ - t_d2game_header h; - bn_short unknown1; - bn_int unknown2; - bn_short unknown3; - bn_byte unknown4; /* id or token? a fixed number for each char*/ - /* player name */ - /* message */ -} t_d2game_server_chat_message; - -#define D2GAME_SERVER_CHAT_MESSAGE_UNKNOWN1 0x0001 -#define D2GAME_SERVER_CHAT_MESSAGE_UNKNOWN2 0x00000002 -#define D2GAME_SERVER_CHAT_MESSAGE_UNKNOWN3 0x0000 -#define D2GAME_SERVER_CHAT_MESSAGE_UNKNOWN4 0x01 - - -/* -0000: 62 b -*/ - -#define D2GAME_CLIENT_QUITGAME 0x62 -typedef struct -{ - t_d2game_header h; -} t_d2game_client_quitgame; - - -/* -0000: 9B FF 01 4E 03 00 00 55 AA 55 AA 47 00 00 00 6F ...N...U.U.G...o -0010: 6E 6C 79 65 72 2D 63 6E 61 61 00 00 00 00 00 00 nlyer-cnaa...... -0020: 00 00 00 DD 00 10 00 82 00 01 00 01 00 FF FF FF ................ -0030: FF FF 53 FF FF FF FF FF FF FF FF FF FF FF FF FF ..S............. -0040: FF FF FF FF FF FF FF FF FF FF FF FF FF FF 00 FF ................ -0050: 00 FF 00 FF 00 FF 00 FF 00 FF 00 FF 00 00 24 00 ..............$. -0060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ -0070: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ -0080: 00 00 00 00 00 5E 17 41 5F 57 6F 6F 21 06 00 00 .....^.A_Woo!... -0090: 00 2A 01 01 00 00 00 00 00 00 00 00 00 00 00 00 .*.............. -00A0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ -00B0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ -00C0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ -00D0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ -00E0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ -00F0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ -0100: 00 00 00 00 00 00 ...... - - - - -*/ - -#define D2GAME_SERVER_PLAYERSAVE 0x9b -typedef struct -{ - t_d2game_header h; - bn_byte size; - bn_byte start; - bn_int total_size; - /* player save file */ -} t_d2game_server_playersave; - - -/* -0000: 98 05 06 -*/ - -#define D2GAME_SERVER_CLOSEGAME 0x98 -typedef struct -{ - t_d2game_header h; - bn_short unknown1; -} t_d2game_server_closegame; - -/* -0000: 5A 02 04 00 00 00 00 03 61 72 63 68 5F 6E 61 67 Z.......arch_nag -0010: 61 00 00 00 B0 FD B6 08 00 FF FF FF 78 07 39 04 a...........x.9. -0020: D5 16 2D 04 01 FD B6 08 ..-..... -*/ - -#define D2GAME_SERVER_JOINGAME_MESSAGE 0x5a -typedef struct -{ - t_d2game_header h; - bn_byte unknown1; - bn_byte unknown2; - bn_int unknown3; - bn_byte unknown4; - /* char name */ -} t_d2game_joingame_message; - - - -#define D2GAME_CLIENT_DIE 0x41 -typedef struct -{ - t_d2game_header h; -} t_d2game_client_die; - - -/* -0000: 02 73 00 00 00 4E 00 8B 0F 7B 14 00 00 .s...N...{... - -#define D2GAME_SERVER_UNKNOWN_2 0x2 - -*/ - -/* -0000: 67 06 00 00 00 01 B2 0F 6B 14 01 00 07 00 05 g.......k...... - -0000: 67 06 00 00 00 01 B2 0F 71 14 01 00 07 00 05 g.......q...... - -0000: 67 0A 00 00 00 01 72 0F 63 14 01 00 07 00 05 g.....r.c...... - - -#define D2GAME_SERVER_UNKNOWN_67 0x67 - -*/ - - -/* -0000: 6D 0A 00 00 00 76 0F 64 14 80 m....v.d.. - -0000: 6D 0A 00 00 00 72 0F 63 14 80 m....r.c.. - -0000: 6D 06 00 00 00 B2 0F 71 14 80 8A 01 0B 00 00 00 m......q........ - -0000: 6D 06 00 00 00 B2 0F 6B 14 80 m......k.. - - - -#define D2GAME_SERVER_UNKNOWN_6D 0x6d - -*/ - -/* -0000: 8A 01 0B 00 00 00 6D 0B 00 00 00 9B 0F 70 14 80 ......m......p.. -0010: 2C 01 0B 00 00 00 11 00 ,....... - -0000: 8A 01 0B 00 00 00 ...... - - -#define D2GAME_SERVER_UNKNOWN_8A 0x8a - -*/ - - -/* -0000: 96 59 80 CC 07 36 8A 4C 36 .Y...6.L6 - -#define D2GAME_SERVER_UNKNOWN_96 0x96 - -*/ - -/* -0000: 24 62 00 00 00 $b... - -#define D2GAME_CLIENT_UNKNOWN_24 0x24 - -*/ - - -/* -CLIENT: - -0000: 2F 01 00 00 00 49 00 00 00 /....I... - -0000: 31 49 00 00 00 00 00 00 00 1I....... - -0000: 30 01 00 00 00 49 00 00 00 0....I... - -0000: 03 8C 17 2E 12 ..... - -0000: 03 87 17 27 12 ...'. command ? - - - -SERVER: - - -*/ - -#endif diff --git a/d2pack109/src/common/elist.h b/d2pack109/src/common/elist.h deleted file mode 100644 index 7bf296c..0000000 --- a/d2pack109/src/common/elist.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (C) 2004 Dizzy (dizzy@roedu.net) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_ELIST_TYPES -#define INCLUDED_ELIST_TYPES - -typedef struct elist_struct { - struct elist_struct *next, *prev; -} t_elist; - -#endif /* INCLUDED_ELIST_TYPES */ - -#ifndef INCLUDED_ELIST_PROTOS -#define INCLUDED_ELIST_PROTOS - -#ifdef HAVE_STDDEF_H -# include -#endif - -/* access to it's members */ -#define elist_next(ptr) ((ptr)->next) -#define elist_prev(ptr) ((ptr)->prev) - -#define __elist_init(elist,val) { (elist)->next = (elist)->prev = (val); } -#define elist_init(elist) __elist_init(elist,elist) -#define DECLARE_ELIST_INIT(var) \ - t_elist var = { &var, &var }; - -/* link an new node just after "where" */ -static inline void elist_add(t_elist *where, t_elist *what) -{ - what->next = where->next; - where->next->prev = what; - what->prev = where; - where->next = what; -} - -/* link a new node just before "where" (usefull in creating queues) */ -static inline void elist_add_tail(t_elist *where, t_elist *what) -{ - what->prev = where->prev; - where->prev->next = what; - what->next = where; - where->prev = what; -} - -/* unlink "what" from it's list */ -static inline void elist_del(t_elist *what) -{ - what->next->prev = what->prev; - what->prev->next = what->next; -} - -/* finds out the container address by computing it from the list node - * address substracting the offset inside the container of the list node - * member */ -#define elist_entry(ptr,type,member) ((type*)(((char*)ptr)-offsetof(type,member))) - -/* DONT remove while traversing with this ! */ -#define elist_for_each(pos,head) \ - for (pos = (head)->next; pos != (head); pos = pos->next) - -#define elist_for_each_rev(pos,head) \ - for (pos = (head)->prev; pos != (head); pos = pos->prev) - -/* safe for removals while traversing */ -#define elist_for_each_safe(pos,head,save) \ - for (pos = (head)->next, save = pos->next; pos != (head); \ - pos = save, save = pos->next) - -#define elist_for_each_safe_rev(pos,head,save) \ - for (pos = (head)->prev, save = pos->prev; pos != (head); \ - pos = save, save = pos->prev) - -#define elist_empty(ptr) ((ptr)->next == (ptr)) - -#endif /* INCLUDED_ELIST_PROTOS */ diff --git a/d2pack109/src/common/eventlog.c b/d2pack109/src/common/eventlog.c deleted file mode 100644 index 24b21eb..0000000 --- a/d2pack109/src/common/eventlog.c +++ /dev/null @@ -1,379 +0,0 @@ -/* - * Copyright (C) 1999 Rob Crittenden (rcrit@greyoak.com) - * Copyright (C) 1999,2000 Ross Combs (rocombs@cs.nmsu.edu) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#include "common/setup_before.h" -#include -#ifdef HAVE_STDDEF_H -# include -#else -# ifndef NULL -# define NULL ((void *)0) -# endif -#endif -#include -#include "compat/strerror.h" -#ifdef HAVE_STRING_H -# include -#else -# ifdef HAVE_STRINGS_H -# include -# endif -#endif -#include "compat/strcasecmp.h" -#ifdef HAVE_STDARG_H -# include -#else -# ifdef HAVE_VARARGS_H -# include -# endif -#endif -#ifdef TIME_WITH_SYS_TIME -# include -# include -#else -# ifdef HAVE_SYS_TIME_H -# include -# else -# include -# endif -#endif -#include "compat/strftime.h" -#ifdef HAVE_UNISTD_H -# include -#endif -#include "common/eventlog.h" -#include "common/setup_after.h" - -#ifdef WIN32_GUI -# include "win32/winmain.h" -#endif - -static FILE * eventstrm=NULL; -static t_eventlog_level currlevel=eventlog_level_debug| - eventlog_level_info| - eventlog_level_warn| - eventlog_level_error| - eventlog_level_fatal; -/* FIXME: maybe this should be default for win32 */ -static int eventlog_debugmode=0; - -extern void eventlog_set_debugmode(int debugmode) -{ - eventlog_debugmode = debugmode; -} - -extern void eventlog_set(FILE * fp) -{ - eventstrm = fp; -} - -extern FILE * eventlog_get(void) -{ - return eventstrm; -} - -extern int eventlog_close(void) -{ - fclose(eventstrm); - return 0; -} - -extern int eventlog_open(char const * filename) -{ - FILE * temp; - - if (!filename) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL filename"); - return -1; - } - - if (!(temp = fopen(filename,"a"))) - { - eventlog(eventlog_level_error,__FUNCTION__,"could not open file \"%s\" for appending (fopen: %s)",filename,strerror(errno)); - return -1; - } - - if (eventstrm && eventstrm!=stderr) /* close old one */ - if (fclose(eventstrm)<0) - { - eventstrm = temp; - eventlog(eventlog_level_error,__FUNCTION__,"could not close previous logfile after writing (fclose: %s)",strerror(errno)); - return 0; - } - eventstrm = temp; - - return 0; -} - - -extern void eventlog_clear_level(void) -{ - currlevel = eventlog_level_none; -} - - -extern int eventlog_add_level(char const * levelname) -{ - if (!levelname) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL levelname"); - return -1; - } - - if (strcasecmp(levelname,"trace")==0) - { - currlevel |= eventlog_level_trace; - return 0; - } - if (strcasecmp(levelname,"debug")==0) - { - currlevel |= eventlog_level_debug; - return 0; - } - if (strcasecmp(levelname,"info")==0) - { - currlevel |= eventlog_level_info; - return 0; - } - if (strcasecmp(levelname,"warn")==0) - { - currlevel |= eventlog_level_warn; - return 0; - } - if (strcasecmp(levelname,"error")==0) - { - currlevel |= eventlog_level_error; - return 0; - } - if (strcasecmp(levelname,"fatal")==0) - { - currlevel |= eventlog_level_fatal; - return 0; - } - - eventlog(eventlog_level_error,__FUNCTION__,"got bad levelname \"%s\"",levelname); - return -1; -} - - -extern int eventlog_del_level(char const * levelname) -{ - if (!levelname) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL levelname"); - return -1; - } - - if (strcasecmp(levelname,"trace")==0) - { - currlevel &= ~eventlog_level_trace; - return 0; - } - if (strcasecmp(levelname,"debug")==0) - { - currlevel &= ~eventlog_level_debug; - return 0; - } - if (strcasecmp(levelname,"info")==0) - { - currlevel &= ~eventlog_level_info; - return 0; - } - if (strcasecmp(levelname,"warn")==0) - { - currlevel &= ~eventlog_level_warn; - return 0; - } - if (strcasecmp(levelname,"error")==0) - { - currlevel &= ~eventlog_level_error; - return 0; - } - if (strcasecmp(levelname,"fatal")==0) - { - currlevel &= ~eventlog_level_fatal; - return 0; - } - - - eventlog(eventlog_level_error,__FUNCTION__,"got bad levelname \"%s\"",levelname); - return -1; -} - -extern char const * eventlog_get_levelname_str(t_eventlog_level level) -{ - switch (level) - { - case eventlog_level_trace: - return "trace"; - case eventlog_level_debug: - return "debug"; - case eventlog_level_info: - return "info "; - case eventlog_level_warn: - return "warn "; - case eventlog_level_error: - return "error"; - case eventlog_level_fatal: - return "fatal"; - default: - return "unknown"; - } -} - - -#ifdef DEBUGMODSTRINGS -extern void eventlog_real(t_eventlog_level level, char const * module, char const * fmt, ...) -#else -extern void eventlog(t_eventlog_level level, char const * module, char const * fmt, ...) -#endif -{ - va_list args; - char time_string[EVENT_TIME_MAXLEN]; - struct tm * tmnow; - time_t now; - - if (!(level&currlevel)) - return; - if (!eventstrm) - return; - - /* get the time before parsing args */ - time(&now); - if (!(tmnow = localtime(&now))) - strcpy(time_string,"?"); - else - strftime(time_string,EVENT_TIME_MAXLEN,EVENT_TIME_FORMAT,tmnow); - - if (!module) - { - fprintf(eventstrm,"%s [error] eventlog: got NULL module\n",time_string); -#ifdef WIN32_GUI - gui_lprintf(eventlog_level_error,"%s [error] eventlog: got NULL module\n",time_string); -#endif - fflush(eventstrm); - return; - } - - if (!fmt) - { - fprintf(eventstrm,"%s [error] eventlog: got NULL fmt\n",time_string); -#ifdef WIN32_GUI - gui_lprintf(eventlog_level_error,"%s [error] eventlog: got NULL fmt\n",time_string); -#endif - fflush(eventstrm); - return; - } - - fprintf(eventstrm,"%s [%s] %s: ",time_string,eventlog_get_levelname_str(level),module); -#ifdef WIN32_GUI - gui_lprintf(level,"%s [%s] %s: ",time_string,eventlog_get_levelname_str(level),module); -#endif - - va_start(args,fmt); - -#ifdef HAVE_VPRINTF - vfprintf(eventstrm,fmt,args); -#ifdef WIN32_GUI - gui_lvprintf(level,fmt,args); -#endif -#else -# if HAVE__DOPRNT - _doprnt(fmt,args,eventstrm); -# else - fprintf(eventstrm,"sorry, vfprintf() and _doprnt() are not available on this system"); -# endif -#endif - va_end(args); - fprintf(eventstrm,"\n"); -#ifdef WIN32_GUI - gui_lprintf(level,"\n"); -#endif - - if (eventlog_debugmode) { - printf("%s [%s] %s: ",time_string,eventlog_get_levelname_str(level),module); - va_start(args,fmt); -#ifdef HAVE_VPRINTF - vprintf(fmt,args); -#else -# if HAVE__DOPRNT - _doprnt(fmt,args,stdout); -# else - printf("sorry, vfprintf() and _doprnt() are not available on this system"); -# endif -#endif - va_end(args); - printf("\n"); - fflush(stdout); - } - fflush(eventstrm); -} - - -extern void eventlog_step(char const * filename, t_eventlog_level level, char const * module, char const * fmt, ...) -{ - va_list args; - char time_string[EVENT_TIME_MAXLEN]; - struct tm * tmnow; - time_t now; - FILE * fp; - - if (!(level&currlevel)) - return; - if (!eventstrm) - return; - - if (!(fp = fopen(filename, "a"))) - return; - - /* get the time before parsing args */ - time(&now); - if (!(tmnow = localtime(&now))) - strcpy(time_string,"?"); - else - strftime(time_string,EVENT_TIME_MAXLEN,EVENT_TIME_FORMAT,tmnow); - - if (!module) - { - fprintf(fp,"%s [error] eventlog_step: got NULL module\n",time_string); - fclose(fp); - return; - } - if (!fmt) - { - fprintf(fp,"%s [error] eventlog_step: got NULL fmt\n",time_string); - fclose(fp); - return; - } - - fprintf(fp,"%s [%s] %s: ",time_string,eventlog_get_levelname_str(level),module); - va_start(args,fmt); -#ifdef HAVE_VPRINTF - vfprintf(fp,fmt,args); -#else -# if HAVE__DOPRNT - _doprnt(fmt,args,fp); -# else - fprintf(fp,"sorry, vfprintf() and _doprnt() are not available on this system"); -# endif -#endif - va_end(args); - fprintf(fp,"\n"); - fclose(fp); -} diff --git a/d2pack109/src/common/eventlog.h b/d2pack109/src/common/eventlog.h deleted file mode 100644 index eadca0d..0000000 --- a/d2pack109/src/common/eventlog.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (C) 1998 Mark Baysinger (mbaysing@ucsd.edu) - * Copyright (C) 1998,1999,2000 Ross Combs (rocombs@cs.nmsu.edu) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_EVENTLOG_TYPES -#define INCLUDED_EVENTLOG_TYPES - -typedef enum -{ - eventlog_level_none = 0, - eventlog_level_trace= 1, - eventlog_level_debug= 2, - eventlog_level_info = 4, - eventlog_level_warn = 8, - eventlog_level_error=16, - eventlog_level_fatal=32 -} t_eventlog_level; - -#endif - - -/*****/ -#ifndef JUST_NEED_TYPES -#ifndef INCLUDED_EVENTLOG_PROTOS -#define INCLUDED_EVENTLOG_PROTOS - -#define JUST_NEED_TYPES -#include -#undef JUST_NEED_TYPES - -extern void eventlog_set_debugmode(int debugmode); -extern void eventlog_set(FILE * fp); -extern FILE * eventlog_get(void); -extern int eventlog_open(char const * filename); -extern int eventlog_close(void); -extern void eventlog_clear_level(void); -extern int eventlog_add_level(char const * levelname); -extern int eventlog_del_level(char const * levelname); -extern char const * eventlog_get_levelname_str(t_eventlog_level level); -#ifdef DEBUGMODSTRINGS - -extern void eventlog_real(t_eventlog_level level, char const * module, char const * fmt, ...) PRINTF_ATTR(3,4); -# if __STDC_VERSION__+1 >= 199901L -# define eventlog(l,m,f,args...) eventlog_real(l,"@(" __FILE__ ":" m "@@" __func__ ")@",f,##args) -# else -# if defined(__GNUC__) && ((__GNUC__ == 2 && __GNUC_MINOR__ >= 7) || __GNUC__ > 2) -# define eventlog(l,m,f,args...) eventlog_real(l,"@(" __FILE__ ":" m "@@" __PRETTY_FUNCTION__ ")@",f,##args) -# else -# error "No function macro available, either don't define DEBUGMODSTRINGS or don't use -pedantic" -# endif -# endif - -#else - -extern void eventlog(t_eventlog_level level, char const * module, char const * fmt, ...); -extern void eventlog_step(char const * filename, t_eventlog_level level, char const * module, char const * fmt, ...); - -#endif - -#endif -#endif diff --git a/d2pack109/src/common/fdwatch.c b/d2pack109/src/common/fdwatch.c deleted file mode 100644 index 2dd7a99..0000000 --- a/d2pack109/src/common/fdwatch.c +++ /dev/null @@ -1,211 +0,0 @@ -/* - * Abstraction API/layer for the various ways PvPGN can inspect sockets state - * 2003 (C) dizzy@roedu.net - * - * Code is based on the ideas found in thttpd project. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "common/setup_before.h" -#ifdef HAVE_STRING_H -# include -#else -# ifdef HAVE_STRINGS_H -# include -# endif -#endif -#ifdef STDC_HEADERS -# include -#else -# ifdef HAVE_MALLOC_H -# include -# endif -#endif -#include "common/eventlog.h" -#define FDWATCH_BACKEND -#include "fdwatch.h" -#ifdef HAVE_SELECT -#include "fdwatch_select.h" -#endif -#ifdef HAVE_POLL -#include "fdwatch_poll.h" -#endif -#ifdef HAVE_KQUEUE -#include "fdwatch_kqueue.h" -#endif -#ifdef HAVE_EPOLL -#include "fdwatch_epoll.h" -#endif -#include "common/rlimit.h" -#include "common/xalloc.h" -#include "common/setup_after.h" - -int fdw_maxcons; -t_fdwatch_fd *fdw_fds = NULL; - -static t_fdw_backend * fdw = NULL; -static DECLARE_ELIST_INIT(freelist); -static DECLARE_ELIST_INIT(uselist); - -extern int fdwatch_init(int maxcons) -{ - int i, maxsys; - - maxsys = get_socket_limit(); - if (maxsys > 0) maxcons = (maxcons < maxsys) ? maxcons : maxsys; - if (maxcons < 32) { - eventlog(eventlog_level_fatal, __FUNCTION__, "too few sockets available (%d)",maxcons); - return -1; - } - fdw_maxcons = maxcons; - - fdw_fds = xmalloc(sizeof(t_fdwatch_fd) * fdw_maxcons); - memset(fdw_fds, 0, sizeof(t_fdwatch_fd) * fdw_maxcons); - /* add all slots to the freelist */ - for(i = 0; i < fdw_maxcons; i++) - elist_add_tail(&freelist,&(fdw_fds[i].freelist)); - -#ifdef HAVE_EPOLL - fdw = &fdw_epoll; - if (!fdw->init(fdw_maxcons)) goto ok; -#endif -#ifdef HAVE_KQUEUE - fdw = &fdw_kqueue; - if (!fdw->init(fdw_maxcons)) goto ok; -#endif -#ifdef HAVE_POLL - fdw = &fdw_poll; - if (!fdw->init(fdw_maxcons)) goto ok; - goto ok; -#endif -#ifdef HAVE_SELECT - fdw = &fdw_select; - if (!fdw->init(fdw_maxcons)) goto ok; -#endif - - eventlog(eventlog_level_fatal, __FUNCTION__, "Found no working fdwatch layer"); - fdw = NULL; - fdwatch_close(); - return -1; - -ok: - return 0; -} - -extern int fdwatch_close(void) -{ - if (fdw) { fdw->close(); fdw = NULL; } - if (fdw_fds) { xfree((void*)fdw_fds); fdw_fds = NULL; } - elist_init(&freelist); - elist_init(&uselist); - - return 0; -} - -extern int fdwatch_add_fd(int fd, t_fdwatch_type rw, fdwatch_handler h, void *data) -{ - t_fdwatch_fd *cfd; - - if (elist_empty(&freelist)) return -1; /* max sockets reached */ - - cfd = elist_entry(elist_next(&freelist),t_fdwatch_fd,freelist); - fdw_fd(cfd) = fd; - - if (fdw->add_fd(fdw_idx(cfd), rw)) return -1; - - /* add it to used sockets list, remove it from free list */ - elist_add_tail(&uselist,&cfd->uselist); - elist_del(&cfd->freelist); - - fdw_rw(cfd) = rw; - fdw_data(cfd) = data; - fdw_hnd(cfd) = h; - - return fdw_idx(cfd); -} - -extern int fdwatch_update_fd(int idx, t_fdwatch_type rw) -{ - if (idx<0 || idx>=fdw_maxcons) { - eventlog(eventlog_level_error,__FUNCTION__,"out of bounds idx [%d] (max: %d)",idx, fdw_maxcons); - return -1; - } - /* do not allow completly reset the access because then backend codes - * can get confused */ - if (!rw) { - eventlog(eventlog_level_error,__FUNCTION__,"tried to reset rw, not allowed"); - return -1; - } - - if (!fdw_rw(fdw_fds + idx)) { - eventlog(eventlog_level_error,__FUNCTION__,"found reseted rw"); - return -1; - } - - if (fdw->add_fd(idx, rw)) return -1; - fdw_rw(&fdw_fds[idx]) = rw; - - return 0; -} - -extern int fdwatch_del_fd(int idx) -{ - t_fdwatch_fd *cfd; - - if (idx<0 || idx>=fdw_maxcons) { - eventlog(eventlog_level_error,__FUNCTION__,"out of bounds idx [%d] (max: %d)",idx, fdw_maxcons); - return -1; - } - - cfd = fdw_fds + idx; - if (!fdw_rw(cfd)) { - eventlog(eventlog_level_error,__FUNCTION__,"found reseted rw"); - return -1; - } - - fdw->del_fd(idx); - - /* remove it from uselist, add it to freelist */ - elist_del(&cfd->uselist); - elist_add_tail(&freelist,&cfd->freelist); - - fdw_fd(cfd) = 0; - fdw_rw(cfd) = 0; - fdw_data(cfd) = NULL; - fdw_hnd(cfd) = NULL; - - return 0; -} - -extern int fdwatch(long timeout_msec) -{ - return fdw->watch(timeout_msec); -} - -extern void fdwatch_handle(void) -{ - fdw->handle(); -} - -extern void fdwatch_traverse(t_fdw_cb cb, void *data) -{ - t_elist *curr; - - elist_for_each(curr,&uselist) - { - if (cb(elist_entry(curr,t_fdwatch_fd,uselist),data)) break; - } -} diff --git a/d2pack109/src/common/fdwatch.h b/d2pack109/src/common/fdwatch.h deleted file mode 100644 index 1ba97fb..0000000 --- a/d2pack109/src/common/fdwatch.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Abstraction API/layer for the various ways PvPGN can inspect sockets state - * 2003 (C) dizzy@roedu.net - * - * Code is based on the ideas found in thttpd project. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef __FDWATCH_INCLUDED__ -#define __FDWATCH_INCLUDED__ - -#include "common/elist.h" - -typedef enum { - fdwatch_type_none = 0, - fdwatch_type_read = 1, - fdwatch_type_write = 2 -} t_fdwatch_type; - -typedef int (*fdwatch_handler)(void *data, t_fdwatch_type); - -typedef struct { - int fd; - int rw; - fdwatch_handler hnd; - void *data; - - t_elist uselist; - t_elist freelist; -} t_fdwatch_fd; - -#ifdef FDWATCH_BACKEND -typedef int (*t_fdw_cb)(t_fdwatch_fd *cfd, void *data); -#endif - -typedef struct { - int (*init)(int nfds); - int (*close)(void); - int (*add_fd)(int idx, t_fdwatch_type rw); - int (*del_fd)(int idx); - int (*watch)(long timeout_msecs); - void (*handle)(void); -} t_fdw_backend; - -extern int fdw_maxcons; -extern t_fdwatch_fd *fdw_fds; - -#define fdw_idx(ptr) ((ptr) - fdw_fds) -#define fdw_fd(ptr) ((ptr)->fd) -#define fdw_rw(ptr) ((ptr)->rw) -#define fdw_data(ptr) ((ptr)->data) -#define fdw_hnd(ptr) ((ptr)->hnd) -extern int fdwatch_init(int maxcons); -extern int fdwatch_close(void); -extern int fdwatch_add_fd(int fd, t_fdwatch_type rw, fdwatch_handler h, void *data); -extern int fdwatch_update_fd(int idx, t_fdwatch_type rw); -extern int fdwatch_del_fd(int idx); -extern int fdwatch(long timeout_msecs); -extern void fdwatch_handle(void); -#ifdef FDWATCH_BACKEND -extern void fdwatch_traverse(t_fdw_cb cb, void *data); -#endif - -#endif /* __FDWATCH_INCLUDED__ */ diff --git a/d2pack109/src/common/fdwatch_epoll.c b/d2pack109/src/common/fdwatch_epoll.c deleted file mode 100644 index 0435955..0000000 --- a/d2pack109/src/common/fdwatch_epoll.c +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Abstraction API/layer for the various ways PvPGN can inspect sockets state - * 2003 (C) dizzy@roedu.net - * - * Code is based on the ideas found in thttpd project. - * - * Linux epoll(4) based backend - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "common/setup_before.h" -#ifdef HAVE_EPOLL - -#ifdef STDC_HEADERS -# include -#else -# ifdef HAVE_MALLOC_H -# include -# endif -#endif -#ifdef HAVE_STRING_H -# include -#else -# ifdef HAVE_STRINGS_H -# include -# endif -#endif -#ifdef HAVE_SYS_EPOLL_H -# include "compat/uint.h" -# include -#endif -#include "fdwatch.h" -#include "common/eventlog.h" -#include "common/xalloc.h" -#include "common/setup_after.h" - -static int sr; -static int epfd; -static struct epoll_event *epevents = NULL; /* events to investigate */ -static struct epoll_event tmpev; - -static int fdw_epoll_init(int nfds); -static int fdw_epoll_close(void); -static int fdw_epoll_add_fd(int idx, t_fdwatch_type rw); -static int fdw_epoll_del_fd(int idx); -static int fdw_epoll_watch(long timeout_msecs); -static void fdw_epoll_handle(void); - -t_fdw_backend fdw_epoll = { - fdw_epoll_init, - fdw_epoll_close, - fdw_epoll_add_fd, - fdw_epoll_del_fd, - fdw_epoll_watch, - fdw_epoll_handle -}; - -static int fdw_epoll_init(int nfds) -{ - if ((epfd = epoll_create(nfds)) < 0) - return -1; - epevents = (struct epoll_event *) xmalloc(sizeof(struct epoll_event) * nfds); - - memset(epevents, 0, sizeof(struct epoll_event) * nfds); - sr = 0; - - eventlog(eventlog_level_info, __FUNCTION__, "fdwatch epoll() based layer initialized (max %d sockets)", nfds); - return 0; -} - -static int fdw_epoll_close(void) -{ - if (epevents != NULL) - xfree((void *) epevents); - sr = 0; - - return 0; -} - -static int fdw_epoll_add_fd(int idx, t_fdwatch_type rw) -{ - int op; -// eventlog(eventlog_level_trace, __FUNCTION__, "called fd: %d rw: %d", fd, rw); - - tmpev.events = 0; - if (rw & fdwatch_type_read) - tmpev.events |= EPOLLIN; - if (rw & fdwatch_type_write) - tmpev.events |= EPOLLOUT; - - if (fdw_rw(fdw_fds + idx)) op = EPOLL_CTL_MOD; - else op = EPOLL_CTL_ADD; - - tmpev.data.fd = idx; - if (epoll_ctl(epfd, op, fdw_fd(fdw_fds + idx), &tmpev)) { - eventlog(eventlog_level_error, __FUNCTION__, "got error from epoll_ctl()"); - return -1; - } - - return 0; -} - -static int fdw_epoll_del_fd(int idx) -{ -// eventlog(eventlog_level_trace, __FUNCTION__, "called fd: %d", fd); - if (sr > 0) - eventlog(eventlog_level_error, __FUNCTION__, "BUG: called while still handling sockets"); - - if (fdw_rw(fdw_fds + idx)) { - tmpev.events = 0; - tmpev.data.fd = idx; - if (epoll_ctl(epfd, EPOLL_CTL_DEL, fdw_fd(fdw_fds + idx), &tmpev)) { - eventlog(eventlog_level_error, __FUNCTION__, "got error from epoll_ctl()"); - return -1; - } - } - - return 0; -} - -static int fdw_epoll_watch(long timeout_msec) -{ - return (sr = epoll_wait(epfd, epevents, fdw_maxcons, timeout_msec)); -} - -static void fdw_epoll_handle(void) -{ - struct epoll_event *ev; - t_fdwatch_fd *cfd; - -// eventlog(eventlog_level_trace, __FUNCTION__, "called"); - for (ev = epevents; sr; sr--, ev++) - { -// eventlog(eventlog_level_trace, __FUNCTION__, "checking %d ident: %d read: %d write: %d", i, kqevents[i].ident, kqevents[i].filter & EVFILT_READ, kqevents[i].filter & EVFILT_WRITE); - cfd = fdw_fds + ev->data.fd; - - if (fdw_rw(cfd) & fdwatch_type_read && ev->events & (EPOLLIN | EPOLLERR | EPOLLHUP)) - if (fdw_hnd(cfd) (fdw_data(cfd), fdwatch_type_read) == -2) - continue; - - if (fdw_rw(cfd) & fdwatch_type_write && ev->events & (EPOLLOUT | EPOLLERR | EPOLLHUP)) - fdw_hnd(cfd) (fdw_data(cfd), fdwatch_type_write); - } - sr = 0; -} - -#endif /* HAVE_EPOLL */ diff --git a/d2pack109/src/common/fdwatch_epoll.h b/d2pack109/src/common/fdwatch_epoll.h deleted file mode 100644 index dd7a226..0000000 --- a/d2pack109/src/common/fdwatch_epoll.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Abstraction API/layer for the various ways PvPGN can inspect sockets state - * 2003 (C) dizzy@roedu.net - * - * Code is based on the ideas found in thttpd project. - * - * Linux epoll(4) based backend - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef __INCLUDED_FDWATCH_EPOLL__ -#define __INCLUDED_FDWATCH_EPOLL__ - -extern t_fdw_backend fdw_epoll; - -#endif /* __INCLUDED_FDWATCH_EPOLL__ */ diff --git a/d2pack109/src/common/fdwatch_kqueue.c b/d2pack109/src/common/fdwatch_kqueue.c deleted file mode 100644 index 1b91f6e..0000000 --- a/d2pack109/src/common/fdwatch_kqueue.c +++ /dev/null @@ -1,286 +0,0 @@ -/* - * Abstraction API/layer for the various ways PvPGN can inspect sockets state - * 2003 (C) dizzy@roedu.net - * - * Code is based on the ideas found in thttpd project. - * - * *BSD kqueue(2) based backend - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "common/setup_before.h" -#ifdef STDC_HEADERS -# include -#else -# ifdef HAVE_MALLOC_H -# include -# endif -#endif -#ifdef HAVE_STRING_H -# include -#else -# ifdef HAVE_STRINGS_H -# include -# endif -#endif -#ifdef HAVE_SYS_TYPES_H -# include -#endif -#ifdef HAVE_SYS_EVENT_H -# include -#endif -#ifdef HAVE_SYS_TIME_H -# include -#endif -#include "fdwatch.h" -#include "common/eventlog.h" -#include "common/xalloc.h" -#include "common/setup_after.h" - -#ifdef HAVE_KQUEUE -static int sr; -static int kq; -static struct kevent *kqchanges = NULL; /* changes to make to kqueue */ -static struct kevent *kqevents = NULL; /* events to investigate */ -/* r/w indices from idx to the kqchanges index where the change is stored */ -static int *_rridx, *_wridx; -static unsigned nochanges; - -static int fdw_kqueue_init(int nfds); -static int fdw_kqueue_close(void); -static int fdw_kqueue_add_fd(int idx, t_fdwatch_type rw); -static int fdw_kqueue_del_fd(int idx); -static int fdw_kqueue_watch(long timeout_msecs); -static void fdw_kqueue_handle(void); - -t_fdw_backend fdw_kqueue = { - fdw_kqueue_init, - fdw_kqueue_close, - fdw_kqueue_add_fd, - fdw_kqueue_del_fd, - fdw_kqueue_watch, - fdw_kqueue_handle -}; - -static int fdw_kqueue_init(int nfds) -{ - int i; - - if ((kq = kqueue()) == -1) - return -1; - kqevents = (struct kevent *) xmalloc(sizeof(struct kevent) * nfds); - kqchanges = (struct kevent *) xmalloc(sizeof(struct kevent) * nfds * 2); - _rridx = (int *) xmalloc(sizeof(int) * nfds); - _wridx = (int *) xmalloc(sizeof(int) * nfds); - - memset(kqchanges, 0, sizeof(struct kevent) * nfds); - for (i = 0; i < nfds; i++) - { - _rridx[i] = -1; - _wridx[i] = -1; - } - sr = 0; - nochanges = 0; - - eventlog(eventlog_level_info, __FUNCTION__, "fdwatch kqueue() based layer initialized (max %d sockets)", nfds); - return 0; -} - -static int fdw_kqueue_close(void) -{ - if (_rridx) { xfree((void *) _rridx); _rridx = NULL; } - if (_wridx) { xfree((void *) _wridx); _wridx = NULL; } - if (kqchanges) { xfree((void *) kqchanges); kqchanges = NULL; } - if (kqevents) { xfree((void *) kqevents); kqevents = NULL; } - sr = 0; - nochanges = 0; - - return 0; -} - -static int fdw_kqueue_add_fd(int idx, t_fdwatch_type rw) -{ - static int ridx; - t_fdwatch_fd *cfd; - -/* eventlog(eventlog_level_trace, __FUNCTION__, "called fd: %d rw: %d", fd, rw); */ - - cfd = fdw_fds + idx; - /* adding read event filter */ - if (!(fdw_rw(cfd) & fdwatch_type_read) && rw & fdwatch_type_read) - { - if (_rridx[idx] >= 0 && _rridx[idx] < nochanges && kqchanges[_rridx[idx]].ident == fdw_fd(cfd)) - { - ridx = _rridx[idx]; -/* eventlog(eventlog_level_trace, __FUNCTION__, "updating change event (read) fd on %d", ridx); */ - } else { - ridx = nochanges++; - _rridx[idx] = ridx; -/* eventlog(eventlog_level_trace, __FUNCTION__, "adding new change event (read) fd on %d", ridx); */ - } - EV_SET(kqchanges + ridx, fdw_fd(cfd), EVFILT_READ, EV_ADD, 0, 0, (void*)idx); - } - else if (fdw_rw(cfd) & fdwatch_type_read && !( rw & fdwatch_type_read)) - { - if (_rridx[idx] >= 0 && _rridx[idx] < nochanges && kqchanges[_rridx[idx]].ident == fdw_fd(cfd)) - { - ridx = _rridx[idx]; -/* eventlog(eventlog_level_trace, __FUNCTION__, "updating change event (read) fd on %d", ridx); */ - } else { - ridx = nochanges++; - _rridx[idx] = ridx; -/* eventlog(eventlog_level_trace, __FUNCTION__, "adding new change event (read) fd on %d", ridx); */ - } - EV_SET(kqchanges + ridx, fdw_fd(cfd), EVFILT_READ, EV_DELETE, 0, 0, (void*)idx); - } - - /* adding write event filter */ - if (!(fdw_rw(cfd) & fdwatch_type_write) && rw & fdwatch_type_write) - { - if (_wridx[idx] >= 0 && _wridx[idx] < nochanges && kqchanges[_wridx[idx]].ident == fdw_fd(cfd)) - { - ridx = _wridx[idx]; -/* eventlog(eventlog_level_trace, __FUNCTION__, "updating change event (write) fd on %d", ridx); */ - } else { - ridx = nochanges++; - _wridx[idx] = ridx; -/* eventlog(eventlog_level_trace, __FUNCTION__, "adding new change event (write) fd on %d", ridx); */ - } - EV_SET(kqchanges + ridx, fdw_fd(cfd), EVFILT_WRITE, EV_ADD, 0, 0, (void*)idx); - } - else if (fdw_rw(cfd) & fdwatch_type_write && !(rw & fdwatch_type_write)) - { - if (_wridx[idx] >= 0 && _wridx[idx] < nochanges && kqchanges[_wridx[idx]].ident == fdw_fd(cfd)) - { - ridx = _wridx[idx]; -/* eventlog(eventlog_level_trace, __FUNCTION__, "updating change event (write) fd on %d", ridx); */ - } else { - ridx = nochanges++; - _wridx[idx] = ridx; -/* eventlog(eventlog_level_trace, __FUNCTION__, "adding new change event (write) fd on %d", ridx); */ - } - EV_SET(kqchanges + ridx, fdw_fd(cfd), EVFILT_WRITE, EV_DELETE, 0, 0, (void*)idx); - } - - return 0; -} - -static int fdw_kqueue_del_fd(int idx) -{ - t_fdwatch_fd *cfd; - -/* eventlog(eventlog_level_trace, __FUNCTION__, "called fd: %d", fd); */ - if (sr > 0) - eventlog(eventlog_level_error, __FUNCTION__, "BUG: called while still handling sockets"); - - cfd = fdw_fds + idx; - /* the last event changes about this fd has not yet been sent to kernel */ - if (fdw_rw(cfd) & fdwatch_type_read && - nochanges && _rridx[idx] >= 0 && _rridx[idx] < nochanges && - kqchanges[_rridx[idx]].ident == fdw_fd(cfd)) - { - nochanges--; - if (_rridx[idx] < nochanges) - { - int oidx; - - oidx = (int)(kqchanges[nochanges].udata); - if (kqchanges[nochanges].filter == EVFILT_READ && - _rridx[oidx] == nochanges) - { -/* eventlog(eventlog_level_trace, __FUNCTION__, "not last, moving %d", kqchanges[rnfds].ident); */ - _rridx[oidx] = _rridx[idx]; - memcpy(kqchanges + _rridx[idx], kqchanges + nochanges, sizeof(struct kevent)); - } - - if (kqchanges[nochanges].filter == EVFILT_WRITE && - _wridx[oidx] == nochanges) - { -/* eventlog(eventlog_level_trace, __FUNCTION__, "not last, moving %d", kqchanges[rnfds].ident); */ - _wridx[oidx] = _rridx[idx]; - memcpy(kqchanges + _rridx[idx], kqchanges + nochanges, sizeof(struct kevent)); - } - } - _rridx[idx] = -1; - } - - if (fdw_rw(cfd) & fdwatch_type_write && - nochanges && _wridx[idx] >= 0 && _wridx[idx] < nochanges && - kqchanges[_wridx[idx]].ident == fdw_fd(cfd)) - { - nochanges--; - if (_wridx[idx] < nochanges) - { - int oidx; - - oidx = (int)(kqchanges[nochanges].udata); - if (kqchanges[nochanges].filter == EVFILT_READ && - _rridx[oidx] == nochanges) - { -/* eventlog(eventlog_level_trace, __FUNCTION__, "not last, moving %d", kqchanges[rnfds].ident); */ - _rridx[oidx] = _wridx[idx]; - memcpy(kqchanges + _wridx[idx], kqchanges + nochanges, sizeof(struct kevent)); - } - - if (kqchanges[nochanges].filter == EVFILT_WRITE && - _wridx[oidx] == nochanges) - { -/* eventlog(eventlog_level_trace, __FUNCTION__, "not last, moving %d", kqchanges[rnfds].ident); */ - _wridx[oidx] = _wridx[idx]; - memcpy(kqchanges + _wridx[idx], kqchanges + nochanges, sizeof(struct kevent)); - } - } - _wridx[idx] = -1; - } - -/* here we presume the calling code does close() on the socket and if so - * it is automatically removed from any kernel kqueues */ - - return 0; -} - -static int fdw_kqueue_watch(long timeout_msec) -{ - static struct timespec ts; - - ts.tv_sec = timeout_msec / 1000L; - ts.tv_nsec = (timeout_msec % 1000L) * 1000000L; - sr = kevent(kq, nochanges > 0 ? kqchanges : NULL, nochanges, kqevents, fdw_maxcons, &ts); - nochanges = 0; - return sr; -} - -static void fdw_kqueue_handle(void) -{ - register unsigned i; - t_fdwatch_fd *cfd; - -/* eventlog(eventlog_level_trace, __FUNCTION__, "called"); */ - for (i = 0; i < sr; i++) - { -/* eventlog(eventlog_level_trace, __FUNCTION__, "checking %d ident: %d read: %d write: %d", i, kqevents[i].ident, kqevents[i].filter & EVFILT_READ, kqevents[i].filter & EVFILT_WRITE); */ - cfd = fdw_fds + (int)kqevents[i].udata; - if (fdw_rw(cfd) & fdwatch_type_read && kqevents[i].filter == EVFILT_READ) - if (fdw_hnd(cfd) (fdw_data(cfd), fdwatch_type_read) == -2) - continue; - - if (fdw_rw(cfd) & fdwatch_type_write && kqevents[i].filter == EVFILT_WRITE) - fdw_hnd(cfd) (fdw_data(cfd), fdwatch_type_write); - } - sr = 0; -} - -#endif /* HAVE_KQUEUE */ diff --git a/d2pack109/src/common/fdwatch_kqueue.h b/d2pack109/src/common/fdwatch_kqueue.h deleted file mode 100644 index 50cec30..0000000 --- a/d2pack109/src/common/fdwatch_kqueue.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Abstraction API/layer for the various ways PvPGN can inspect sockets state - * 2003 (C) dizzy@roedu.net - * - * Code is based on the ideas found in thttpd project. - * - * *BSD kqueue() based backend - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef __INCLUDED_FDWATCH_KQUEUE__ -#define __INCLUDED_FDWATCH_KQUEUE__ - -extern t_fdw_backend fdw_kqueue; - -#endif /* __INCLUDED_FDWATCH_KQUEUE__ */ diff --git a/d2pack109/src/common/fdwatch_poll.c b/d2pack109/src/common/fdwatch_poll.c deleted file mode 100644 index b76405c..0000000 --- a/d2pack109/src/common/fdwatch_poll.c +++ /dev/null @@ -1,185 +0,0 @@ -/* - * Abstraction API/layer for the various ways PvPGN can inspect sockets state - * 2003 (C) dizzy@roedu.net - * - * Code is based on the ideas found in thttpd project. - * - * poll(2) based backend - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "common/setup_before.h" -#ifdef STDC_HEADERS -# include -#else -# ifdef HAVE_MALLOC_H -# include -# endif -#endif -#ifdef HAVE_STRING_H -# include -#else -# ifdef HAVE_STRINGS_H -# include -# endif -#endif -#ifdef HAVE_POLL_H -# include -#else -# ifdef HAVE_SYS_POLL_H -# include -# endif -#endif -#include "fdwatch.h" -#include "common/eventlog.h" -#include "common/xalloc.h" -#include "common/setup_after.h" - -#ifdef HAVE_POLL -static int sr; -static struct pollfd *fds = NULL; /* working set */ -static int *_rridx = NULL; -static int *_ridx = NULL; -static unsigned nofds; - -static int fdw_poll_init(int nfds); -static int fdw_poll_close(void); -static int fdw_poll_add_fd(int idx, t_fdwatch_type rw); -static int fdw_poll_del_fd(int idx); -static int fdw_poll_watch(long timeout_msecs); -static void fdw_poll_handle(void); - -t_fdw_backend fdw_poll = { - fdw_poll_init, - fdw_poll_close, - fdw_poll_add_fd, - fdw_poll_del_fd, - fdw_poll_watch, - fdw_poll_handle -}; - -static int fdw_poll_init(int nfds) -{ - int i; - - _ridx = xmalloc(sizeof(int) * nfds); - fds = xmalloc(sizeof(struct pollfd) * nfds); - _rridx = xmalloc(sizeof(int) * nfds); - - memset(fds, 0, sizeof(struct pollfd) * nfds); - memset(_rridx, 0, sizeof(int) * nfds); -/* I would use a memset with 255 but that is dirty and doesnt gain us anything */ - for(i = 0; i < nfds; i++) _ridx[i] = -1; - nofds = sr = 0; - - eventlog(eventlog_level_info, __FUNCTION__, "fdwatch poll() based layer initialized (max %d sockets)", nfds); - return 0; -} - -static int fdw_poll_close(void) -{ - if (fds) { xfree((void *)fds); fds = NULL; } - if (_ridx) { xfree((void *)_ridx); _ridx = NULL; } - if (_rridx) { xfree((void *)_rridx); _rridx = NULL; } - nofds = sr = 0; - - return 0; -} - -static int fdw_poll_add_fd(int idx, t_fdwatch_type rw) -{ - static int ridx; - -// eventlog(eventlog_level_trace, __FUNCTION__, "called fd: %d rw: %d", fd, rw); - if (_ridx[idx] < 0) { - ridx = nofds++; - fds[ridx].fd = fdw_fd(fdw_fds + idx); - _ridx[idx] = ridx; - _rridx[ridx] = idx; -// eventlog(eventlog_level_trace, __FUNCTION__, "adding new fd on %d", ridx); - } else { - if (fds[_ridx[idx]].fd != fdw_fd(fdw_fds + idx)) { - eventlog(eventlog_level_error,__FUNCTION__,"BUG: found existent poll_fd entry for same idx with different fd"); - return -1; - } - ridx = _ridx[idx]; -// eventlog(eventlog_level_trace, __FUNCTION__, "updating fd on %d", ridx); - } - - fds[ridx].events = 0; - if (rw & fdwatch_type_read) fds[ridx].events |= POLLIN; - if (rw & fdwatch_type_write) fds[ridx].events |= POLLOUT; - - return 0; -} - -static int fdw_poll_del_fd(int idx) -{ -// eventlog(eventlog_level_trace, __FUNCTION__, "called fd: %d", fd); - if (_ridx[idx] < 0 || !nofds) return -1; - if (sr > 0) - eventlog(eventlog_level_error, __FUNCTION__, "BUG: called while still handling sockets"); - - /* move the last entry to the deleted one and decrement nofds count */ - nofds--; - if (_ridx[idx] < nofds) { -// eventlog(eventlog_level_trace, __FUNCTION__, "not last, moving %d", tfds[nofds].fd); - _ridx[_rridx[nofds]] = _ridx[idx]; - _rridx[_ridx[idx]] = _rridx[nofds]; - memcpy(fds + _ridx[idx], fds + nofds, sizeof(struct pollfd)); - } - _ridx[idx] = -1; - - return 0; -} - -static int fdw_poll_watch(long timeout_msec) -{ - return (sr = poll(fds, nofds, timeout_msec)); -} - -static void fdw_poll_handle(void) -{ - register unsigned i; - int changed; - t_fdwatch_fd *cfd; - - for(i = 0; i < nofds && sr; i++) { - changed = 0; - cfd = fdw_fds + _rridx[i]; - - if (fdw_rw(cfd) & fdwatch_type_read && - fds[i].revents & (POLLIN | POLLERR | POLLHUP | POLLNVAL)) - { - if (fdw_hnd(cfd)(fdw_data(cfd), fdwatch_type_read) == -2) { - sr--; - continue; - } - changed = 1; - } - - if (fdw_rw(cfd) & fdwatch_type_write && - fds[i].revents & (POLLOUT | POLLERR | POLLHUP | POLLNVAL)) - { - fdw_hnd(cfd)(fdw_data(cfd), fdwatch_type_write); - changed = 1; - } - - if (changed) sr--; - } -} - -#endif /* HAVE_POLL */ diff --git a/d2pack109/src/common/fdwatch_poll.h b/d2pack109/src/common/fdwatch_poll.h deleted file mode 100644 index 7d688d3..0000000 --- a/d2pack109/src/common/fdwatch_poll.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Abstraction API/layer for the various ways PvPGN can inspect sockets state - * 2003 (C) dizzy@roedu.net - * - * Code is based on the ideas found in thttpd project. - * - * poll() based backend - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef __INCLUDED_FDWATCH_POLL__ -#define __INCLUDED_FDWATCH_POLL__ - -extern t_fdw_backend fdw_poll; - -#endif /* __INCLUDED_FDWATCH_POLL__ */ diff --git a/d2pack109/src/common/fdwatch_select.c b/d2pack109/src/common/fdwatch_select.c deleted file mode 100644 index 00a0a21..0000000 --- a/d2pack109/src/common/fdwatch_select.c +++ /dev/null @@ -1,176 +0,0 @@ -/* - * Abstraction API/layer for the various ways PvPGN can inspect sockets state - * 2003 (C) dizzy@roedu.net - * - * Code is based on the ideas found in thttpd project. - * - * select() based backend - * - * 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. - */ - -#define FDWATCH_BACKEND -#include "common/setup_before.h" -#ifdef STDC_HEADERS -# include -#else -# ifdef HAVE_MALLOC_H -# include -# endif -#endif -#ifdef HAVE_STRING_H -# include -#else -# ifdef HAVE_STRINGS_H -# include -# endif -#endif -/* According to earlier standards */ -#ifdef HAVE_SYS_TIME_H -# include -#endif -#ifdef HAVE_SYS_TYPES_H -# include -#endif -#ifdef HAVE_UNISTD_H -# include -#endif -/* According to POSIX 1003.1-2001 */ -#ifdef HAVE_SYS_SELECT_H -# include -#endif -#include "compat/psock.h" -#include "fdwatch.h" -#include "common/eventlog.h" -#include "common/xalloc.h" -#include "common/elist.h" -#include "common/setup_after.h" - -#ifdef HAVE_SELECT - -static int sr; -static int smaxfd; -static t_psock_fd_set *rfds = NULL, *wfds = NULL, /* working sets (updated often) */ - *trfds = NULL, *twfds = NULL; /* templates (updated rare) */ - -static int fdw_select_init(int nfds); -static int fdw_select_close(void); -static int fdw_select_add_fd(int idx, t_fdwatch_type rw); -static int fdw_select_del_fd(int idx); -static int fdw_select_watch(long timeout_msecs); -static void fdw_select_handle(void); - -t_fdw_backend fdw_select = { - fdw_select_init, - fdw_select_close, - fdw_select_add_fd, - fdw_select_del_fd, - fdw_select_watch, - fdw_select_handle -}; - -static int fdw_select_init(int nfds) -{ - if (nfds > FD_SETSIZE) return -1; /* this should not happen */ - - rfds = xmalloc(sizeof(t_psock_fd_set)); - wfds = xmalloc(sizeof(t_psock_fd_set)); - trfds = xmalloc(sizeof(t_psock_fd_set)); - twfds = xmalloc(sizeof(t_psock_fd_set)); - - PSOCK_FD_ZERO(trfds); PSOCK_FD_ZERO(twfds); - smaxfd = sr = 0; - - eventlog(eventlog_level_info, __FUNCTION__, "fdwatch select() based layer initialized (max %d sockets)", nfds); - return 0; -} - -static int fdw_select_close(void) -{ - if (rfds) { xfree((void *)rfds); rfds = NULL; } - if (wfds) { xfree((void *)wfds); wfds = NULL; } - if (trfds) { xfree((void *)trfds); trfds = NULL; } - if (twfds) { xfree((void *)twfds); twfds = NULL; } - smaxfd = sr = 0; - - return 0; -} - -static int fdw_select_add_fd(int idx, t_fdwatch_type rw) -{ - int fd; - -// eventlog(eventlog_level_trace, __FUNCTION__, "called fd: %d rw: %d", fd, rw); - fd = fdw_fd(fdw_fds + idx); - - /* select() interface is limited by FD_SETSIZE max socket value */ - if (fd >= FD_SETSIZE) return -1; - - if (rw & fdwatch_type_read) PSOCK_FD_SET(fd, trfds); - else PSOCK_FD_CLR(fd, trfds); - if (rw & fdwatch_type_write) PSOCK_FD_SET(fd, twfds); - else PSOCK_FD_CLR(fd, twfds); - if (smaxfd < fd) smaxfd = fd; - - return 0; -} - -static int fdw_select_del_fd(int idx) -{ - int fd; - - fd = fdw_fd(fdw_fds + idx); -// eventlog(eventlog_level_trace, __FUNCTION__, "called fd: %d", fd); - if (sr > 0) - eventlog(eventlog_level_error, __FUNCTION__, "BUG: called while still handling sockets"); - PSOCK_FD_CLR(fd, trfds); - PSOCK_FD_CLR(fd, twfds); - - return 0; -} - -static int fdw_select_watch(long timeout_msec) -{ - static struct timeval tv; - - tv.tv_sec = timeout_msec / 1000; - tv.tv_usec = timeout_msec % 1000; - - /* set the working sets based on the templates */ - memcpy(rfds, trfds, sizeof(t_psock_fd_set)); - memcpy(wfds, twfds, sizeof(t_psock_fd_set)); - - return (sr = psock_select(smaxfd + 1, rfds, wfds, NULL, &tv)); -} - -static int fdw_select_cb(t_fdwatch_fd *cfd, void *data) -{ -// eventlog(eventlog_level_trace, __FUNCTION__, "idx: %d fd: %d", idx, fdw_fd->fd); - if (fdw_rw(cfd) & fdwatch_type_read && PSOCK_FD_ISSET(fdw_fd(cfd), rfds) - && fdw_hnd(cfd)(fdw_data(cfd), fdwatch_type_read) == -2) return 0; - if (fdw_rw(cfd) & fdwatch_type_write && PSOCK_FD_ISSET(fdw_fd(cfd), wfds)) - fdw_hnd(cfd)(fdw_data(cfd), fdwatch_type_write); - - return 0; -} - -static void fdw_select_handle(void) -{ -// eventlog(eventlog_level_trace, __FUNCTION__, "called nofds: %d", fdw_nofds); - fdwatch_traverse(fdw_select_cb,NULL); - sr = 0; -} - -#endif /* HAVE_SELECT */ diff --git a/d2pack109/src/common/fdwatch_select.h b/d2pack109/src/common/fdwatch_select.h deleted file mode 100644 index 34394e4..0000000 --- a/d2pack109/src/common/fdwatch_select.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Abstraction API/layer for the various ways PvPGN can inspect sockets state - * 2003 (C) dizzy@roedu.net - * - * Code is based on the ideas found in thttpd project. - * - * select() based backend - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef __INCLUDED_FDWATCH_SELECT__ -#define __INCLUDED_FDWATCH_SELECT__ - -extern t_fdw_backend fdw_select; - -#endif /* __INCLUDED_FDWATCH_SELECT__ */ diff --git a/d2pack109/src/common/field_sizes.h b/d2pack109/src/common/field_sizes.h deleted file mode 100644 index 19079ea..0000000 --- a/d2pack109/src/common/field_sizes.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (C) 1998,1999,2000 Ross Combs (rocombs@cs.nmsu.edu) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_FIELD_SIZES_TYPES -#define INCLUDED_FIELD_SIZES_TYPES - -#define MAX_PACKET_SIZE 3072 -#define MAX_NORMAL_TYPE 0xffff -#define MAX_FILE_TYPE 0xffff -#define MAX_AUTH_TYPE 0xff -#define MAX_GAMES_LIST 20 -#define MAX_MESSAGE_LEN 255 -#define MAX_COMMAND_LEN 32 -#define USER_NAME_MAX 16 /* including terminating NUL char */ -#define USER_NAME_MIN 2 -#define UNCHECKED_NAME_STR 32 /* including terminating NUL char */ - /* (longer than USER_NAME_MAX and CHAR_NAME_LEN so that - * proper error packets can be returned) */ -#define MAX_CLANNAME_LEN 64 -#define CHANNEL_NAME_LEN 64 -#define CHAR_NAME_LEN 16 /* including terminating NUL char */ -#define REALM_NAME_LEN 32 -#define GAME_NAME_LEN 32 -#define GAME_PASS_LEN 32 -#define GAME_INFO_LEN 256 -#define MAP_NAME_LEN 64 -#define BNETHASH_LEN 20 /* uint32*5, see bnethash.h */ -#define MAX_EXEINFO_STR 256 /* including terminating NUL char */ -#define MAX_OWNER_STR 128 /* including terminating NUL char */ -#define MAX_CDKEY_STR 128 /* including terminating NUL char */ -#define MAX_EMAIL_STR 128 /* including terminating NUL char */ -#define MAX_WINHOST_STR 128 /* including terminating NUL char */ -#define MAX_WINUSER_STR 128 /* including terminating NUL char */ -#define MAX_LANG_STR 64 /* including terminating NUL char */ -#define MAX_COUNTRYNAME_STR 128 /* including terminating NUL char */ -#define MAX_FILENAME_STR 2048 /* including terminating NUL char */ -#define MAX_GAMEREP_HEAD_STR 2048 /* including terminating NUL char */ -#define MAX_GAMEREP_BODY_STR 8192 /* including terminating NUL char */ -#define MAX_PLAYERINFO_STR 2048 /* including terminating NUL char */ -#define MAX_COUNTRYCODE_STR 32 /* including terminating NUL char */ -#define MAX_COUNTRY_STR 32 /* including terminating NUL char */ -#define MAX_ATTRKEY_STR 1024 /* including terminating NUL char */ -#define MAX_ATTRVAL_STR 4096 /* including terminating NUL char */ -#define MAX_IRC_MESSAGE_LEN 512 /* including CRLF (according to RFC 2812) */ -#define MAX_TOPIC_LEN 201 /* including terminating NUL char */ -#define CLANSHORT_NAME_MAX 4 -#define CLAN_NAME_MAX 25 /* including terminating NUL char */ - -#endif diff --git a/d2pack109/src/common/flags.h b/d2pack109/src/common/flags.h deleted file mode 100644 index 7cea849..0000000 --- a/d2pack109/src/common/flags.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) 2004 Dizzy (dizzy@roedu.net) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef INCLUDED_FLAGS_H -#define INCLUDED_FLAGS_H - -#define FLAG_ZERO(var) *(var) = 0 -#define FLAG_SET(var,flag) *(var) |= flag -#define FLAG_CLEAR(var,flag) *(var) &= ~flag -#define FLAG_ISSET(var,flag) (var & flag) - -#endif /* INCLUDED_FLAGS_H */ diff --git a/d2pack109/src/common/hashtable.c b/d2pack109/src/common/hashtable.c deleted file mode 100644 index 772011b..0000000 --- a/d2pack109/src/common/hashtable.c +++ /dev/null @@ -1,593 +0,0 @@ -/* - * Copyright (C) 2000,2001 Ross Combs (rocombs@cs.nmsu.edu) - * - * 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. - */ -#define HASHTABLE_INTERNAL_ACCESS -#include "common/setup_before.h" -#ifdef HAVE_STDDEF_H -# include -#else -# ifndef NULL -# define NULL ((void *)0) -# endif -#endif -#ifdef STDC_HEADERS -# include -#else -# ifdef HAVE_MALLOC_H -# include -# endif -#endif -#include "common/eventlog.h" -#include "common/hashtable.h" -#include "common/xalloc.h" -#include "common/setup_after.h" - - -static int nodata; /* if data points to this, then the entry was actually deleted */ - - -static t_entry * hashtable_entry_export(t_internentry * entry, t_hashtable const * hashtable, unsigned int row); - - -static t_entry * hashtable_entry_export(t_internentry * entry, t_hashtable const * hashtable, unsigned int row) -{ - t_entry * temp; - - if (!entry) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL entry"); - return NULL; - } - if (!hashtable) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL hashtable"); - return NULL; - } - if (row>=hashtable->num_rows) - { - eventlog(eventlog_level_error,__FUNCTION__,"got bad row %u (max %u)",row,hashtable->num_rows-1); - return NULL; - } - - temp = xmalloc(sizeof(t_entry)); - temp->row = row; - temp->real = entry; - temp->hashtable = hashtable; - - return temp; -} - - -extern t_hashtable * hashtable_create(unsigned int num_rows) -{ - t_hashtable * new; - unsigned int i; - - if (num_rows<1) - { - eventlog(eventlog_level_error,__FUNCTION__,"num_rows must be at least 1"); - return NULL; - } - - new = xmalloc(sizeof(t_hashtable)); - new->rows = xmalloc(sizeof(t_internentry *)*num_rows); - new->num_rows = num_rows; - new->len = 0; - for (i=0; irows[i] = NULL; - - return new; -} - - -extern int hashtable_destroy(t_hashtable * hashtable) -{ - unsigned int i; - - if (!hashtable) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL hashtable"); - return -1; - } - - hashtable_purge(hashtable); - for (i=0; inum_rows; i++) - if (hashtable->rows[i]) - eventlog(eventlog_level_error,__FUNCTION__,"got non-empty hashtable"); - - xfree(hashtable->rows); - xfree(hashtable); - - return 0; -} - - -extern int hashtable_purge(t_hashtable * hashtable) -{ - unsigned int row; - t_internentry * curr; - t_internentry * head; - t_internentry * next; - t_internentry * * change; - - if (!hashtable) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL hashtable"); - return -1; - } - -#ifdef HASHTABLE_DEBUG - hashtable_check(hashtable); -#endif - - for (row=0; rownum_rows; row++) - { - head = NULL; - change = NULL; - for (curr=hashtable->rows[row]; curr; curr=next) - { - next = curr->next; - if (curr->data==&nodata) - { - if (change) - *change = next; - xfree(curr); - } - else - { - if (!head) - head = curr; - change = &curr->next; - } - } - hashtable->rows[row] = head; - } - - return 0; -} - - -extern int hashtable_check(t_hashtable const * hashtable) -{ - unsigned int emptycnt; - unsigned int validcnt; - unsigned int row; - unsigned int temp; - t_internentry const * tail; - t_internentry const * curr; - - if (!hashtable) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL hashtable"); - return -1; - } - if (hashtable->num_rows<1) - { - eventlog(eventlog_level_error,__FUNCTION__,"num_rows=%u",hashtable->num_rows); - return -1; - } - if (!hashtable->rows) - { - eventlog(eventlog_level_error,__FUNCTION__,"hashtable->rows is NULL"); - return -1; - } - - emptycnt=validcnt = 0; - for (row=0; rownum_rows; row++) - { - tail = NULL; - for (curr=hashtable->rows[row]; curr; curr=curr->next) - { - if (tail) - { - if (curr==tail) /* tail is currently the previous node */ - { - eventlog(eventlog_level_error,__FUNCTION__,"row %u is circular (curr==prev==%p)",row,curr); - return -1; - } - if (curr->next==tail) - { - eventlog(eventlog_level_error,__FUNCTION__,"row %u is circular (curr->next==prev==%p)",row,curr); - return -1; - } - for (temp=0; tempnum_rows; temp++) - if (curr==hashtable->rows[temp]) - { - eventlog(eventlog_level_error,__FUNCTION__,"row %u is circular (curr==rows[%u]==%p)",row,temp,curr); - return -1; - } - } - if (curr->data==&nodata) - emptycnt++; - else - validcnt++; - tail = curr; - } - } - - if (emptycnt>10 && emptycnt>validcnt+5) /* arbitrary heuristic to detect missing list_purge() cal -ls */ - eventlog(eventlog_level_warn,__FUNCTION__,"emptycnt=%u but validcnt=%u",emptycnt,validcnt); - if (hashtable->len!=validcnt) - { - eventlog(eventlog_level_error,__FUNCTION__,"hashtable->len=%u but validcnt=%u",hashtable->len,validcnt); - return -1; - } - - return 0; -} - - -extern unsigned int hashtable_get_length(t_hashtable const * hashtable) -{ - if (!hashtable) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL hashtable"); - return 0; - } - - return hashtable->len; -} - - -extern int hashtable_insert_data(t_hashtable * hashtable, void * data, unsigned int hash) -{ - unsigned int row; - t_internentry * entry; - - if (!hashtable) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL hashtable"); - return -1; - } - - entry = xmalloc(sizeof(t_internentry)); - entry->data = data; - - row = hash%hashtable->num_rows; - entry->next = hashtable->rows[row]; - hashtable->rows[row] = entry; - hashtable->len++; - - return 0; -} - - -extern t_entry * hashtable_get_entry_by_data(t_hashtable const * hashtable, void const * data, unsigned int hash) -{ - unsigned int row; - t_internentry * curr; - - if (!hashtable) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL hashtable"); - return NULL; - } - - row = hash%hashtable->num_rows; - for (curr=hashtable->rows[row]; curr; curr=curr->next) - if (curr->data==data) - return hashtable_entry_export(curr,hashtable,row); - - return NULL; -} - - -extern t_entry const * hashtable_get_entry_by_data_const(t_hashtable const * hashtable, void const * data, unsigned int hash) -{ - unsigned int row; - t_internentry * curr; - - if (!hashtable) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL hashtable"); - return NULL; - } - - row = hash%hashtable->num_rows; - for (curr=hashtable->rows[row]; curr; curr=curr->next) - if (curr->data==data) - return hashtable_entry_export(curr,hashtable,row); - - return NULL; -} - - -extern int hashtable_remove_entry(t_hashtable * hashtable, t_entry * entry) -{ - if (!hashtable) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL hashtable"); - return -1; - } - if (!entry) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL entry"); - return -1; - } - if (!entry->real) - { - eventlog(eventlog_level_error,__FUNCTION__,"entry has NULL real pointer"); - return -1; - } - if (entry->real->data==&nodata) - { - eventlog(eventlog_level_error,__FUNCTION__,"got deleted entry"); - return -1; - } - - entry->real->data = &nodata; - hashtable->len--; - - return 0; -} - - -extern int hashtable_remove_data(t_hashtable * hashtable, void const * data, unsigned int hash) -{ - t_entry * entry; - int retval; - - if (!hashtable) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL hashtable"); - return -1; - } - - if (!(entry = hashtable_get_entry_by_data(hashtable,data,hash))) - return -1; - - retval = hashtable_remove_entry(hashtable,entry); - - hashtable_entry_release(entry); - - return retval; -} - - -extern void * entry_get_data(t_entry const * entry) -{ - if (!entry) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL entry"); - return NULL; - } - if (!entry->real) - { - eventlog(eventlog_level_error,__FUNCTION__,"entry has NULL real pointer"); - return NULL; - } - if (entry->real->data==&nodata) - { - eventlog(eventlog_level_error,__FUNCTION__,"got deleted entry"); - return NULL; - } - - return entry->real->data; -} - - -extern void * hashtable_get_data_by_pos(t_hashtable const * hashtable, unsigned int pos) -{ - t_internentry const * curr; - unsigned int row; - unsigned int len; - - if (!hashtable) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL hashtable"); - return NULL; - } - - len = 0; - row = 0; - curr = NULL; - for (;;) - { - if (!curr) - { - if (row>=hashtable->num_rows) - break; - curr = hashtable->rows[row++]; - continue; - } - if (curr->data!=&nodata && len++==pos) - return curr->data; - curr = curr->next; - } - - eventlog(eventlog_level_error,__FUNCTION__,"requested position %u but len=%u",pos,len); - return NULL; -} - - -#ifdef HASHTABLE_DEBUG -extern t_entry * hashtable_get_first_real(t_hashtable const * hashtable, char const * fn, unsigned int ln) -#else -extern t_entry * hashtable_get_first(t_hashtable const * hashtable) -#endif -{ - unsigned int row; - t_internentry * curr; - - if (!hashtable) - { -#ifdef HASHTABLE_DEBUG - eventlog(eventlog_level_error,__FUNCTION__,"got NULL hashtable from %s:%u",fn,ln); -#else - eventlog(eventlog_level_error,__FUNCTION__,"got NULL hashtable"); -#endif - return NULL; - } - - for (row=0; rownum_rows; row++) - for (curr=hashtable->rows[row]; curr; curr=curr->next) - if (curr->data!=&nodata) - return hashtable_entry_export(curr,hashtable,row); - - return NULL; -} - - -extern t_entry * entry_get_next(t_entry * entry) -{ - t_hashtable const * hashtable; - unsigned int row; - t_internentry * curr; - - if (!entry) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL entry"); - return NULL; - } - - hashtable = entry->hashtable; - - for (curr=entry->real->next; curr; curr=curr->next) - if (curr->data!=&nodata) - { - entry->real = curr; - return entry; - } - - for (row=entry->row+1; rownum_rows; row++) - for (curr=hashtable->rows[row]; curr; curr=curr->next) - if (curr->data!=&nodata) - { - entry->real = curr; - entry->row = row; - return entry; - } - - hashtable_entry_release(entry); - return NULL; -} - - -#ifdef HASHTABLE_DEBUG -extern t_entry * hashtable_get_first_matching_real(t_hashtable const * hashtable, unsigned int hash, char const * fn, unsigned int ln) -#else -extern t_entry * hashtable_get_first_matching(t_hashtable const * hashtable, unsigned int hash) -#endif -{ - unsigned int row; - t_internentry * curr; - - if (!hashtable) - { -#ifdef HASHTABLE_DEBUG - eventlog(eventlog_level_error,__FUNCTION__,"got NULL hashtable from %s:%u",fn,ln); -#else - eventlog(eventlog_level_error,__FUNCTION__,"got NULL hashtable"); -#endif - return NULL; - } - - row = hash%hashtable->num_rows; - for (curr=hashtable->rows[row]; curr; curr=curr->next) - if (curr->data!=&nodata) - return hashtable_entry_export(curr,hashtable,row); - - return NULL; -} - - -extern t_entry * entry_get_next_matching(t_entry * entry) -{ - t_internentry * curr; - - if (!entry) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL entry"); - return NULL; - } - - for (curr=entry->real->next; curr; curr=curr->next) - if (curr->data!=&nodata) - { - entry->real = curr; - return entry; - } - - hashtable_entry_release(entry); - return NULL; -} - - -extern int hashtable_entry_release(t_entry * entry) -{ - if (!entry) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL entry"); - return -1; - } - if (!entry->hashtable) - { - eventlog(eventlog_level_error,__FUNCTION__,"got entry with NULL hashtable"); - return -1; - } - if (!entry->real) - { - eventlog(eventlog_level_error,__FUNCTION__,"got entry with NULL real pointer"); - return -1; - } - if (entry->row>=entry->hashtable->num_rows) - { - eventlog(eventlog_level_error,__FUNCTION__,"entry has bad row %u (max %u)",entry->row,entry->hashtable->num_rows-1); - return -1; - } - -#ifdef HASHTABLE_DEBUG - hashtable_check(entry->hashtable); -#endif - xfree(entry); - return 0; -} - - -extern int hashtable_stats(t_hashtable * hashtable) -{ - unsigned int row; - t_internentry * curr; - unsigned int rcount, max, min; - - if (!hashtable) - { - eventlog(eventlog_level_error, __FUNCTION__,"got NULL hashtable"); - return -1; - } - -#ifdef HASHTABLE_DEBUG - hashtable_check(hashtable); -#endif - - max = 0; - min = hashtable->len; - for (row=0; rownum_rows; row++) - { - rcount = 0; - for (curr=hashtable->rows[row]; curr; curr=curr->next) - if (curr->data!=&nodata) rcount++; - if (rcount > max) max = rcount; - if (rcount < min) min = rcount; - } - - eventlog(eventlog_level_info, __FUNCTION__, "hashsize: %u min: %u max: %u avg: %.2f diff: %.2f%c", hashtable->num_rows, min, max, (float)(min + max)/2, (float)(max - min)/max*100, '%'); - return 0; -} - - diff --git a/d2pack109/src/common/hashtable.h b/d2pack109/src/common/hashtable.h deleted file mode 100644 index 0626714..0000000 --- a/d2pack109/src/common/hashtable.h +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (C) 2000 Ross Combs (rocombs@cs.nmsu.edu) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_HASHTABLE_TYPES -#define INCLUDED_HASHTABLE_TYPES - -#ifdef HASHTABLE_INTERNAL_ACCESS -struct hashtable; /* forward reference for t_entry */ -#endif - -#ifdef HASHTABLE_INTERNAL_ACCESS -typedef struct internentry -{ - void * data; - struct internentry * next; -} -t_internentry; -#endif - -typedef struct entry -#ifdef HASHTABLE_INTERNAL_ACCESS -{ - unsigned int row; - t_internentry * real; - struct hashtable const * hashtable; -} -#endif -t_entry; - -typedef struct hashtable -#ifdef HASHTABLE_INTERNAL_ACCESS -{ - unsigned int num_rows; - unsigned int len; - unsigned int zombies; - t_internentry * * rows; -} -#endif -t_hashtable; - -#endif - - -/*****/ -#ifndef JUST_NEED_TYPES -#ifndef INCLUDED_HASHTABLE_PROTOS -#define INCLUDED_HASHTABLE_PROTOS - -extern t_hashtable * hashtable_create(unsigned int num_rows) ; -extern int hashtable_destroy(t_hashtable * hashtable); -extern int hashtable_purge(t_hashtable * hashtable); -extern int hashtable_check(t_hashtable const * hashtable); -extern unsigned int hashtable_get_length(t_hashtable const * hashtable); -extern int hashtable_insert_data(t_hashtable * hashtable, void * data, unsigned int hash); -extern t_entry * hashtable_get_entry_by_data(t_hashtable const * hashtable, void const * data, unsigned int hash); -extern t_entry const * hashtable_get_entry_by_data_const(t_hashtable const * hashtable, void const * data, unsigned int hash); -extern int hashtable_remove_data(t_hashtable * hashtable, void const * data, unsigned int hash); /* delete matching item */ -extern int hashtable_remove_entry(t_hashtable * hashtable, t_entry * entry); -extern void * hashtable_get_data_by_pos(t_hashtable const * hashtable, unsigned int pos); -extern void * entry_get_data(t_entry const * entry); -#ifdef HASHTABLE_DEBUG -extern t_entry * hashtable_match_get_first_real(t_hashtable const * hashtable, unsigned int hash, char const * fn, unsigned int ln); -# define hashtable_match_get_first(L,H) hashtable_match_get_first_real(L,H,__FILE__,__LINE__) -#else -extern t_entry * hashtable_match_get_first(t_hashtable const * hashtable, unsigned int hash); -#endif -extern t_entry * entry_match_get_next(t_entry const * entry, unsigned int hash); -#ifdef HASHTABLE_DEBUG -extern t_entry * hashtable_get_first_real(t_hashtable const * hashtable, char const * fn, unsigned int ln); -# define hashtable_get_first(L) hashtable_get_first_real(L,__FILE__,__LINE__) -#else -extern t_entry * hashtable_get_first(t_hashtable const * hashtable); -#endif -extern t_entry * entry_get_next(t_entry * entry); -#ifdef HASHTABLE_DEBUG -extern t_entry * hashtable_get_first_matching_real(t_hashtable const * hashtable, unsigned int hash, char const * fn, unsigned int ln); -# define hashtable_get_first_matching(L,H) hashtable_get_first_matching_real(L,H,__FILE__,__LINE__) -#else -extern t_entry * hashtable_get_first_matching(t_hashtable const * hashtable, unsigned int hash); -#endif -extern t_entry * entry_get_next_matching(t_entry * entry); -extern int hashtable_entry_release(t_entry * entry); -extern int hashtable_stats(t_hashtable * hashtable); - -#define HASHTABLE_TRAVERSE(hashtable,curr) for (curr=hashtable_get_first(hashtable); curr; curr=entry_get_next(curr)) -#define HASHTABLE_TRAVERSE_MATCHING(hashtable,curr,hash) for (curr=hashtable_get_first_matching(hashtable,hash); curr; curr=entry_get_next_matching(curr)) - -#endif -#endif diff --git a/d2pack109/src/common/hexdump.c b/d2pack109/src/common/hexdump.c deleted file mode 100644 index 4b0cb0c..0000000 --- a/d2pack109/src/common/hexdump.c +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (C) 1998 Mark Baysinger (mbaysing@ucsd.edu) - * Copyright (C) 1998,1999 Ross Combs (rocombs@cs.nmsu.edu) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#include "common/setup_before.h" -#include -#ifdef HAVE_STDDEF_H -# include -#else -# ifndef NULL -# define NULL ((void *)0) -# endif -#endif -#include "common/hexdump.h" -#include "common/setup_after.h" - - -extern void hexdump(FILE * stream, void const * data, unsigned int len) -{ - unsigned int i; - unsigned int r,c; - - if (!stream) - return; - if (!data) - return; - - for (r=0,i=0; r<(len/16+(len%16!=0)); r++,i+=16) - { - fprintf(stream,"%04X: ",i); /* location of first byte in line */ - - for (c=i; c=32 && - ((unsigned char const *)data)[c]<127) - fprintf(stream,"%c",((char const *)data)[c]); - else - fprintf(stream,"."); /* put this for non-printables */ - else - fprintf(stream," "); /* pad if short line */ - - fprintf(stream,"\n"); - } - - fflush(stream); -} diff --git a/d2pack109/src/common/hexdump.h b/d2pack109/src/common/hexdump.h deleted file mode 100644 index cda4619..0000000 --- a/d2pack109/src/common/hexdump.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 1998 Mark Baysinger (mbaysing@ucsd.edu) - * Copyright (C) 1998,1999 Ross Combs (rocombs@cs.nmsu.edu) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - - -#ifndef JUST_NEED_TYPES -#ifndef INCLUDED_HEXDUMP_PROTOS -#define INCLUDED_HEXDUMP_PROTOS - -#define JUST_NEED_TYPES -#include -#undef JUST_NEED_TYPES - -extern void hexdump(FILE * stream, void const * data, unsigned int len); - -#endif -#endif diff --git a/d2pack109/src/common/init_protocol.h b/d2pack109/src/common/init_protocol.h deleted file mode 100644 index 28faaa5..0000000 --- a/d2pack109/src/common/init_protocol.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (C) 1998,1999 Ross Combs (rocombs@cs.nmsu.edu) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_INIT_PROTOCOL_TYPES -#define INCLUDED_INIT_PROTOCOL_TYPES - -#ifdef JUST_NEED_TYPES -# include "common/bn_type.h" -#else -# define JUST_NEED_TYPES -# include "common/bn_type.h" -# undef JUST_NEED_TYPES -#endif - -/* There is no header for this packet class and there is only - * one packet type. - */ - -/* - * There is a single byte sent upon initial connections that - * reports the connection type. - */ - -/******************************************************/ -#define CLIENT_INITCONN 0x1 -typedef struct -{ - bn_byte class; -} PACKED_ATTR() t_client_initconn; -/******************************************************/ - -#endif - - -/*****/ -#ifndef JUST_NEED_TYPES -#ifndef INCLUDED_INIT_PROTOCOL_PROTOS -#define INCLUDED_INIT_PROTOCOL_PROTOS - -#define CLIENT_INITCONN_CLASS_DEFER 0x01 /* great... means either "bnet protocol" or "auth protocol" */ -#define CLIENT_INITCONN_CLASS_FILE 0x02 -#define CLIENT_INITCONN_CLASS_BOT 0x03 -#define CLIENT_INITCONN_CLASS_ENC 0x04 /* encrypted connection */ -#define CLIENT_INITCONN_CLASS_TELNET 0x0d /* Hack alert: look for user to hit \r when they connect */ -#define CLIENT_INITCONN_CLASS_D2CS 0x01 -#define CLIENT_INITCONN_CLASS_D2GS 0x64 -#define CLIENT_INITCONN_CLASS_D2CS_BNETD 0x65 - -#endif -#endif diff --git a/d2pack109/src/common/list.c b/d2pack109/src/common/list.c deleted file mode 100644 index c5170ff..0000000 --- a/d2pack109/src/common/list.c +++ /dev/null @@ -1,345 +0,0 @@ -/* - * Copyright (C) 1998,1999,2000 Ross Combs (rocombs@cs.nmsu.edu) - * - * 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. - */ -#define LIST_INTERNAL_ACCESS -#include "common/setup_before.h" -#ifdef HAVE_STDDEF_H -# include -#else -# ifndef NULL -# define NULL ((void *)0) -# endif -#endif -#ifdef STDC_HEADERS -# include -#else -# ifdef HAVE_MALLOC_H -# include -# endif -#endif -#ifdef HAVE_ASSERT_H -# include -#endif -#include "common/eventlog.h" -#include "common/xalloc.h" -#include "common/list.h" -#include "common/setup_after.h" - - -static t_elem listhead; - - -extern t_list * list_create(void) -{ - t_list * new; - - new = xmalloc(sizeof(t_list)); - new->head = NULL; - new->tail = NULL; - new->len = 0; - - return new; -} - - -extern int list_destroy(t_list * list) -{ - if (!list) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL list"); - return -1; - } - - if (list->head) - eventlog(eventlog_level_error,__FUNCTION__,"got non-empty list"); - - xfree(list); - - return 0; -} - -extern unsigned int list_get_length(t_list const * list) -{ - if (!list) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL list"); - return 0; - } - - return list->len; -} - - -extern int list_prepend_data(t_list * list, void * data) -{ - t_elem * elem; - - assert(list != NULL); - - elem = xmalloc(sizeof(t_elem)); - elem->data = data; - - if (list->head) - list->head->prev = elem; - elem->next = list->head; - elem->prev = NULL; - list->head = elem; - if (!list->tail) - list->tail = elem; - list->len++; - - return 0; -} - - -extern int list_append_data(t_list * list, void * data) -{ - t_elem * elem; - - assert(list != NULL); - - elem = xmalloc(sizeof(t_elem)); - elem->data = data; - - elem->next = NULL; - if (!list->head) - { - list->head = elem; - elem->prev = NULL; - } - if (list->tail) - { - elem->prev = list->tail; - list->tail->next = elem; - } - list->tail = elem; - list->len++; - - return 0; -} - - -extern t_elem * list_get_elem_by_data(t_list const * list, void const * data) -{ - t_elem * curr; - - if (!list) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL list"); - return NULL; - } - - LIST_TRAVERSE(list,curr) - if (curr->data==data) - return curr; - - return NULL; -} - - -extern t_elem const * list_get_elem_by_data_const(t_list const * list, void const * data) -{ - t_elem const * curr; - - if (!list) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL list"); - return NULL; - } - - LIST_TRAVERSE_CONST(list,curr) - if (curr->data==data) - return curr; - - return NULL; -} - - -extern int list_remove_elem(t_list * list, t_elem ** elem) -{ - t_elem * target; - - if (!list) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL list"); - return -1; - } - - if (!elem) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL *elem"); - return -1; - } - - target = *elem; - - if (target->prev) - { - target->prev->next = target->next; - } - if (target->next) - { - target->next->prev = target->prev; - } - - if (target == list->tail) - { - list->tail = target->prev; - } - if (target == list->head) - { - list->head = target->next; - *elem = &listhead; - } - else - *elem = target->prev; - - target->next = NULL; - target->prev = NULL; - xfree(target); - - list->len--; - - return 0; -} - - -extern int list_remove_data(t_list * list, void const * data, t_elem ** elem) -{ - if (!list) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL list"); - return -1; - } - - if (!(*elem = list_get_elem_by_data(list,data))) - return -1; - - return list_remove_elem(list,elem); -} - - -extern int elem_set_data(t_elem * elem, void * data) -{ - if (!elem) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL elem"); - return -1; - } - - elem->data = data; - - return 0; -} - - -extern void * elem_get_data(t_elem const * elem) -{ - if (!elem) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL elem"); - return NULL; - } - - return elem->data; -} - - -extern void * list_get_data_by_pos(t_list const * list, unsigned int pos) -{ - t_elem const * curr; - unsigned int len; - - len = 0; - LIST_TRAVERSE_CONST(list,curr) - if (len++==pos) - return curr->data; - - eventlog(eventlog_level_error,__FUNCTION__,"requested position %u but len=%u",pos,len); - return NULL; -} - - -#ifdef LIST_DEBUG -extern t_elem * list_get_first_real(t_list const * list, char const * fn, unsigned int ln) -#else -extern t_elem * list_get_first(t_list const * list) -#endif -{ - if (!list) - { -#ifdef LIST_DEBUG - eventlog(eventlog_level_error,__FUNCTION__,"got NULL list from %s:%u",fn,ln); -#else - eventlog(eventlog_level_error,__FUNCTION__,"got NULL list"); -#endif - return NULL; - } - - - return list->head; -} - - -#ifdef LIST_DEBUG -extern t_elem const * list_get_first_const_real(t_list const * list, char const * fn, unsigned int ln) -#else -extern t_elem const * list_get_first_const(t_list const * list) -#endif -{ - if (!list) - { -#ifdef LIST_DEBUG - eventlog(eventlog_level_error,__FUNCTION__,"got NULL list from %s:%u",fn,ln); -#else - eventlog(eventlog_level_error,__FUNCTION__,"got NULL list"); -#endif - return NULL; - } - - return list->head; -} - - -extern t_elem * elem_get_next_real(t_list const * list, t_elem const * elem, char const * fn, unsigned int ln) -{ - if (!elem) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL elem from %s:%u",fn,ln); - return NULL; - } - - if (elem == &listhead) - return list->head; - else - return elem->next; -} - - -extern t_elem const * elem_get_next_const(t_list const * list, t_elem const * elem) -{ - if (!elem) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL elem"); - return NULL; - } - - if (elem == &listhead) - return list->head; - else - return elem->next; -} diff --git a/d2pack109/src/common/list.h b/d2pack109/src/common/list.h deleted file mode 100644 index 48958fe..0000000 --- a/d2pack109/src/common/list.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (C) 1999,2000 Ross Combs (rocombs@cs.nmsu.edu) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_LIST_TYPES -#define INCLUDED_LIST_TYPES - -typedef struct elem -#ifdef LIST_INTERNAL_ACCESS -{ - void * data; - struct elem * prev; - struct elem * next; -} -#endif -t_elem; - -typedef struct list -#ifdef LIST_INTERNAL_ACCESS -{ - unsigned int len; - t_elem * head; - t_elem * tail; -} -#endif -t_list; - -#endif - - -/*****/ -#ifndef JUST_NEED_TYPES -#ifndef INCLUDED_LIST_PROTOS -#define INCLUDED_LIST_PROTOS - -extern t_list * list_create(void) ; -extern int list_destroy(t_list * list); -extern unsigned int list_get_length(t_list const * list); -extern int list_prepend_data(t_list * list, void * data); -extern int list_append_data(t_list * list, void * data); -extern t_elem * list_get_elem_by_data(t_list const * list, void const * data); -extern t_elem const * list_get_elem_by_data_const(t_list const * list, void const * data); - -/* note changed API for those commands: - due to direct removal of elements from list, you need to take special care during list traversal. - a pointer to the traversal variable needs to be passed to the list_remove functions, so they - can properly modify it to point to the "previous" element (the one before the element to be deleted) - so the next elem_get_next call will address the "next" element (the one after the element to be deleted) */ - -extern int list_remove_data(t_list * list, void const * data, t_elem ** elem); /* delete matching item */ -extern int list_remove_elem(t_list * list, t_elem ** elem); - -extern void * list_get_data_by_pos(t_list const * list, unsigned int pos); -#ifdef LIST_DEBUG -extern t_elem * list_get_first_real(t_list const * list, char const * fn, unsigned int ln); -# define list_get_first(L) list_get_first_real(L,__FILE__,__LINE__) -#else -extern t_elem * list_get_first(t_list const * list); -#endif -#ifdef LIST_DEBUG -extern t_elem const * list_get_first_const_real(t_list const * list, char const * fn, unsigned int ln); -# define list_get_first_const(L) list_get_first_const_real(L,__FILE__,__LINE__) -#else -extern t_elem const * list_get_first_const(t_list const * list); -#endif - -extern void * elem_get_data(t_elem const * elem); -extern int elem_set_data(t_elem * elem, void * data); -#define elem_get_next(list,elem) elem_get_next_real(list,elem,__FILE__,__LINE__) -extern t_elem * elem_get_next_real(t_list const * list, t_elem const * elem,char const * fn, unsigned int ln); -extern t_elem const * elem_get_next_const(t_list const * list, t_elem const * elem); - -#define LIST_TRAVERSE(list,curr) for (curr=(list)?list_get_first(list):(NULL); curr; curr=elem_get_next(list,curr)) -#define LIST_TRAVERSE_CONST(list,curr) for (curr=(list)?list_get_first_const(list):(NULL); curr; curr=elem_get_next_const(list,curr)) - -#endif -#endif diff --git a/d2pack109/src/common/network.c b/d2pack109/src/common/network.c deleted file mode 100644 index 3f7d527..0000000 --- a/d2pack109/src/common/network.c +++ /dev/null @@ -1,233 +0,0 @@ -/* - * Copyright (C) 1998 Mark Baysinger (mbaysing@ucsd.edu) - * Copyright (C) 1998,1999,2000 Ross Combs (rocombs@cs.nmsu.edu) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#include "common/setup_before.h" -#ifdef HAVE_STRING_H -# include -#else -# ifdef HAVE_STRINGS_H -# include -# endif -#endif -#ifdef HAVE_UNISTD_H -# include -#endif -#include -#include "compat/strerror.h" -#ifdef HAVE_SYS_TYPES_H -# include -#endif -#ifdef HAVE_SYS_SOCKET_H -# include -#endif -#include "compat/socket.h" -#include "compat/recv.h" -#include "compat/send.h" -#ifdef HAVE_NETINET_IN_H -# include -#endif -#include "compat/netinet_in.h" -#include "compat/psock.h" -#include "common/packet.h" -#include "common/eventlog.h" -#include "common/field_sizes.h" -#include "common/network.h" -#include "common/setup_after.h" - - -extern int net_recv_packet(int sock, t_packet * packet, unsigned int * currsize) -{ - int addlen; - unsigned int header_size; - void * temp; - - if (!packet) - { - eventlog(eventlog_level_error,__FUNCTION__,"[%d] got NULL packet (closing connection)",sock); - return -1; - } - if (!currsize) - { - eventlog(eventlog_level_error,__FUNCTION__,"[%d] got NULL currsize (closing connection)",sock); - return -1; - } - - if ((header_size = packet_get_header_size(packet))>=MAX_PACKET_SIZE) - { - eventlog(eventlog_level_error,__FUNCTION__,"[%d] could not determine header size (closing connection)",sock); - return -1; - } - - if (!(temp = packet_get_raw_data_build(packet,*currsize))) - { - eventlog(eventlog_level_error,__FUNCTION__,"[%d] could not obtain raw data pointer at offset %u (closing connection)",sock,*currsize); - return -1; - } - - if (*currsize=total_size) - { - eventlog(eventlog_level_warn,__FUNCTION__,"[%d] more data requested for already complete packet (total_size=%u currsize=%u) (closing connection)",sock,total_size,*currsize); - return -1; - } - - addlen = psock_recv(sock, - temp, - total_size-*currsize, - 0); - } - - if (addlen==0) - { - eventlog(eventlog_level_debug,__FUNCTION__,"[%d] remote host closed connection",sock); - return -1; - } - if (addlen<0) - { - if ( -#ifdef PSOCK_EINTR - psock_errno()==PSOCK_EINTR || -#endif -#ifdef PSOCK_EAGAIN - psock_errno()==PSOCK_EAGAIN || -#endif -#ifdef PSOCK_EWOULDBLOCK - psock_errno()==PSOCK_EWOULDBLOCK || -#endif -#ifdef PSOCK_ENOMEM - psock_errno()==PSOCK_ENOMEM || -#endif - 0) /* try later */ - return 0; - if ( -#ifdef PSOCK_ENOTCONN - psock_errno()==PSOCK_ENOTCONN || -#endif -#ifdef PSOCK_ECONNRESET - psock_errno()==PSOCK_ECONNRESET || -#endif - 0) - { -/* eventlog(eventlog_level_debug,__FUNCTION__,"[%d] remote host closed connection (psock_recv: %s)",sock,strerror(psock_errno())); */ - return -1; /* common error: close connection, but no message */ - } - eventlog(eventlog_level_debug,__FUNCTION__,"[%d] receive error (closing connection) (psock_recv: %s)",sock,strerror(psock_errno())); - return -1; - } - - *currsize += addlen; - - if (*currsize>=header_size && *currsize==packet_get_size(packet)) - return 1; - - return 0; -} - - -extern int net_send_packet(int sock, t_packet const * packet, unsigned int * currsize) -{ - unsigned int size; - int addlen; - - if (!packet) - { - eventlog(eventlog_level_error,__FUNCTION__,"[%d] got NULL packet (closing connection)",sock); - return -1; - } - if (!currsize) - { - eventlog(eventlog_level_error,__FUNCTION__,"[%d] got NULL currsize (closing connection)",sock); - return -1; - } - - if ((size = packet_get_size(packet))<1) - { - eventlog(eventlog_level_error,__FUNCTION__,"[%d] packet to send is empty (skipping it)",sock); - *currsize = 0; - return 1; - } - - addlen = psock_send(sock, - packet_get_raw_data_const(packet,*currsize), - size-*currsize, - 0); - - if (addlen<0) - { - if ( -#ifdef PSOCK_EINTR - psock_errno()==PSOCK_EINTR || -#endif -#ifdef PSOCK_EAGAIN - psock_errno()==PSOCK_EAGAIN || -#endif -#ifdef PSOCK_EWOULDBLOCK - psock_errno()==PSOCK_EWOULDBLOCK || -#endif -#ifdef PSOCK_ENOBUFS - psock_errno()==PSOCK_ENOBUFS || -#endif -#ifdef PSOCK_ENOMEM - psock_errno()==PSOCK_ENOMEM || -#endif - 0) - return 0; /* try again later */ - - if ( -#ifdef PSOCK_EPIPE - psock_errno()!=PSOCK_EPIPE && -#endif -#ifdef PSOCK_ECONNRESET - psock_errno()!=PSOCK_ECONNRESET && -#endif - 1) eventlog(eventlog_level_debug,__FUNCTION__,"[%d] could not send data (closing connection) (psock_send: %s)",sock,strerror(psock_errno())); - return -1; - } - - if (addlen==0) - { - eventlog(eventlog_level_debug,__FUNCTION__,"[%d] no data sent (closing connection)",sock); - return -1; - } - - *currsize += addlen; - - /* sent all data in this packet? */ - if (size==*currsize) - { - *currsize = 0; - return 1; - } - - return 0; -} diff --git a/d2pack109/src/common/network.h b/d2pack109/src/common/network.h deleted file mode 100644 index 9b49c5c..0000000 --- a/d2pack109/src/common/network.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 1998 Mark Baysinger (mbaysing@ucsd.edu) - * Copyright (C) 1998,1999 Ross Combs (rocombs@cs.nmsu.edu) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - - -/*****/ -#ifndef JUST_NEED_TYPES -#ifndef INCLUDED_NETWORK_PROTOS -#define INCLUDED_NETWORK_PROTOS - -#define JUST_NEED_TYPES -#include "common/packet.h" -#undef JUST_NEED_TYPES - -extern int net_recv_packet(int sock, t_packet * packet, unsigned int * currsize); -extern int net_send_packet(int sock, t_packet const * packet, unsigned int * currsize); - -#endif -#endif diff --git a/d2pack109/src/common/packet.c b/d2pack109/src/common/packet.c deleted file mode 100644 index 4283332..0000000 --- a/d2pack109/src/common/packet.c +++ /dev/null @@ -1,787 +0,0 @@ -/* - * Copyright (C) 1998,1999,2000 Ross Combs (rocombs@cs.nmsu.edu) - * Copyright (C) 1999,2000,2001 Marco Ziech (mmz@gmx.net) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#include "common/setup_before.h" -#ifdef HAVE_STDDEF_H -# include -#else -# ifndef NULL -# define NULL ((void *)0) -# endif -#endif -#ifdef STDC_HEADERS -# include -#else -# ifdef HAVE_MALLOC_H -# include -# endif -#endif -#ifdef HAVE_STRING_H -# include -#else -# ifdef HAVE_STRINGS_H -# include -# endif -#endif -#ifdef HAVE_MEMORY_H -# include -#endif -#include "compat/memcpy.h" -#include "common/eventlog.h" -#include "common/bn_type.h" -#include "common/field_sizes.h" -#include "common/xalloc.h" -#include "common/packet.h" -#include "common/setup_after.h" - - -extern t_packet * packet_create(t_packet_class class) -{ - t_packet * temp; - - if (class!=packet_class_init && - class!=packet_class_raw && - class!=packet_class_d2game && - class!=packet_class_d2cs && - class!=packet_class_d2gs && - class!=packet_class_d2cs_bnetd) - { - eventlog(eventlog_level_error,__FUNCTION__,"invalid packet class %d",(int)class); - return NULL; - } - - temp = xmalloc(sizeof(t_packet)); - temp->ref = 1; - temp->class = class; - temp->flags = 0; - packet_set_size(temp,0); - - return temp; -} - - -extern void packet_destroy(t_packet const * packet) -{ - if (!packet) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL packet"); - return; - } - - xfree((void *)packet); /* avoid warning */ -} - - -extern t_packet * packet_add_ref(t_packet * packet) -{ - if (!packet) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL packet"); - return NULL; - } - - packet->ref++; - return packet; -} - - -extern void packet_del_ref(t_packet * packet) -{ - if (!packet) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL packet"); - return; - } - - if (packet->ref<2) /* if would go to zero */ - packet_destroy(packet); - else - packet->ref--; -} - - -extern t_packet_class packet_get_class(t_packet const * packet) -{ - if (!packet) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL packet"); - return packet_class_none; - } - - switch (packet->class) - { - case packet_class_init: - return packet_class_init; - case packet_class_raw: - return packet_class_raw; - case packet_class_d2game: - return packet_class_d2game; - case packet_class_d2cs: - return packet_class_d2cs; - case packet_class_d2gs: - return packet_class_d2gs; - case packet_class_d2cs_bnetd: - return packet_class_d2cs_bnetd; - case packet_class_none: - return packet_class_none; - default: - eventlog(eventlog_level_error,__FUNCTION__,"packet has invalid class %d",(int)packet->class); - return packet_class_none; - } -} - - -extern char const * packet_get_class_str(t_packet const * packet) -{ - if (!packet) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL packet"); - return "unknown"; - } - - switch (packet->class) - { - case packet_class_init: - return "init"; - case packet_class_raw: - return "raw"; - case packet_class_d2game: - return "d2game"; - case packet_class_d2gs: - return "d2gs"; - case packet_class_d2cs_bnetd: - return "d2cs_bnetd"; - case packet_class_d2cs: - return "d2cs"; - case packet_class_none: - return "none"; - default: - eventlog(eventlog_level_error,__FUNCTION__,"packet has invalid class %d",(int)packet->class); - return "unknown"; - } -} - - -extern int packet_set_class(t_packet * packet, t_packet_class class) -{ - if (!packet) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL packet"); - return -1; - } - if (packet->class!=packet_class_raw) - { - eventlog(eventlog_level_error,__FUNCTION__,"got non-raw packet"); - return -1; - } - if (class!=packet_class_init && - class!=packet_class_raw && - class!=packet_class_d2game && - class!=packet_class_d2cs && - class!=packet_class_d2gs && - class!=packet_class_d2cs_bnetd) - { - eventlog(eventlog_level_error,__FUNCTION__,"invalid packet class %d",(int)class); - return -1; - } - - packet->class = class; - return 0; -} - - -extern unsigned int packet_get_type(t_packet const * packet) -{ - if (!packet) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL packet"); - return 0; - } - - switch (packet->class) - { - case packet_class_init: - return CLIENT_INITCONN; /* all init packets are of this type */ - - case packet_class_raw: - return 0; /* raw packets don't have a type, but don't warn because the packet dump tries anyway */ - - case packet_class_d2game: - if (packet_get_size(packet)u.d2game.h.type); - - case packet_class_d2gs: - if (packet_get_size(packet)u.d2cs_d2gs.h.type); - case packet_class_d2cs_bnetd: - if (packet_get_size(packet)u.d2cs_d2gs.h.type); - - case packet_class_d2cs: - if (packet_get_size(packet)u.d2cs_client.h.type); - - default: - eventlog(eventlog_level_error,__FUNCTION__,"packet has invalid class %d",(int)packet->class); - return 0; - } -} - - -extern char const * packet_get_type_str(t_packet const * packet, t_packet_dir dir) -{ - if (!packet) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL packet"); - return "unknown"; - } - - switch (dir) - { - case packet_dir_from_client: - switch (packet->class) - { - case packet_class_init: - return "CLIENT_INITCONN"; - case packet_class_raw: - return "CLIENT_RAW"; - - case packet_class_d2game: - if (packet_get_size(packet)u.d2game.h.type)) - { - default: - return "CLIENT_D2GAME"; - } - return "unknown"; - - case packet_class_d2cs: - return "D2CS"; - case packet_class_d2gs: - return "D2GS"; - case packet_class_d2cs_bnetd: - return "D2CS_BNETD"; - - case packet_class_none: - return "unknown"; - } - - eventlog(eventlog_level_error,__FUNCTION__,"packet has invalid class %d",(int)packet->class); - return "unknown"; - - case packet_dir_from_server: - switch (packet->class) - { - case packet_class_init: - return "unknown"; - case packet_class_raw: - return "SERVER_RAW"; - - case packet_class_d2game: - if (packet_get_size(packet)u.d2game.h.type)) - { - default: - return "SERVER_D2GAME"; - } - return "unknown"; - - case packet_class_d2cs: - return "D2CS"; - case packet_class_d2gs: - return "D2GS"; - case packet_class_d2cs_bnetd: - return "D2CS_BNETD"; - - case packet_class_none: - return "unknown"; - } - - eventlog(eventlog_level_error,__FUNCTION__,"packet has invalid class %d",(int)packet->class); - return "unknown"; - } - - eventlog(eventlog_level_error,__FUNCTION__,"got unknown direction %d",(int)dir); - return "unknown"; -} - - -extern int packet_set_type(t_packet * packet, unsigned int type) -{ - if (!packet) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL packet"); - return -1; - } - - switch (packet->class) - { - case packet_class_init: - if (type!=CLIENT_INITCONN) - { - eventlog(eventlog_level_error,__FUNCTION__,"init packet type 0x%08x is not valid",type); - return -1; - } - return 0; - - case packet_class_d2game: - if (packet_get_size(packet)u.d2game.h.type,type); - return 0; - - case packet_class_d2gs: - if (packet_get_size(packet)u.d2cs_d2gs.h.type,type); - return 0; - - case packet_class_d2cs_bnetd: - if (packet_get_size(packet)u.d2cs_bnetd.h.type,type); - return 0; - - case packet_class_d2cs: - if (packet_get_size(packet)u.d2cs_client.h.type,type); - return 0; - - case packet_class_raw: - eventlog(eventlog_level_error,__FUNCTION__,"can not set packet type for raw packet"); - return 0; - - default: - eventlog(eventlog_level_error,__FUNCTION__,"packet has invalid class %d",(int)packet->class); - return -1; - } -} - - -/* size of the _complete_ packet, not the amount currently received or sent */ -extern unsigned int packet_get_size(t_packet const * packet) -{ - unsigned int size; - - if (!packet) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL packet"); - return 0; - } - - switch (packet->class) - { - case packet_class_init: - size = sizeof(t_client_initconn); - break; - case packet_class_raw: - size = packet->len; - break; - case packet_class_d2game: - size = packet->len; /* FIXME: does header not contain the size? */ - break; - case packet_class_d2gs: - size = (unsigned int)bn_short_get(packet->u.d2cs_d2gs.h.size); - break; - case packet_class_d2cs_bnetd: - size = (unsigned int)bn_short_get(packet->u.d2cs_bnetd.h.size); - break; - case packet_class_d2cs: - size = (unsigned int)bn_short_get(packet->u.d2cs_client.h.size); - break; - default: - eventlog(eventlog_level_error,__FUNCTION__,"packet has invalid class %d",(int)packet->class); - return 0; - } - - if (size>MAX_PACKET_SIZE) - { - eventlog(eventlog_level_error,__FUNCTION__,"packet has bad size %u",size); - return 0; - } - return size; -} - - -extern int packet_set_size(t_packet * packet, unsigned int size) -{ - if (!packet) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL packet"); - return -1; - } - if (size>MAX_PACKET_SIZE) - { - eventlog(eventlog_level_error,__FUNCTION__,"got bad size %u",size); - return -1; - } - - switch (packet->class) - { - case packet_class_init: - if (size!=0 && size!=sizeof(t_client_initconn)) - { - eventlog(eventlog_level_error,__FUNCTION__,"invalid size %u for init packet",size); - return -1; - } - packet->len = size; - return 0; - case packet_class_raw: - packet->len = size; - return 0; - case packet_class_d2game: - packet->len = size; /* FIXME: does header not contain the size? */ - return 0; - case packet_class_d2cs: - bn_short_set(&packet->u.d2cs_client.h.size,size); - return 0; - case packet_class_d2gs: - bn_short_set(&packet->u.d2cs_d2gs.h.size,size); - return 0; - case packet_class_d2cs_bnetd: - bn_short_set(&packet->u.d2cs_bnetd.h.size,size); - return 0; - default: - eventlog(eventlog_level_error,__FUNCTION__,"packet has invalid class %d",(int)packet->class); - return -1; - } -} - - -extern unsigned int packet_get_header_size(t_packet const * packet) -{ - if (!packet) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL packet"); - return MAX_PACKET_SIZE; - } - - switch (packet_get_class(packet)) - { - case packet_class_init: - return 0; - case packet_class_raw: - return 0; - case packet_class_d2game: - return 0; /* FIXME: is there no game packet header? */ - case packet_class_d2cs: - return sizeof(t_d2cs_client_header); - case packet_class_d2gs: - return sizeof(t_d2cs_d2gs_header); - case packet_class_d2cs_bnetd: - return sizeof(t_d2cs_bnetd_header); - default: - eventlog(eventlog_level_error,__FUNCTION__,"packet has bad class %d",(int)packet_get_class(packet)); - return MAX_PACKET_SIZE; - } -} - - -extern unsigned int packet_get_flags(t_packet const * packet) -{ - if (!packet) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL packet"); - return 0; - } - - return packet->flags; -} - - -extern int packet_set_flags(t_packet * packet, unsigned int flags) -{ - if (!packet) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL packet"); - return -1; - } - - packet->flags = flags; - return 0; -} - - -extern int packet_append_string(t_packet * packet, char const * str) -{ - unsigned int len; - unsigned short addlen; - unsigned short size; - - if (!packet) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL packet"); - return -1; - } - if (!str) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL string"); - return -1; - } - - len = strlen(str)+1; - size = packet_get_size(packet); - if (size>=MAX_PACKET_SIZE) - return -1; - - if (MAX_PACKET_SIZE-(unsigned int)size>len) - addlen = len; - else - addlen = MAX_PACKET_SIZE-size; - if (addlen<1) - return -1; - - memcpy(packet->u.data+size,str,addlen-1); - packet->u.data[size+addlen-1] = '\0'; - packet_set_size(packet,size+addlen); - - return (int)addlen; -} - - -extern int packet_append_ntstring(t_packet * packet, char const * str) -{ - unsigned int len; - unsigned short addlen; - unsigned short size; - - if (!packet) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL packet"); - return -1; - } - if (!str) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL string"); - return -1; - } - - len = strlen(str); - size = packet_get_size(packet); - if (size>=MAX_PACKET_SIZE) - return -1; - - if (MAX_PACKET_SIZE-(unsigned int)size>len) - addlen = len; - else - addlen = MAX_PACKET_SIZE-size; - if (addlen<1) - return -1; - - memcpy(packet->u.data+size,str,addlen); - packet_set_size(packet,size+addlen); - - return (int)addlen; -} - - -extern int packet_append_data(t_packet * packet, void const * data, unsigned int len) -{ - unsigned short addlen; - unsigned short size; - - if (!packet) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL packet"); - return -1; - } - if (!data) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL data"); - return -1; - } - - size = packet_get_size(packet); - if (size>=MAX_PACKET_SIZE) - return -1; - - if (MAX_PACKET_SIZE-(unsigned int)size>len) - addlen = len; - else - addlen = MAX_PACKET_SIZE-size; - if (addlen<1) - return -1; - - memcpy(packet->u.data+size,data,addlen); - packet_set_size(packet,size+addlen); - - return (int)addlen; -} - - -extern void const * packet_get_raw_data_const(t_packet const * packet, unsigned int offset) -{ - unsigned int size; - - if (!packet) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL packet"); - return NULL; - } - size = (unsigned int)packet_get_size(packet); - if (offset>=size || offset>=MAX_PACKET_SIZE) - { - eventlog(eventlog_level_error,__FUNCTION__,"got bad offset %u for packet size %u",offset,size); - return NULL; - } - - return packet->u.data+offset; -} - - -extern void * packet_get_raw_data(t_packet * packet, unsigned int offset) -{ - unsigned int size; - - if (!packet) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL packet"); - return NULL; - } - size = (unsigned int)packet_get_size(packet); - if (offset>=size || offset>=MAX_PACKET_SIZE) - { - eventlog(eventlog_level_error,__FUNCTION__,"got bad offset %u for packet size %u",offset,size); - return NULL; - } - - return packet->u.data+offset; -} - - -extern void * packet_get_raw_data_build(t_packet * packet, unsigned int offset) -{ - if (!packet) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL packet"); - return NULL; - } - - if (offset>=MAX_PACKET_SIZE) - { - eventlog(eventlog_level_error,__FUNCTION__,"got bad offset %u for packet",offset); - return NULL; - } - - return packet->u.data+offset; -} - - -/* maxlen includes room for NUL char */ -extern char const * packet_get_str_const(t_packet const * packet, unsigned int offset, unsigned int maxlen) -{ - unsigned int size; - unsigned int pos; - - if (!packet) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL packet"); - return NULL; - } - size = (unsigned int)packet_get_size(packet); - if (offset>=size) - { - eventlog(eventlog_level_error,__FUNCTION__,"got bad offset %u for packet size %u",offset,size); - return NULL; - } - - for (pos=offset; packet->u.data[pos]!='\0'; pos++) - if (pos>=size || pos-offset>=maxlen) - return NULL; - if (pos>=size || pos-offset>=maxlen) /* NUL must be inside too */ - return NULL; - return packet->u.data+offset; -} - - -extern void const * packet_get_data_const(t_packet const * packet, unsigned int offset, unsigned int len) -{ - unsigned int size; - - if (!packet) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL packet"); - return NULL; - } - if (len<1) - { - eventlog(eventlog_level_error,__FUNCTION__,"got zero length"); - return NULL; - } - size = (unsigned int)packet_get_size(packet); - if (offset+len>size) - { - eventlog(eventlog_level_error,__FUNCTION__,"got bad offset %u and length %u for packet size %u",offset,len,size); - return NULL; - } - - return packet->u.data+offset; -} - - -extern t_packet * packet_duplicate(t_packet const * src) -{ - t_packet * p; - - if (!(p = packet_create(packet_get_class(src)))) - { - eventlog(eventlog_level_error,__FUNCTION__,"could not create packet"); - return NULL; - } - packet_append_data(p,src->u.data,packet_get_size(src)); - packet_set_flags(p,packet_get_flags(src)); - - return p; -} - diff --git a/d2pack109/src/common/packet.h b/d2pack109/src/common/packet.h deleted file mode 100644 index 5e31a3d..0000000 --- a/d2pack109/src/common/packet.h +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Copyright (C) 1998 Mark Baysinger (mbaysng@ucsd.edu) - * Copyright (C) 1998,1999,2000 Ross Combs (rocombs@cs.nmsu.edu) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_PACKET_TYPES -#define INCLUDED_PACKET_TYPES - -#ifdef JUST_NEED_TYPES -# include "common/field_sizes.h" -# include "common/init_protocol.h" -# include "common/d2game_protocol.h" -# include "d2cs/d2cs_protocol.h" -# include "d2cs/d2cs_d2gs_protocol.h" -# include "d2cs/d2cs_bnetd_protocol.h" -#else -# define JUST_NEED_TYPES -# include "common/field_sizes.h" -# include "common/init_protocol.h" -# include "common/d2game_protocol.h" -# include "d2cs/d2cs_protocol.h" -# include "d2cs/d2cs_d2gs_protocol.h" -# include "d2cs/d2cs_bnetd_protocol.h" -# undef JUST_NEED_TYPES -#endif - -typedef enum -{ - packet_class_none, - packet_class_init, - packet_class_raw, - packet_class_d2game, - packet_class_d2gs, - packet_class_d2cs, - packet_class_d2cs_bnetd -} t_packet_class; - - -typedef enum -{ - packet_dir_from_client, - packet_dir_from_server -} t_packet_dir; - - -/* These aren't really packets so much as records in a TCP stream. They are variable- - * length structures which make up the Battle.net protocol. It is just easier to call - * them "packets". - */ -typedef struct -{ - unsigned int ref; /* reference count */ - t_packet_class class; - unsigned int flags; /* user-defined flags (used to mark UDP in bnproxy) */ - unsigned int len; /* raw packets have no header, so we use this */ - - /* next part looks just like it would on the network (no padding, byte for byte) */ - union - { - char data[MAX_PACKET_SIZE]; - - t_d2game_generic d2game; - - t_client_initconn client_initconn; - - t_d2cs_bnetd_generic d2cs_bnetd; - t_bnetd_d2cs_authreq bnetd_d2cs_authreq; - t_d2cs_bnetd_authreply d2cs_bnetd_authreply; - t_bnetd_d2cs_authreply bnetd_d2cs_authreply; - t_d2cs_bnetd_accountloginreq d2cs_bnetd_accountloginreq; - t_bnetd_d2cs_accountloginreply bnetd_d2cs_accountloginreply; - t_d2cs_bnetd_charloginreq d2cs_bnetd_charloginreq; - t_bnetd_d2cs_charloginreply bnetd_d2cs_charloginreply; - t_bnetd_d2cs_gameinforeq bnetd_d2cs_gameinforeq; - t_d2cs_bnetd_gameinforeply d2cs_bnetd_gameinforeply; - - t_d2cs_d2gs_generic d2cs_d2gs; - t_d2cs_d2gs_authreq d2cs_d2gs_authreq; - t_d2gs_d2cs_authreply d2gs_d2cs_authreply; - t_d2cs_d2gs_authreply d2cs_d2gs_authreply; - t_d2cs_d2gs_setgsinfo d2cs_d2gs_setgsinfo; - t_d2gs_d2cs_setgsinfo d2gs_d2cs_setgsinfo; - t_d2cs_d2gs_creategamereq d2cs_d2gs_creategamereq; - t_d2gs_d2cs_creategamereply d2gs_d2cs_creategamereply; - t_d2cs_d2gs_joingamereq d2cs_d2gs_joingamereq; - t_d2gs_d2cs_joingamereply d2gs_d2cs_joingamereply; - t_d2gs_d2cs_updategameinfo d2gs_d2cs_updategameinfo; - t_d2gs_d2cs_closegame d2gs_d2cs_closegame; - t_d2cs_d2gs_echoreq d2cs_d2gs_echoreq; - t_d2gs_d2cs_echoreply d2gs_d2cs_echoreply; - t_d2cs_d2gs_control d2cs_d2gs_control; - - t_d2cs_client_generic d2cs_client; - t_client_d2cs_loginreq client_d2cs_loginreq; - t_d2cs_client_loginreply d2cs_client_loginreply; - t_client_d2cs_createcharreq client_d2cs_createcharreq; - t_d2cs_client_createcharreply d2cs_client_createcharreply; - t_client_d2cs_creategamereq client_d2cs_creategamereq; - t_d2cs_client_creategamereply d2cs_client_creategamereply; - t_client_d2cs_joingamereq client_d2cs_joingamereq; - t_d2cs_client_joingamereply d2cs_client_joingamereply; - t_client_d2cs_gamelistreq client_d2cs_gamelistreq; - t_d2cs_client_gamelistreply d2cs_client_gamelistreply; - t_client_d2cs_gameinforeq client_d2cs_gameinforeq; - t_d2cs_client_gameinforeply d2cs_client_gameinforeply; - t_client_d2cs_charloginreq client_d2cs_charloginreq; - t_d2cs_client_charloginreply d2cs_client_charloginreply; - t_client_d2cs_deletecharreq client_d2cs_deletecharreq; - t_d2cs_client_deletecharreply d2cs_client_deletecharreply; - t_client_d2cs_ladderreq client_d2cs_ladderreq; - t_d2cs_client_ladderreply d2cs_client_ladderreply; - t_client_d2cs_motdreq client_d2cs_motdreq; - t_d2cs_client_motdreply d2cs_client_motdreply; - t_client_d2cs_cancelcreategame client_d2cs_cancelcreategame; - t_d2cs_client_creategamewait d2cs_client_creategamewait; - t_client_d2cs_charladderreq client_d2cs_charladderreq; - t_client_d2cs_charlistreq client_d2cs_charlistreq; - t_d2cs_client_charlistreply d2cs_client_charlistreply; - t_client_d2cs_convertcharreq client_d2cs_convertcharreq; - t_d2cs_client_convertcharreply d2cs_client_convertcharreply; - } u; -} t_packet; - -#endif - -/*****/ -#ifndef JUST_NEED_TYPES -#ifndef INCLUDED_PACKET_PROTOS -#define INCLUDED_PACKET_PROTOS - -extern t_packet * packet_create(t_packet_class class) ; -extern void packet_destroy(t_packet const * packet); -extern t_packet * packet_add_ref(t_packet * packet); -extern void packet_del_ref(t_packet * packet); -extern t_packet_class packet_get_class(t_packet const * packet); -extern char const * packet_get_class_str(t_packet const * packet); -extern int packet_set_class(t_packet * packet, t_packet_class class); -extern unsigned int packet_get_type(t_packet const * packet); -extern char const * packet_get_type_str(t_packet const * packet, t_packet_dir dir); -extern int packet_set_type(t_packet * packet, unsigned int type); -extern unsigned int packet_get_size(t_packet const * packet); -extern int packet_set_size(t_packet * packet, unsigned int size); -extern unsigned int packet_get_header_size(t_packet const * packet); -extern unsigned int packet_get_flags(t_packet const * packet); -extern int packet_set_flags(t_packet * packet, unsigned int flags); -extern int packet_append_string(t_packet * packet, char const * str); -extern int packet_append_ntstring(t_packet * packet, char const * str); -extern int packet_append_data(t_packet * packet, void const * data, unsigned int len); -extern void const * packet_get_raw_data_const(t_packet const * packet, unsigned int offset); -extern void * packet_get_raw_data(t_packet * packet, unsigned int offset); -extern void * packet_get_raw_data_build(t_packet * packet, unsigned int offset); -extern char const * packet_get_str_const(t_packet const * packet, unsigned int offset, unsigned int maxlen); -extern void const * packet_get_data_const(t_packet const * packet, unsigned int offset, unsigned int len); -extern t_packet * packet_duplicate(t_packet const * src); - -#endif -#endif diff --git a/d2pack109/src/common/queue.c b/d2pack109/src/common/queue.c deleted file mode 100644 index 291f4ba..0000000 --- a/d2pack109/src/common/queue.c +++ /dev/null @@ -1,207 +0,0 @@ -/* - * Copyright (C) 1998,1999,2001 Ross Combs (rocombs@cs.nmsu.edu) - * - * 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. - */ -#define QUEUE_INTERNAL_ACCESS -#include "common/setup_before.h" -#ifdef HAVE_STDDEF_H -# include -#else -# ifndef NULL -# define NULL ((void *)0) -# endif -#endif -#ifdef STDC_HEADERS -# include -#else -# ifdef HAVE_MALLOC_H -# include -# endif -#endif -#ifdef HAVE_STRING_H -# include -#else -# ifdef HAVE_STRINGS_H -# include -# endif -# ifdef HAVE_MEMORY_H -# include -# endif -#endif -#include "common/packet.h" -#include "common/eventlog.h" -#include "common/xalloc.h" -#include "common/queue.h" -#include "common/setup_after.h" - -#define QUEUE_QUANTUM 10 /* allocate ring buffer slots for 10 packets at once */ - -extern t_packet * queue_pull_packet(t_queue * * queue) -{ - t_queue * temp; - t_packet * packet; - -// eventlog(eventlog_level_debug, __FUNCTION__, "entered: queue %p", queue); - if (!queue) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL queue pointer"); - return NULL; - } - - temp = *queue; - - if (!temp || !temp->ulen) - return NULL; - -// eventlog(eventlog_level_debug, __FUNCTION__, "getting element from tail (%d/%d head/tail %d/%d)", temp->alen, temp->ulen, temp->head, temp->tail); - /* getting entry from tail and updating queue */ - packet = temp->ring[temp->tail]; - temp->tail = (temp->tail + 1) % temp->alen; - temp->ulen--; -// eventlog(eventlog_level_debug, __FUNCTION__, "read %p element from tail (%d/%d head/tail %d/%d)", packet, temp->alen, temp->ulen, temp->head, temp->tail); - - if (!packet) - { - eventlog(eventlog_level_error,__FUNCTION__,"NULL packet in queue"); - return NULL; - } - - return packet; -} - - -extern t_packet * queue_peek_packet(t_queue const * const * queue) -{ - t_packet * packet; - -// eventlog(eventlog_level_debug, __FUNCTION__, "entered: queue %p", queue); - if (!queue) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL queue pointer"); - return NULL; - } - if (!*queue || !(*queue)->ulen) - return NULL; - - packet = (*queue)->ring[(*queue)->tail]; - - if (!packet) - { - eventlog(eventlog_level_error,__FUNCTION__,"NULL packet in queue"); - return NULL; - } - - return packet; -} - - -extern void queue_push_packet(t_queue * * queue, t_packet * packet) -{ - t_queue * temp; - void *ptr; - -// eventlog(eventlog_level_debug, __FUNCTION__, "entered: queue %p packet %p", queue, packet); - if (!queue) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL queue pointer"); - return; - } - if (!packet) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL packet"); - return; - } - - temp = *queue; - - if (!temp) - { -// eventlog(eventlog_level_debug, __FUNCTION__, "queue is NULL , initilizing"); - temp = xmalloc(sizeof(t_queue)); - temp->alen = temp->ulen = 0; - temp->ring = NULL; - temp->head = temp->tail = 0; - *queue = temp; - } - - if (temp->ulen == temp->alen) { /* ring queue is full, need to allocate some memory */ -/* FIXME: find a solution - if (temp->alen) - eventlog(eventlog_level_error, __FUNCTION__, "queue is full (resizing) (oldsize: %u)", temp->alen); -*/ - - ptr = xrealloc(temp->ring, sizeof(t_packet *) * (temp->alen + QUEUE_QUANTUM)); - temp->ring = (t_packet **)ptr; - temp->alen += QUEUE_QUANTUM; - -// eventlog(eventlog_level_debug, __FUNCTION__, "queue new size %d/%d head/tail %d/%d", temp->alen, temp->ulen, temp->head, temp->tail); - if (temp->head) { - unsigned moved; - - moved = (QUEUE_QUANTUM <= temp->head) ? QUEUE_QUANTUM : temp->head; - memmove(temp->ring + temp->ulen, temp->ring, sizeof(t_packet *) * moved); - if (temp->head > QUEUE_QUANTUM) { - memmove(temp->ring, temp->ring + moved, sizeof(t_packet *) * (temp->head - moved)); - temp->head -= moved; - } else if (temp->head < QUEUE_QUANTUM) - temp->head = temp->ulen + moved; - else temp->head = 0; - } else temp->head = temp->ulen; - - } - - temp->ring[temp->head] = packet_add_ref(packet); - - temp->head = (temp->head + 1) % temp->alen; - temp->ulen++; -// eventlog(eventlog_level_debug, __FUNCTION__, "packet added (%d/%d head/tail %d/%d)", temp->alen, temp->ulen, temp->head, temp->tail); -} - - -extern int queue_get_length(t_queue const * const * queue) -{ -// eventlog(eventlog_level_debug, __FUNCTION__, "entered: queue %p", queue); - if (!queue) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL queue pointer"); - return 0; - } - - if (*queue == NULL) return 0; - - return (*queue)->ulen; -} - - -extern void queue_clear(t_queue * * queue) -{ - t_packet * temp; - -// eventlog(eventlog_level_debug, __FUNCTION__, "entered: queue %p", queue); - if (!queue) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL queue pointer"); - return; - } - - if (*queue) { - while ((temp = queue_pull_packet(queue))) - packet_del_ref(temp); - - if ((*queue)->ring) xfree((void*)((*queue)->ring)); - xfree((void*)(*queue)); - } -} diff --git a/d2pack109/src/common/queue.h b/d2pack109/src/common/queue.h deleted file mode 100644 index 0f8a460..0000000 --- a/d2pack109/src/common/queue.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 1998,1999 Ross Combs (rocombs@cs.nmsu.edu) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_QUEUE_TYPES -#define INCLUDED_QUEUE_TYPES - -#ifdef QUEUE_INTERNAL_ACCESS -#ifdef JUST_NEED_TYPES -# include "common/packet.h" -#else -# define JUST_NEED_TYPES -# include "common/packet.h" -# undef JUST_NEED_TYPES -#endif -#endif - -typedef struct queue -#ifdef QUEUE_INTERNAL_ACCESS -{ - unsigned ulen, alen; - t_packet ** ring; - unsigned head, tail; -} -#endif -t_queue; - -#endif - - -/*****/ -#ifndef JUST_NEED_TYPES -#ifndef INCLUDED_QUEUE_PROTOS -#define INCLUDED_QUEUE_PROTOS - -#define JUST_NEED_TYPES -#include "common/packet.h" -#undef JUST_NEED_TYPES - -extern t_packet * queue_pull_packet(t_queue * * queue); -extern t_packet * queue_peek_packet(t_queue const * const * queue); -extern void queue_push_packet(t_queue * * queue, t_packet * packet); -extern int queue_get_length(t_queue const * const * queue); -extern void queue_clear(t_queue * * queue); - -#endif -#endif diff --git a/d2pack109/src/common/rlimit.c b/d2pack109/src/common/rlimit.c deleted file mode 100644 index 1bf64d2..0000000 --- a/d2pack109/src/common/rlimit.c +++ /dev/null @@ -1,79 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "common/setup_before.h" -#include -#ifdef HAVE_UNISTD_H -# include -#endif -#include -#include "compat/strerror.h" -#ifdef TIME_WITH_SYS_TIME -# include -# include -#else -# ifdef HAVE_SYS_TIME_H -# include -# else -# include -# endif -#endif -#ifdef HAVE_STRING_H -# include -#endif -#ifdef HAVE_SYS_RESOURCE_H -# include -#endif -#include "common/eventlog.h" -#include "common/bn_type.h" -#include "common/setup_after.h" - - -/* file descriptor limit has different name on BSD and Linux */ -#ifdef RLIMIT_NOFILE -# define RLIM_NUMFILES RLIMIT_NOFILE -#else -# ifdef RLIMIT_OFILE -# define RLIM_NUMFILES RLIMIT_OFILE -# endif -#endif - -extern int get_socket_limit(void) -{ - unsigned int socklimit = BNETD_MAX_SOCKETS; -#ifdef HAVE_GETRLIMIT - struct rlimit rlim; - if(getrlimit(RLIM_NUMFILES, &rlim) < 0) - eventlog(eventlog_level_error, __FUNCTION__, "getrlimit returned error: %s", strerror(errno)); - socklimit = rlim.rlim_cur; -#else - /* FIXME: WIN32: somehow get WSAData win32 socket limit here */ -#endif - -#if !(defined HAVE_POLL || defined HAVE_KQUEUE || defined HAVE_EPOLL) - if(FD_SETSIZE < socklimit) - socklimit = FD_SETSIZE; -#endif - - - /* make socket limit smaller than file limit to make sure log files, - db connections and save files will still work */ - socklimit -= 64; - - eventlog(eventlog_level_debug, __FUNCTION__, "limit: %d", socklimit); - - return socklimit; -} diff --git a/d2pack109/src/common/rlimit.h b/d2pack109/src/common/rlimit.h deleted file mode 100644 index 80e7427..0000000 --- a/d2pack109/src/common/rlimit.h +++ /dev/null @@ -1,19 +0,0 @@ -/* - * 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. - */ - -/*****/ - -extern int get_socket_limit(void); diff --git a/d2pack109/src/common/setup_before.h b/d2pack109/src/common/setup_before.h deleted file mode 100644 index d71dff4..0000000 --- a/d2pack109/src/common/setup_before.h +++ /dev/null @@ -1,374 +0,0 @@ -/* - * Copyright (C) 1998,1999,2000 Ross Combs (rocombs@cs.nmsu.edu) - * Copyright (C) 1999 Rob Crittenden (rcrit@greyoak.com) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifdef INCLUDED_SETUP_AFTER_H -# error "This file must be included before all other header files" -#endif -#ifndef INCLUDED_SETUP_BEFORE_H -#define INCLUDED_SETUP_BEFORE_H - -/* get autoconf defines */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#ifdef WIN32 -#ifndef __BORLANDC__ /* Borland uses config.h.win32borland instead */ -# include "win32/configwin.h" -#endif -#endif - -/* This file contains compile-time configuration parameters including - * debugging options, default configuration values, and format strings. - */ - -#include "version.h" - -/***************************************************************/ -/* Debugging options */ - -/* print bad calling locations of account functions */ -#define DEBUG_ACCOUNT - -/* make bnchat, etc. print debug messages */ -#define CLIENTDEBUG - -/* make the routines call xxx_check() and notice - xxx_purge() calls during list traversal */ -#undef LIST_DEBUG -#undef HASHTABLE_DEBUG - -/* this will use GCC evensions to verify that all module arguments to - eventlog() are correct. */ -#undef DEBUGMODSTRINGS -/* - After you compile, use this script: - strings bnetd | - egrep '@\([^@]*@@[a-z_]*\)@' | - sed -e 's/@(\([^:]*\):\([a-z_]*\)@@\([a-z_]*\))@/\1 \2 \3/g' | - awk '{ if ( $2 != $3 ) printf("%s: %s->%s\n",$1,$2,$3); }' -*/ - -/* this will test get/unget memory management in account.c */ -#undef TESTUNGET - -/* check ladders for impossible combinations when returning them */ -#define LADDER_DEBUG - -/***************************************************************/ -/* compile-time options */ - -/* how long do we wait for the UDP test reply? */ -#define CLIENT_MAX_UDPTEST_WAIT 5 - -/* length of listen socket queue */ -/* #define LISTEN_QUEUE SOMAXCONN */ -#define LISTEN_QUEUE 10 - -/* the format for account numbers */ -#define UID_FORMAT "#%08u" -#define UID_MAXLEN 8 - -/* the format for game ids */ -#define GAMEID_FORMAT "#%06u" -#define GAMEID_MAXLEN 8 - -/* the format of timestamps in the logfile */ -#define EVENT_TIME_FORMAT "%b %d %H:%M:%S" -#define EVENT_TIME_MAXLEN 32 - -/* the format of the stat times in bnstat */ -#define STAT_TIME_FORMAT "%Y %b %d %H:%M:%S" -#define STAT_TIME_MAXLEN 32 - -/* the format of the file modification time in bnftp */ -#define FILE_TIME_FORMAT "%Y %b %d %H:%M:%S" -#define FILE_TIME_MAXLEN 32 - -/* the format of the dates in the game report and for /gameinfo */ -#define GAME_TIME_FORMAT "%a %b %d %H:%M:%S %Z" -#define GAME_TIME_MAXLEN 32 - -/* the format of the timestamps for the start/end of channel log files */ -#define CHANLOG_TIME_FORMAT "%Y %b %d %H:%M:%S %Z" -#define CHANLOG_TIME_MAXLEN 32 - -/* the format of the timestamps for lines in the channel log files */ -#define CHANLOGLINE_TIME_FORMAT "%b %d %H:%M:%S" -#define CHANLOGLINE_TIME_MAXLEN 32 - -/* adjustable constants */ -#define BNETD_LADDER_DEFAULT_TIME "19764578 0" /* 0:00 1 Jan 1970 GMT */ - -/* for clients if ioctl(TIOCGWINSZ) fails and $LINES and $COLUMNS aren't set */ -#define DEF_SCREEN_WIDTH 80 -#define DEF_SCREEN_HEIGHT 24 - -/***************************************************************/ -/* default values for bnetd.conf */ - -/* default Boolean setup values */ -#define BNETD_CHANLOG 0 - -/* default path configuration values */ -#ifndef BNETD_DEFAULT_CONF_FILE -# define BNETD_DEFAULT_CONF_FILE "conf/bnetd.conf" -#endif -#define BNETD_FILE_DIR "files" -#define BNETD_STORAGE_PATH "" -#define BNETD_REPORT_DIR "reports" -#define BNETD_LOG_FILE "logs/bnetd.log" -#define BNETD_MOTD_FILE "conf/bnmotd.txt" -#define BNETD_NEWS_DIR "news" -#define BNETD_AD_FILE "conf/ad.conf" -#define BNETD_CHANNEL_FILE "conf/channel.list" -#define BNETD_PID_FILE "" /* this means "none" */ -#define BNETD_ACCOUNT_TMP ".bnetd_acct_temp" -#define BNETD_IPBAN_FILE "conf/bnban" -#define BNETD_HELP_FILE "conf/bnhelpfile" -#define BNETD_FORTUNECMD "/usr/games/fortune" -#define BNETD_TRANS_FILE "conf/gametrans" -#define BNETD_CHANLOG_DIR "chanlogs" -#define BNETD_REALM_FILE "conf/realm.list" -#define BNETD_ISSUE_FILE "conf/bnissue.txt" -#define BNETD_MAIL_DIR "var/bnmail" -#define PVPGN_VERSIONCHECK "conf/versioncheck" -#define BNETD_LADDER_DIR "var/ladders" -#define BNETD_STATUS_DIR "var/status" -#define BNETD_TOPIC_FILE "var/topics" -#define BNETD_DBLAYOUT_FILE "conf/sql_DB_layout" - -#define BNETD_COMMAND_GROUPS_FILE "conf/command_groups.txt" -#define BNETD_TOURNAMENT_FILE "conf/tournament.conf" -#define BNETD_ALIASFILE "conf/bnalias.list" -#define BNETD_W3TRANS_FILE "conf/w3trans" -/* ADDED BY UNDYING SOULZZ 4/9/02 */ -/* default identify timeout value */ -#define W3_IDENTTIMEOUT 15 /* seconds */ -/* Added by Soar */ -/* time limit for new member as newer(whom cannot be promoted) in clan, (hrs) */ -#define CLAN_NEWER_TIME 168 -#define CLAN_MAX_MEMBERS 50 - -/* moved from account.h */ -#define MAX_FRIENDS 20 - -/* maximum ammount of bytes sent in a single server.c/sd_tcpoutput call */ -#define BNETD_MAX_OUTBURST 16384 - -/* default files relative to FILE_DIR */ -#define BNETD_TOS_FILE "tos.txt" -#define BNETD_ICON_FILE "icons.bni" -#define BNETD_WAR3_ICON_FILE "icons-WAR3.bni" -#define BNETD_STAR_ICON_FILE "icons_STAR.bni" -#define BNETD_MPQ_FILE "autoupdate" - -/* other default configuration values */ -#define BNETD_LOG_LEVELS "warn,error" -#define BNETD_SERV_ADDRS ":" /* this means "all" */ -#define BNETD_SERV_PORT 6112 -#define BNETD_W3ROUTE_ADDR "0.0.0.0" -#define BNETD_W3ROUTE_PORT 6200 -#define BNETD_IRC_ADDRS "" /* this means none */ -#define BNETD_IRC_PORT 6667 /* used if port not specified */ -#define BNETD_TRACK_ADDRS "track.pvpgn.org" -#define BNETD_TRACK_PORT 6114 /* use this port if not specified */ -#define BNETD_DEF_TEST_PORT 6112 /* default guess for UDP test port */ -#define BNETD_MIN_TEST_PORT 6112 -#define BNETD_MAX_TEST_PORT 6500 -#define BNETD_USERSYNC 300 /* s */ -#define BNETD_USERFLUSH 1000 -#define BNETD_LATENCY 10 /* s */ -#define BNETD_IRC_LATENCY 180 /* s */ /* Ping timeout for IRC connections */ -#define BNETD_DEF_NULLMSG 120 /* s */ -#define BNETD_TRACK_TIME 0 -#define BNETD_POLL_INTERVAL 20 /* 20 ms */ -#define BNETD_JIFFIES 50 /* 50 ms jiffies time quantum */ -#define BNETD_SHUTDELAY 300 /* s */ -#define BNETD_SHUTDECR 60 /* s */ -#define BNETD_DEFAULT_OWNER "PvPGN" -#define BNETD_DEFAULT_KEY "3310541526205" -#define BNETD_DEFAULT_HOST "localhost" -#define BNETD_QUOTA_DOBAE 7 /* lines */ -#define BNETD_QUOTA_LINES 5 /* lines */ -#define BNETD_QUOTA_TIME 5 /* s */ -#define BNETD_QUOTA_WLINE 40 /* chars */ -#define BNETD_QUOTA_MLINE 200 /* chars */ -#define BNETD_LADDER_INIT_RAT 1000 -#define BNETD_MAIL_SUPPORT 0 -#define BNETD_MAIL_QUOTA 5 -#define BNETD_LOG_NOTICE "*** Please note this channel is logged! ***" -#define BNETD_HASHTABLE_SIZE 61 -#define BNETD_REALM_PORT 6113 /* where D2CS listens */ -#define BNETD_TELNET_ADDRS "" /* this means none */ -#define BNETD_TELNET_PORT 23 /* used if port not specified */ -#define BNETD_EXEINFO_MATCH "exact" -#define PVPGN_VERSION_TIMEDIV 3600 /* 1 hour */ -#define PVPGN_CACHE_MEMLIMIT 5000000 /* bytes */ -#define PVPGN_DEFAULT_SYMB "-_[]" - -/***************************************************************/ -/* default values for the tracking server */ - -#define BNTRACKD_EXPIRE 600 -#define BNTRACKD_UPDATE 150 -#define BNTRACKD_GRANULARITY 5 -#define BNTRACKD_SERVER_PORT 6114 -#define BNTRACKD_PIDFILE "" /* this means "none" */ -#define BNTRACKD_OUTFILE "pvpgnlist.txt" -#ifdef WIN32 -#define BNTRACKD_PROCESS "process.pl" -#define BNTRACKD_LOGFILE "bntrackd.log" -#else -#define BNTRACKD_PROCESS "scripts/process.pl" -#define BNTRACKD_LOGFILE "logs/bntrackd.log" -#endif - -/***************************************************************/ -/* default values for W3XP anongameinfo packet */ - -#define PVPGN_DEFAULT_URL "www.pvpgn.org" - -#define PVPGN_PG_1V1_DESC "Solo Games" -#define PVPGN_AT_2V2_DESC "2 player team" -#define PVPGN_AT_3V3_DESC "3 player team" -#define PVPGN_AT_4V4_DESC "4 player team" -#define PVPGN_PG_TEAM_DESC "Team Games" -#define PVPGN_PG_FFA_DESC "Free for All Games" - -#define PVPGN_1V1_GT_DESC "One vs. One" -#define PVPGN_1V1_GT_LONG "Two players fight to the death" - -#define PVPGN_2V2_GT_DESC "Two vs. Two" -#define PVPGN_2V2_GT_LONG "Two teams of two vie for dominance" - -#define PVPGN_3V3_GT_DESC "Three vs. Three" -#define PVPGN_3V3_GT_LONG "Two teams of three face off on the battlefield" - -#define PVPGN_4V4_GT_DESC "Four vs. Four" -#define PVPGN_4V4_GT_LONG "Two teams of four head to battle" - -#define PVPGN_5V5_GT_DESC "Five vs. Five" -#define PVPGN_5V5_GT_LONG "Two teams of five - who will prevail?" - -#define PVPGN_6V6_GT_DESC "Six vs. Six" -#define PVPGN_6V6_GT_LONG "Two teams of six - get ready to rumble!" - -#define PVPGN_SFFA_GT_DESC "Small Free for All" -#define PVPGN_SFFA_GT_LONG "Can you defeat 3-5 opponents alone?" - -#define PVPGN_TFFA_GT_DESC "Team Free for All" -#define PVPGN_TFFA_GT_LONG "Can your team defeat 1-2 others?" - -#define PVPGN_2V2V2_GT_DESC "Two vs. Two vs. Two" -#define PVPGN_2V2V2_GT_LONG "Three teams of two, can you handle it?" - -#define PVPGN_3V3V3_GT_DESC "Three vs. Three vs. Three" -#define PVPGN_3V3V3_GT_LONG "Three teams of three battle each other " - -#define PVPGN_4V4V4_GT_DESC "Four vs. Four vs. Four" -#define PVPGN_4V4V4_GT_LONG "Three teams of four - things getting crowded?" - -#define PVPGN_2V2V2V2_GT_DESC "Two vs. Two vs. Two vs. Two" -#define PVPGN_2V2V2V2_GT_LONG "Four teams of two, is this a challenge?" - -#define PVPGN_3V3V3V3_GT_DESC "Three vs. Three vs. Three vs. Three" -#define PVPGN_3V3V3V3_GT_LONG "Four teams of three, the ultimate challenge!" - -#define PVPGN_AINFO_FILE "conf/anongame_infos.conf" - -/* max number of players in an anongame match [Omega] */ -#define ANONGAME_MAX_GAMECOUNT 12 - -/* max level of players*/ -#define ANONGAME_MAX_LEVEL 100 - -/***************************************************************/ -/* platform dependent features */ - -/* conditionally enabled features */ - -#if defined(HAVE_SIGACTION) && defined(HAVE_SIGPROCMASK) && defined(HAVE_SIGADDSET) -# define DO_POSIXSIG -#endif - -#if defined(HAVE_FORK) && defined(HAVE_PIPE) -# define DO_SUBPROC -#endif - -#if defined(HAVE_FORK) && defined(HAVE_CHDIR) && (defined(HAVE_SETPGID) || defined(HAVE_SETPGRP)) -# define DO_DAEMONIZE -#endif - - -/* GCC attributes */ - -/* enable format mismatch warnings from gcc */ -#if defined(__GNUC__) && ((__GNUC__ == 2 && __GNUC_MINOR__ >= 5) || __GNUC__ > 2) -# if __GNUC__ == 2 && __GNUC_MINOR__ < 7 -/* namespace clean versions were available starting in 2.6.4 */ -# define __format__ format -# define __printf__ printf -# endif -# define PRINTF_ATTR(FMTARG,VARG) __attribute__((__format__(printf,FMTARG,VARG))) -#else -# define PRINTF_ATTR(FMTARG,VARG) -#endif - -/* type attributes */ - -/* set GCC machine storage mode */ -#if defined(__GNUC__) && ((__GNUC__ == 2 && __GNUC_MINOR__ >= 7) || __GNUC__ > 2) -# define MODE_ATTR(M) __attribute__((__mode__(M))) -# define HAVE_MODE_ATTR -#else -# define MODE_ATTR(M) -#endif - -/* avoid using padding on GCC, for other compilers you need alternate solutions */ -#if defined(__GNUC__) -# define PACKED_ATTR() __attribute__((__packed__)) -#else -# define PACKED_ATTR() -#endif - -/* default maxim number of sockets in the fdwatch pool */ -#define BNETD_MAX_SOCKETS 1000 - -/* Used for FDSETSIZE redefine (only on WIN32 so so far) */ -#define BNETD_MAX_SOCKVAL 8192 - -/* - * select() hackery... works most places, need to add autoconf checks - * because some systems may redefine FD_SETSIZE, have it as a variable, - * or not have the concept of such a value. - * dizzy: this is a total hack. only WIN32 so far specifies this as beeing - * "legal"; in UNIX in general it should be NOT because the kernel interface - * of select will never notice your userland changes to the fd_sets - */ -/* Win32 defaults to 64, BSD and Linux default to 1024 */ -/* FIXME: how big can this be before things break? */ -#ifdef WIN32 -# define FD_SETSIZE BNETD_MAX_SOCKVAL -#endif - -#ifdef HAVE_EPOLL_CREATE -# define HAVE_EPOLL 1 -#endif - -#endif diff --git a/d2pack109/src/common/tag.c b/d2pack109/src/common/tag.c deleted file mode 100644 index e533ebe..0000000 --- a/d2pack109/src/common/tag.c +++ /dev/null @@ -1,246 +0,0 @@ -/* - * Copyright (C) 2004 Aaron - * Copyright (C) 2004 CreepLord (creeplord@pvpgn.org) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#include "common/setup_before.h" -#ifdef HAVE_STDDEF_H -# include -#else -# ifndef NULL -# define NULL ((void *)0) -# endif -#endif -#ifdef STDC_HEADERS -# include -#else -# ifdef HAVE_MALLOC_H -# include -# endif -#endif -#ifdef HAVE_STRING_H -# include -#else -# ifdef HAVE_STRINGS_H -# include -# endif -#endif -#include -#include "errno.h" -#include "compat/strerror.h" -#include "common/eventlog.h" -#include "common/tag.h" -#include "common/setup_after.h" - -/* fixme: have all functions call tag_str_to_uint() */ -extern t_clienttag clienttag_str_to_uint(char const * clienttag) -{ - if (!clienttag) - { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL clienttag"); - return CLIENTTAG_UNKNOWN_UINT; - } - - return tag_str_to_uint(clienttag); -} - -/* fixme: have all fuctions call tag_uint_to_str() */ -extern char const * clienttag_uint_to_str(t_clienttag clienttag) -{ - switch (clienttag) - { - case CLIENTTAG_BNCHATBOT_UINT: - return CLIENTTAG_BNCHATBOT; - case CLIENTTAG_STARCRAFT_UINT: - return CLIENTTAG_STARCRAFT; - case CLIENTTAG_BROODWARS_UINT: - return CLIENTTAG_BROODWARS; - case CLIENTTAG_SHAREWARE_UINT: - return CLIENTTAG_SHAREWARE; - case CLIENTTAG_DIABLORTL_UINT: - return CLIENTTAG_DIABLORTL; - case CLIENTTAG_DIABLOSHR_UINT: - return CLIENTTAG_DIABLOSHR; - case CLIENTTAG_WARCIIBNE_UINT: - return CLIENTTAG_WARCIIBNE; - case CLIENTTAG_DIABLO2DV_UINT: - return CLIENTTAG_DIABLO2DV; - case CLIENTTAG_STARJAPAN_UINT: - return CLIENTTAG_STARJAPAN; - case CLIENTTAG_DIABLO2ST_UINT: - return CLIENTTAG_DIABLO2ST; - case CLIENTTAG_DIABLO2XP_UINT: - return CLIENTTAG_DIABLO2XP; - case CLIENTTAG_WARCRAFT3_UINT: - return CLIENTTAG_WARCRAFT3; - case CLIENTTAG_WAR3XP_UINT: - return CLIENTTAG_WAR3XP; - default: - return CLIENTTAG_UNKNOWN; - } -} - -/*****/ -/* make all letters in string upper case - used in command.c*/ -extern t_tag tag_case_str_to_uint(char const * tag_str) -{ - unsigned int i, len; - char temp_str[5]; - - len = strlen(tag_str); - if (len != 4) - eventlog(eventlog_level_warn,__FUNCTION__,"got unusual sized clienttag '%s'",tag_str); - - for (i=0; i>24) ); - tag_str[1] = ((unsigned char)(tag_uint>>16)&0xff); - tag_str[2] = ((unsigned char)(tag_uint>> 8)&0xff); - tag_str[3] = ((unsigned char)(tag_uint )&0xff); - tag_str[4] = '\0'; - return tag_str; -} - -extern int tag_check_arch(t_tag tag_uint) -{ - switch (tag_uint) - { - case ARCHTAG_WINX86_UINT: - case ARCHTAG_MACPPC_UINT: - case ARCHTAG_OSXPPC_UINT: - return 1; - default: - return 0; - } -} - -extern int tag_check_client(t_tag tag_uint) -{ - switch (tag_uint) - { - case CLIENTTAG_BNCHATBOT_UINT: - case CLIENTTAG_STARCRAFT_UINT: - case CLIENTTAG_BROODWARS_UINT: - case CLIENTTAG_SHAREWARE_UINT: - case CLIENTTAG_DIABLORTL_UINT: - case CLIENTTAG_DIABLOSHR_UINT: - case CLIENTTAG_WARCIIBNE_UINT: - case CLIENTTAG_DIABLO2DV_UINT: - case CLIENTTAG_STARJAPAN_UINT: - case CLIENTTAG_DIABLO2ST_UINT: - case CLIENTTAG_DIABLO2XP_UINT: - case CLIENTTAG_WARCRAFT3_UINT: - case CLIENTTAG_WAR3XP_UINT: - return 1; - default: - return 0; - } -} - -extern int tag_check_gamelang(t_tag gamelang) -{ - switch (gamelang) - { - case GAMELANG_ENGLISH_UINT: /* enUS */ - case GAMELANG_GERMAN_UINT: /* deDE */ - case GAMELANG_CZECH_UINT: /* csCZ */ - case GAMELANG_SPANISH_UINT: /* esES */ - case GAMELANG_FRENCH_UINT: /* frFR */ - case GAMELANG_ITALIAN_UINT: /* itIT */ - case GAMELANG_JAPANESE_UINT: /* jaJA */ - case GAMELANG_KOREAN_UINT: /* koKR */ - case GAMELANG_POLISH_UINT: /* plPL */ - case GAMELANG_RUSSIAN_UINT: /* ruRU */ - case GAMELANG_CHINESE_S_UINT: /* zhCN */ - case GAMELANG_CHINESE_T_UINT: /* zhTW */ - return 1; - default: - return 0; - } -} - -extern char const * clienttag_get_title(t_clienttag clienttag) -{ - switch (clienttag) - { - case CLIENTTAG_WAR3XP_UINT: - return "Warcraft III Frozen Throne"; - case CLIENTTAG_WARCRAFT3_UINT: - return "Warcraft III"; - case CLIENTTAG_DIABLO2XP_UINT: - return "Diablo II Lord of Destruction"; - case CLIENTTAG_DIABLO2DV_UINT: - return "Diablo II"; - case CLIENTTAG_STARJAPAN_UINT: - return "Starcraft (Japan)"; - case CLIENTTAG_WARCIIBNE_UINT: - return "Warcraft II"; - case CLIENTTAG_DIABLOSHR_UINT: - return "Diablo I (Shareware)"; - case CLIENTTAG_DIABLORTL_UINT: - return "Diablo I"; - case CLIENTTAG_SHAREWARE_UINT: - return "Starcraft (Shareware)"; - case CLIENTTAG_BROODWARS_UINT: - return "Starcraft: BroodWars"; - case CLIENTTAG_STARCRAFT_UINT: - return "Starcraft"; - case CLIENTTAG_BNCHATBOT_UINT: - return "Chat"; - default: - return "Unknown"; - } -} - diff --git a/d2pack109/src/common/tag.h b/d2pack109/src/common/tag.h deleted file mode 100644 index a0c1399..0000000 --- a/d2pack109/src/common/tag.h +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright (C) 1998 Mark Baysinger (mbaysing@ucsd.edu) - * Copyright (C) 1998,1999,2000 Ross Combs (rocombs@cs.nmsu.edu) - * Copyright (C) 2004 CreepLord (creeplord@pvpgn.org) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_TAG_TYPES -#define INCLUDED_TAG_TYPES - -#ifdef JUST_NEED_TYPES -#include "compat/uint.h" -#else -#define JUST_NEED_TYPES -#include "compat/uint.h" -#undef JUST_NEED_TYPES -#endif - -typedef t_uint32 t_tag; -typedef t_tag t_archtag; -typedef t_tag t_clienttag; -typedef t_tag t_gamelang; - -#endif - -/*****/ -#ifndef JUST_NEED_TYPES -#ifndef INCLUDED_TAG_PROTOS -#define INCLUDED_TAG_PROTOS - -/* Software tags */ -#define CLIENTTAG_BNCHATBOT "CHAT" /* CHAT bot */ -#define CLIENTTAG_BNCHATBOT_UINT 0x43484154 -#define CLIENTTAG_STARCRAFT "STAR" /* Starcraft (original) */ -#define CLIENTTAG_STARCRAFT_UINT 0x53544152 -#define CLIENTTAG_BROODWARS "SEXP" /* Starcraft EXpansion Pack */ -#define CLIENTTAG_BROODWARS_UINT 0x53455850 -#define CLIENTTAG_SHAREWARE "SSHR" /* Starcraft Shareware */ -#define CLIENTTAG_SHAREWARE_UINT 0x53534852 -#define CLIENTTAG_DIABLORTL "DRTL" /* Diablo ReTaiL */ -#define CLIENTTAG_DIABLORTL_UINT 0x4452544C -#define CLIENTTAG_DIABLOSHR "DSHR" /* Diablo SHaReware */ -#define CLIENTTAG_DIABLOSHR_UINT 0x44534852 -#define CLIENTTAG_WARCIIBNE "W2BN" /* WarCraft II Battle.net Edition */ -#define CLIENTTAG_WARCIIBNE_UINT 0x5732424E -#define CLIENTTAG_DIABLO2DV "D2DV" /* Diablo II Diablo's Victory */ -#define CLIENTTAG_DIABLO2DV_UINT 0x44324456 -#define CLIENTTAG_STARJAPAN "JSTR" /* Starcraft (Japan) */ -#define CLIENTTAG_STARJAPAN_UINT 0x4A535452 -#define CLIENTTAG_DIABLO2ST "D2ST" /* Diablo II Stress Test */ -#define CLIENTTAG_DIABLO2ST_UINT 0x44325354 -#define CLIENTTAG_DIABLO2XP "D2XP" /* Diablo II Extension Pack */ -#define CLIENTTAG_DIABLO2XP_UINT 0x44325850 -/* FIXME: according to FSGS: - SJPN==Starcraft (Japanese) - SSJP==Starcraft (Japanese,Spawn) -*/ -#define CLIENTTAG_WARCRAFT3 "WAR3" /* WarCraft III */ -#define CLIENTTAG_WARCRAFT3_UINT 0x57415233 -#define CLIENTTAG_WAR3XP "W3XP" /* WarCraft III Expansion */ -#define CLIENTTAG_WAR3XP_UINT 0x57335850 - -/* BNETD-specific software tags - we try to use lowercase to avoid collisions */ -#define CLIENTTAG_FREECRAFT "free" /* FreeCraft http://www.freecraft.com/ */ - -#define CLIENTTAG_UNKNOWN "UNKN" -#define CLIENTTAG_UNKNOWN_UINT 0x554E4B4E - -/* Architecture tags */ -#define ARCHTAG_WINX86 "IX86" /* MS Windows on Intel x86 */ -#define ARCHTAG_MACPPC "PMAC" /* MacOS on PowerPC */ -#define ARCHTAG_OSXPPC "XMAC" /* MacOS X on PowerPC */ - -#define ARCHTAG_WINX86_UINT 0x49583836 /* IX86 */ -#define ARCHTAG_MACPPC_UINT 0x504D4143 /* PMAC */ -#define ARCHTAG_OSXPPC_UINT 0x584D4143 /* XMAC */ - -/* game languages */ -#define GAMELANG_ENGLISH_UINT 0x656E5553 /* enUS */ -#define GAMELANG_GERMAN_UINT 0x64654445 /* deDE */ -#define GAMELANG_CZECH_UINT 0x6373435A /* csCZ */ -#define GAMELANG_SPANISH_UINT 0x65734553 /* esES */ -#define GAMELANG_FRENCH_UINT 0x66724652 /* frFR */ -#define GAMELANG_ITALIAN_UINT 0x69744954 /* itIT */ -#define GAMELANG_JAPANESE_UINT 0x6A614A41 /* jaJA */ -#define GAMELANG_KOREAN_UINT 0x6B6F4B52 /* koKR */ -#define GAMELANG_POLISH_UINT 0x706C504C /* plPL */ -#define GAMELANG_RUSSIAN_UINT 0x72755255 /* ruRU */ -#define GAMELANG_CHINESE_S_UINT 0x7A68434E /* zhCN */ -#define GAMELANG_CHINESE_T_UINT 0x7A685457 /* zhTW */ - -#define TAG_UNKNOWN_UINT 0x554E4B4E /* UNKN */ -#define TAG_UNKNOWN "UNKN" - -/* Server tag */ -#define BNETTAG "bnet" /* Battle.net */ - -/* Filetype tags (note these are "backwards") */ -#define EXTENSIONTAG_PCX "xcp." -#define EXTENSIONTAG_SMK "kms." -#define EXTENSIONTAG_MNG "gnm." - -extern t_clienttag clienttag_str_to_uint(char const * clienttag); -extern char const * clienttag_uint_to_str(t_clienttag clienttag); -extern char const * clienttag_get_title(t_clienttag clienttag); - -extern t_tag tag_str_to_uint(char const * tag_str); -extern t_tag tag_case_str_to_uint(char const * tag_str); -extern char * tag_uint_to_str(char * tag_str, t_tag tag_uint); -extern int tag_check_arch(t_tag tag_uint); -extern int tag_check_client(t_tag tag_uint); -extern int tag_check_gamelang(t_tag tag_uint); - -#endif -#endif diff --git a/d2pack109/src/common/trans.c b/d2pack109/src/common/trans.c deleted file mode 100644 index 4b0e094..0000000 --- a/d2pack109/src/common/trans.c +++ /dev/null @@ -1,353 +0,0 @@ -/* - * Copyright (C) 2004 CreepLord (creeplord@pvpgn.org) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#define TRANS_INTERNAL_ACCESS -#include "common/setup_before.h" -#include -#ifdef HAVE_STDDEF_H -# include -#else -# ifndef NULL -# define NULL ((void *)0) -# endif -#endif -#ifdef STDC_HEADERS -# include -#else -# ifdef HAVE_MALLOC_H -# include -# endif -#endif -#ifdef HAVE_STRING_H -# include -#else -# ifdef HAVE_STRINGS_H -# include -# endif -#endif -#include "compat/strrchr.h" -#include -#include "compat/strerror.h" -#include "common/eventlog.h" -#include "common/list.h" -#include "common/addr.h" -#include "common/util.h" -#include "common/xalloc.h" -#include "trans.h" -#include "common/setup_after.h" - -#define DEBUG_TRANS - -static t_list * trans_head=NULL; - -extern int trans_load(char const * filename, int program) -{ - FILE *fp; - unsigned int line; - unsigned int pos; - char *buff; - char *temp; - char const *input; - char const *output; - char const *exclude; - char const *include; - unsigned int npos; - char *network; - char *tmp; - char tmp1[32]; - char tmp2[32]; - char tmp3[32]; - t_trans *entry; - - if (!filename) { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL filename"); - return -1; - } - if (!(fp = fopen(filename,"r"))) { - eventlog(eventlog_level_error,__FUNCTION__,"could not open file \"%s\" for reading (fopen: %s)",filename,strerror(errno)); - return -1; - } - trans_head = list_create(); - for (line=1; (buff = file_get_line(fp)); line++) { - for (pos=0; buff[pos]=='\t' || buff[pos]==' '; pos++); - if (buff[pos]=='\0' || buff[pos]=='#') { - xfree(buff); - continue; - } - if ((temp = strrchr(buff,'#'))) { - unsigned int len; - unsigned int endpos; - - *temp = '\0'; - len = strlen(buff)+1; - for (endpos=len-1; buff[endpos]=='\t' || buff[endpos]==' '; endpos--); - buff[endpos+1] = '\0'; - } - if (!(input = strtok(buff," \t"))) { /* strtok modifies the string it is passed */ - eventlog(eventlog_level_error,__FUNCTION__,"missing input line %u of file \"%s\"",line,filename); - xfree(buff); - continue; - } - /* check for port number - this tells us what programs will use this entry */ - if (!(temp = strrchr(input,':'))) { - eventlog(eventlog_level_error,__FUNCTION__,"missing port # on input line %u of file \"%s\"",line,filename); - xfree(buff); - continue; - } - temp++; - /* bnetd doesn't want the port 4000 entries */ - if (program==TRANS_BNETD && strcmp(temp,"4000")==0) { -#ifdef DEBUG_TRANS - eventlog(eventlog_level_debug,__FUNCTION__,"d2gs input (ignoring) \"%s\"",input); -#endif - xfree(buff); - continue; - } - /* d2cs only wants the port 4000 entries */ - if (program==TRANS_D2CS && strcmp(temp,"4000")!=0) { -#ifdef DEBUG_TRANS - eventlog(eventlog_level_debug,__FUNCTION__,"non d2gs input (ignoring) \"%s\"",input); -#endif - xfree(buff); - continue; - } - if (!(output = strtok(NULL," \t"))) { - eventlog(eventlog_level_error,__FUNCTION__,"missing output on line %u of file \"%s\"",line,filename); - xfree(buff); - continue; - } - if (!(exclude = strtok(NULL," \t"))) { - eventlog(eventlog_level_error,__FUNCTION__,"missing exclude on line %u of file \"%s\"",line,filename); - xfree(buff); - continue; - } - if (!(include = strtok(NULL," \t"))) { - eventlog(eventlog_level_error,__FUNCTION__,"missing include on line %u of file \"%s\"",line,filename); - xfree(buff); - continue; - } - /* add exlude networks */ - tmp = xstrdup(exclude); - npos=0; - while (tmp[npos]) { - network = &tmp[npos]; - for (; tmp[npos]!=',' && tmp[npos]!='\0'; npos++); - if (tmp[npos]=='\0') - npos--; - else - tmp[npos]='\0'; - if (strcmp(network,"NONE")==0) { - npos++; - continue; - } - entry = xmalloc(sizeof(t_trans)); - if (!(entry->input = addr_create_str(input,0,0))) { - eventlog(eventlog_level_error,__FUNCTION__,"could not allocate memory for input address"); - xfree(entry); - npos++; - continue; - } - if (!(entry->output = addr_create_str(input,0,0))) { - eventlog(eventlog_level_error,__FUNCTION__,"could not allocate memory for output address"); - addr_destroy(entry->input); - xfree(entry); - npos++; - continue; - } - if (strcmp(network,"ANY")==0) { - if (!(entry->network = netaddr_create_str("0.0.0.0/0"))) { - eventlog(eventlog_level_error,__FUNCTION__,"could not allocate memory for network address"); - addr_destroy(entry->output); - addr_destroy(entry->input); - xfree(entry); - npos++; - continue; - } - } else { - if (!(entry->network = netaddr_create_str(network))) { - eventlog(eventlog_level_error,__FUNCTION__,"could not allocate memory for network address"); - addr_destroy(entry->output); - addr_destroy(entry->input); - xfree(entry); - npos++; - continue; - } - } -#ifdef DEBUG_TRANS - eventlog(eventlog_level_debug,__FUNCTION__, - "Adding Host -> %s, Output -> %s, Network %s - (exclude)", - addr_get_addr_str(entry->input,tmp1,sizeof(tmp1)), - addr_get_addr_str(entry->output,tmp2,sizeof(tmp2)), - netaddr_get_addr_str(entry->network,tmp3,sizeof(tmp3))); -#endif - list_append_data(trans_head,entry); - npos++; - } - xfree(tmp); - /* add include networks */ - tmp = xstrdup(include); - npos=0; - while (tmp[npos]) { - network = &tmp[npos]; - for (; tmp[npos]!=',' && tmp[npos]!='\0'; npos++); - if (tmp[npos]=='\0') - npos--; - else - tmp[npos]='\0'; - if (strcmp(network,"NONE")==0) { - npos++; - continue; - } - entry = xmalloc(sizeof(t_trans)); - if (!(entry->input = addr_create_str(input,0,0))) { - eventlog(eventlog_level_error,__FUNCTION__,"could not allocate memory for input address"); - xfree(entry); - npos++; - continue; - } - if (!(entry->output = addr_create_str(output,0,0))) { - eventlog(eventlog_level_error,__FUNCTION__,"could not allocate memory for output address"); - addr_destroy(entry->input); - xfree(entry); - npos++; - continue; - } - if (strcmp(network,"ANY")==0) { - if (!(entry->network = netaddr_create_str("0.0.0.0/0"))) { - eventlog(eventlog_level_error,__FUNCTION__,"could not allocate memory for network address"); - addr_destroy(entry->output); - addr_destroy(entry->input); - xfree(entry); - npos++; - continue; - } - } else { - if (!(entry->network = netaddr_create_str(network))) { - eventlog(eventlog_level_error,__FUNCTION__,"could not allocate memory for network address"); - addr_destroy(entry->output); - addr_destroy(entry->input); - xfree(entry); - npos++; - continue; - } - } -#ifdef DEBUG_TRANS - eventlog(eventlog_level_debug,__FUNCTION__, - "Adding Host -> %s, Output -> %s, Network %s - (include)", - addr_get_addr_str(entry->input,tmp1,sizeof(tmp1)), - addr_get_addr_str(entry->output,tmp2,sizeof(tmp2)), - netaddr_get_addr_str(entry->network,tmp3,sizeof(tmp3))); -#endif - list_append_data(trans_head,entry); - npos++; - } - xfree(tmp); - xfree(buff); - } - fclose(fp); - eventlog(eventlog_level_info,__FUNCTION__,"trans file loaded"); - return 0; -} - -extern int trans_unload(void) -{ - t_elem *curr; - t_trans *entry; - - if (trans_head) { - LIST_TRAVERSE(trans_head,curr) - { - if (!(entry = elem_get_data(curr))) { - eventlog(eventlog_level_error,__FUNCTION__,"found NULL entry in list"); - } else { - netaddr_destroy(entry->network); - addr_destroy(entry->output); - addr_destroy(entry->input); - xfree(entry); - } - list_remove_elem(trans_head,&curr); - } - list_destroy(trans_head); - trans_head = NULL; - } - return 0; -} - -extern int trans_reload(char const * filename, int program) -{ - trans_unload(); - if(trans_load(filename,program)<0) return -1; - return 0; -} - -extern int trans_net(unsigned int clientaddr, unsigned int *addr, unsigned short *port) -{ - t_elem const *curr; - t_trans *entry; - char temp1[32]; - char temp2[32]; - char temp3[32]; - char temp4[32]; - -#ifdef DEBUG_TRANS - eventlog(eventlog_level_debug,__FUNCTION__,"checking %s for client %s ...", - addr_num_to_addr_str(*addr, *port), - addr_num_to_ip_str(clientaddr)); -#endif - - if (trans_head) { - LIST_TRAVERSE_CONST(trans_head,curr) - { - if (!(entry = elem_get_data(curr))) { - eventlog(eventlog_level_error,__FUNCTION__,"found NULL entry in list"); - continue; - } - -#ifdef DEBUG_TRANS - eventlog(eventlog_level_debug,__FUNCTION__,"against entry -> %s output %s network %s", - addr_get_addr_str(entry->input,temp1,sizeof(temp1)), - addr_get_addr_str(entry->output,temp2,sizeof(temp2)), - netaddr_get_addr_str(entry->network,temp3,sizeof(temp3))); -#endif - if (addr_get_ip(entry->input)!=*addr || addr_get_port(entry->input)!=*port) { -#ifdef DEBUG_TRANS - eventlog(eventlog_level_debug,__FUNCTION__,"entry does match input address"); -#endif - continue; - } - if (netaddr_contains_addr_num(entry->network,clientaddr)==0) { -#ifdef DEBUG_TRANS - eventlog(eventlog_level_debug,__FUNCTION__,"client is not in the correct network"); -#endif - continue; - } -#ifdef DEBUG_TRANS - eventlog(eventlog_level_debug,__FUNCTION__,"%s translated to %s", - addr_num_to_addr_str(*addr, *port), - addr_get_addr_str(entry->output,temp4,sizeof(temp4))); -#endif - *addr = addr_get_ip(entry->output); - *port = addr_get_port(entry->output); - return 1; /* match found in list */ - } - } -#ifdef DEBUG_TRANS - eventlog(eventlog_level_debug,__FUNCTION__,"no match found for %s (not translated)", - addr_num_to_addr_str(*addr, *port)); -#endif - return 0; /* no match found in list */ -} diff --git a/d2pack109/src/common/trans.h b/d2pack109/src/common/trans.h deleted file mode 100644 index 3e9bc1b..0000000 --- a/d2pack109/src/common/trans.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2004 CreepLord (creeplord@pvpgn.org) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_TRANS_TYPES -#define INCLUDED_TRANS_TYPES - -#ifdef TRANS_INTERNAL_ACCESS - -#ifdef JUST_NEED_TYPES -# include "common/addr.h" -#else -# define JUST_NEED_TYPES -# include "common/addr.h" -# undef JUST_NEED_TYPES -#endif - -typedef struct -{ - t_addr *input; - t_addr *output; - t_netaddr *network; -} t_trans; - -#endif - -#endif - -#ifndef JUST_NEED_TYPES -#ifndef INCLUDED_TRANS_PROTOS -#define INCLUDED_TRANS_PROTOS - -#define TRANS_BNETD 1 -#define TRANS_D2CS 2 - -extern int trans_load(char const * filename, int program); -extern int trans_unload(void); -extern int trans_reload(char const * filename, int program); -extern int trans_net(unsigned int clientaddr, unsigned int *addr, unsigned short *port); - -#endif -#endif diff --git a/d2pack109/src/common/util.c b/d2pack109/src/common/util.c deleted file mode 100644 index 68fd627..0000000 --- a/d2pack109/src/common/util.c +++ /dev/null @@ -1,634 +0,0 @@ -/* - * Copyright (C) 1998 Mark Baysinger (mbaysing@ucsd.edu) - * Copyright (C) 1998,1999,2000,2001 Ross Combs (rocombs@cs.nmsu.edu) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#include "common/setup_before.h" -#include -#ifdef HAVE_STDDEF_H -# include -#else -# ifndef NULL -# define NULL ((void *)0) -# endif -#endif -#ifdef STDC_HEADERS -# include -#else -# ifdef HAVE_MALLOC_H -# include -# endif -#endif -#include "compat/strtoul.h" -#ifdef HAVE_STRING_H -# include -#else -# ifdef HAVE_STRINGS_H -# include -# endif -#endif -#include "compat/strcasecmp.h" -#include "compat/strncasecmp.h" -#include "common/xalloc.h" -#include -#include "common/util.h" -#include "common/setup_after.h" - - -extern int strstart(char const * full, char const * part) -{ - size_t strlen_full, strlen_part; - if (!full || !part) - return 1; - strlen_full = strlen(full); - strlen_part = strlen(part); - if (strlen_fullstrlen_part && full[strlen_part]!=' ' && full[strlen_part]!='\0') - return 1; - return strncasecmp(full,part,strlen_part); -} - - -#define DEF_LEN 64 -#define INC_LEN 16 - -extern char * file_get_line(FILE * fp) -{ - char * line; - unsigned int len=DEF_LEN; - unsigned int pos=0; - int prev_char,curr_char; - - line = xmalloc(DEF_LEN); - prev_char = '\0'; - while ((curr_char = fgetc(fp))!=EOF) - { - if (((char)curr_char)=='\r') - continue; /* make DOS line endings look Unix-like */ - if (((char)curr_char)=='\n') - { - if (pos<1 || ((char)prev_char)!='\\') - break; - pos--; /* throw away the backslash */ - prev_char = '\0'; - continue; - } - prev_char = curr_char; - - line[pos++] = (char)curr_char; - if ((pos+1)>=len) - { - len += INC_LEN; - line = xrealloc(line,len); - } - } - - if (curr_char==EOF && pos<1) /* not even an empty line */ - { - xfree(line); - return NULL; - } - - if (pos+1='\000' && str[i]<'\040')) && - (!allow_nl || (str[i]!='\r' && str[i]!='\n'))) - fprintf(fp,"^%c",str[i]+64); - else - fputc((int)str[i],fp); - - return 0; -} - - -extern int str_get_bool(char const * str) -{ - if (!str) - return -1; - - if (strcasecmp(str,"true")==0 || - strcasecmp(str,"yes")==0 || - strcasecmp(str,"on")==0 || - strcmp(str,"1")==0) - return 1; - - if (strcasecmp(str,"false")==0 || - strcasecmp(str,"no")==0 || - strcasecmp(str,"off")==0 || - strcmp(str,"0")==0) - return 0; - - return -1; -} - - -extern char const * seconds_to_timestr(unsigned int totsecs) -{ - static char temp[256]; - int days; - int hours; - int minutes; - int seconds; - - days = totsecs/(24*60*60); - hours = totsecs/(60*60) - days*24; - minutes = totsecs/60 - days*24*60 - hours*60; - seconds = totsecs - days*24*60*60 - hours*60*60 - minutes*60; - - if (days>0) - sprintf(temp,"%d day%s %d hour%s %d minute%s %d second%s", - days,days==1 ? "" : "s", - hours,hours==1 ? "" : "s", - minutes,minutes==1 ? "" : "s", - seconds,seconds==1 ? "" : "s"); - else if (hours>0) - sprintf(temp,"%d hour%s %d minute%s %d second%s", - hours,hours==1 ? "" : "s", - minutes,minutes==1 ? "" : "s", - seconds,seconds==1 ? "" : "s"); - else if (minutes>0) - sprintf(temp,"%d minute%s %d second%s", - minutes,minutes==1 ? "" : "s", - seconds,seconds==1 ? "" : "s"); - else - sprintf(temp,"%d second%s.", - seconds,seconds==1 ? "" : "s"); - - return temp; -} - - -extern int clockstr_to_seconds(char const * clockstr, unsigned int * totsecs) -{ - unsigned int i,j; - unsigned int temp; - - if (!clockstr) - return -1; - if (!totsecs) - return -1; - - for (i=j=temp=0; j= len*3+1 then the buffer was overflowed */ - out[outpos] = '\0'; - - return out; -} - - -extern char * escape_chars(char const * in, unsigned int len) -{ - char * out; - unsigned int inpos; - unsigned int outpos; - - if (!in) - return NULL; - out = xmalloc(len*4+1); /* if all turn into \xxx */ - - for (inpos=0,outpos=0; inpos= len*4+1 then the buffer was overflowed */ - out[outpos] = '\0'; - - return out; -} - - -extern char * unescape_chars(char const * in) -{ - char * out; - unsigned int inpos; - unsigned int outpos; - - if (!in) - return NULL; - out = xmalloc(strlen(in)+1); - - for (inpos=0,outpos=0; inpos255) /* bad escape (including \000), leave it as-is */ - { - out[outpos++] = '\\'; - strcpy(&out[outpos],temp); - outpos += strlen(temp); - } - else - out[outpos++] = (unsigned char)num; - } - } - } - out[outpos] = '\0'; - - return out; -} - - -extern void str_to_hex(char * target, char * data, int datalen) -{ - unsigned char c; - int i; - for (i = 0; i < datalen; i++) - { - c = (data[i]) & 0xff; - - sprintf(target + i*3, "%02X ", c); - target[i*3+3] = '\0'; - - /* fprintf(stderr, "str_to_hex %d | '%02x' '%s'\n", i, c, target); */ - } -} - - -extern int hex_to_str(char const * source, char * data, int datalen) -{ - /* - * TODO: We really need a more robust function here, - * for now, I'll just use this hack for a quick evaluation - */ - char byte; - char c; - int i; - - for (i = 0; i < datalen; i++) - { - byte = 0; - - /* fprintf(stderr, "hex_to_str %d | '%02x'", i, byte); */ - - c = source [i*3 + 0]; - byte += 16 * ( c > '9' ? (c - 'A' + 10) : (c - '0')); - - /* fprintf(stderr, " | '%c' '%02x'", c, byte); */ - - c = source [i*3 + 1]; - byte += 1 * ( c > '9' ? (c - 'A' + 10) : (c - '0')); - - /* fprintf(stderr, " | '%c' '%02x'", c, byte); */ - - /* fprintf(stderr, "\n"); */ - - data[i] = byte; - } - - /* fprintf(stderr, "finished, returning %d from '%s'\n", i, source); */ - - return i; -} diff --git a/d2pack109/src/common/util.h b/d2pack109/src/common/util.h deleted file mode 100644 index 194bf65..0000000 --- a/d2pack109/src/common/util.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 1998,1999,2000 Ross Combs (rocombs@cs.nmsu.edu) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - - -/*****/ -#ifndef JUST_NEED_TYPES -#ifndef INCLUDED_UTIL_PROTOS -#define INCLUDED_UTIL_PROTOS - -#define JUST_NEED_TYPES -#include -#undef JUST_NEED_TYPES - -extern int strstart(char const * full, char const * part) ; -extern char * file_get_line(FILE * fp) ; -extern char * strreverse(char * str); -extern int str_to_uint(char const * str, unsigned int * num); -extern int str_to_ushort(char const * str, unsigned short * num); -extern int str_print_term(FILE * fp, char const * str, unsigned int len, int allow_nl); -extern int str_get_bool(char const * str) ; -extern char const * seconds_to_timestr(unsigned int totsecs); /* FIXME: can this be marked pure? */ -extern int clockstr_to_seconds(char const * clockstr, unsigned int * totsecs); -extern char * escape_fs_chars(char const * in, unsigned int len) ; -extern char * escape_chars(char const * in, unsigned int len) ; -extern char * unescape_chars(char const * in) ; -extern void str_to_hex(char * target, char * data, int datalen); -extern int hex_to_str(char const * source, char * data, int datalen); - -#endif -#endif diff --git a/d2pack109/src/common/version.h b/d2pack109/src/common/version.h deleted file mode 100644 index 68a7cb5..0000000 --- a/d2pack109/src/common/version.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef PVPGN_VERSION -#define PVPGN_VERSION "0.7-CVS" -#endif -#ifndef PVPGN_SOFTWARE -#define PVPGN_SOFTWARE "PvPGN D2Pack109" -#endif diff --git a/d2pack109/src/common/xalloc.c b/d2pack109/src/common/xalloc.c deleted file mode 100644 index 5e8eb29..0000000 --- a/d2pack109/src/common/xalloc.c +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright (C) 2004 Dizzy (dizzy@roedu.net) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "common/setup_before.h" -#ifndef XALLOC_SKIP - -#ifdef HAVE_STDDEF_H -# include -#endif -#ifdef STDC_HEADERS -# include -#else -# ifdef HAVE_MALLOC_H -# include -# endif -#endif -#ifdef HAVE_STRING_H -# include -#else -# ifdef HAVE_STRINGS_H -# include -# endif -#endif -#include "compat/strdup.h" -#include "common/eventlog.h" -#include "common/xalloc.h" -#define XALLOC_INTERNAL_ACCESS -#include "common/setup_after.h" -#undef XALLOC_INTERNAL_ACCESS - -static t_oom_cb oom_cb = NULL; - -void *xmalloc_real(size_t size, const char *fn, unsigned ln) -{ - void *res; - - res = malloc(size); - if (!res) { - eventlog(eventlog_level_fatal, __FUNCTION__, "out of memory (from %s:%u)",fn,ln); - if (oom_cb && oom_cb() && (res = malloc(size))) return res; - abort(); - } - - return res; -} - -void *xcalloc_real(size_t nmemb, size_t size, const char *fn, unsigned ln) -{ - void *res; - - res = calloc(nmemb,size); - if (!res) { - eventlog(eventlog_level_fatal, __FUNCTION__, "out of memory (from %s:%u)",fn,ln); - if (oom_cb && oom_cb() && (res = calloc(nmemb,size))) return res; - abort(); - } - - return res; -} - -void *xrealloc_real(void *ptr, size_t size, const char *fn, unsigned ln) -{ - void *res; - - res = realloc(ptr,size); - if (!res) { - eventlog(eventlog_level_fatal, __FUNCTION__, "out of memory (from %s:%u)",fn,ln); - if (oom_cb && oom_cb() && (res = realloc(ptr,size))) return res; - abort(); - } - - return res; -} - -char *xstrdup_real(const char *str, const char *fn, unsigned ln) -{ - char *res; - - res = strdup(str); - if (!res) { - eventlog(eventlog_level_fatal, __FUNCTION__, "out of memory (from %s:%u)",fn,ln); - if (oom_cb && oom_cb() && (res = strdup(str))) return res; - abort(); - } - - return res; -} - -void xfree_real(void *ptr, const char *fn, unsigned ln) -{ - if (!ptr) { - eventlog(eventlog_level_error, __FUNCTION__, "got NULL ptr (from %s:%u)",fn,ln); - return; - } - - free(ptr); -} - -void xalloc_setcb(t_oom_cb cb) -{ - oom_cb = cb; -} - -#endif /* XALLOC_SKIP */ diff --git a/d2pack109/src/common/xalloc.h b/d2pack109/src/common/xalloc.h deleted file mode 100644 index b409944..0000000 --- a/d2pack109/src/common/xalloc.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (C) 2004 Dizzy (dizzy@roedu.net) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef INCLUDED_XALLOC_TYPES - -/* out of memory callback function */ -typedef int (*t_oom_cb)(void); - -#define INCLUDED_XALLOC_TYPES - -#endif /* INCLUDED_XALLOC_TYPES */ - -#ifndef INCLUDED_XALLOC_PROTOS -#define INCLUDED_XALLOC_PROTOS - -#ifdef HAVE_STDDEF_H -# include -#endif -#ifdef STDC_HEADERS -# include -#else -# ifdef HAVE_MALLOC_H -# include -# endif -#endif - -#ifndef XALLOC_SKIP - -#define xmalloc(size) xmalloc_real(size,__FILE__,__LINE__) -void *xmalloc_real(size_t size, const char *fn, unsigned ln); -#define xcalloc(no,size) xcalloc_real(no,size,__FILE__,__LINE__) -void *xcalloc_real(size_t nmemb, size_t size, const char *fn, unsigned ln); -#define xrealloc(ptr,size) xrealloc_real(ptr,size,__FILE__,__LINE__) -void *xrealloc_real(void *ptr, size_t size, const char *fn, unsigned ln); -#define xstrdup(str) xstrdup_real(str,__FILE__,__LINE__) -char *xstrdup_real(const char *str, const char *fn, unsigned ln); -#define xfree(ptr) xfree_real(ptr,__FILE__,__LINE__) -void xfree_real(void *ptr, const char *fn, unsigned ln); -void xalloc_setcb(t_oom_cb cb); - -#else /* XALLOC_SKIP */ - -#define xmalloc(size) malloc(size) -#define xcalloc(no,size) calloc(no,size) -#define xrealloc(ptr,size) realloc(ptr,size) -#define xstrdup(str) strdup(str) -#define xfree(ptr) free(ptr) -#define xalloc_setcb(cb) - -#endif - -#endif /* INCLUDED_XALLOC_PROTOS */ diff --git a/d2pack109/src/compat/access.h b/d2pack109/src/compat/access.h deleted file mode 100644 index 079d3ff..0000000 --- a/d2pack109/src/compat/access.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 1999 Ross Combs (rocombs@cs.nmsu.edu) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_ACCESS_PROTOS -#define INCLUDED_ACCESS_PROTOS - -#ifdef WIN32 -# include -/* Values for the second argument to access. These may be OR'd together. */ -# define R_OK 4 /* Test for read permission. */ -# define W_OK 2 /* Test for write permission. */ -# define X_OK 1 /* Test for execute permission. */ -# define F_OK 0 /* Test for existence. */ -#endif - -#endif diff --git a/d2pack109/src/compat/char_bit.h b/d2pack109/src/compat/char_bit.h deleted file mode 100644 index 8a32ff6..0000000 --- a/d2pack109/src/compat/char_bit.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2000,2001 Ross Combs (rocombs@cs.nmsu.edu) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_CHAR_BIT_TYPES -#define INCLUDED_CHAR_BIT_TYPES - -# ifdef HAVE_LIMITS_H -# include -# endif -# ifdef HAVE_SYS_PARAM_H -# include -# endif -# ifndef CHAR_BIT -# ifdef NBBY -# define CHAR_BIT NBBY -# else -# define CHAR_BIT 8 /* well, this is usually true :) */ -# endif -# endif - -#endif diff --git a/d2pack109/src/compat/difftime.c b/d2pack109/src/compat/difftime.c deleted file mode 100644 index be649c8..0000000 --- a/d2pack109/src/compat/difftime.c +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2000 Ross Combs (rocombs@cs.nmsu.edu) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#include "common/setup_before.h" -#ifndef HAVE_DIFFTIME - -#ifdef TIME_WITH_SYS_TIME -# include -# include -#else -# ifdef HAVE_SYS_TIME_H -# include -# else -# include -# endif -#endif -#include "difftime.h" -#include "common/setup_after.h" - - -extern double difftime(time_t after, time_t before) -{ - return ((double)after)-((double)before); -} - -#else -typedef int filenotempty; /* make ISO standard happy */ -#endif diff --git a/d2pack109/src/compat/difftime.h b/d2pack109/src/compat/difftime.h deleted file mode 100644 index 367d997..0000000 --- a/d2pack109/src/compat/difftime.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (C) 2000 Ross Combs (rocombs@cs.nmsu.edu) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_DIFFTIME_PROTOS -#define INCLUDED_DIFFTIME_PROTOS - -#ifndef HAVE_DIFFTIME - -#ifdef TIME_WITH_SYS_TIME -# include -# include -#else -# ifdef HAVE_SYS_TIME_H -# include -# else -# include -# endif -#endif - -extern double difftime(time_t after, time_t before); - -#endif - -#endif diff --git a/d2pack109/src/compat/exitstatus.h b/d2pack109/src/compat/exitstatus.h deleted file mode 100644 index 429de58..0000000 --- a/d2pack109/src/compat/exitstatus.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2000 Ross Combs (rocombs@cs.nmsu.edu) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_EXITSTATUS_PROTOS -#define INCLUDED_EXITSTATUS_PROTOS - -#ifdef EXIT_FAILURE -# if !EXIT_FAILURE -# define STATUS_FAILURE 1 -# else -# define STATUS_FAILURE EXIT_FAILURE -# endif -#else -# define STATUS_FAILURE 1 -#endif - -#ifdef EXIT_SUCCESS -# define STATUS_SUCCESS EXIT_SUCCESS -#else -# define STATUS_SUCCESS 0 -#endif - -#endif diff --git a/d2pack109/src/compat/gethostname.h b/d2pack109/src/compat/gethostname.h deleted file mode 100644 index 4ff4071..0000000 --- a/d2pack109/src/compat/gethostname.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 1999 Ross Combs (rocombs@cs.nmsu.edu) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_GETHOSTNAME_PROTOS -#define INCLUDED_GETHOSTNAME_PROTOS - -/* - * This is from unistd.h on Unix systems, but it's included with - * the socket stuff under Windows. This tries to hide that. - */ - -#ifdef WIN32 -# include -#endif - -#ifndef HAVE_GETHOSTNAME -# error "This program requires gethostname()" -#endif - -#endif diff --git a/d2pack109/src/compat/getopt.c b/d2pack109/src/compat/getopt.c deleted file mode 100644 index 20e06eb..0000000 --- a/d2pack109/src/compat/getopt.c +++ /dev/null @@ -1,1009 +0,0 @@ -/* Getopt for GNU. - NOTE: getopt is now part of the C library, so if you don't know what - "Keep this file name-space clean" means, talk to roland@gnu.ai.mit.edu - before changing it! - - Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97 - Free Software Foundation, Inc. - - This file is part of the GNU C Library. Its master source is NOT part of - the C library, however. The master source lives in /gd/gnu/lib. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -#ifndef __WIN32__ /* caused problems/warnings compiling on bcc/vs.net otherwise */ -#include -#endif - -/* This tells Alpha OSF/1 not to define a getopt prototype in . - Ditto for AIX 3.2 and . */ -#ifndef _NO_PROTO -#define _NO_PROTO -#endif - - -#ifndef HAVE_GETOPT - -#if !defined (__STDC__) || !__STDC__ -/* This is a separate conditional since some stdc systems - reject `defined (const)'. */ -#ifndef const -#define const -#endif -#endif - -#include -#include - - -/* Comment out all this code if we are using the GNU C Library, and are not - actually compiling the library itself. This code is part of the GNU C - Library, but also included in many other GNU distributions. Compiling - and linking in this code is a waste when using the GNU C library - (especially if it is a shared library). Rather than having every GNU - program understand `configure --with-gnu-libc' and omit the object files, - it is simpler to just do this in the source for each such file. */ - -#define GETOPT_INTERFACE_VERSION 2 -#if !defined (_LIBC) && defined (__GLIBC__) && __GLIBC__ >= 2 -#include -#if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION -#define ELIDE_CODE -#endif -#endif - -#ifndef ELIDE_CODE - - -/* This needs to come after some library #include - to get __GNU_LIBRARY__ defined. */ -#ifdef __GNU_LIBRARY__ -/* Don't include stdlib.h for non-GNU C libraries because some of them - contain conflicting prototypes for getopt. */ -#include -#include -#endif /* GNU C library. */ - -#ifdef VMS -#include -#if HAVE_STRING_H - 0 -#include -#endif -#endif - -#if defined (WIN32) && !defined (__CYGWIN32__) -/* It's not Unix, really. See? Capital letters. */ -#include -#define getpid() GetCurrentProcessId() -#endif - -#ifndef _ -/* This is for other GNU distributions with internationalized messages. - When compiling libc, the _ macro is predefined. */ -#ifdef HAVE_LIBINTL_H -# include -# define _(msgid) gettext (msgid) -#else -# define _(msgid) (msgid) -#endif -#endif - -/* This version of `getopt' appears to the caller like standard Unix `getopt' - but it behaves differently for the user, since it allows the user - to intersperse the options with the other arguments. - - As `getopt' works, it permutes the elements of ARGV so that, - when it is done, all the options precede everything else. Thus - all application programs are extended to handle flexible argument order. - - Setting the environment variable POSIXLY_CORRECT disables permutation. - Then the behavior is completely standard. - - GNU application programs can use a third alternative mode in which - they can distinguish the relative order of options and other arguments. */ - -#include "getopt.h" - -#include "common/setup_after.h" - -/* For communication from `getopt' to the caller. - When `getopt' finds an option that takes an argument, - the argument value is returned here. - Also, when `ordering' is RETURN_IN_ORDER, - each non-option ARGV-element is returned here. */ - -char *optarg = NULL; - -/* Index in ARGV of the next element to be scanned. - This is used for communication to and from the caller - and for communication between successive calls to `getopt'. - - On entry to `getopt', zero means this is the first call; initialize. - - When `getopt' returns -1, this is the index of the first of the - non-option elements that the caller should itself scan. - - Otherwise, `optind' communicates from one call to the next - how much of ARGV has been scanned so far. */ - -/* 1003.2 says this must be 1 before any call. */ -int optind = 1; - -/* Formerly, initialization of getopt depended on optind==0, which - causes problems with re-calling getopt as programs generally don't - know that. */ - -int __getopt_initialized = 0; - -/* The next char to be scanned in the option-element - in which the last option character we returned was found. - This allows us to pick up the scan where we left off. - - If this is zero, or a null string, it means resume the scan - by advancing to the next ARGV-element. */ - -static char *nextchar; - -/* Callers store zero here to inhibit the error message - for unrecognized options. */ - -int opterr = 1; - -/* Set to an option character which was unrecognized. - This must be initialized on some systems to avoid linking in the - system's own getopt implementation. */ - -int optopt = '?'; - -/* Describe how to deal with options that follow non-option ARGV-elements. - - If the caller did not specify anything, - the default is REQUIRE_ORDER if the environment variable - POSIXLY_CORRECT is defined, PERMUTE otherwise. - - REQUIRE_ORDER means don't recognize them as options; - stop option processing when the first non-option is seen. - This is what Unix does. - This mode of operation is selected by either setting the environment - variable POSIXLY_CORRECT, or using `+' as the first character - of the list of option characters. - - PERMUTE is the default. We permute the contents of ARGV as we scan, - so that eventually all the non-options are at the end. This allows options - to be given in any order, even with programs that were not written to - expect this. - - RETURN_IN_ORDER is an option available to programs that were written - to expect options and other ARGV-elements in any order and that care about - the ordering of the two. We describe each non-option ARGV-element - as if it were the argument of an option with character code 1. - Using `-' as the first character of the list of option characters - selects this mode of operation. - - The special argument `--' forces an end of option-scanning regardless - of the value of `ordering'. In the case of RETURN_IN_ORDER, only - `--' can cause `getopt' to return -1 with `optind' != ARGC. */ - -static enum -{ - REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER -} ordering; - -/* Value of POSIXLY_CORRECT environment variable. */ -static char *posixly_correct; - -#ifdef __GNU_LIBRARY__ -/* We want to avoid inclusion of string.h with non-GNU libraries - because there are many ways it can cause trouble. - On some systems, it contains special magic macros that don't work - in GCC. */ -#include -#define my_index strchr -#else - -/* Avoid depending on library functions or files - whose names are inconsistent. */ - -char *getenv (); - -static char * -my_index (str, chr) - const char *str; - int chr; -{ - while (*str) - { - if (*str == chr) - return (char *) str; - str++; - } - return 0; -} - -/* If using GCC, we can safely declare strlen this way. - If not using GCC, it is ok not to declare it. */ -#ifdef __GNUC__ -/* Note that Motorola Delta 68k R3V7 comes with GCC but not stddef.h. - That was relevant to code that was here before. */ -#if !defined (__STDC__) || !__STDC__ -/* gcc with -traditional declares the built-in strlen to return int, - and has done so at least since version 2.4.5. -- rms. */ -extern int strlen (const char *); -#endif /* not __STDC__ */ -#endif /* __GNUC__ */ - -#endif /* not __GNU_LIBRARY__ */ - -/* Handle permutation of arguments. */ - -/* Describe the part of ARGV that contains non-options that have - been skipped. `first_nonopt' is the index in ARGV of the first of them; - `last_nonopt' is the index after the last of them. */ - -static int first_nonopt; -static int last_nonopt; - -#ifdef _LIBC -/* Bash 2.0 gives us an environment variable containing flags - indicating ARGV elements that should not be considered arguments. */ - -static const char *nonoption_flags; -static int nonoption_flags_len; - -static int original_argc; -static char *const *original_argv; - -/* Make sure the environment variable bash 2.0 puts in the environment - is valid for the getopt call we must make sure that the ARGV passed - to getopt is that one passed to the process. */ -static void store_args (int argc, char *const *argv) __attribute__ ((unused)); -static void -store_args (int argc, char *const *argv) -{ - /* XXX This is no good solution. We should rather copy the args so - that we can compare them later. But we must not use malloc(3). */ - original_argc = argc; - original_argv = argv; -} -text_set_element (__libc_subinit, store_args); -#endif - -/* Exchange two adjacent subsequences of ARGV. - One subsequence is elements [first_nonopt,last_nonopt) - which contains all the non-options that have been skipped so far. - The other is elements [last_nonopt,optind), which contains all - the options processed since those non-options were skipped. - - `first_nonopt' and `last_nonopt' are relocated so that they describe - the new indices of the non-options in ARGV after they are moved. */ - -#if defined (__STDC__) && __STDC__ -static void exchange (char **); -#endif - -static void -exchange (argv) - char **argv; -{ - int bottom = first_nonopt; - int middle = last_nonopt; - int top = optind; - char *tem; - - /* Exchange the shorter segment with the far end of the longer segment. - That puts the shorter segment into the right place. - It leaves the longer segment in the right place overall, - but it consists of two parts that need to be swapped next. */ - - while (top > middle && middle > bottom) - { - if (top - middle > middle - bottom) - { - /* Bottom segment is the short one. */ - int len = middle - bottom; - register int i; - - /* Swap it with the top part of the top segment. */ - for (i = 0; i < len; i++) - { - tem = argv[bottom + i]; - argv[bottom + i] = argv[top - (middle - bottom) + i]; - argv[top - (middle - bottom) + i] = tem; - } - /* Exclude the moved bottom segment from further swapping. */ - top -= len; - } - else - { - /* Top segment is the short one. */ - int len = top - middle; - register int i; - - /* Swap it with the bottom part of the bottom segment. */ - for (i = 0; i < len; i++) - { - tem = argv[bottom + i]; - argv[bottom + i] = argv[middle + i]; - argv[middle + i] = tem; - } - /* Exclude the moved top segment from further swapping. */ - bottom += len; - } - } - - /* Update records for the slots the non-options now occupy. */ - - first_nonopt += (optind - last_nonopt); - last_nonopt = optind; -} - -/* Initialize the internal data when the first call is made. */ - -#if defined (__STDC__) && __STDC__ -static const char *_getopt_initialize (int, char *const *, const char *); -#endif -static const char * -_getopt_initialize (argc, argv, optstring) - int argc; - char *const *argv; - const char *optstring; -{ - /* Start processing options with ARGV-element 1 (since ARGV-element 0 - is the program name); the sequence of previously skipped - non-option ARGV-elements is empty. */ - - first_nonopt = last_nonopt = optind = 1; - - nextchar = NULL; - - posixly_correct = getenv ("POSIXLY_CORRECT"); - - /* Determine how to handle the ordering of options and nonoptions. */ - - if (optstring[0] == '-') - { - ordering = RETURN_IN_ORDER; - ++optstring; - } - else if (optstring[0] == '+') - { - ordering = REQUIRE_ORDER; - ++optstring; - } - else if (posixly_correct != NULL) - ordering = REQUIRE_ORDER; - else - ordering = PERMUTE; - -#ifdef _LIBC - if (posixly_correct == NULL - && argc == original_argc && argv == original_argv) - { - /* Bash 2.0 puts a special variable in the environment for each - command it runs, specifying which ARGV elements are the results of - file name wildcard expansion and therefore should not be - considered as options. */ - char var[100]; - sprintf (var, "_%d_GNU_nonoption_argv_flags_", getpid ()); - nonoption_flags = getenv (var); - if (nonoption_flags == NULL) - nonoption_flags_len = 0; - else - nonoption_flags_len = strlen (nonoption_flags); - } - else - nonoption_flags_len = 0; -#endif - - return optstring; -} - -/* Scan elements of ARGV (whose length is ARGC) for option characters - given in OPTSTRING. - - If an element of ARGV starts with '-', and is not exactly "-" or "--", - then it is an option element. The characters of this element - (aside from the initial '-') are option characters. If `getopt' - is called repeatedly, it returns successively each of the option characters - from each of the option elements. - - If `getopt' finds another option character, it returns that character, - updating `optind' and `nextchar' so that the next call to `getopt' can - resume the scan with the following option character or ARGV-element. - - If there are no more option characters, `getopt' returns -1. - Then `optind' is the index in ARGV of the first ARGV-element - that is not an option. (The ARGV-elements have been permuted - so that those that are not options now come last.) - - OPTSTRING is a string containing the legitimate option characters. - If an option character is seen that is not listed in OPTSTRING, - return '?' after printing an error message. If you set `opterr' to - zero, the error message is suppressed but we still return '?'. - - If a char in OPTSTRING is followed by a colon, that means it wants an arg, - so the following text in the same ARGV-element, or the text of the following - ARGV-element, is returned in `optarg'. Two colons mean an option that - wants an optional arg; if there is text in the current ARGV-element, - it is returned in `optarg', otherwise `optarg' is set to zero. - - If OPTSTRING starts with `-' or `+', it requests different methods of - handling the non-option ARGV-elements. - See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above. - - Long-named options begin with `--' instead of `-'. - Their names may be abbreviated as long as the abbreviation is unique - or is an exact match for some defined option. If they have an - argument, it follows the option name in the same ARGV-element, separated - from the option name by a `=', or else the in next ARGV-element. - When `getopt' finds a long-named option, it returns 0 if that option's - `flag' field is nonzero, the value of the option's `val' field - if the `flag' field is zero. - - The elements of ARGV aren't really const, because we permute them. - But we pretend they're const in the prototype to be compatible - with other systems. - - LONGOPTS is a vector of `struct option' terminated by an - element containing a name which is zero. - - LONGIND returns the index in LONGOPT of the long-named option found. - It is only valid when a long-named option has been found by the most - recent call. - - If LONG_ONLY is nonzero, '-' as well as '--' can introduce - long-named options. */ - -int -_getopt_internal (argc, argv, optstring, longopts, longind, long_only) - int argc; - char *const *argv; - const char *optstring; - const struct option *longopts; - int *longind; - int long_only; -{ - optarg = NULL; - - if (!__getopt_initialized || optind == 0) - { - optstring = _getopt_initialize (argc, argv, optstring); - optind = 1; /* Don't scan ARGV[0], the program name. */ - __getopt_initialized = 1; - } - - /* Test whether ARGV[optind] points to a non-option argument. - Either it does not have option syntax, or there is an environment flag - from the shell indicating it is not an option. The later information - is only used when the used in the GNU libc. */ -#ifdef _LIBC -#define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0' \ - || (optind < nonoption_flags_len \ - && nonoption_flags[optind] == '1')) -#else -#define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0') -#endif - - if (nextchar == NULL || *nextchar == '\0') - { - /* Advance to the next ARGV-element. */ - - /* Give FIRST_NONOPT & LAST_NONOPT rational values if OPTIND has been - moved back by the user (who may also have changed the arguments). */ - if (last_nonopt > optind) - last_nonopt = optind; - if (first_nonopt > optind) - first_nonopt = optind; - - if (ordering == PERMUTE) - { - /* If we have just processed some options following some non-options, - exchange them so that the options come first. */ - - if (first_nonopt != last_nonopt && last_nonopt != optind) - exchange ((char **) argv); - else if (last_nonopt != optind) - first_nonopt = optind; - - /* Skip any additional non-options - and extend the range of non-options previously skipped. */ - - while (optind < argc && NONOPTION_P) - optind++; - last_nonopt = optind; - } - - /* The special ARGV-element `--' means premature end of options. - Skip it like a null option, - then exchange with previous non-options as if it were an option, - then skip everything else like a non-option. */ - - if (optind != argc && !strcmp (argv[optind], "--")) - { - optind++; - - if (first_nonopt != last_nonopt && last_nonopt != optind) - exchange ((char **) argv); - else if (first_nonopt == last_nonopt) - first_nonopt = optind; - last_nonopt = argc; - - optind = argc; - } - - /* If we have done all the ARGV-elements, stop the scan - and back over any non-options that we skipped and permuted. */ - - if (optind == argc) - { - /* Set the next-arg-index to point at the non-options - that we previously skipped, so the caller will digest them. */ - if (first_nonopt != last_nonopt) - optind = first_nonopt; - return -1; - } - - /* If we have come to a non-option and did not permute it, - either stop the scan or describe it to the caller and pass it by. */ - - if (NONOPTION_P) - { - if (ordering == REQUIRE_ORDER) - return -1; - optarg = argv[optind++]; - return 1; - } - - /* We have found another option-ARGV-element. - Skip the initial punctuation. */ - - nextchar = (argv[optind] + 1 - + (longopts != NULL && argv[optind][1] == '-')); - } - - /* Decode the current option-ARGV-element. */ - - /* Check whether the ARGV-element is a long option. - - If long_only and the ARGV-element has the form "-f", where f is - a valid short option, don't consider it an abbreviated form of - a long option that starts with f. Otherwise there would be no - way to give the -f short option. - - On the other hand, if there's a long option "fubar" and - the ARGV-element is "-fu", do consider that an abbreviation of - the long option, just like "--fu", and not "-f" with arg "u". - - This distinction seems to be the most useful approach. */ - - if (longopts != NULL - && (argv[optind][1] == '-' - || (long_only && (argv[optind][2] || !my_index (optstring, argv[optind][1]))))) - { - char *nameend; - const struct option *p; - const struct option *pfound = NULL; - int exact = 0; - int ambig = 0; - int indfound = -1; - int option_index; - - for (nameend = nextchar; *nameend && *nameend != '='; nameend++) - /* Do nothing. */ ; - - /* Test all long options for either exact match - or abbreviated matches. */ - for (p = longopts, option_index = 0; p->name; p++, option_index++) - if (!strncmp (p->name, nextchar, nameend - nextchar)) - { - if ((unsigned int) (nameend - nextchar) - == (unsigned int) strlen (p->name)) - { - /* Exact match found. */ - pfound = p; - indfound = option_index; - exact = 1; - break; - } - else if (pfound == NULL) - { - /* First nonexact match found. */ - pfound = p; - indfound = option_index; - } - else - /* Second or later nonexact match found. */ - ambig = 1; - } - - if (ambig && !exact) - { - if (opterr) - fprintf (stderr, _("%s: option `%s' is ambiguous\n"), - argv[0], argv[optind]); - nextchar += strlen (nextchar); - optind++; - optopt = 0; - return '?'; - } - - if (pfound != NULL) - { - option_index = indfound; - optind++; - if (*nameend) - { - /* Don't test has_arg with >, because some C compilers don't - allow it to be used on enums. */ - if (pfound->has_arg) - optarg = nameend + 1; - else - { - if (opterr) - if (argv[optind - 1][1] == '-') - /* --option */ - fprintf (stderr, - _("%s: option `--%s' doesn't allow an argument\n"), - argv[0], pfound->name); - else - /* +option or -option */ - fprintf (stderr, - _("%s: option `%c%s' doesn't allow an argument\n"), - argv[0], argv[optind - 1][0], pfound->name); - - nextchar += strlen (nextchar); - - optopt = pfound->val; - return '?'; - } - } - else if (pfound->has_arg == 1) - { - if (optind < argc) - optarg = argv[optind++]; - else - { - if (opterr) - fprintf (stderr, - _("%s: option `%s' requires an argument\n"), - argv[0], argv[optind - 1]); - nextchar += strlen (nextchar); - optopt = pfound->val; - return optstring[0] == ':' ? ':' : '?'; - } - } - nextchar += strlen (nextchar); - if (longind != NULL) - *longind = option_index; - if (pfound->flag) - { - *(pfound->flag) = pfound->val; - return 0; - } - return pfound->val; - } - - /* Can't find it as a long option. If this is not getopt_long_only, - or the option starts with '--' or is not a valid short - option, then it's an error. - Otherwise interpret it as a short option. */ - if (!long_only || argv[optind][1] == '-' - || my_index (optstring, *nextchar) == NULL) - { - if (opterr) - { - if (argv[optind][1] == '-') - /* --option */ - fprintf (stderr, _("%s: unrecognized option `--%s'\n"), - argv[0], nextchar); - else - /* +option or -option */ - fprintf (stderr, _("%s: unrecognized option `%c%s'\n"), - argv[0], argv[optind][0], nextchar); - } - nextchar = (char *) ""; - optind++; - optopt = 0; - return '?'; - } - } - - /* Look at and handle the next short option-character. */ - - { - char c = *nextchar++; - char *temp = my_index (optstring, c); - - /* Increment `optind' when we start to process its last character. */ - if (*nextchar == '\0') - ++optind; - - if (temp == NULL || c == ':') - { - if (opterr) - { - if (posixly_correct) - /* 1003.2 specifies the format of this message. */ - fprintf (stderr, _("%s: illegal option -- %c\n"), - argv[0], c); - else - fprintf (stderr, _("%s: invalid option -- %c\n"), - argv[0], c); - } - optopt = c; - return '?'; - } - /* Convenience. Treat POSIX -W foo same as long option --foo */ - if (temp[0] == 'W' && temp[1] == ';') - { - char *nameend; - const struct option *p; - const struct option *pfound = NULL; - int exact = 0; - int ambig = 0; - int indfound = 0; - int option_index; - - /* This is an option that requires an argument. */ - if (*nextchar != '\0') - { - optarg = nextchar; - /* If we end this ARGV-element by taking the rest as an arg, - we must advance to the next element now. */ - optind++; - } - else if (optind == argc) - { - if (opterr) - { - /* 1003.2 specifies the format of this message. */ - fprintf (stderr, _("%s: option requires an argument -- %c\n"), - argv[0], c); - } - optopt = c; - if (optstring[0] == ':') - c = ':'; - else - c = '?'; - return c; - } - else - /* We already incremented `optind' once; - increment it again when taking next ARGV-elt as argument. */ - optarg = argv[optind++]; - - /* optarg is now the argument, see if it's in the - table of longopts. */ - - for (nextchar = nameend = optarg; *nameend && *nameend != '='; nameend++) - /* Do nothing. */ ; - - /* Test all long options for either exact match - or abbreviated matches. */ - for (p = longopts, option_index = 0; p->name; p++, option_index++) - if (!strncmp (p->name, nextchar, nameend - nextchar)) - { - if ((unsigned int) (nameend - nextchar) == strlen (p->name)) - { - /* Exact match found. */ - pfound = p; - indfound = option_index; - exact = 1; - break; - } - else if (pfound == NULL) - { - /* First nonexact match found. */ - pfound = p; - indfound = option_index; - } - else - /* Second or later nonexact match found. */ - ambig = 1; - } - if (ambig && !exact) - { - if (opterr) - fprintf (stderr, _("%s: option `-W %s' is ambiguous\n"), - argv[0], argv[optind]); - nextchar += strlen (nextchar); - optind++; - return '?'; - } - if (pfound != NULL) - { - option_index = indfound; - if (*nameend) - { - /* Don't test has_arg with >, because some C compilers don't - allow it to be used on enums. */ - if (pfound->has_arg) - optarg = nameend + 1; - else - { - if (opterr) - fprintf (stderr, _("\ -%s: option `-W %s' doesn't allow an argument\n"), - argv[0], pfound->name); - - nextchar += strlen (nextchar); - return '?'; - } - } - else if (pfound->has_arg == 1) - { - if (optind < argc) - optarg = argv[optind++]; - else - { - if (opterr) - fprintf (stderr, - _("%s: option `%s' requires an argument\n"), - argv[0], argv[optind - 1]); - nextchar += strlen (nextchar); - return optstring[0] == ':' ? ':' : '?'; - } - } - nextchar += strlen (nextchar); - if (longind != NULL) - *longind = option_index; - if (pfound->flag) - { - *(pfound->flag) = pfound->val; - return 0; - } - return pfound->val; - } - nextchar = NULL; - return 'W'; /* Let the application handle it. */ - } - if (temp[1] == ':') - { - if (temp[2] == ':') - { - /* This is an option that accepts an argument optionally. */ - if (*nextchar != '\0') - { - optarg = nextchar; - optind++; - } - else - optarg = NULL; - nextchar = NULL; - } - else - { - /* This is an option that requires an argument. */ - if (*nextchar != '\0') - { - optarg = nextchar; - /* If we end this ARGV-element by taking the rest as an arg, - we must advance to the next element now. */ - optind++; - } - else if (optind == argc) - { - if (opterr) - { - /* 1003.2 specifies the format of this message. */ - fprintf (stderr, - _("%s: option requires an argument -- %c\n"), - argv[0], c); - } - optopt = c; - if (optstring[0] == ':') - c = ':'; - else - c = '?'; - } - else - /* We already incremented `optind' once; - increment it again when taking next ARGV-elt as argument. */ - optarg = argv[optind++]; - nextchar = NULL; - } - } - return c; - } -} - -int -getopt (argc, argv, optstring) - int argc; - char *const *argv; - const char *optstring; -{ - return _getopt_internal (argc, argv, optstring, - (const struct option *) 0, - (int *) 0, - 0); -} - -#endif /* Not ELIDE_CODE. */ - -#ifdef TEST - -/* Compile with -DTEST to make an executable for use in testing - the above definition of `getopt'. */ - -int -main (argc, argv) - int argc; - char **argv; -{ - int c; - int digit_optind = 0; - - while (1) - { - int this_option_optind = optind ? optind : 1; - - c = getopt (argc, argv, "abc:d:0123456789"); - if (c == -1) - break; - - switch (c) - { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - if (digit_optind != 0 && digit_optind != this_option_optind) - printf ("digits occur in two different argv-elements.\n"); - digit_optind = this_option_optind; - printf ("option %c\n", c); - break; - - case 'a': - printf ("option a\n"); - break; - - case 'b': - printf ("option b\n"); - break; - - case 'c': - printf ("option c with value `%s'\n", optarg); - break; - - case '?': - break; - - default: - printf ("?? getopt returned character code 0%o ??\n", c); - } - } - - if (optind < argc) - { - printf ("non-option ARGV-elements: "); - while (optind < argc) - printf ("%s ", argv[optind++]); - printf ("\n"); - } - - exit (0); -} - -#endif /* TEST */ - -#endif /* !HAVE_GETOPT */ diff --git a/d2pack109/src/compat/getopt.h b/d2pack109/src/compat/getopt.h deleted file mode 100644 index 561fa53..0000000 --- a/d2pack109/src/compat/getopt.h +++ /dev/null @@ -1,151 +0,0 @@ -/* Declarations for getopt. - Copyright (C) 1989,90,91,92,93,94,96,97 Free Software Foundation, Inc. - - This file is part of the GNU C Library. Its master source is NOT part of - the C library, however. The master source lives in /gd/gnu/lib. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -#ifndef _PVPGN_GETOPT_H_ -#define _PVPGN_GETOPT_H_ 1 - -#include "common/setup_before.h" - -#ifdef HAVE_UNISTD_H -# include -#endif - -#ifndef HAVE_GETOPT - -#ifdef __cplusplus -extern "C" { -#endif - -/* For communication from `getopt' to the caller. - When `getopt' finds an option that takes an argument, - the argument value is returned here. - Also, when `ordering' is RETURN_IN_ORDER, - each non-option ARGV-element is returned here. */ - -extern char *optarg; - -/* Index in ARGV of the next element to be scanned. - This is used for communication to and from the caller - and for communication between successive calls to `getopt'. - - On entry to `getopt', zero means this is the first call; initialize. - - When `getopt' returns -1, this is the index of the first of the - non-option elements that the caller should itself scan. - - Otherwise, `optind' communicates from one call to the next - how much of ARGV has been scanned so far. */ - -extern int optind; - -/* Callers store zero here to inhibit the error message `getopt' prints - for unrecognized options. */ - -extern int opterr; - -/* Set to an option character which was unrecognized. */ - -extern int optopt; - -/* Describe the long-named options requested by the application. - The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector - of `struct option' terminated by an element containing a name which is - zero. - - The field `has_arg' is: - no_argument (or 0) if the option does not take an argument, - required_argument (or 1) if the option requires an argument, - optional_argument (or 2) if the option takes an optional argument. - - If the field `flag' is not NULL, it points to a variable that is set - to the value given in the field `val' when the option is found, but - left unchanged if the option is not found. - - To have a long-named option do something other than set an `int' to - a compiled-in constant, such as set a value from `optarg', set the - option's `flag' field to zero and its `val' field to a nonzero - value (the equivalent single-letter option character, if there is - one). For long options that have a zero `flag' field, `getopt' - returns the contents of the `val' field. */ - -struct option -{ -#if defined (__STDC__) && __STDC__ - const char *name; -#else - char *name; -#endif - /* has_arg can't be an enum because some compilers complain about - type mismatches in all the code that assumes it is an int. */ - int has_arg; - int *flag; - int val; -}; - -/* Names for the values of the `has_arg' field of `struct option'. */ - -#define no_argument 0 -#define required_argument 1 -#define optional_argument 2 - -#ifdef WIN32 -#define extern -#endif - -#if defined (__STDC__) && __STDC__ -#ifdef __GNU_LIBRARY__ -/* Many other libraries have conflicting prototypes for getopt, with - differences in the consts, in stdlib.h. To avoid compilation - errors, only prototype getopt for the GNU C library. */ -extern int getopt (int argc, char *const *argv, const char *shortopts); -#else /* not __GNU_LIBRARY__ */ -extern int getopt (); -#endif /* __GNU_LIBRARY__ */ -extern int getopt_long (int argc, char *const *argv, const char *shortopts, - const struct option *longopts, int *longind); -extern int getopt_long_only (int argc, char *const *argv, - const char *shortopts, - const struct option *longopts, int *longind); - -/* Internal only. Users should not call this directly. */ -extern int _getopt_internal (int argc, char *const *argv, - const char *shortopts, - const struct option *longopts, int *longind, - int long_only); -#else /* not __STDC__ */ -extern int getopt (); -extern int getopt_long (); -extern int getopt_long_only (); - -extern int _getopt_internal (); -#endif /* __STDC__ */ - -#ifdef WIN32 -#undef extern -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* !HAVE_GETOPT */ - -#endif /* _PVPGN_GETOPT_H_ */ diff --git a/d2pack109/src/compat/gettimeofday.c b/d2pack109/src/compat/gettimeofday.c deleted file mode 100644 index 6633b34..0000000 --- a/d2pack109/src/compat/gettimeofday.c +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (C) 2000 Ross Combs (rocombs@cs.nmsu.edu) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#include "common/setup_before.h" -#ifndef HAVE_GETTIMEOFDAY - -#include -#ifdef TIME_WITH_SYS_TIME -# include -# include -#else -# ifdef HAVE_SYS_TIME_H -# include -# else -# include -# endif -#endif -#ifdef HAVE_SYS_TIMEB_H -# include -#endif -#include "gettimeofday.h" -#include "common/setup_after.h" - - -extern int gettimeofday(struct timeval * tv, struct timezone * tz) -{ -#ifdef HAVE_FTIME - struct timeb tb; -#endif - - if (!tv) - { - errno = EFAULT; - return -1; - } - -#ifdef HAVE_FTIME - tb.millitm = 0; /* apparently the MS CRT version of this doesn't set this member */ - /* FIXME: what would be a more appropriate function for that platform? */ - ftime(&tb); /* FIXME: some versions are void return others int */ - - tv->tv_sec = tb.time; - tv->tv_usec = ((long)tb.millitm)*1000; - if (tz) - { - tz->tz_minuteswest = 0; - tz->tz_dsttime = 0; - } - - return 0; -#else -# error "This program requires either gettimeofday() or ftime()" -#endif -} - -#else -typedef int filenotempty; /* make ISO standard happy */ -#endif diff --git a/d2pack109/src/compat/gettimeofday.h b/d2pack109/src/compat/gettimeofday.h deleted file mode 100644 index 33164ee..0000000 --- a/d2pack109/src/compat/gettimeofday.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) 2000 Ross Combs (rocombs@cs.nmsu.edu) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_GETTIMEOFDAY_TYPES -#define INCLUDED_GETTIMEOFDAY_TYPES - -#ifndef HAVE_GETTIMEOFDAY - -/* FIXME: these might already exist even if gettimeofday() doesn't */ -struct timeval -{ - long tv_sec; - long tv_usec; -}; - - -struct timezone -{ - int tz_minuteswest; - int tz_dsttime; -}; - -#endif - -#endif - - -#ifndef INCLUDED_GETTIMEOFDAY_PROTOS -#define INCLUDED_GETTIMEOFDAY_PROTOS - -#ifndef HAVE_GETTIMEOFDAY -extern int gettimeofday(struct timeval * tv, struct timezone * tz); -#endif - -#endif diff --git a/d2pack109/src/compat/inet_aton.c b/d2pack109/src/compat/inet_aton.c deleted file mode 100644 index 9088313..0000000 --- a/d2pack109/src/compat/inet_aton.c +++ /dev/null @@ -1,183 +0,0 @@ -/* - * ++Copyright++ 1983, 1990, 1993 - * - - * Copyright (c) 1983, 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - - * Portions Copyright (c) 1993 by Digital Equipment Corporation. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies, and that - * the name of Digital Equipment Corporation not be used in advertising or - * publicity pertaining to distribution of the document or software without - * specific, written prior permission. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL - * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT - * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL - * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR - * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS - * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS - * SOFTWARE. - * - - * --Copyright-- - */ -#include "common/setup_before.h" -#ifndef HAVE_INET_ATON - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)inet_addr.c 8.1 (Berkeley) 6/17/93"; -static char rcsid[] = "$Id: inet_aton.c,v 1.1.1.1 2004/03/11 18:57:31 dizzy Exp $"; -#endif /* LIBC_SCCS and not lint */ - -#include -#ifdef HAVE_SYS_TYPES_H -# include -#endif -#ifdef HAVE_SYS_PARAM_H -# include -#endif -#ifdef HAVE_NETINET_IN_H -# include -#endif -#ifdef HAVE_ARPA_INET_H -# include -#endif -#include "compat/socket.h" /* for Win32 address types, maybe there should be compat/netinet_in.h */ -#include "inet_aton.h" -#include "common/setup_after.h" - - -/* - * Check whether "cp" is a valid ASCII representation - * of an Internet address and convert to a binary address. - * Returns 1 if the address is valid, 0 if not. - * This replaces inet_addr, the return value from which - * cannot distinguish between failure and a local wildcard address. - * Only handles IPv4. - * Assumes 32-bit ints. - */ -extern int inet_aton(char const * cp, struct in_addr * addr) -{ - unsigned int val; - int base, n; - char c; - unsigned int parts[4]; - unsigned int *pp = parts; - - c = *cp; - for (;;) { - /* - * Collect number up to ``.''. - * Values are specified as for C: - * 0x=hex, 0=octal, isdigit=decimal. - */ - if (!isdigit((int)c)) - return (0); - val = 0; base = 10; - if (c == '0') { - c = *++cp; - if (c == 'x' || c == 'X') - base = 16, c = *++cp; - else - base = 8; - } - for (;;) { - if (isascii((int)c) && isdigit((int)c)) { - val = (val * base) + (c - '0'); - c = *++cp; - } else if (base == 16 && isascii((int)c) && isxdigit((int)c)) { - val = (val << 4) | - (c + 10 - (islower((int)c) ? 'a' : 'A')); - c = *++cp; - } else - break; - } - if (c == '.') { - /* - * Internet format: - * a.b.c.d - * a.b.c (with c treated as 16 bits) - * a.b (with b treated as 24 bits) - */ - if (pp >= parts + 3) - return (0); - *pp++ = val; - c = *++cp; - } else - break; - } - /* - * Check for trailing characters. - */ - if (c != '\0' && (!isascii((int)c) || !isspace((int)c))) - return (0); - /* - * Concoct the address according to - * the number of parts specified. - */ - n = pp - parts + 1; - switch (n) { - - case 0: - return (0); /* initial nondigit */ - - case 1: /* a -- 32 bits */ - break; - - case 2: /* a.b -- 8.24 bits */ - if (val > 0xffffff) - return (0); - val |= parts[0] << 24; - break; - - case 3: /* a.b.c -- 8.8.16 bits */ - if (val > 0xffff) - return (0); - val |= (parts[0] << 24) | (parts[1] << 16); - break; - - case 4: /* a.b.c.d -- 8.8.8.8 bits */ - if (val > 0xff) - return (0); - val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8); - break; - } - if (addr) - addr->s_addr = htonl(val); - return (1); -} - -#else -typedef int filenotempty; /* make ISO standard happy */ -#endif diff --git a/d2pack109/src/compat/inet_aton.h b/d2pack109/src/compat/inet_aton.h deleted file mode 100644 index 87a5a0a..0000000 --- a/d2pack109/src/compat/inet_aton.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * ++Copyright++ 1983, 1990, 1993 - * - - * Copyright (c) 1983, 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - - * Portions Copyright (c) 1993 by Digital Equipment Corporation. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies, and that - * the name of Digital Equipment Corporation not be used in advertising or - * publicity pertaining to distribution of the document or software without - * specific, written prior permission. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL - * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT - * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL - * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR - * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS - * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS - * SOFTWARE. - * - - * --Copyright-- - */ -#ifndef INCLUDED_INET_ATON_H -#define INCLUDED_INET_ATON_H - -#ifndef HAVE_INET_ATON - -#ifdef HAVE_NETINET_IN_H -# include -#endif -#ifdef HAVE_ARPA_INET_H -# include -#endif - -extern int inet_aton(char const * cp, struct in_addr * addr); - -#endif - -#endif diff --git a/d2pack109/src/compat/inet_ntoa.c b/d2pack109/src/compat/inet_ntoa.c deleted file mode 100644 index 997e52c..0000000 --- a/d2pack109/src/compat/inet_ntoa.c +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (C) 1999 Ross Combs (rocombs@cs.nmsu.edu) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#include "common/setup_before.h" -#ifndef HAVE_INET_NTOA - -#include -#ifdef HAVE_STDDEF_H -# include -#else -# ifndef NULL -# define NULL ((void *)0) -# endif -#endif -#ifdef HAVE_SYS_TYPES -# include -#endif -#ifdef HAVE_SYS_PARAM_H -# include -#endif -#ifdef HAVE_NETINET_IN_H -# include -#endif -#ifdef HAVE_ARPA_INET_H -# include -#endif -#include "inet_ntoa.h" -#include "common/setup_after.h" - - -extern char const * inet_ntoa(struct in_addr const * addr) -{ - static char buff[16]; - unsigned long val; - - if (!addr) - return NULL; - - val = ntohl(addr->s_addr); - sprintf(buff,"%u.%u.%u.%u", - (val>>24)&0xff, - (val>>16)&0xff, - (val>> 8)&0xff, - (val )&0xff); - return buff; -} - -#else -typedef int filenotempty; /* make ISO standard happy */ -#endif diff --git a/d2pack109/src/compat/inet_ntoa.h b/d2pack109/src/compat/inet_ntoa.h deleted file mode 100644 index 2f6e6d0..0000000 --- a/d2pack109/src/compat/inet_ntoa.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 1999 Ross Combs (rocombs@cs.nmsu.edu) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_INET_NTOA_H -#define INCLUDED_INET_NTOA_H - -#ifndef HAVE_INET_NTOA - -#ifdef HAVE_NETINET_IN_H -# include -#endif -#ifdef HAVE_ARPA_INET_H -# include -#endif - -extern char const * inet_ntoa(struct in_addr const * addr); - -#endif - -#endif diff --git a/d2pack109/src/compat/memcpy.c b/d2pack109/src/compat/memcpy.c deleted file mode 100644 index 89151cf..0000000 --- a/d2pack109/src/compat/memcpy.c +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (C) 2000 Ross Combs (rocombs@cs.nmsu.edu) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#include "common/setup_before.h" -#ifndef HAVE_MEMCPY - -#ifdef HAVE_STDDEF_H -# include -#else -# ifndef NULL -# define NULL ((void *)0) -# endif -#endif -#ifdef HAVE_BCOPY -# ifdef HAVE_STRING_H -# include -# endif -# ifdef HAVE_MEMORY_H -# include -# endif -#endif -#include "memcpy.h" -#include "common/setup_after.h" - -extern void * memcpy(void * dest, void const * src, unsigned long n) -{ -#ifdef HAVE_BCOPY - bcopy(src,dest,n); - return dest; -#else -/* very slow, but we don't care */ - unsigned char * td=dest; - unsigned char * ts=src; - unsigned long i; - - if (!td || !ts) - return NULL; - - for (i=0; i -#else -# ifndef NULL -# define NULL ((void *)0) -# endif -#endif -#include "memmove.h" -#include "common/setup_after.h" - -extern void * memmove(void * dest, void const * src, unsigned long n) -{ -/* very slow, but we don't care */ -/* FIXME: does this handle all overlapping cases correctly? */ - unsigned char * td=dest; - const unsigned char * ts=src; - unsigned long i; - - if (!td || !ts) - return NULL; - - for (i=0; i -#else -# ifndef NULL -# define NULL ((void *)0) -# endif -#endif -#include "memset.h" -#include "common/setup_after.h" - -/* very slow, but we don't care */ -extern void * memset(void * dest, int c, unsigned long n) -{ - unsigned char * temp=dest; - unsigned long i; - - if (!temp) - return NULL; - - for (i=0; i -#endif -#ifdef HAVE_DIRECT_H -# include -#endif -#ifdef HAVE_UNISTD_H -# include -#endif - -#ifdef MKDIR_TAKES_ONE_ARG -# ifdef HAVE_MKDIR -# define p_mkdir(A,B) mkdir(A) -# else -# ifdef HAVE__MKDIR -# define p_mkdir(A,B) _mkdir(A) -# else -# error "This program requires either mkdir() or _mkdir()" -# endif -# endif -#else -# ifdef HAVE_MKDIR -# define p_mkdir mkdir -# else -# ifdef HAVE__MKDIR -# define p_mkdir _mkdir -# else -# error "This program requires either mkdir() or _mkdir()" -# endif -# endif -#endif - -#endif diff --git a/d2pack109/src/compat/mmap.c b/d2pack109/src/compat/mmap.c deleted file mode 100644 index 5105c48..0000000 --- a/d2pack109/src/compat/mmap.c +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (C) 2003 RUSU Mihai (dizzy@roedu.net) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#include "common/setup_before.h" -#ifndef HAVE_MMAP -#ifdef STDC_HEADERS -# include -#else -# ifdef HAVE_MALLOC_H -# include -# endif -#endif -#ifdef HAVE_SYS_TYPES_H -# include -#endif -#ifdef HAVE_UNISTD_H -# include -#endif -#include "common/xalloc.h" -#include "mmap.h" -#ifdef WIN32 -# include -# include -#endif -#include "common/setup_after.h" - -extern void * pmmap(void *addr, unsigned len, int prot, int flags, int fd, unsigned offset) -{ - void *mem; -#ifdef WIN32 - HANDLE hFile, hMapping; - - /* under win32 we only support readonly mappings, the only ones used in pvpgn now :) */ - if (prot != PROT_READ) return NULL; - hFile = (HANDLE) _get_osfhandle(fd); - if (hFile == (HANDLE) - 1) return MAP_FAILED; - hMapping = CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 0, NULL); - if (!hMapping) return MAP_FAILED; - mem = MapViewOfFile(hMapping, FILE_MAP_READ, 0, 0 ,0); -#else /* systems without mmap or win32 */ - unsigned pos; - int res; - - mem = xmalloc(len); - pos = 0; - while(pos < len) { - res = read(fd, (char *)mem + pos, len - pos); - if (res < 0) { - xfree(mem); - return MAP_FAILED; - } - pos += res; - } -#endif - - return mem; -} - -extern int pmunmap(void *addr, unsigned len) -{ -#ifdef WIN32 - UnmapViewOfFile(addr); -#else - xfree(addr); -#endif - return 0; -} -#else -typedef int filenotempty; /* make ISO standard happy */ -#endif diff --git a/d2pack109/src/compat/mmap.h b/d2pack109/src/compat/mmap.h deleted file mode 100644 index 6900c65..0000000 --- a/d2pack109/src/compat/mmap.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (C) 2003 Mihai RUSU (dizzy@roedu.net) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_PMMAP_PROTOS -#define INCLUDED_PMMAP_PROTOS - -#ifdef HAVE_SYS_TYPES_H -# include -#endif -#ifdef HAVE_SYS_MMAN_H -# include -#endif -#ifdef __BORLANDC__ -# include -#endif - -#ifndef PROT_NONE -#define PROT_NONE 0x00 /* no permissions */ -#endif -#ifndef PROT_READ -#define PROT_READ 0x01 /* pages can be read */ -#endif -#ifndef PROT_WRITE -#define PROT_WRITE 0x02 /* pages can be written */ -#endif -#ifndef PROT_EXEC -#define PROT_EXEC 0x04 /* pages can be executed */ -#endif -#ifndef MAP_SHARED -#define MAP_SHARED 0x0001 /* share changes */ -#endif -#ifndef MAP_PRIVATE -#define MAP_PRIVATE 0x0002 /* changes are private */ -#endif -#ifndef MAP_COPY -#define MAP_COPY MAP_PRIVATE /* Obsolete */ -#endif -#ifndef MAP_FAILED -#define MAP_FAILED ((void *)-1) -#endif - -#ifdef HAVE_MMAP -#define pmmap(a,b,c,d,e,f) mmap(a,b,c,d,e,f) -#define pmunmap(a,b) munmap(a,b) -#else - -extern void * pmmap(void *addr, unsigned len, int prot, int flags, int fd, unsigned offset); -extern int pmunmap(void *addr, unsigned len); - -#endif - -#endif diff --git a/d2pack109/src/compat/pdir.c b/d2pack109/src/compat/pdir.c deleted file mode 100644 index 95f9e3f..0000000 --- a/d2pack109/src/compat/pdir.c +++ /dev/null @@ -1,241 +0,0 @@ -/* - * Copyright (C) 2001 Dizzy (dizzy@roedu.net) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#define PDIR_INTERNAL_ACCESS -#include "common/setup_before.h" -#ifdef HAVE_STDDEF_H -# include -#else -# ifndef NULL -# define NULL ((void *)0) -# endif -#endif -#ifdef STDC_HEADERS -# include -#else -# ifdef HAVE_MALLOC_H -# include -# endif -#endif -#ifdef HAVE_SYS_TYPES_H -# include -#endif -#ifdef HAVE_STRING_H -# include -#else -# ifdef HAVE_STRINGS_H -# include -# endif -#endif -#include "compat/strdup.h" -#ifdef HAVE_DIRENT_H -# include -#else -# ifdef HAVE_SYS_NDIR_H -# include -# endif -# if HAVE_SYS_DIR_H -# include -# endif -# if HAVE_NDIR_H -# include -# endif -# define dirent direct -#endif -#ifdef WIN32 -# include /* for _findfirst(), _findnext(), etc */ -#endif -#include -#include "compat/strerror.h" -#include "common/eventlog.h" -#include "common/xalloc.h" -#include "pdir.h" -#include "common/setup_after.h" - - -extern t_pdir * p_opendir(const char * path) { -#ifdef WIN32 - char npath[_MAX_PATH]; -#endif - t_pdir * pdir; - - if (path==NULL) { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL path"); - return NULL; - } -/* while(path[strlen(path)]=='/') path[strlen(path)]='\0'; */ - /* win32 can use slash in addition to backslash */ - pdir=xmalloc(sizeof(t_pdir)); - -#ifdef WIN32 - if (strlen(path)+1+3+1>_MAX_PATH) { - eventlog(eventlog_level_error,__FUNCTION__,"WIN32: path too long"); - xfree(pdir); - return NULL; - } - strcpy(npath, path); - strcat(npath, "/*.*"); - pdir->path=xstrdup(npath); - - pdir->status = 0; - memset(&pdir->fileinfo, 0, sizeof(pdir->fileinfo)); /* no need for compat because WIN32 always has memset() */ - pdir->lFindHandle = _findfirst(npath, &pdir->fileinfo); - if (pdir->lFindHandle < 0) { - xfree((void *)pdir->path); /* avoid warning */ - xfree(pdir); - return NULL; - } - -#else /* POSIX style */ - - pdir->path=xstrdup(path); - if ((pdir->dir=opendir(path))==NULL) { - xfree((void *)pdir->path); /* avoid warning */ - xfree(pdir); - return NULL; - } - -#endif /* WIN32-POSIX */ - - return pdir; -} - - -extern int p_rewinddir(t_pdir * pdir) { - if (pdir==NULL) { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL pdir"); - return -1; - } - if (pdir->path==NULL) { - eventlog(eventlog_level_error,__FUNCTION__,"got pdir with NULL path"); - return -1; - } -#ifdef WIN32 - /* i dont have any win32 around so i dont know if io.h has any rewinddir equivalent */ - /* FIXME: for the time being ill just close and reopen it */ - if (pdir->status!=-1) - { - if (pdir->lFindHandle<0) { - eventlog(eventlog_level_error,__FUNCTION__,"WIN32: got negative lFindHandle"); - return -1; - } - _findclose(pdir->lFindHandle); - } - pdir->status = 0; - memset(&pdir->fileinfo, 0, sizeof(pdir->fileinfo)); /* no need for compat because WIN32 always has memset() */ - pdir->lFindHandle = _findfirst(pdir->path, &pdir->fileinfo); - if (pdir->lFindHandle < 0) { - pdir->status = -1; - return -1; - } -#else /* POSIX */ - if (pdir->dir==NULL) { - eventlog(eventlog_level_error,__FUNCTION__,"POSIX: got pdir with NULL dir"); - return -1; - } - rewinddir(pdir->dir); -#endif - return 0; -} - - -extern char const * p_readdir(t_pdir * pdir) { - if (pdir==NULL) { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL pdir"); - return NULL; - } - if (pdir->path==NULL) { - eventlog(eventlog_level_error,__FUNCTION__,"got pdir with NULL path"); - return NULL; - } -#ifdef WIN32 - switch (pdir->status) - { - default: - case -1: /* couldn't rewind */ - eventlog(eventlog_level_error,__FUNCTION__,"got pdir with status -1"); - return NULL; - case 0: /* freshly opened */ - pdir->status = 1; - return pdir->fileinfo.name; - case 1: /* reading */ - if (_findnext(pdir->lFindHandle, &pdir->fileinfo)<0) - { - pdir->status = 2; - return NULL; - } - else - return pdir->fileinfo.name; - break; - case 2: /* EOF */ - return NULL; - } -#else /* POSIX */ - { - struct dirent * dentry; - - if (pdir->dir==NULL) { - eventlog(eventlog_level_error,__FUNCTION__,"POSIX: got pdir with NULL dir"); - return NULL; - } - if ((dentry=readdir(pdir->dir))==NULL) - return NULL; - return dentry->d_name; - } -#endif /* WIN32-POSIX */ -} - - -extern int p_closedir(t_pdir * pdir) { - int ret; - - if (pdir==NULL) { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL pdir"); - return -1; - } - if (pdir->path==NULL) { - eventlog(eventlog_level_error,__FUNCTION__,"got pdir with NULL path"); - return -1; - } - -#ifdef WIN32 - if (pdir->status!=-1) - { - if (pdir->lFindHandle<0) { - eventlog(eventlog_level_info,__FUNCTION__,"WIN32: got NULL findhandle"); - return -1; - } - _findclose(pdir->lFindHandle); /* FIXME: what does _findclose() return on error? */ - } - ret = 0; -#else /* POSIX */ - if (pdir->dir==NULL) { - eventlog(eventlog_level_info,__FUNCTION__,"POSIX: got NULL dir"); - return -1; - } -# ifdef CLOSEDIR_VOID - closedir(pdir->dir); - ret = 0; -# else - ret = closedir(pdir->dir); -# endif -#endif /* WIN32-POSIX */ - - xfree((void *)pdir->path); /* avoid warning */ - xfree(pdir); - return ret; -} diff --git a/d2pack109/src/compat/pdir.h b/d2pack109/src/compat/pdir.h deleted file mode 100644 index 7ec930b..0000000 --- a/d2pack109/src/compat/pdir.h +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (C) 2001 Dizzy (dizzy@roedu.net) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_PDIR_TYPES -#define INCLUDED_PDIR_TYPES - -#ifdef PDIR_INTERNAL_ACCESS - -#ifdef JUST_NEED_TYPES -# ifdef HAVE_DIRENT_H -# include -# else -# ifdef HAVE_SYS_NDIR_H -# include -# endif -# if HAVE_SYS_DIR_H -# include -# endif -# if HAVE_NDIR_H -# include -# endif -# define dirent direct -# endif -# ifdef WIN32 -# include /* for _findfirst(), _findnext(), etc */ -# endif -#else -# define JUST_NEED_TYPES -# ifdef HAVE_DIRENT_H -# include -# else -# ifdef HAVE_SYS_NDIR_H -# include -# endif -# if HAVE_SYS_DIR_H -# include -# endif -# if HAVE_NDIR_H -# include -# endif -# define dirent direct -# endif -# ifdef WIN32 -# include /* for _findfirst(), _findnext(), etc */ -# endif -# undef JUST_NEED_TYPES -#endif - -#endif - -typedef struct pdir_struct -#ifdef PDIR_INTERNAL_ACCESS -{ - char const * path; - char const * lastret; -#ifdef WIN32 - long lFindHandle; - struct _finddata_t fileinfo; - int status; /* -1 == failure, 0 == freshly opened, 1 == opened and read, 2 == eof */ -#else /* POSIX */ - DIR * dir; -#endif -} -#endif -t_pdir; - -#endif - -#ifndef JUST_NEED_TYPES -#ifndef INCLUDED_PDIR_PROTOS -#define INCLUDED_PDIR_PROTOS - -extern t_pdir * p_opendir(const char * dirname); -extern int p_rewinddir(t_pdir * pdir); -extern char const * p_readdir(t_pdir * pdir); -extern int p_closedir(t_pdir * pdir); - -#endif - -#endif diff --git a/d2pack109/src/compat/psock.c b/d2pack109/src/compat/psock.c deleted file mode 100644 index 0b0013d..0000000 --- a/d2pack109/src/compat/psock.c +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (C) 1999 Philippe Dubois (pdubois1@hotmail.com) - * Copyright (C) 1999 Ross Combs (rocombs@cs.nmsu.edu) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#include "common/setup_before.h" -#ifdef WIN32 - -#include -#include "psock.h" -#include "common/setup_after.h" - - -extern int psock_init(void) -{ - WORD wVersionRequested; - WSADATA wsaData; - - wVersionRequested = MAKEWORD(2, 2); - - if (WSAStartup(wVersionRequested, &wsaData)!=0) - { - /* FIXME: Tell the user that we could not find a usable WinSock DLL. */ - return -1; - } - - return 0; -} - -extern int psock_deinit(void) -{ - - if (WSACleanup()!=0) - { - return -1; - } - - return 0; -} - -extern int psock_ctl(int sd, int mode) -{ - unsigned long nParam=1; /* u_long or DWORD or what? */ - - return ioctlsocket(sd,mode,&nParam); -} - -#else - -#ifdef HAVE_UNISTD_H -# include -#endif -#ifdef HAVE_FCNTL_H -# include -#else -# ifdef HAVE_SYS_FILE_H -# include -# endif -#endif -#include "psock.h" -#include "common/setup_after.h" - - -extern int psock_ctl(int sd, long int mode) -{ - long int oldmode; - - if ((oldmode = fcntl(sd,F_GETFL))<0) - oldmode = 0; - oldmode |= mode; - return fcntl(sd,F_SETFL,mode); -} - -#endif diff --git a/d2pack109/src/compat/psock.h b/d2pack109/src/compat/psock.h deleted file mode 100644 index 87f0199..0000000 --- a/d2pack109/src/compat/psock.h +++ /dev/null @@ -1,275 +0,0 @@ -/* - * Copyright (C) 1999 Philippe Dubois (pdubois1@hotmail.com) - * Copyright (C) 1999,2000,2002 Ross Combs (rocombs@cs.nmsu.edu) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef JUST_NEED_TYPES -#ifndef INCLUDED_PSOCK_PROTOS -#define INCLUDED_PSOCK_PROTOS - -/* - * This file is like the other compat header files in that it - * tries to hide differences between systems. It is somewhat - * different in that it doesn't present a "normal" interface - * to the rest of the code, but instead defines its own macros - * and functions. This is done since Win32 uses closesocket() - * instead of close() for sockets, but it can't be remapped - * since it already has a close() for file descriptors. Also, - * this allows us to hide the fact that some systems use - * fcntl() and some use ioctl(). The select() function is - * included here even though it isn't strictly for sockets. - * Just call this version if any of the file descriptors might - * be sockets. - * - * This file must be included _after_ any other socket related - * headers and any other compat socket fixup headers. - */ - -#ifdef WIN32 /* winsock2 */ - -#include - -/* protocol families */ -#define PSOCK_PF_INET PF_INET - -/* address families */ -#define PSOCK_AF_INET AF_INET - -/* socket types */ -#define PSOCK_SOCK_STREAM SOCK_STREAM -#define PSOCK_SOCK_DGRAM SOCK_DGRAM - -/* socket protocols */ -#ifdef IPPROTO_TCP -# define PSOCK_IPPROTO_TCP IPPROTO_TCP -#else -# define PSOCK_IPPROTO_TCP 0 -#endif -#ifdef IPPROTO_UDP -# define PSOCK_IPPROTO_UDP IPPROTO_UDP -#else -# define PSOCK_IPPROTO_UDP 0 -#endif - -/* psock_[gs]etsockopt() flags */ -#define PSOCK_SOL_SOCKET SOL_SOCKET -#define PSOCK_SO_REUSEADDR SO_REUSEADDR -#define PSOCK_SO_KEEPALIVE SO_KEEPALIVE -#define PSOCK_SO_ERROR SO_ERROR - -/* psock_ctl() flags */ -#define PSOCK_NONBLOCK FIONBIO - -/* psock_errno() values */ -#ifdef WSAEWOULDBLOCK -# define PSOCK_EWOULDBLOCK WSAEWOULDBLOCK -#endif -#ifdef WSAEINPROGRESS -# define PSOCK_EINPROGRESS WSAEINPROGRESS -#endif -#ifdef WSAEINTR -# define PSOCK_EINTR WSAEINTR -#endif -#ifdef WSAECONNABORTED -# define PSOCK_ECONNABORTED WSAECONNABORTED -#endif -#ifdef WSATRY_AGAIN -# define PSOCK_EAGAIN WSATRY_AGAIN -#endif -#ifdef WSAECONNRESET -# define PSOCK_ECONNRESET WSAECONNRESET -#endif -#ifdef WSAENOTCONN -# define PSOCK_ENOTCONN WSAENOTCONN -#endif -#ifdef WSAEPIPE -# define PSOCK_EPIPE WSAEPIPE -#endif -#ifdef WSAEPROTO -# define PSOCK_EPROTO WSAEPROTO -#endif -#ifdef WSAENOBUFS -# define PSOCK_ENOBUFS WSAENOBUFS -#endif -#ifdef WSAENOMEM -# define PSOCK_ENOMEM WSAENOMEM -#endif - -/* psock_shutdown() flags */ -#define PSOCK_SHUT_RD 0 -#define PSOCK_SHUT_WR 1 -#define PSOCK_SHUT_RDWR 2 - -/* psock types */ -#define psock_t_socklen int - -/* psock_select() macros and types */ -#define t_psock_fd_set fd_set -#define PSOCK_FD_ZERO FD_ZERO -#define PSOCK_FD_CLR FD_CLR -#define PSOCK_FD_SET FD_SET -#define PSOCK_FD_ISSET FD_ISSET - -/* psock functions */ -extern int psock_init(void); /* a real functions in */ -extern int psock_deinit(void); /* compat/psock.c */ -#define psock_errno() WSAGetLastError() -#define psock_socket(pf, t, ps) socket(pf, t, ps) -#define psock_getsockopt(s, l, o, v, size) getsockopt(s, l, o, (void *)(v), size) -#define psock_setsockopt(s, l, o, v, size) setsockopt(s, l, o, (void *)(v), size) -extern int psock_ctl(int sd, int mode); /* a real function in compat/psock.c */ -#define psock_listen(s, b) listen(s, b) -#define psock_bind(s, a, l) bind(s, a, l) -#define psock_accept(s, a, l) accept(s, a, l) -#define psock_connect(s, a, l) connect(s, a, l) -#define psock_send(s, b, l, f) send(s, (void *)(b), l, f) -#define psock_sendto(s, b, l, f, a, al) sendto(s, (void *)(b), l, f, a, al) -#define psock_recv(s, b, l, f) recv(s, (void *)(b), l, f) -#define psock_recvfrom(s, b, l, f, a, al) recvfrom(s, (void *)(b), l, f, a, al) -#define psock_shutdown(s, how) shutdown(s, how) -#define psock_close(s) closesocket(s) -#define psock_select(s, r, w, e, t) select(s, r, w, e ,t) -#define psock_getsockname(s, a, l) getsockname(s, a, l) - -/* PDubois - 991111 */ -/*#define inet_aton(cp, pAdd) (((*pAdd).s_addr = inet_addr(cp)) != INADDR_NONE)*/ -/* (this should be done in compat/inet_aton.h and this isn't a 100% correct implementation anyway -Ross) */ - -#else /* assume POSIX */ - -/* protocol families */ -#define PSOCK_PF_INET PF_INET - -/* address families */ -#define PSOCK_AF_INET AF_INET - -/* socket types */ -#define PSOCK_SOCK_STREAM SOCK_STREAM -#define PSOCK_SOCK_DGRAM SOCK_DGRAM - -/* socket protocols */ -#ifdef IPPROTO_TCP -# define PSOCK_IPPROTO_TCP IPPROTO_TCP -#else -# define PSOCK_IPPROTO_TCP 0 -#endif -#ifdef IPPROTO_UDP -# define PSOCK_IPPROTO_UDP IPPROTO_UDP -#else -# define PSOCK_IPPROTO_UDP 0 -#endif - -/* psock_[gs]etsockopt() flags */ -#define PSOCK_SOL_SOCKET SOL_SOCKET -#define PSOCK_SO_REUSEADDR SO_REUSEADDR -#define PSOCK_SO_KEEPALIVE SO_KEEPALIVE -#define PSOCK_SO_ERROR SO_ERROR - -/* psock_ctl() flags */ -#define PSOCK_NONBLOCK O_NONBLOCK - -/* psock_errno() values */ -#ifdef EWOULDBLOCK -# define PSOCK_EWOULDBLOCK EWOULDBLOCK -#endif -#ifdef EINPROGRESS -# define PSOCK_EINPROGRESS EINPROGRESS -#endif -#ifdef EINTR -# define PSOCK_EINTR EINTR -#endif -#ifdef ECONNABORTED -# define PSOCK_ECONNABORTED ECONNABORTED -#endif -#ifdef EAGAIN -# define PSOCK_EAGAIN EAGAIN -#endif -#ifdef ECONNRESET -# define PSOCK_ECONNRESET ECONNRESET -#endif -#ifdef ENOTCONN -# define PSOCK_ENOTCONN ENOTCONN -#endif -#ifdef EPIPE -# define PSOCK_EPIPE EPIPE -#endif -#ifdef EPROTO -# define PSOCK_EPROTO EPROTO -#endif -#ifdef ENOBUFS -# define PSOCK_ENOBUFS ENOBUFS -#endif -#ifdef ENOMEM -# define PSOCK_ENOMEM ENOMEM -#endif - -/* psock_shutdown() flags */ -#ifdef SHUT_RD -# define PSOCK_SHUT_RD SHUT_RD -#else -# define PSOCK_SHUT_RD 0 -#endif -#ifdef SHUT_WR -# define PSOCK_SHUT_WR SHUT_WR -#else -# define PSOCK_SHUT_WR 1 -#endif -#ifdef SHUT_RDWR -# define PSOCK_SHUT_RDWR SHUT_RDWR -#else -# define PSOCK_SHUT_RDWR 2 -#endif - -/* psock types */ -/* FIXME: write configure test to check for this type */ -#ifdef HAVE_SOCKLEN_T -# define psock_t_socklen socklen_t -#else -# define psock_t_socklen unsigned int -#endif - -/* psock_select() macros and types */ -#define t_psock_fd_set fd_set -#define PSOCK_FD_ZERO FD_ZERO -#define PSOCK_FD_CLR FD_CLR -#define PSOCK_FD_SET FD_SET -#define PSOCK_FD_ISSET FD_ISSET - -/* psock functions */ -#define psock_init() (0) -#define psock_deinit() (0) -#define psock_errno() (errno) -#define psock_socket(pf, t, ps) socket(pf, t, ps) -#define psock_getsockopt(s, l, o, v, size) getsockopt(s, l, o, (void *)(v), size) -#define psock_setsockopt(s, l, o, v, size) setsockopt(s, l, o, (void *)(v), size) -extern int psock_ctl(int sd, long int mode); /* a real function in compat/psock.c */ -#define psock_listen(s, b) listen(s, b) -#define psock_bind(s, a, l) bind(s, a, l) -#define psock_accept(s, a, l) accept(s, a, l) -#define psock_connect(s, a, l) connect(s, a, l) -#define psock_send(s, b, l, f) send(s, (void *)(b), l, f) -#define psock_sendto(s, b, l, f, a, al) sendto(s, (void *)(b), l, f, a, al) -#define psock_recv(s, b, l, f) recv(s, (void *)(b), l, f) -#define psock_recvfrom(s, b, l, f, a, al) recvfrom(s, (void *)(b), l, f, a, al) -#define psock_shutdown(s, how) shutdown(s, how) -#define psock_close(s) close(s) -#define psock_select(s, r, w, e, t) select(s, r, w, e ,t) -#define psock_getsockname(s, a, l) getsockname(s, a, l) - -#endif - -#endif -#endif diff --git a/d2pack109/src/compat/recv.h b/d2pack109/src/compat/recv.h deleted file mode 100644 index 21f2eb4..0000000 --- a/d2pack109/src/compat/recv.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 1999 Ross Combs (rocombs@cs.nmsu.edu) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_RECV_PROTOS -#define INCLUDED_RECV_PROTOS - -#ifndef HAVE_RECV - -/* some recvfrom()s don't handle NULL, but recv is called depreciated on BSD */ -#ifdef HAVE_RECVFROM -# ifdef HAVE_STDDEF_H -# include -# else -# ifndef NULL -# define NULL ((void *)0) -# endif -# endif -# define recv(s, b, l, f) recvfrom(s, b, l, f, NULL, NULL) -#else -# error "This program requires recvfrom()" -#endif - -#endif - -#endif diff --git a/d2pack109/src/compat/rename.h b/d2pack109/src/compat/rename.h deleted file mode 100644 index 5c421ca..0000000 --- a/d2pack109/src/compat/rename.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2004 CreepLord (creeplord@pvpgn.org) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_RENAME_PROTOS -#define INCLUDED_RENAME_PROTOS - -#ifdef HAVE_UNISTD_H -# include -#endif -#include "compat/access.h" - -static inline int p_rename(const char * old, const char * new) -{ -#ifdef WIN32 - if(access(new, F_OK) == 0) - if(remove(new) < 0) - return -1; -#endif - return rename(old, new); -} - -#endif diff --git a/d2pack109/src/compat/seek.h b/d2pack109/src/compat/seek.h deleted file mode 100644 index 1247253..0000000 --- a/d2pack109/src/compat/seek.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 2000 Ross Combs (rocombs@cs.nmsu.edu) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_SEEK_PROTOS -#define INCLUDED_SEEK_PROTOS - -#ifndef SEEK_SET -# ifdef L_SET -# define SEEK_SET L_SET -# else -# define SEEK_SET 0 -# endif -#endif - -#ifndef SEEK_CUR -# ifdef L_INCR -# define SEEK_CUR L_INCR -# else -# define SEEK_CUR 1 -# endif -#endif - -#ifndef SEEK_END -# ifdef L_XTND -# define SEEK_END L_XTND -# else -# define SEEK_END 2 -# endif -#endif - -#endif diff --git a/d2pack109/src/compat/send.h b/d2pack109/src/compat/send.h deleted file mode 100644 index 79823bb..0000000 --- a/d2pack109/src/compat/send.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 1999 Ross Combs (rocombs@cs.nmsu.edu) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_SEND_PROTOS -#define INCLUDED_SEND_PROTOS - -#ifndef HAVE_SEND - -/* some sendto()s don't handle NULL, but send is called depreciated on BSD */ -#ifdef HAVE_SENDTO -# ifdef HAVE_STDDEF_H -# include -# else -# ifndef NULL -# define NULL ((void *)0) -# endif -# endif -# define send(s, b, l, f) sendto(s, b, l, f, NULL, NULL) -#else -# error "This program requires sendto()" -#endif - -#endif - -#endif diff --git a/d2pack109/src/compat/signal.h b/d2pack109/src/compat/signal.h deleted file mode 100644 index 75ab812..0000000 --- a/d2pack109/src/compat/signal.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (C) 1999 Ross Combs (rocombs@cs.nmsu.edu) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_SIGNAL_PROTOS -#define INCLUDED_SIGNAL_PROTOS - -/* for Cygnus B20.1 on win32 */ -#ifndef SA_RESTART -#define SA_RESTART 0 -#endif - -#endif diff --git a/d2pack109/src/compat/socket.h b/d2pack109/src/compat/socket.h deleted file mode 100644 index f9e881f..0000000 --- a/d2pack109/src/compat/socket.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 1999 Philippe Dubois (pdubois1@hotmail.com) - * Copyright (C) 1999 Ross Combs (rocombs@cs.nmsu.edu) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_SOCKET_PROTOS -#define INCLUDED_SOCKET_PROTOS - -#ifdef WIN32 /* assume winsock2 is available */ - -# include -/* - * Including that file is basically equivalent to including: - * - * - * - * - * - * - * - * It should be included once for any file needing one or more - * of those headers. - */ - -#endif - -#endif diff --git a/d2pack109/src/compat/stdfileno.h b/d2pack109/src/compat/stdfileno.h deleted file mode 100644 index e88f106..0000000 --- a/d2pack109/src/compat/stdfileno.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2000 Ross Combs (rocombs@cs.nmsu.edu) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_STDFILENO_PROTOS -#define INCLUDED_STDFILENO_PROTOS - -#ifdef STDIN_FILENO -# define STDINFD STDIN_FILENO -#else -# define STDINFD 0 -#endif - -#ifdef STDOUT_FILENO -# define STDOUTFD STDOUT_FILENO -#else -# define STDOUTFD 1 -#endif - -#ifdef STDERR_FILENO -# define STDERRFD STDERR_FILENO -#else -# define STDERRFD 2 -#endif - -#endif diff --git a/d2pack109/src/compat/strcasecmp.c b/d2pack109/src/compat/strcasecmp.c deleted file mode 100644 index 1fdc9af..0000000 --- a/d2pack109/src/compat/strcasecmp.c +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (C) 1999 Ross Combs (rocombs@cs.nmsu.edu) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#include "common/setup_before.h" -#ifndef HAVE_STRCASECMP - -#include -#ifdef HAVE_STRING_H -# include -#else -# ifdef HAVE_STRINGS_H -# include -# endif -#endif -#include "strcasecmp.h" -#include "common/setup_after.h" - - -extern int strcasecmp(char const * str1, char const * str2) -{ - unsigned int i; - int a; - int b; - - if (!str1 || !str2) - return -1; - - /* some versions of tolower() break when given already lowercase characters */ - for (i=0; str1[i]!='\0' && str2[i]!='\0'; i++) - { - if (isupper((int)str1[i])) - a = (int)tolower((int)str1[i]); - else - a = (int)str1[i]; - - if (isupper((int)str2[i])) - b = (int)tolower((int)str2[i]); - else - b = (int)str2[i]; - - if (ab) - return +1; - } - - if (str1[i]!='\0') - return -1; - if (str2[i]!='\0') - return +1; - return 0; -} - -#else -typedef int filenotempty; /* make ISO standard happy */ -#endif diff --git a/d2pack109/src/compat/strcasecmp.h b/d2pack109/src/compat/strcasecmp.h deleted file mode 100644 index c55d920..0000000 --- a/d2pack109/src/compat/strcasecmp.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 1999 Ross Combs (rocombs@cs.nmsu.edu) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_STRCASECMP_PROTOS -#define INCLUDED_STRCASECMP_PROTOS - -#ifndef HAVE_STRCASECMP - -#ifdef HAVE_STRICMP -# define strcasecmp(s1, s2) stricmp(s1, s2) -# define HAVE_STRCASECMP -#else - -extern int strcasecmp(char const * str1, char const * str2); - -#endif - -#endif - -#endif diff --git a/d2pack109/src/compat/strchr.h b/d2pack109/src/compat/strchr.h deleted file mode 100644 index a4aa853..0000000 --- a/d2pack109/src/compat/strchr.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (C) 2000 Ross Combs (rocombs@cs.nmsu.edu) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_STRCHR_PROTOS -#define INCLUDED_STRCHR_PROTOS - -#ifndef HAVE_STRCHR - -#ifdef HAVE_INDEX -# define strchr index -#else -# error "This program requires either strchr() or index()" -#endif - -#endif - -#endif diff --git a/d2pack109/src/compat/strdup.c b/d2pack109/src/compat/strdup.c deleted file mode 100644 index 9a14440..0000000 --- a/d2pack109/src/compat/strdup.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (C) 1999 Ross Combs (rocombs@cs.nmsu.edu) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#include "common/setup_before.h" -#ifndef HAVE_STRDUP -#ifdef HAVE_STDDEF_H -# include -#else -# ifndef NULL -# define NULL ((void *)0) -# endif -#endif -#ifdef STDC_HEADERS -# include -#else -# ifdef HAVE_MALLOC_H -# include -# endif -#endif -#ifdef HAVE_STRING_H -# include -#else -# ifdef HAVE_STRINGS_H -# include -# endif -#endif -#include "strdup.h" -#include "common/setup_after.h" - - -extern char * strdup(char const * str) -{ - char * out; - - if (!(out = malloc(strlen(str)+1))) - return NULL; - strcpy(out,str); - return out; -} - -#else -typedef int filenotempty; /* make ISO standard happy */ -#endif diff --git a/d2pack109/src/compat/strdup.h b/d2pack109/src/compat/strdup.h deleted file mode 100644 index 98f52ea..0000000 --- a/d2pack109/src/compat/strdup.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) 1999 Ross Combs (rocombs@cs.nmsu.edu) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_STRDUP_PROTOS -#define INCLUDED_STRDUP_PROTOS - -#ifndef HAVE_STRDUP - -extern char * strdup(char const * str); - -#endif - -#endif diff --git a/d2pack109/src/compat/strerror.c b/d2pack109/src/compat/strerror.c deleted file mode 100644 index 049cd28..0000000 --- a/d2pack109/src/compat/strerror.c +++ /dev/null @@ -1,291 +0,0 @@ -/* - * Copyright (C) 1999 Ross Combs (rocombs@cs.nmsu.edu) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#include "common/setup_before.h" -#ifndef HAVE_STRERROR - -#include -#include "strerror.h" -#include "common/setup_after.h" - - -extern char const * strerror(int errornum) -{ - if (errornum==0) - return "No error"; -#ifdef EPERM - if (errornum==EPERM) - return "Operation not permitted"; -#endif -#ifdef ENOENT - if (errornum==ENOENT) - return "No such file or directory"; -#endif -#ifdef ESRCH - if (errornum==ESRCH) - return "No such process"; -#endif -#ifdef EINTR - if (errornum==EINTR) - return "Interrupted system call"; -#endif -#ifdef EIO - if (errornum==EIO) - return "I/O error"; -#endif -#ifdef ENXIO - if (errornum==EIO) - return "No such device or address"; -#endif -#ifdef EBADF - if (errornum==EBADF) - return "Bad file number"; -#endif -#ifdef EAGAIN - if (errornum==EAGAIN) - return "Try again"; -#endif -#ifdef ENOMEM - if (errornum==ENOMEM) - return "Out of memory"; -#endif -#ifdef EACCES - if (errornum==EACCES) - return "Permission denied"; -#endif -#ifdef EFAULT - if (errornum==EFAULT) - return "Bad address"; -#endif -#ifdef EBUSY - if (errornum==EBUSY) - return "Device or resource busy"; -#endif -#ifdef EEXIST - if (errornum==EEXIST) - return "File exists"; -#endif -#ifdef EXDEV - if (errornum==EXDEV) - return "Cross-device link"; -#endif -#ifdef EDEADLK - if (errornum==EXDEV) - return "Resource deadlock would occur"; -#endif -#ifdef EDEADLOCK - if (errornum==EDEADLOCK) - return "Resource deadlock would occur"; -#endif -#ifdef ENODEV - if (errornum==ENODEV) - return "No such device"; -#endif -#ifdef ENOTDIR - if (errornum==ENOTDIR) - return "Not a directory"; -#endif -#ifdef EISDIR - if (errornum==EISDIR) - return "Is a directory"; -#endif -#ifdef EINVAL - if (errornum==EINVAL) - return "Invalid argument"; -#endif -#ifdef ENFILE - if (errornum==ENFILE) - return "Too many open files in system"; -#endif -#ifdef EMFILE - if (errornum==EMFILE) - return "Too many open files"; -#endif -#ifdef ENOTTY - if (errornum==ENOTTY) - return "Not a typewriter"; -#endif -#ifdef ETXTBSY - if (errornum==ETXTBSY) - return "Text file busy"; -#endif -#ifdef EFBIG - if (errornum==EFBIG) - return "File too large"; -#endif -#ifdef ENOSPC - if (errornum==ENOSPC) - return "No space left on device"; -#endif -#ifdef ESPIPE - if (errornum==ESPIPE) - return "Illegal seek"; -#endif -#ifdef EROFS - if (errornum==EROFS) - return "Read-only file system"; -#endif -#ifdef EMLINK - if (errornum==EMLINK) - return "Too many links"; -#endif -#ifdef EPIPE - if (errornum==EPIPE) - return "Broken pipe"; -#endif -#ifdef EDOM - if (errornum==EDOM) - return "Math argument out of domain of func"; -#endif -#ifdef ERANGE - if (errornum==ERANGE) - return "Math result not representable"; -#endif -#ifdef ENAMETOOLONG - if (errornum==ENAMETOOLONG) - return "File name too long"; -#endif -#ifdef ENOLCK - if (errornum==ENOLCK) - return "No record locks available"; -#endif -#ifdef ENOSYS - if (errornum==ENOSYS) - return "Function not implemented"; -#endif -#ifdef ENOTEMPTY - if (errornum==ENOTEMPTY) - return "Directory not empty"; -#endif -#ifdef ELOOP - if (errornum==ELOOP) - return "Too many symbolic links encountered"; -#endif -#ifdef EHOSTDOWN - if (errornum==EHOSTDOWN) - return "Host is down"; -#endif -#ifdef EHOSTUNREACH - if (errornum==EHOSTUNREACH) - return "No route to host"; -#endif -#ifdef EALREADY - if (errornum==EALREADY) - return "Operation already in progress"; -#endif -#ifdef EINPROGRESS - if (errornum==EINPROGRESS) - return "Operation now in progress"; -#endif -#ifdef ESTALE - if (errornum==ESTALE) - return "Stale NFS filehandle"; -#endif -#ifdef EDQUOT - if (errornum==EDQUOT) - return "Quota exceeded"; -#endif -#ifdef EWOULDBLOCK - if (errornum==EWOULDBLOCK) - return "Operation would block"; -#endif -#ifdef ECOMM - if (errornum==ECOMM) - return "Communication error on send"; -#endif -#ifdef EPROTO - if (errornum==EPROTO) - return "Protocol error"; -#endif -#ifdef EPROTONOSUPPORT - if (errornum==EPROTONOSUPPORT) - return "Protocol not supported"; -#endif -#ifdef ESOCKTNOSUPPORT - if (errornum==ESOCKTNOSUPPORT) - return "Socket type not supported"; -#endif -#ifdef ESOCKTNOSUPPORT - if (errornum==EOPNOTSUPP) - return "Operation not supported"; -#endif -#ifdef EPFNOSUPPORT - if (errornum==EPFNOSUPPORT) - return "Protocol family not supported"; -#endif -#ifdef EAFNOSUPPORT - if (errornum==EAFNOSUPPORT) - return "Address family not supported by protocol family"; -#endif -#ifdef EADDRINUSE - if (errornum==EADDRINUSE) - return "Address already in use"; -#endif -#ifdef EADDRNOTAVAIL - if (errornum==EADDRNOTAVAIL) - return "Cannot assign requested address"; -#endif -#ifdef ENETDOWN - if (errornum==ENETDOWN) - return "Network is down"; -#endif -#ifdef ENETUNREACH - if (errornum==ENETUNREACH) - return "Network is unreachable"; -#endif -#ifdef ENETRESET - if (errornum==ENETRESET) - return "Network dropped connection on reset"; -#endif -#ifdef ECONNABORTED - if (errornum==ECONNABORTED) - return "Software caused connection abort"; -#endif -#ifdef ECONNRESET - if (errornum==ECONNRESET) - return " Connection reset by peer"; -#endif -#ifdef ENOBUFS - if (errornum==ENOBUFS) - return "No buffer space available"; -#endif -#ifdef EISCONN - if (errornum==EISCONN) - return "Socket is already connected"; -#endif -#ifdef ENOTCONN - if (errornum==ENOTCONN) - return "Socket is not connected"; -#endif -#ifdef ESHUTDOWN - if (errornum==ESHUTDOWN) - return " Cannot send after socket shutdown"; -#endif -#ifdef ETIMEDOUT - if (errornum==ETIMEDOUT) - return "Connection timed out"; -#endif -#ifdef ECONNREFUSED - if (errornum==ECONNREFUSED) - return "Connection refused"; -#endif - return "Unknown error"; -} - -#else -typedef int filenotempty; /* make ISO standard happy */ -#endif diff --git a/d2pack109/src/compat/strerror.h b/d2pack109/src/compat/strerror.h deleted file mode 100644 index f9e80ea..0000000 --- a/d2pack109/src/compat/strerror.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) 1999 Ross Combs (rocombs@cs.nmsu.edu) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_STRERROR_PROTOS -#define INCLUDED_STRERROR_PROTOS - -#ifndef HAVE_STRERROR - -extern char const * strerror(int errornum); - -#endif - -#endif diff --git a/d2pack109/src/compat/strftime.c b/d2pack109/src/compat/strftime.c deleted file mode 100644 index 829c78c..0000000 --- a/d2pack109/src/compat/strftime.c +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (C) 1999 Ross Combs (rocombs@cs.nmsu.edu) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#include "common/setup_before.h" -#ifndef HAVE_STRFTIME - -#include -#ifdef HAVE_STRING_H -# include -#else -# ifdef HAVE_STRINGS_H -# include -# endif -#endif -#include "strftime.h" -#include "common/setup_after.h" - - -/* We are not even trying to copy the functionality. - We are just trying to get a timestamp. */ -extern int strftime(char * buf, int bufsize, char const * fmt, struct tm const * tm) -{ - if (!buf || !fmt || !tm) - return 0; - - if (bufsize>24) - sprintf(buf,"%.4d %.2d %.2d %02.2d:%02.2d:%02.2d", - tm->tm_year, - tm->tm_mon, - tm->tm_mday, - tm->tm_hour, - tm->tm_min, - tm->tm_sec); - else if (bufsize>10) - sprintf(buf,"%02.2d:%02.2d:%02.2d", - tm->tm_hour, - tm->tm_min, - tm->tm_sec); - else - buf[0] = '\0'; - - return strlen(buf); -} - -#else -typedef int filenotempty; /* make ISO standard happy */ -#endif diff --git a/d2pack109/src/compat/strftime.h b/d2pack109/src/compat/strftime.h deleted file mode 100644 index 0b053f4..0000000 --- a/d2pack109/src/compat/strftime.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) 1999 Ross Combs (rocombs@cs.nmsu.edu) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_STRFTIME_PROTOS -#define INCLUDED_STRFTIME_PROTOS - -#ifndef HAVE_STRFTIME - -extern int strftime(char * buf, int bufsize, char const * fmt, struct tm const * tm); - -#endif - -#endif diff --git a/d2pack109/src/compat/strncasecmp.c b/d2pack109/src/compat/strncasecmp.c deleted file mode 100644 index 2c5e752..0000000 --- a/d2pack109/src/compat/strncasecmp.c +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (C) 1999 Ross Combs (rocombs@cs.nmsu.edu) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#include "common/setup_before.h" -#ifndef HAVE_STRCASECMP - -#include -#ifdef HAVE_STRING_H -# include -#else -# ifdef HAVE_STRINGS_H -# include -# endif -#endif -#include "strncasecmp.h" -#include "common/setup_after.h" - - -extern int strncasecmp(char const * str1, char const * str2, unsigned int cnt) -{ - unsigned int i; - int a; - int b; - - if (!str1 || !str2) - return -1; - - /* some versions of tolower() break when given already lowercase characters */ - for (i=0; ib) - return +1; - } - - if (i -#else -# ifdef HAVE_STRINGS_H -# include -# endif -#endif -#include "compat/strchr.h" -#include "strsep.h" -#include "common/setup_after.h" - - -extern char * strsep(char * * str, char const * delims) -{ - char * begin; - - begin = *str; - - if (!begin) - return NULL; /* already returned last token */ - - /* FIXME: optimiz case of 1 char delims (maybe not worth the effort) */ - for (; **str!='\0'; (*str)++) - if (strchr(delims,**str)) - { - **str = '\0'; /* terminate token */ - (*str)++; /* remember the position of the next char */ - return begin; - } - - *str = NULL; - return begin; /* return the whole input string */ -} - -#else -typedef int filenotempty; /* make ISO standard happy */ -#endif diff --git a/d2pack109/src/compat/strsep.h b/d2pack109/src/compat/strsep.h deleted file mode 100644 index c4d21dd..0000000 --- a/d2pack109/src/compat/strsep.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) 2002 Ross Combs (rocombs@cs.nmsu.edu) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_STRSEP_PROTOS -#define INCLUDED_STRSEP_PROTOS - -#ifndef HAVE_STRSEP - -extern char * strsep(char * * str, char const * delim); - -#endif - -#endif diff --git a/d2pack109/src/compat/strtoul.c b/d2pack109/src/compat/strtoul.c deleted file mode 100644 index fdfb214..0000000 --- a/d2pack109/src/compat/strtoul.c +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (C) 1999 Ross Combs (rocombs@cs.nmsu.edu) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#include "common/setup_before.h" -#ifndef HAVE_STRTOUL - -#include "strtoul.h" -#include "common/setup_after.h" - - -extern unsigned long strtoul(char const * str, char * * endptr, int base) -{ - unsigned int pos; - unsigned int i; - unsigned long val; - - if (!str) - return 0; /* EINVAL */ - - for (pos=0; str[pos]==' ' || str[pos]=='\t'; pos++); - if (str[pos]=='-' || str[pos]=='+') - pos++; - if ((base==0 || base==16) && str[pos]=='0' && (str[pos+1]=='x' || str[pos+1]=='X')) - { - base = 16; - pos += 2; /* skip 0x prefix */ - } - else if ((base==0 || base==8) && str[pos]=='0') - { - base = 8; - pos += 1; - } - else if (base==0) - { - base = 10; - } - - if (base<2 || base>16) /* sorry, not complete emulation (should do up to 36) */ - return 0; /* EINVAL */ - - val = 0; - for (i=pos; str[i]!='\0'; i++) - { - val *= base; - - /* we could assume ASCII and subtraction but this isn't too hard */ - if (str[i]=='0') - val += 0; - else if (str[i]=='1') - val += 1; - else if (base>2 && str[i]=='2') - val += 2; - else if (base>3 && str[i]=='3') - val += 3; - else if (base>4 && str[i]=='4') - val += 4; - else if (base>5 && str[i]=='5') - val += 5; - else if (base>6 && str[i]=='6') - val += 6; - else if (base>7 && str[i]=='7') - val += 7; - else if (base>8 && str[i]=='8') - val += 8; - else if (base>9 && str[i]=='9') - val += 9; - else if (base>10 && (str[i]=='a' || str[i]=='A')) - val += 10; - else if (base>11 && (str[i]=='b' || str[i]=='B')) - val += 11; - else if (base>12 && (str[i]=='c' || str[i]=='C')) - val += 12; - else if (base>13 && (str[i]=='d' || str[i]=='D')) - val += 13; - else if (base>14 && (str[i]=='e' || str[i]=='E')) - val += 14; - else if (base>15 && (str[i]=='f' || str[i]=='F')) - val += 15; - else - break; - } - - if (endptr) - *endptr = (void *)&str[i]; /* avoid warning */ - - return val; -} - -#else -typedef int filenotempty; /* make ISO standard happy */ -#endif diff --git a/d2pack109/src/compat/strtoul.h b/d2pack109/src/compat/strtoul.h deleted file mode 100644 index 50f3324..0000000 --- a/d2pack109/src/compat/strtoul.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) 1999 Ross Combs (rocombs@cs.nmsu.edu) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_STRTOUL_PROTOS -#define INCLUDED_STRTOUL_PROTOS - -#ifndef HAVE_STRTOUL - -extern unsigned long strtoul(char const * str, char * * endptr, int base); - -#endif - -#endif diff --git a/d2pack109/src/compat/termios.h b/d2pack109/src/compat/termios.h deleted file mode 100644 index c1afd10..0000000 --- a/d2pack109/src/compat/termios.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2000 Ross Combs (rocombs@cs.nmsu.edu) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_TERMIOS_TYPES -#define INCLUDED_TERMIOS_TYPES - -/* FIXME: this might already exist even if termios.h doesn't... check - for the type in autoconf */ -# ifndef HAVE_TERMIOS_H -struct termios -{ - int c_lflag; - int c_cc[1]; -}; - -# define ECHO 1 -# define ICANON 1 -# define VMIN 1 -# define VTIME 1 - -# endif - -#endif - - -#ifndef INCLUDED_TERMIOS_PROTOS -#define INCLUDED_TERMIOS_PROTOS - -/* FIXME: check for functions or macros (autoconf doesn't protect header inclusion for function tests so it isn't easy */ -#ifndef HAVE_TERMIOS_H -# define tcgetattr(F,T) (-1) -#endif - -/* FIXME: check for functions or macros (autoconf doesn't protect header inclusion for function tests so it isn't easy */ -#ifndef HAVE_TERMIOS_H -# define tcsetattr(F,A,T) (-1) -#endif - -#endif diff --git a/d2pack109/src/compat/uint.h b/d2pack109/src/compat/uint.h deleted file mode 100644 index 9b7ce22..0000000 --- a/d2pack109/src/compat/uint.h +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (C) 2000 Ross Combs (rocombs@cs.nmsu.edu) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_UINT_TYPES -#define INCLUDED_UINT_TYPES - -#ifdef HAVE_STDINT_H - -# include -typedef uint8_t t_uint8; -typedef uint16_t t_uint16; -typedef uint32_t t_uint32; -typedef uint64_t t_uint64; -# define HAVE_UINT64_T - -#else -#ifdef HAVE_MODE_ATTR -typedef unsigned int t_uint8 MODE_ATTR(__QI__); -typedef unsigned int t_uint16 MODE_ATTR(__HI__); -typedef unsigned int t_uint32 MODE_ATTR(__SI__); -typedef unsigned int t_uint64 MODE_ATTR(__DI__); /* FIXME: I guess DI is always available... Is there a way to check? */ -# define HAVE_UINT64_T - -# else - -# ifdef HAVE_LIMITS_H -# include -# endif -# ifndef CHAR_BIT -# define MY_CHAR_BIT 8 /* well, this is usually true :) */ -# else -# define MY_CHAR_BIT CHAR_BIT -# endif - -# if SIZEOF_UNSIGNED_CHAR*MY_CHAR_BIT == 8 -typedef unsigned char t_uint8; -# else -# error "Unable to find 8-bit integer type" -# endif - -# if SIZEOF_UNSIGNED_SHORT*MY_CHAR_BIT == 16 -typedef unsigned short t_uint16; -# else -# if SIZEOF_UNSIGNED_INT*MY_CHAR_BIT == 16 -typedef unsigned int t_uint16; -# else -# error "Unable to find 16-bit integer type" -# endif -# endif - -# if SIZEOF_UNSIGNED_SHORT*MY_CHAR_BIT == 32 -typedef unsigned short t_uint32; -# else -# if SIZEOF_UNSIGNED_INT*MY_CHAR_BIT == 32 -typedef unsigned int t_uint32; -# else -# if SIZEOF_UNSIGNED_LONG*MY_CHAR_BIT == 32 -typedef unsigned long t_uint32; -# else -# error "Unable to find 32-bit integer type" -# endif -# endif -# endif - -# if SIZEOF_UNSIGNED_INT*MY_CHAR_BIT == 64 -typedef unsigned int t_uint64; -# define HAVE_UINT64_T -# else -# if SIZEOF_UNSIGNED_LONG*MY_CHAR_BIT == 64 -typedef unsigned long t_uint64; -# define HAVE_UINT64_T -# else -# if SIZEOF_UNSIGNED_LONG_LONG*MY_CHAR_BIT == 64 -typedef unsigned long long t_uint64; -# define HAVE_UINT64_T -# endif -# endif -# endif - -# undef MY_CHAR_BIT - -# endif -#endif - -#endif diff --git a/d2pack109/src/compat/uname.c b/d2pack109/src/compat/uname.c deleted file mode 100644 index a2b3e31..0000000 --- a/d2pack109/src/compat/uname.c +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2000 Ross Combs (rocombs@cs.nmsu.edu) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#include "common/setup_before.h" -#ifndef HAVE_UNAME - -#ifdef HAVE_STRING_H -# include -#else -# ifdef HAVE_STRINGS_H -# include -# endif -#endif -#include -#include "uname.h" -#include "common/setup_after.h" - - -extern int uname(struct utsname * buf) -{ - if (!buf) - { - errno = EFAULT; - return -1; - } - -#ifdef WIN32 -/* FIXME: distinguish between: */ -/* Microsoft Windows 3.1-32s/3.11-32s/95/95SP1/95A/95B/95OSR2/95OSR2.1/95OSR2.5/95B+MSIE/98/98OEM/98SE/2000ME "New Technology" 3.1/3.5 Server/3.51 Server/4.0 Server/4.0SP1 Server/4.0SP2 Server/4.0SP3 Server/4.0SP4 Server/4.0SP6 Server/3.5 Workstation/3.51 Workstation/4.0 Workstation/4.0SP1 Workstation/4.0SP2 Workstation/4.0SP3 Workstation/4.0SP4 Workstation/4.0SP6 Workstation/"2000 Professional Edition"/"2000 Server"/"2000 Advanced Server"/"Windows 2000 Terminal Server" Win CE/"Windows Powered"/"Pocket OS" 1.0/1.1/2.0/2.1 */ -/* maybe report the build number too */ - strcpy(buf->sysname,"Win32"); -#else - strcpy(buf->sysname,""); -#endif - strcpy(buf->nodename,""); - strcpy(buf->release,""); - strcpy(buf->version,""); - strcpy(buf->machine,""); - strcpy(buf->domainname,""); - - return 0; -} - -#else -typedef int filenotempty; /* make ISO standard happy */ -#endif diff --git a/d2pack109/src/compat/uname.h b/d2pack109/src/compat/uname.h deleted file mode 100644 index b1a52f4..0000000 --- a/d2pack109/src/compat/uname.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) 2000 Ross Combs (rocombs@cs.nmsu.edu) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_UNAME_TYPES -#define INCLUDED_UNAME_TYPES - -#ifndef HAVE_UNAME - -#ifndef SYS_NMLN -# define SYS_NMLN 64 -#endif - -struct utsname -{ - char sysname[SYS_NMLN]; - char nodename[SYS_NMLN]; - char release[SYS_NMLN]; - char version[SYS_NMLN]; - char machine[SYS_NMLN]; - char domainname[SYS_NMLN]; -}; - -#endif - -#endif - - -#ifndef INCLUDED_UNAME_PROTOS -#define INCLUDED_UNAME_PROTOS - -#ifndef HAVE_UNAME -extern int uname(struct utsname * buf); -#endif - -#endif diff --git a/d2pack109/src/configure.in b/d2pack109/src/configure.in deleted file mode 100644 index ee3c8f1..0000000 --- a/d2pack109/src/configure.in +++ /dev/null @@ -1,196 +0,0 @@ -# -# Copyright (C) 1999 Rob Crittenden (rcrit@greyoak.com) -# Copyright (C) 1999,2000 Ross Combs (rocombs@cs.nmsu.edu) -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# - -# Process this file with autoconf to produce a configure script. -AC_INIT(d2cs/handle_d2gs.c) -AC_CONFIG_HEADER(config.h) - -AUTOCONF_CONFIG_DIR="autoconf" -AC_CONFIG_AUX_DIR(${AUTOCONF_CONFIG_DIR}) -builtin(include,autoconf/ccstdc.m4) -builtin(include,autoconf/mkdir.m4) - -AC_CANONICAL_SYSTEM - -# Checks for programs. -AC_PROG_CC -AC_PROG_INSTALL - -# Checks compiler. -AC_PROG_CPP - -# Checks for systems. -AC_AIX -AC_ISC_POSIX -AC_MINIX - -# Custom checks. -zwarnflags="" -AC_ARG_WITH(warn, [ --with-warn enable compiler warnings], [zwarnflags="-pedantic -Wall -W -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-qual -Wcast-align -Wwrite-strings -Wstrict-prototypes -Wmissing-declarations -Wredundant-decls -Wnested-externs -Wunreachable-code -Winline -Wpacked -Wno-sign-compare"]) - - -extra_include="" -AC_ARG_WITH(includes, [ --with-includes=DIR search include DIR for header files], [ -case "x$withval" in -x/*|x.*) - AC_MSG_RESULT([adding ${withval} to include search path]) - if test ! -d ${withval}; then - AC_MSG_RESULT([Warning: directory ${withval} does not exist]) - fi - extra_include="${extra_include} -I${withval}" - ;; -*) - AC_MSG_RESULT([not adding any includes]) - ;; -esac]) - -extra_lib_dir="" -AC_ARG_WITH(libraries, [ --with-libraries=DIR search library DIR for libraries], [ -case "x${withval}" in -x/*|x.*) - AC_MSG_RESULT([adding ${withval} to library search path]) - if test ! -d ${withval}; then - AC_MSG_RESULT([Warning: directory ${withval} does not exist]) - fi - extra_lib_dir="${extra_lib_dir} -L${withval}" - ;; -*) - AC_MSG_RESULT([not adding any libs]) - ;; -esac]) - -extra_lib="" -extra_define="" - -LDFLAGS="${LDFLAGS} ${extra_lib_dir}" -LIBS="${LIBS} ${extra_lib}" -CFLAGS="${CFLAGS} ${zwarnflags}" -DEFINES="${DEFINES} ${extra_define}" -CPPFLAGS="${CPPFLAGS} ${extra_include}" - -# This is our invention so we have to substitute it ourselves -# autoconf uses DEFS -AC_SUBST(DEFINES) - -# Checks for compiler quirks. -AC_PROG_GCC_TRADITIONAL -AM_PROG_CC_STDC -AC_C_CONST -AC_C_INLINE -#AC_EXEEXT - -# Checks for libraries. -AC_CHECK_LIB(m, pow, [LIBS="$LIBS -lm"]) -AC_CHECK_LIB(nsl, gethostbyname, [LIBS="$LIBS -lnsl"]) -AC_CHECK_LIB(socket, socket, [LIBS="$LIBS -lsocket"]) -AC_CHECK_LIB(resolv, inet_aton, [LIBS="$LIBS -lresolv"]) -AC_CHECK_LIB(z, compress, [LIBS="$LIBS -lz"]) -dnl BeOS BONE... -AC_CHECK_LIB(bind, __inet_aton, [LIBS="$LIBS -lbind"]) -case "$host" in - [*-beos*]) - if test "$ac_cv_lib_bind___inet_aton" = "yes"; then - dnl force things, AC_CHECK_FUNC will never get the mangled versions anyway. - echo "Forcing inet_aton() and inet_ntoa() to be enabled" - ac_cv_func_inet_aton='yes' - ac_cv_func_inet_ntoa='yes' - fi - ;; -esac - -mssql_include_path="" -dnl Detecting mssql paths -if test "$ac_with_mssql" = "yes" ; then - echo -n "checking for mssql/FreeTDS include path ... " - mssql_try_includes="/usr/include /usr/include/freetds /usr/local/include /usr/local/include/freetds /usr/local/freetds/include" - for i in `echo ${mssql_try_includes}`; do - if test -f "${i}/sqlfront.h" ; then - echo ${i} - CPPFLAGS="${CPPFLAGS} -I${i}" - mssql_include_path=${i} - break - fi - done -fi - -mssql_lib_path="" -if test "$ac_with_mssql" = "yes" ; then - AC_CHECK_LIB(sybdb, dbinit, [DEFINES="${DEFINES} -DWITH_SQL_MSSQL" ; LIBS="${LIBS} -lsybdb"], [ - echo -n "checking for mssql/FreeTDS lib path ... " - mssql_try_libs="/usr/lib /usr/lib/freetds /usr/local/lib /usr/local/lib/freetds /usr/local/freetds/lib" - for i in `echo ${mssql_try_libs}`; do - if test -f "${i}/libsybdb.so" -o -f "${i}/libsybdb.a" ; then - echo ${i} - save_ldflags="${LDFLAGS}" - LDFLAGS="${LDFLAGS} -L${i}" - AC_CHECK_LIB(sybdb, dbclose, [DEFINES="${DEFINES} -DWITH_SQL_MSSQL" ; LIBS="${LIBS} -lsybdb" ; mssql_lib_path="${i}"], [LDFLAGS="${save_ldflags}"]) - break - fi - done - ]) -fi - -# Checks for header files. -AC_HEADER_DIRENT -AC_HEADER_STDC -AC_HEADER_TIME -AC_HEADER_STAT -AC_CHECK_HEADERS(fcntl.h time.h sys/time.h sys/select.h string.h strings.h unistd.h stdarg.h varargs.h malloc.h sys/utsname.h sys/timeb.h sys/socket.h sys/param.h netinet/in.h arpa/inet.h netdb.h termios.h stddef.h memory.h sys/types.h sys/wait.h sys/ioctl.h stdint.h sys/file.h limits.h poll.h sys/poll.h stropts.h sys/stropts.h sys/stat.h pwd.h grp.h dir.h direct.h sys/mman.h sys/event.h sys/epoll.h sys/resource.h assert.h) - -# Checks for typedefs and structures -AC_STRUCT_TM -AC_TYPE_PID_T -AC_TYPE_SIGNAL -AC_TYPE_OFF_T -AC_TYPE_SIZE_T -AC_CHECK_SIZEOF(unsigned char, 1) -AC_CHECK_SIZEOF(unsigned short, 2) -AC_CHECK_SIZEOF(unsigned int, 4) -AC_CHECK_SIZEOF(unsigned long, 4) -AC_CHECK_SIZEOF(unsigned long long, 0) - -# Checks for library functions. -AC_FUNC_MMAP -AC_FUNC_STRFTIME -AC_FUNC_VPRINTF -AC_FUNC_SETPGRP -AC_FUNC_CLOSEDIR_VOID -AC_FUNC_MKDIR_ARGS -AC_CHECK_FUNCS(gethostname gettimeofday select socket strdup strtoul strerror inet_aton inet_ntoa uname recv send recvfrom sendto uname fork getpid sigaction sigprocmask sigaddset setpgid setpgrp ftime strcasecmp strncasecmp stricmp strnicmp chdir difftime strchr strrchr index rindex memcpy memset memmove bcopy wait waitpid pipe getenv ioctl setsid mktime poll gethostbyname getservbyname getlogin pow getpwnam getgrnam getuid getgid setuid setgid mkdir _mkdir strsep getopt kqueue setitimer epoll_create getrlimit) - -if test X"${am_cv_prog_cc_stdc}" = X"no"; then - COMPILEANSI1='${PREPROCESS} $< | sed '"'"'s/^# *\([0-9][0-9]*\) *\([^ ]*[a-z][^ ]*\) *.*$$/#line \1 \2/'"'"' | ${SRC_ACDIR}/ansi2knr > ${SRC_SRCDIR}/.ansi2knr_tmp.c' - COMPILEANSI2='${COMPILE} ${SRC_SRCDIR}/.ansi2knr_tmp.c -o $@' - COMPILEANSI3='@${RMF} ${SRC_SRCDIR}/.ansi2knr_tmp.c' - ANSI2KNR_TMP='${SRC_SRCDIR}/.ansi2knr_tmp.c' - ANSI2KNR_DEP='${SRC_ACDIR}/ansi2knr' -else - COMPILEANSI1='${COMPILE} $< -o $@' - COMPILEANSI2='@:' - COMPILEANSI3='@:' - ANSI2KNR_TMP='' - ANSI2KNR_DEP='' -fi -AC_SUBST(COMPILEANSI1) -AC_SUBST(COMPILEANSI2) -AC_SUBST(COMPILEANSI3) -AC_SUBST(ANSI2KNR_TMP) -AC_SUBST(ANSI2KNR_DEP) - -AC_OUTPUT(Makefile) diff --git a/d2pack109/src/d2cs/bit.h b/d2pack109/src/d2cs/bit.h deleted file mode 100644 index 0e66e47..0000000 --- a/d2pack109/src/d2cs/bit.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2000,2001 Onlyer (onlyer@263.net) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_BIT_H -#define INCLUDED_BIT_H - -#define BIT_POS(n) ( 1u << (n) ) -#define BIT_SET_FLAG(n,f) ( (n) |= (f) ) -#define BIT_CLR_FLAG(n,f) ( (n) &= ~(f) ) -#define BIT_TST_FLAG(n,f) ( (n) & (f) ) - -#define BIT_RANGE(n,m) ( BIT_POS((m)+1-(n)) - BIT_POS(n) ) -#define BIT_LSHIFT(n,m) ( (n) << (m) ) -#define BIT_RSHIFT(n,m) ( (n) >> (m) ) - -#endif diff --git a/d2pack109/src/d2cs/bnetd.c b/d2pack109/src/d2cs/bnetd.c deleted file mode 100644 index f3f2ae6..0000000 --- a/d2pack109/src/d2cs/bnetd.c +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (C) 2000,2001 Onlyer (onlyer@263.net) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#include "common/setup_before.h" -#include "setup.h" - -#ifdef HAVE_STDDEF_H -# include -#else -# ifndef NULL -# define NULL ((void *)0) -# endif -#endif -#ifdef TIME_WITH_SYS_TIME -# include -# include -#else -# ifdef HAVE_SYS_TIME_H -# include -# else -# include -# endif -#endif - -#include "bnetd.h" -#include "prefs.h" -#include "s2s.h" -#include "handle_bnetd.h" -#include "connection.h" -#include "common/eventlog.h" -#include "common/setup_after.h" - -static t_connection * bnetd_connection=NULL; - -extern int bnetd_init(void) -{ - return bnetd_check(); -} - -extern int bnetd_check(void) -{ - static unsigned int prev_connecting_checktime=0; - - if (bnetd_connection) { - if (d2cs_conn_get_state(bnetd_connection)==conn_state_connecting) { - if (time(NULL) - prev_connecting_checktime > prefs_get_s2s_timeout()) { - eventlog(eventlog_level_warn,__FUNCTION__,"connection to bnetd s2s timeout"); - d2cs_conn_set_state(bnetd_connection,conn_state_destroy); - return -1; - } - } - return 0; - } - if (!(bnetd_connection=s2s_create(prefs_get_bnetdaddr(),BNETD_SERV_PORT,conn_class_bnetd))) { - return -1; - } - if (d2cs_conn_get_state(bnetd_connection)==conn_state_init) { - handle_bnetd_init(bnetd_connection); - } else { - prev_connecting_checktime=time(NULL); - } - return 0; -} - - -extern t_connection * bnetd_conn(void) -{ - return bnetd_connection; -} - -extern int bnetd_set_connection(t_connection * c) -{ - bnetd_connection=c; - return 0; -} - -extern int bnetd_destroy(t_connection * c) -{ - if (bnetd_connection != c) { - eventlog(eventlog_level_error,__FUNCTION__,"bnetd connection do not match"); - return -1; - } - bnetd_connection=NULL; - return 0; -} diff --git a/d2pack109/src/d2cs/bnetd.h b/d2pack109/src/d2cs/bnetd.h deleted file mode 100644 index 00c5d8d..0000000 --- a/d2pack109/src/d2cs/bnetd.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2000,2001 Onlyer (onlyer@263.net) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_BNETD_H -#define INCLUDED_BNETD_H - -#include "s2s.h" - -extern int bnetd_init(void); -extern int bnetd_check(void); -extern t_connection * bnetd_conn(void); -extern int bnetd_destroy(t_connection * c); -extern int bnetd_set_connection(t_connection * c); -extern int bnetd_keepalive(void); - -#endif diff --git a/d2pack109/src/d2cs/cmdline_parse.c b/d2pack109/src/d2cs/cmdline_parse.c deleted file mode 100644 index bad125c..0000000 --- a/d2pack109/src/d2cs/cmdline_parse.c +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Copyright (C) 2000,2001 Onlyer (onlyer@263.net) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#include "common/setup_before.h" -#include "setup.h" - -#ifdef HAVE_STDDEF_H -# include -#else -# ifndef NULL -# define NULL ((void *)0) -# endif -#endif -#include -#ifdef HAVE_STRING_H -# include -#else -# ifdef HAVE_STRINGS_H -# include -# endif -# ifdef HAVE_MEMORY_H -# include -# endif -#endif -#include "compat/memset.h" - -#include "conf.h" -#include "version.h" -#include "cmdline_parse.h" -#include "common/eventlog.h" -#include "common/setup_after.h" - -static t_conf_table param_conf_table[]={ - { "-c", offsetof(t_param,prefs_file), conf_type_str, 0, D2CS_DEFAULT_CONF_FILE}, - { "-l", offsetof(t_param,logfile), conf_type_str, 0, NULL }, - { "-h", offsetof(t_param,help), conf_type_bool,0, NULL }, - { "--help", offsetof(t_param,help), conf_type_bool,0, NULL }, - { "-v", offsetof(t_param,version), conf_type_bool,0, NULL }, - { "--version", offsetof(t_param,version), conf_type_bool,0, NULL }, - { "-f", offsetof(t_param,foreground), conf_type_bool,0, NULL }, - { "--foreground",offsetof(t_param,foreground), conf_type_bool,0, NULL }, - { "-D", offsetof(t_param,debugmode), conf_type_bool,0, NULL }, - { "--debug", offsetof(t_param,debugmode), conf_type_bool,0, NULL }, -#ifdef WIN32 - { "--service", offsetof(t_param,run_as_service),conf_type_bool,0, NULL }, - { "-s", offsetof(t_param,make_service), conf_type_str, 0, NULL }, -#endif - { NULL, 0, conf_type_none,0, NULL } -}; - -static t_param cmdline_param; - -static char help_message[]="\n" -"Usage: d2cs []\n" -" -m : set memory debug logging file to FILE\n" -" -c : set configuration file to FILE\n" -" -l : set log to FILE\n" -" -h, --help: show this help message and exit\n" -" -v, --version: show version information and exit\n" -" -f, --foreground: start in foreground mode (don`t daemonize)\n" -" -D, --debug: run in debug mode (run in foreground and log to stdout)\n" -#ifdef WIN32 -" Running as service functions:\n" -" --service run as service\n" -" -s install install service\n" -" -s uninstall uninstall service\n" -#endif -"\n" -"Notes:\n" -" 1.You should always use absolute path here for all FILE names\n\n"; - -extern void cmdline_show_help(void) -{ - fprintf(stderr,help_message); - return; -} - -extern void cmdline_show_version(void) -{ - fprintf(stderr,D2CS_VERSION); - fprintf(stderr,"\n\n"); - return; -} - -extern int cmdline_parse(int argc, char ** argv) -{ - memset(&cmdline_param,0, sizeof(cmdline_param)); - if (conf_parse_param(argc, argv, param_conf_table, &cmdline_param, sizeof(cmdline_param))<0) { - return -1; - } - return 0; -} - -extern int cmdline_cleanup(void) -{ - return conf_cleanup(param_conf_table, &cmdline_param, sizeof(cmdline_param)); -} - -extern char const * cmdline_get_prefs_file(void) -{ - return cmdline_param.prefs_file; -} - -extern unsigned int cmdline_get_help(void) -{ - return cmdline_param.help; -} - -extern unsigned int cmdline_get_version(void) -{ - return cmdline_param.version; -} - -extern unsigned int cmdline_get_foreground(void) -{ - return cmdline_param.foreground; -} - -extern unsigned int cmdline_get_debugmode(void) -{ - return cmdline_param.debugmode; -} - -extern char const * cmdline_get_logfile(void) -{ - return cmdline_param.logfile; -} - -#ifdef WIN32 -extern unsigned int cmdline_get_run_as_service(void) -{ - return cmdline_param.run_as_service; -} - -extern char const * cmdline_get_make_service(void) -{ - return cmdline_param.make_service; -} - -#endif diff --git a/d2pack109/src/d2cs/cmdline_parse.h b/d2pack109/src/d2cs/cmdline_parse.h deleted file mode 100644 index a41d7cf..0000000 --- a/d2pack109/src/d2cs/cmdline_parse.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (C) 2000,2001 Onlyer (onlyer@263.net) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_CMDLINE_PARSE_H -#define INCLUDED_CMDLINE_PARSE_H - -typedef struct -{ - char const * prefs_file; - char const * logfile; - unsigned int foreground; - unsigned int help; - unsigned int version; - unsigned int debugmode; - unsigned int run_as_service; - char const * make_service; -} t_param; - -extern int cmdline_parse(int argc, char ** argv); -extern int cmdline_cleanup(void); -extern void cmdline_show_help(void); -extern void cmdline_show_version(void); -extern char const * cmdline_get_prefs_file(void); -extern char const * cmdline_get_logfile(void); -extern unsigned int cmdline_get_version(void); -extern unsigned int cmdline_get_help(void); -extern unsigned int cmdline_get_foreground(void); -extern unsigned int cmdline_get_debugmode(void); -#ifdef WIN32 -extern unsigned int cmdline_get_run_as_service(void); -extern char const * cmdline_get_make_service(void); -#endif - -#endif diff --git a/d2pack109/src/d2cs/conf.c b/d2pack109/src/d2cs/conf.c deleted file mode 100644 index b0fb68b..0000000 --- a/d2pack109/src/d2cs/conf.c +++ /dev/null @@ -1,319 +0,0 @@ -/* - * Copyright (C) 2000,2001 Onlyer (onlyer@263.net) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#include "common/setup_before.h" -#include "setup.h" - -#ifdef HAVE_STDDEF_H -# include -#else -# ifndef NULL -# define NULL ((void *)0) -# endif -#endif -#include -#ifdef STDC_HEADERS -# include -#else -# ifdef HAVE_MALLOC_H -# include -# endif -#endif -#ifdef HAVE_STRING_H -# include -#else -# ifdef HAVE_STRINGS_H -# include -# endif -# ifdef HAVE_MEMORY_H -# include -# endif -#endif -#include "compat/strcasecmp.h" -#include "compat/strtoul.h" -#include "compat/memset.h" -#include "compat/strdup.h" -#include -#include "compat/strerror.h" - -#include "xstring.h" -#include "conf.h" -#include "common/util.h" -#include "common/eventlog.h" -#include "common/xalloc.h" -#include "common/setup_after.h" - -static int conf_set_default(t_conf_table * conf_table, void * param_data, int datalen); -static int conf_set_value(t_conf_table * conf, void * param_data, char * value); -static int conf_int_set(void * data, int value); -static int conf_bool_set(void * data, int value); -static int conf_str_set(void * data, char const * value); -static int conf_hexstr_set(void * data, char const * value); -static int conf_type_get_size(e_conf_type type); - -static int conf_int_set(void * data, int value) -{ - int * p; - - p=(int *)data; - *p=value; - return 0; -} - -static int conf_bool_set(void * data, int value) -{ - char * p; - - p=(char *)data; - *p=tf(value); - return 0; -} - -static int conf_str_set(void * data, char const * value) -{ - char * * p; - - p=(char * *)data; - if (*p) xfree(*p); - if (value) *p=xstrdup(value); - else *p=NULL; - - return 0; -} - -static int conf_hexstr_set(void * data, char const * value) -{ - char * * p; - - p=(char * *)data; - if (*p) xfree(*p); - if (value) *p=hexstrdup(value); - else *p=NULL; - return 0; -} - -static int conf_set_default(t_conf_table * conf_table, void * param_data, int datalen) -{ - unsigned int i; - char * p; - - ASSERT(conf_table,-1); - ASSERT(param_data,-1); - memset(param_data,0,datalen); - for (i=0; conf_table[i].name; i++) { - if (conf_table[i].offset + conf_type_get_size(conf_table[i].type) > datalen) { - eventlog(eventlog_level_error,__FUNCTION__,"conf table item %d bad offset %d exceed %d",i,conf_table[i].offset,datalen); - return -1; - } - p=(char *)param_data+conf_table[i].offset; - switch (conf_table[i].type) { - CASE(conf_type_bool, conf_bool_set(p, conf_table[i].def_intval)); - CASE(conf_type_int, conf_int_set(p, conf_table[i].def_intval)); - CASE(conf_type_str, conf_str_set(p, conf_table[i].def_strval)); - CASE(conf_type_hexstr, conf_hexstr_set(p, conf_table[i].def_strval)); - default: - eventlog(eventlog_level_error,__FUNCTION__,"conf table item %d bad type %d",i,conf_table[i].type); - return -1; - } - } - return 0; -} - -static int conf_set_value(t_conf_table * conf, void * param_data, char * value) -{ - char * p; - - ASSERT(conf,-1); - ASSERT(param_data,-1); - ASSERT(value,-1); - p=(char *)param_data+conf->offset; - switch (conf->type) { - CASE(conf_type_bool, conf_bool_set(p, strtoul(value,NULL,0))); - CASE(conf_type_int, conf_int_set(p, strtoul(value,NULL,0))); - CASE(conf_type_str, conf_str_set(p, value)); - CASE(conf_type_hexstr, conf_hexstr_set(p, value)); - default: - eventlog(eventlog_level_error,__FUNCTION__,"got bad conf type %d",conf->type); - return -1; - } - return 0; -} - -static int conf_type_get_size(e_conf_type type) -{ - switch (type) { - case conf_type_bool: - return sizeof(char); - case conf_type_int: - return sizeof(int); - case conf_type_str: - case conf_type_hexstr: - return sizeof(char *); - default: - eventlog(eventlog_level_error,__FUNCTION__,"got bad conf type %d",type); - return 0; - } -} - -extern int conf_parse_param(int argc, char ** argv, t_conf_table * conf_table, void * data, int datalen) -{ - int i; - unsigned int j; - char * p; - int match; - - ASSERT(argc,-1); - ASSERT(argv,-1); - ASSERT(data, -1); - if (conf_set_default(conf_table, data, datalen)<0) { - eventlog(eventlog_level_error,__FUNCTION__,"error setting default values"); - return -1; - } - for (i=1; i< argc; i++) { - match=0; - for (j=0; conf_table[j].name; j++) { - if (!strcmp(conf_table[j].name,argv[i])) { - match=1; - p=(char *)data + conf_table[j].offset; - switch (conf_table[j].type) { - case conf_type_bool: - conf_bool_set(p,1); - break; - case conf_type_int: - if (i+1>=argc) { - eventlog(eventlog_level_error,__FUNCTION__,"got bad int conf %s without value",argv[i]); - break; - } - i++; - conf_int_set(p,strtoul(argv[i],NULL,0)); - break; - case conf_type_str: - if (i+1>=argc) { - eventlog(eventlog_level_error,__FUNCTION__,"got bad str conf %s without value",argv[i]); - break; - } - i++; - conf_str_set(p,argv[i]); - break; - case conf_type_hexstr: - if (i+1>=argc) { - eventlog(eventlog_level_error,__FUNCTION__,"got bad hexstr conf %s without value",argv[i]); - break; - } - i++; - conf_hexstr_set(p,argv[i]); - break; - default: - eventlog(eventlog_level_error,__FUNCTION__,"got bad conf type %d",conf_table[i].type); - break; - } - break; - } - } - if (!match) { - eventlog(eventlog_level_error,__FUNCTION__,"bad option \"%s\"",argv[i]); - return -1; - } - } - return 0; -} - -extern int conf_load_file(char const * filename, t_conf_table * conf_table, void * param_data, int datalen) -{ - FILE * fp; - unsigned int i, line, count, match; - char * buff; - char * * item; - - ASSERT(conf_table,-1); - ASSERT(param_data,-1); - if (conf_set_default(conf_table, param_data, datalen)<0) { - eventlog(eventlog_level_error,__FUNCTION__,"error setting default values"); - return -1; - } - if (!filename) return 0; - if (!(fp=fopen(filename,"r"))) { - eventlog(eventlog_level_error,__FUNCTION__,"could not open configuration file \"%s\" for reading (fopen: %s)",filename,strerror(errno)); - return -1; - } - for (line=1; (buff=file_get_line(fp)); line++) { - if (buff[0]=='#') { - xfree(buff); - continue; - } - if (!(item=strtoargv(buff,&count))) { - xfree(buff); - continue; - } - xfree(buff); - if (!count) { - xfree(item); - continue; - } - if (count!=3) { - eventlog(eventlog_level_error,__FUNCTION__,"bad item count %d in file %s line %d",count,filename,line); - xfree(item); - continue; - } - if (strcmp(item[1],"=")) { - eventlog(eventlog_level_error,__FUNCTION__,"missing '=' in file %s line %d",filename,line); - xfree(item); - continue; - } - match=0; - for (i=0; conf_table[i].name; i++) { - if (!strcasecmp(conf_table[i].name,item[0])) { - conf_set_value(conf_table+i, param_data, item[2]); - match=1; - } - } - if (!match) { - eventlog(eventlog_level_warn,__FUNCTION__,"got unknown field \"%s\" in line %d,(ignored)",item[0],line); - } - xfree(item); - } - fclose(fp); - return 0; -} - -extern int conf_cleanup(t_conf_table * conf_table, void * param_data, int datalen) -{ - unsigned int i; - char * p; - - ASSERT(conf_table,-1); - ASSERT(param_data,-1); - for (i=0; conf_table[i].name; i++) { - if (conf_table[i].offset + conf_type_get_size(conf_table[i].type) > datalen) { - eventlog(eventlog_level_error,__FUNCTION__,"conf table item %d bad offset %d exceed %d",i,conf_table[i].offset,datalen); - return -1; - } - - p=(char *)param_data+conf_table[i].offset; - switch (conf_table[i].type) { - CASE(conf_type_bool, conf_bool_set(p, 0)); - CASE(conf_type_int, conf_int_set(p, 0)); - CASE(conf_type_str, conf_str_set(p, NULL)); - CASE(conf_type_hexstr, conf_hexstr_set(p, NULL)); - default: - eventlog(eventlog_level_error,__FUNCTION__,"conf table item %d bad type %d",i,conf_table[i].type); - return -1; - } - } - memset(param_data,0,datalen); - return 0; -} diff --git a/d2pack109/src/d2cs/conf.h b/d2pack109/src/d2cs/conf.h deleted file mode 100644 index 639f4af..0000000 --- a/d2pack109/src/d2cs/conf.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 2000,2001 Onlyer (onlyer@263.net) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_CONFFILE_H -#define INCLUDED_CONFFILE_H - -typedef enum -{ - conf_type_none, - conf_type_bool, - conf_type_int, - conf_type_str, - conf_type_hexstr -} e_conf_type; - -typedef struct -{ - char const * name; - int offset; - e_conf_type type; - int def_intval; - char const * def_strval; -} t_conf_table; - -extern int conf_cleanup(t_conf_table * conf_table, void * param_data, int size); -extern int conf_load_file(char const * filename, t_conf_table * conf_table, void * data, int datalen); -extern int conf_parse_param(int argc, char * * argv, t_conf_table * conf_table, void * data, int datalen); - -#endif diff --git a/d2pack109/src/d2cs/connection.c b/d2pack109/src/d2cs/connection.c deleted file mode 100644 index 02fff92..0000000 --- a/d2pack109/src/d2cs/connection.c +++ /dev/null @@ -1,839 +0,0 @@ -/* - * Copyright (C) 2000,2001 Onlyer (onlyer@263.net) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#include "common/setup_before.h" -#include "setup.h" - -#include -#ifdef HAVE_STRING_H -# include -#else -# ifdef HAVE_STRINGS_H -# include -# endif -# ifdef HAVE_MEMORY_H -# include -# endif -#endif -#ifdef STDC_HEADERS -# include -#else -# ifdef HAVE_MALLOC_H -# include -# endif -#endif -#include "compat/memcpy.h" -#include "compat/strdup.h" -#ifdef HAVE_UNISTD_H -# include -#endif -#ifdef HAVE_SYS_TYPES_H -# include -#endif -#ifdef HAVE_SYS_SOCKET_H -# include -#endif -#include "compat/psock.h" -#ifdef HAVE_NETINET_IN_H -# include -#endif -#include "compat/netinet_in.h" -#ifdef HAVE_LIMITS_H -# include -#endif -#include "compat/char_bit.h" -#ifdef TIME_WITH_SYS_TIME -# include -# include -#else -# ifdef HAVE_SYS_TIME_H -# include -# else -# include -# endif -#endif -#ifdef HAVE_ASSERT_H -# include -#endif - -#include "compat/psock.h" -#include "compat/strcasecmp.h" -#include "connection.h" -#include "game.h" -#include "gamequeue.h" -#include "prefs.h" -#include "d2gs.h" -#include "net.h" -#include "s2s.h" -#include "handle_d2gs.h" -#include "handle_d2cs.h" -#include "handle_init.h" -#include "handle_bnetd.h" -#include "d2charfile.h" -#include "common/fdwatch.h" -#include "common/addr.h" -#include "common/introtate.h" -#include "common/network.h" -#include "common/packet.h" -#include "common/hashtable.h" -#include "common/queue.h" -#include "common/eventlog.h" -#include "common/xalloc.h" -#include "common/setup_after.h" - -static t_hashtable * connlist_head=NULL; -static t_hashtable * conn_charname_list_head=NULL; -static t_list * connlist_dead=NULL; -static unsigned int total_connection=0; - -static int conn_handle_connecting(t_connection * c); -static t_packet * conn_create_packet(t_connection * c); -static int conn_handle_packet(t_connection * c, t_packet * packet); -static int conn_handle_read(t_connection * c); -static int conn_handle_write(t_connection * c); -static unsigned int conn_charname_hash(char const * charname); -static unsigned int conn_sessionnum_hash(unsigned int sessionnum); - -static unsigned int conn_sessionnum_hash(unsigned int sessionnum) -{ - return sessionnum; -} - -static unsigned int conn_charname_hash(char const * charname) -{ - unsigned int hash; - unsigned int i, len, pos; - unsigned int ch; - - ASSERT(charname,0); - len=strlen(charname); - for (hash=0, i=0, pos=0; isessionnum==sessionnum) { - hashtable_entry_release(curr); - return c; - } - } - return NULL; -} - -extern t_connection * d2cs_connlist_find_connection_by_charname(char const * charname) -{ - t_entry * curr; - t_connection * c; - unsigned int hash; - - hash=conn_charname_hash(charname); - HASHTABLE_TRAVERSE_MATCHING(connlist_head,curr,hash) - { - if (!(c=entry_get_data(curr))) { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL connection in list"); - } else { - if (!c->charname) continue; - if (!strcmp_charname(c->charname,charname)) { - hashtable_entry_release(curr); - return c; - } - } - } - return NULL; -} - -static t_packet * conn_create_packet(t_connection * c) -{ - t_packet * packet; - - switch (c->class) { - CASE(conn_class_init, packet=packet_create(packet_class_init)); - CASE(conn_class_d2cs, packet=packet_create(packet_class_d2cs)); - CASE(conn_class_d2gs, packet=packet_create(packet_class_d2gs)); - CASE(conn_class_bnetd, packet=packet_create(packet_class_d2cs_bnetd)); - default: - eventlog(eventlog_level_error,__FUNCTION__,"got bad connection class %d",c->class); - return NULL; - } - if (!packet) { - eventlog(eventlog_level_error,__FUNCTION__,"error create packet"); - return NULL; - } - d2cs_conn_set_in_queue(c,packet); - return packet; -} - -static int conn_handle_connecting(t_connection * c) -{ - int retval; - - if (net_check_connected(c->sock)<0) { - eventlog(eventlog_level_warn,__FUNCTION__,"can not connect to %s",addr_num_to_addr_str(c->addr, c->port)); - return -1; - } - eventlog(eventlog_level_info,__FUNCTION__,"connected to %s",addr_num_to_addr_str(c->addr, c->port)); - c->state=conn_state_init; - /* this is a kind of hack to not update fd but updating breaks kqueue - * and the clean fix would require a cache a userland copy of the kernel - * kqueue fds, considering that it also doesnt brake anything else should do - * for the moment - fdwatch_update_fd(c->sock, fdwatch_type_read); */ - switch (c->class) { - case conn_class_bnetd: - retval=handle_bnetd_init(c); - break; - default: - eventlog(eventlog_level_error,__FUNCTION__,"got bad connection class %d",c->class); - return -1; - } - return retval; -} - -static int conn_handle_packet(t_connection * c, t_packet * packet) -{ - int retval; - - switch (c->class) { - CASE (conn_class_init, retval=d2cs_handle_init_packet(c,packet)); - CASE (conn_class_d2cs, retval=d2cs_handle_d2cs_packet(c,packet)); - CASE (conn_class_d2gs, retval=handle_d2gs_packet(c,packet)); - CASE (conn_class_bnetd, retval=handle_bnetd_packet(c,packet)); - default: - eventlog(eventlog_level_error,__FUNCTION__,"got bad connection class %d (close connection)",c->class); - retval=-1; - break; - } - return retval; -} - -static int conn_handle_read(t_connection * c) -{ - t_packet * packet; - int retval; - - packet = d2cs_conn_get_in_queue(c); - if (!packet) { - packet = conn_create_packet(c); - if (!packet) return -1; - c->insize=0; - } - - switch (net_recv_packet(c->sock,packet,&c->insize)) { - case -1: - retval=-1; - break; - case 0: - retval=0; - break; - case 1: - c->insize=0; - d2cs_conn_set_in_queue(c,NULL); - retval=conn_handle_packet(c,packet); - packet_del_ref(packet); - break; - default: - retval=0; - break; - } - return retval; -} - -static int conn_handle_write(t_connection * c) -{ - t_packet * packet; - int retval; - - if (c->state==conn_state_connecting) { - return conn_handle_connecting(c); - } - - if (!(packet=conn_peek_outqueue(c))) return 0; - - switch (net_send_packet(c->sock, packet, &c->outsize)) { - case -1: - retval=-1; - break; - case 0: - retval=0; - break; - case 1: - c->outsize=0; - packet=conn_pull_outqueue(c); - packet_del_ref(packet); - retval=0; - break; - default: - retval = -1; - } - return retval; -} - -extern int conn_handle_socket(t_connection * c) -{ - time_t now; - - ASSERT(c,-1); - now=time(NULL); - if (c->socket_flag & SOCKET_FLAG_READ) { - if (conn_handle_read(c)<0) return -1; - c->last_active=now; - } - if (c->socket_flag & SOCKET_FLAG_WRITE) { - if (conn_handle_write(c)<0) return -1; - c->last_active=now; - } - c->socket_flag=0; - return 0; -} - -extern int connlist_check_timeout(void) -{ - t_connection * c; - time_t now; - - now=time(NULL); - BEGIN_HASHTABLE_TRAVERSE_DATA(connlist_head, c) - { - switch (c->class) { - case conn_class_d2cs: - if (prefs_get_idletime() && (now - c->last_active > prefs_get_idletime())) { - eventlog(eventlog_level_info,__FUNCTION__,"client %d idled too long time, destroy it",c->sessionnum); - d2cs_conn_set_state(c,conn_state_destroy); - } - break; - case conn_class_d2gs: - if (prefs_get_s2s_idletime() && now - c->last_active > prefs_get_s2s_idletime()) { - eventlog(eventlog_level_info,__FUNCTION__,"server %d timed out",c->sessionnum); - d2cs_conn_set_state(c,conn_state_destroy); - } - break; - case conn_class_bnetd: - break; - default: - break; - } - } - END_HASHTABLE_TRAVERSE_DATA() - return 0; -} - -extern t_connection * d2cs_conn_create(int sock, unsigned int local_addr, unsigned short local_port, - unsigned int addr, unsigned short port) -{ - static unsigned int sessionnum=1; - t_connection * c; - - if (sock<0) { - eventlog(eventlog_level_error,__FUNCTION__,"got bad socket"); - return NULL; - } - c=xmalloc(sizeof(t_connection)); - c->charname=NULL; - c->account=NULL; - c->sock=sock; - c->fdw_idx = -1; - c->socket_flag=0; - c->local_addr=local_addr; - c->local_port=local_port; - c->addr=addr; - c->port=port; - c->class=conn_class_init; - c->state=conn_state_init; - c->sessionnum=sessionnum++; - c->outqueue=NULL; - c->inqueue=NULL; - c->outsize=0; - c->outsizep=0; - c->insize=0; - c->charinfo=NULL; - c->d2gs_id=0; - c->gamequeue=NULL; - c->last_active=time(NULL); - c->sessionnum_hash=conn_sessionnum_hash(c->sessionnum); - c->bnetd_sessionnum=0; - c->charname_hash=0; - if (hashtable_insert_data(connlist_head, c, c->sessionnum_hash)<0) { - xfree(c); - eventlog(eventlog_level_error,__FUNCTION__,"error add connection to list"); - return NULL; - } - total_connection++; - eventlog(eventlog_level_info,__FUNCTION__,"created session=%d socket=%d (%d current connections)", c->sessionnum, sock, total_connection); - return c; -} - -extern int d2cs_conn_destroy(t_connection * c, t_elem ** curr) -{ - t_elem * elem; - - ASSERT(c,-1); - if (c->state==conn_state_destroying) return 0; - if (hashtable_remove_data(connlist_head,c,c->sessionnum_hash)<0) { - eventlog(eventlog_level_error,__FUNCTION__,"error remove connection from list"); - return -1; - } - c->state=conn_state_destroying; - if (c->d2gs_id && c->class==conn_class_d2gs) { - d2gs_deactive(d2gslist_find_gs(c->d2gs_id),c); - } - if (c->class==conn_class_bnetd) { - s2s_destroy(c); - } - if (c->gamequeue) { - gq_destroy(c->gamequeue,&elem); - } - if (c->account) xfree((void *)c->account); - if (c->charinfo) xfree((void *)c->charinfo); - if (c->charname) d2cs_conn_set_charname(c,NULL); - if (c->inqueue) packet_del_ref(c->inqueue); - queue_clear(&c->outqueue); - - if (connlist_dead) list_remove_data(connlist_dead, c, curr); - fdwatch_del_fd(c->fdw_idx); - psock_shutdown(c->sock,PSOCK_SHUT_RDWR); - psock_close(c->sock); - - total_connection--; - eventlog(eventlog_level_info,__FUNCTION__,"[%d] closed connection %d (%d left)",c->sock,c->sessionnum,total_connection); - xfree(c); - return 0; -} - -extern int d2cs_conn_get_socket(t_connection const * c) -{ - ASSERT(c,-1); - return c->sock; -} - -extern t_conn_state d2cs_conn_get_state(t_connection const * c) -{ - ASSERT(c,conn_state_none); - return c->state; -} - -extern int d2cs_conn_set_state(t_connection * c, t_conn_state state) -{ - t_elem * curr; - - ASSERT(c,-1); - /* special case for destroying connections, add them to connlist_dead list */ - if (state == conn_state_destroy && c->state != conn_state_destroy) { - if (!connlist_dead) - connlist_dead = list_create(); - list_append_data(connlist_dead, c); - } else if (state != conn_state_destroy && c->state == conn_state_destroy) { - if (list_remove_data(connlist_dead, c, &curr)) { - eventlog(eventlog_level_error, __FUNCTION__, "could not remove dead connection"); - return -1; - } - } - c->state=state; - return 0; -} - -extern t_conn_class d2cs_conn_get_class(t_connection const * c) -{ - ASSERT(c,conn_class_none); - return c->class; -} - -extern int d2cs_conn_set_class(t_connection * c, t_conn_class class) -{ - ASSERT(c,-1); - c->class=class; - return 0; -} - -extern t_packet * d2cs_conn_get_in_queue(t_connection const * c) -{ - ASSERT(c,NULL); - return c->inqueue; -} - -extern void d2cs_conn_set_in_queue(t_connection * c, t_packet *packet) -{ - assert(c); - c->inqueue = packet; -} - -extern unsigned int d2cs_conn_get_out_size(t_connection const * c) -{ - ASSERT(c,0); - return c->outsize; -} - -extern t_queue * * d2cs_conn_get_out_queue(t_connection const * c) -{ - ASSERT(c,NULL); - return (t_queue * *)&c->outqueue; -} - -extern unsigned int d2cs_conn_get_in_size(t_connection const * c) -{ - ASSERT(c,0); - return c->insize; -} - -extern int conn_push_outqueue(t_connection * c, t_packet * packet) -{ - if (!c) - { - eventlog(eventlog_level_error, __FUNCTION__, "got NULL connection"); - return -1; - } - - if (!packet) - { - eventlog(eventlog_level_error, __FUNCTION__, "got NULL packet"); - return -1; - } - - queue_push_packet((t_queue * *)&c->outqueue, packet); - if (!c->outsizep++) fdwatch_update_fd(c->fdw_idx, fdwatch_type_read | fdwatch_type_write); - - return 0; -} - -extern t_packet * conn_peek_outqueue(t_connection * c) -{ - if (!c) - { - eventlog(eventlog_level_error, __FUNCTION__, "got NULL connection"); - return NULL; - } - - return queue_peek_packet((t_queue const * const *)&c->outqueue); -} - -extern t_packet * conn_pull_outqueue(t_connection * c) -{ - if (!c) - { - eventlog(eventlog_level_error, __FUNCTION__, "got NULL connection"); - return NULL; - } - - if (c->outsizep) { - if (!(--c->outsizep)) fdwatch_update_fd(c->fdw_idx, fdwatch_type_read); - return queue_pull_packet((t_queue * *)&c->outqueue); - } - - return NULL; -} - -extern int conn_add_socket_flag(t_connection * c, unsigned int flag) -{ - ASSERT(c,-1); - c->socket_flag |= flag; - return 0; -} - -extern int conn_process_packet(t_connection * c, t_packet * packet, t_packet_handle_table * table, - unsigned int table_size) -{ - unsigned int type; - unsigned int size; - - ASSERT(c,-1); - ASSERT(packet,-1); - ASSERT(table,-1); - type=packet_get_type(packet); - size=packet_get_size(packet); - - if (type >= table_size || !table[type].size) { - eventlog(eventlog_level_error,__FUNCTION__,"got bad packet type %d (class %d)",type,packet_get_class(packet)); - return -1; - } - if (size < table[type].size) { - eventlog(eventlog_level_error,__FUNCTION__,"got bad packet size %d (type %d class %d)",size,type,packet_get_class(packet)); - return -1; - } - if (!(c->state & table[type].state)) { - eventlog(eventlog_level_error,__FUNCTION__,"connection %d state mismatch for packet type %d (class %d)",c->sessionnum, - type,packet_get_class(packet)); - return -1; - } - if (!table[type].handler) { - eventlog(eventlog_level_error,__FUNCTION__,"missing handler for packet type %d (class %d)",type,packet_get_class(packet)); - return -1; - } - return table[type].handler(c,packet); -} - -extern int d2cs_conn_set_account(t_connection * c, char const * account) -{ - ASSERT(c,-1); - if (!account) { - if (c->account) xfree((void *)c->account); - c->account=NULL; - } - if (c->account) xfree((void *)c->account); - c->account=xstrdup(account); - - return 0; -} - -extern char const * d2cs_conn_get_account(t_connection const * c) -{ - ASSERT(c,NULL); - return c->account; -} - -extern int d2cs_conn_set_charname(t_connection * c, char const * charname) -{ - char const * temp; - - ASSERT(c,-1); - temp=NULL; - if (charname) temp=xstrdup(charname); - if (c->charname) { - if (hashtable_remove_data(conn_charname_list_head,c,c->charname_hash) <0) { - eventlog(eventlog_level_error,__FUNCTION__,"error remove charname %s from list",charname); - if (temp) xfree((void *)temp); - return -1; - } - hashtable_purge(conn_charname_list_head); - xfree((void *)c->charname); - } - if (charname) { - c->charname=temp; - c->charname_hash=conn_charname_hash(charname); - if (hashtable_insert_data(conn_charname_list_head,c,c->charname_hash) <0) { - eventlog(eventlog_level_error,__FUNCTION__,"error insert charname %s to list",charname); - xfree((void *)c->charname); - c->charname=NULL; - return -1; - } - } else { - c->charname=NULL; - c->charname_hash=0; - } - return 0; -} - -extern char const * d2cs_conn_get_charname(t_connection const * c) -{ - ASSERT(c,NULL); - return c->charname; -} - -extern unsigned int d2cs_conn_get_sessionnum(t_connection const * c) -{ - ASSERT(c,0); - return c->sessionnum; -} - -extern unsigned int conn_get_charinfo_expansion(t_connection const * c) -{ - ASSERT(c,0); - return d2charinfo_get_expansion(c->charinfo); -} - -extern unsigned int conn_get_charinfo_hardcore(t_connection const * c) -{ - ASSERT(c,0); - return d2charinfo_get_hardcore(c->charinfo); -} - -extern unsigned int conn_get_charinfo_dead(t_connection const * c) -{ - ASSERT(c,0); - return d2charinfo_get_dead(c->charinfo); -} - -extern unsigned int conn_get_charinfo_difficulty(t_connection const * c) -{ - ASSERT(c,0); - return d2charinfo_get_difficulty(c->charinfo); -} - -extern unsigned int conn_get_charinfo_level(t_connection const * c) -{ - ASSERT(c,0); - return d2charinfo_get_level(c->charinfo); -} - -extern unsigned int conn_get_charinfo_class(t_connection const * c) -{ - ASSERT(c,0); - return d2charinfo_get_class(c->charinfo); -} - -extern int conn_set_charinfo(t_connection * c, t_d2charinfo_summary const * charinfo) -{ - ASSERT(c,-1); - if (!charinfo) { - if (c->charinfo) xfree((void *)c->charinfo); - c->charinfo=NULL; - return 0; - } - if (c->charinfo) xfree((void *)c->charinfo); - c->charinfo=xmalloc(sizeof(t_d2charinfo_summary)); - memcpy((void*)c->charinfo,charinfo,sizeof(t_d2charinfo_summary)); - return 0; -} - -extern int conn_set_d2gs_id(t_connection * c, unsigned int d2gs_id) -{ - ASSERT(c,-1) - c->d2gs_id=d2gs_id; - return 0; -} - -extern unsigned int conn_get_d2gs_id(t_connection const * c) -{ - ASSERT(c,0) - return c->d2gs_id; -} - -extern unsigned int d2cs_conn_get_addr(t_connection const * c) -{ - ASSERT(c,0); - return c->addr; -} - -extern unsigned short d2cs_conn_get_port(t_connection const * c) -{ - ASSERT(c,0); - return c->port; -} - -extern t_gq * conn_get_gamequeue(t_connection const * c) -{ - ASSERT(c,NULL); - return c->gamequeue; -} - -extern int conn_set_gamequeue(t_connection * c, t_gq * gq) -{ - ASSERT(c,-1); - c->gamequeue=gq; - return 0; -} - -extern int conn_set_bnetd_sessionnum(t_connection * c, unsigned int sessionnum) -{ - ASSERT(c,-1); - c->bnetd_sessionnum=sessionnum; - return 0; -} - -extern unsigned int conn_get_bnetd_sessionnum(t_connection const * c) -{ - ASSERT(c,-1); - return c->bnetd_sessionnum; -} - -extern int conn_add_fd(t_connection * c, t_fdwatch_type rw, fdwatch_handler handler) -{ - assert(c); - c->fdw_idx = fdwatch_add_fd(c->sock,rw,handler,c); - return c->fdw_idx; -} diff --git a/d2pack109/src/d2cs/connection.h b/d2pack109/src/d2cs/connection.h deleted file mode 100644 index a322211..0000000 --- a/d2pack109/src/d2cs/connection.h +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright (C) 2000,2001 Onlyer (onlyer@263.net) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_CONNECTION_H -#define INCLUDED_CONNECTION_H - -#include "common/queue.h" -#include "common/hashtable.h" -#include "common/packet.h" -#include "common/fdwatch.h" -#include "d2charfile.h" -#include "gamequeue.h" - -typedef enum -{ - conn_state_none = 0x00, - conn_state_init = 0x01, - conn_state_connecting = 0x02, - conn_state_connected = 0x04, - conn_state_authed = 0x08, - conn_state_char_authed = 0x10, - conn_state_destroy = 0x20, - conn_state_destroying = 0x40, - conn_state_any = 0xff -} t_conn_state; - -typedef enum -{ - conn_class_none, - conn_class_init, - conn_class_d2cs, - conn_class_d2gs, - conn_class_bnetd -} t_conn_class; - -typedef struct -{ - char const * charname; - char const * account; - int sock; - int fdw_idx; - unsigned int socket_flag; - unsigned int addr; - unsigned int local_addr; - unsigned short port; - unsigned short local_port; - unsigned int last_active; - t_conn_class class; - t_conn_state state; - unsigned int sessionnum; - t_queue * outqueue; - unsigned int outsize; - unsigned int outsizep; - t_packet * inqueue; - unsigned int insize; - t_d2charinfo_summary const * charinfo; - unsigned int d2gs_id; - t_gq * gamequeue; - unsigned int bnetd_sessionnum; - unsigned int sessionnum_hash; - unsigned int charname_hash; -} t_connection; - -typedef int ( * packet_handle_func) (t_connection * c, t_packet * packet); -typedef struct -{ - unsigned int size; - t_conn_state state; - packet_handle_func handler; -} t_packet_handle_table; - -#define SOCKET_FLAG_READ 0x1 -#define SOCKET_FLAG_WRITE 0x2 - -extern t_hashtable * d2cs_connlist(void); -extern int d2cs_connlist_destroy(void); -extern int d2cs_connlist_reap(void); -extern int d2cs_connlist_create(void); -extern int conn_check_multilogin(t_connection const * c,char const * charname); -extern t_connection * d2cs_connlist_find_connection_by_sessionnum(unsigned int sessionnum); -extern t_connection * d2cs_connlist_find_connection_by_charname(char const * charname); -extern int conn_handle_socket(t_connection * c); -extern t_connection * d2cs_conn_create(int sock, unsigned int local_addr, unsigned short local_port, - unsigned int addr, unsigned short port); -extern int d2cs_conn_destroy(t_connection * c, t_elem ** elem); -extern int d2cs_conn_get_socket(t_connection const * c); -extern unsigned int d2cs_conn_get_sessionnum(t_connection const * c); -extern t_conn_class d2cs_conn_get_class(t_connection const * c); -extern int d2cs_conn_set_class(t_connection * c, t_conn_class class); -extern t_conn_state d2cs_conn_get_state(t_connection const * c); -extern int d2cs_conn_set_state(t_connection * c, t_conn_state state); -extern t_queue * * d2cs_conn_get_out_queue(t_connection const * c); -extern t_packet * d2cs_conn_get_in_queue(t_connection const * c); -extern void d2cs_conn_set_in_queue(t_connection * c, t_packet * packet); -extern unsigned int d2cs_conn_get_in_size(t_connection const * c); -extern unsigned int d2cs_conn_get_out_size(t_connection const * c); -extern int conn_push_outqueue(t_connection * c, t_packet * packet); -extern t_packet * conn_peek_outqueue(t_connection * c); -extern t_packet * conn_pull_outqueue(t_connection * c); -extern int conn_add_socket_flag(t_connection * c, unsigned int flag); -extern int conn_process_packet(t_connection * c, t_packet * packet, t_packet_handle_table * table, - unsigned int table_size); -extern int d2cs_conn_set_account(t_connection * c, char const * account); -extern int d2cs_conn_set_charname(t_connection * c, char const * charname); -extern char const * d2cs_conn_get_account(t_connection const * c); -extern char const * d2cs_conn_get_charname(t_connection const * c); -extern int conn_set_charinfo(t_connection * c, t_d2charinfo_summary const * charinfo); -extern unsigned int conn_get_charinfo_expansion(t_connection const * c); -extern unsigned int conn_get_charinfo_hardcore(t_connection const * c); -extern unsigned int conn_get_charinfo_dead(t_connection const * c); -extern unsigned int conn_get_charinfo_difficulty(t_connection const * c); -extern unsigned int conn_get_charinfo_level(t_connection const * c); -extern unsigned int conn_get_charinfo_class(t_connection const * c); -extern unsigned int conn_get_d2gs_id(t_connection const * c); -extern int conn_set_d2gs_id(t_connection * c, unsigned int d2gs_id); -extern unsigned int d2cs_conn_get_addr(t_connection const * c); -extern unsigned short d2cs_conn_get_port(t_connection const * c); -extern t_gq * conn_get_gamequeue(t_connection const * c); -extern int conn_set_gamequeue(t_connection * c, t_gq * gq); -extern int conn_set_bnetd_sessionnum(t_connection * c, unsigned int sessionnum); -extern unsigned int conn_get_bnetd_sessionnum(t_connection const * c); -extern int conn_add_fd(t_connection * c, t_fdwatch_type rw, fdwatch_handler handler); -extern int connlist_check_timeout(void); - -#endif diff --git a/d2pack109/src/d2cs/d2charfile.c b/d2pack109/src/d2cs/d2charfile.c deleted file mode 100644 index 9847804..0000000 --- a/d2pack109/src/d2cs/d2charfile.c +++ /dev/null @@ -1,763 +0,0 @@ -/* - * Copyright (C) 2000,2001 Onlyer (onlyer@263.net) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#include "common/setup_before.h" -#include "setup.h" - -#ifdef HAVE_STDDEF_H -# include -#else -# ifndef NULL -# define NULL ((void *)0) -# endif -#endif -#include -#include -#ifdef HAVE_STRING_H -# include -#else -# ifdef HAVE_STRINGS_H -# include -# endif -# ifdef HAVE_MEMORY_H -# include -# endif -#endif -#ifdef STDC_HEADERS -# include -#else -# ifdef HAVE_MALLOC_H -# include -# endif -#endif -#include "compat/memset.h" -#include "compat/memcpy.h" -#include -#include "compat/strerror.h" -#ifdef HAVE_UNISTD_H -# include -#endif -#include "compat/access.h" -#ifdef TIME_WITH_SYS_TIME -# include -# include -#else -# ifdef HAVE_SYS_TIME_H -# include -# else -# include -# endif -#endif -#ifdef HAVE_SYS_STAT_H -# include -#endif - -#include "d2charfile.h" -#include "prefs.h" -#include "xstring.h" -#include "common/bn_type.h" -#include "common/eventlog.h" -#include "common/xalloc.h" -#include "common/setup_after.h" - -static int d2charsave_init(void * buffer,char const * charname,unsigned char class,unsigned short status); -static int d2charinfo_init(t_d2charinfo_file * chardata, char const * account, char const * charname, - unsigned char class, unsigned short status); -static int d2charsave_checksum(unsigned char const * data, unsigned int len, unsigned int offset); - - -static int d2charsave_init(void * buffer,char const * charname,unsigned char class,unsigned short status) -{ - ASSERT(buffer,-1); - ASSERT(charname,-1); - bn_byte_set((bn_byte *)((char *)buffer+D2CHARSAVE_CLASS_OFFSET), class); - bn_short_set((bn_short *)((char *)buffer+D2CHARSAVE_STATUS_OFFSET),status); - strncpy((char *)buffer+D2CHARSAVE_CHARNAME_OFFSET,charname,MAX_CHARNAME_LEN); - return 0; -} - - -static int d2charinfo_init(t_d2charinfo_file * chardata, char const * account, char const * charname, - unsigned char class, unsigned short status) -{ - unsigned int i; - time_t now; - - now=time(NULL); - bn_int_set(&chardata->header.magicword,D2CHARINFO_MAGICWORD); - bn_int_set(&chardata->header.version,D2CHARINFO_VERSION); - bn_int_set(&chardata->header.create_time,now); - bn_int_set(&chardata->header.last_time,now); - - memset(chardata->header.charname,0,MAX_CHARNAME_LEN); - strncpy(chardata->header.charname,charname,MAX_CHARNAME_LEN); - memset(chardata->header.account, 0,MAX_ACCTNAME_LEN); - strncpy(chardata->header.account,account,MAX_ACCTNAME_LEN); - memset(chardata->header.realmname, 0,MAX_REALMNAME_LEN); - strncpy(chardata->header.realmname,prefs_get_realmname(),MAX_REALMNAME_LEN); - bn_int_set(&chardata->header.checksum,0); - for (i=0; iheader.reserved); i++) { - bn_int_set(&chardata->header.reserved[i],0); - } - bn_int_set(&chardata->summary.charlevel,1); - bn_int_set(&chardata->summary.experience,0); - bn_int_set(&chardata->summary.charclass,class); - bn_int_set(&chardata->summary.charstatus,status); - - memset(chardata->portrait.gfx,D2CHARINFO_PORTRAIT_PADBYTE,sizeof(chardata->portrait.gfx)); - memset(chardata->portrait.color,D2CHARINFO_PORTRAIT_PADBYTE,sizeof(chardata->portrait.color)); - memset(chardata->portrait.u2,D2CHARINFO_PORTRAIT_PADBYTE,sizeof(chardata->portrait.u2)); - memset(chardata->portrait.u1,D2CHARINFO_PORTRAIT_MASK,sizeof(chardata->portrait.u1)); - memset(chardata->pad,0,sizeof(chardata->pad)); - - bn_short_set(&chardata->portrait.header,D2CHARINFO_PORTRAIT_HEADER); - bn_byte_set(&chardata->portrait.status,status|D2CHARINFO_PORTRAIT_MASK); - bn_byte_set(&chardata->portrait.class,class+1); - bn_byte_set(&chardata->portrait.level,1); - bn_byte_set(&chardata->portrait.end,'\0'); - memset(chardata->pad,0,sizeof(chardata->pad)); - return 0; -} - - -extern int d2char_create(char const * account, char const * charname, unsigned char class, unsigned short status) -{ - t_d2charinfo_file chardata; - char * savefile, * infofile; - char buffer[1024]; - unsigned int size; - FILE * fp; - - - ASSERT(account,-1); - ASSERT(charname,-1); - if (class>D2CHAR_MAX_CLASS) class=0; - status &= 0xFF; - charstatus_set_init(status,1); - -/* We need to make sure we are creating the correct character (Classic or Expansion) - for the type of game server we are running. If lod_realm = 1 then only Expansion - characters can be created and if set to 0 then only Classic character can - be created */ - - if (!(prefs_get_lod_realm() == 2)) { - if (prefs_get_lod_realm() && ((status & 0x20) != 0x20)) { - eventlog(eventlog_level_warn,__FUNCTION__,"This Realm is for LOD Characters Only"); - return -1; - } - if (!prefs_get_lod_realm() && ((status & 0x20) != 0x00)) { - eventlog(eventlog_level_warn,__FUNCTION__,"This Realm is for Classic Characters Only"); - return -1; - } - } - -/* Once correct type of character is varified then continue with creation of character */ - - if (!prefs_allow_newchar()) { - eventlog(eventlog_level_warn,__FUNCTION__,"creation of new character is disabled"); - return -1; - } - if (d2char_check_charname(charname)<0) { - eventlog(eventlog_level_error,__FUNCTION__,"got bad character name \"%s\"",charname); - return -1; - } - if (d2char_check_acctname(account)<0) { - eventlog(eventlog_level_error,__FUNCTION__,"got bad account name \"%s\"",account); - return -1; - } - size=sizeof(buffer); - if (file_read(prefs_get_charsave_newbie(), buffer, &size)<0) { - eventlog(eventlog_level_error,__FUNCTION__,"error loading newbie save file"); - return -1; - } - if (size>=sizeof(buffer)) { - eventlog(eventlog_level_error,__FUNCTION__,"newbie save file \"%s\" is corrupt (length %lu, expected <%lu)",prefs_get_charsave_newbie(),(unsigned long)size,(unsigned long)sizeof(buffer)); - return -1; - } - - savefile=xmalloc(strlen(prefs_get_charsave_dir())+1+strlen(charname)+1); - d2char_get_savefile_name(savefile,charname); - if ((fp=fopen(savefile,"rb"))) { - eventlog(eventlog_level_warn,__FUNCTION__,"character save file \"%s\" for \"%s\" already exist",savefile,charname); - fclose(fp); - xfree(savefile); - return -1; - } - - infofile=xmalloc(strlen(prefs_get_charinfo_dir())+1+strlen(account)+1+strlen(charname)+1); - d2char_get_infofile_name(infofile,account,charname); - - d2charsave_init(buffer,charname,class,status); - d2charinfo_init(&chardata,account,charname,class,status); - - if (file_write(infofile,&chardata,sizeof(chardata))<0) { - eventlog(eventlog_level_error,__FUNCTION__,"error writing info file \"%s\"",infofile); - remove(infofile); - xfree(infofile); - xfree(savefile); - return -1; - } - - if (file_write(savefile,buffer,size)<0) { - eventlog(eventlog_level_error,__FUNCTION__,"error writing save file \"%s\"",savefile); - remove(infofile); - remove(savefile); - xfree(savefile); - xfree(infofile); - return -1; - } - xfree(savefile); - xfree(infofile); - eventlog(eventlog_level_info,__FUNCTION__,"character %s(*%s) class %d status 0x%X created",charname,account,class,status); - return 0; -} - - -extern int d2char_find(char const * account, char const * charname) -{ - char * file; - FILE * fp; - - ASSERT(account,-1); - ASSERT(charname,-1); - file=xmalloc(strlen(prefs_get_charinfo_dir())+1+strlen(account)+1+strlen(charname)+1); - d2char_get_infofile_name(file,account,charname); - fp=fopen(file,"rb"); - xfree(file); - if (fp) { - fclose(fp); - return 0; - } - return -1; -} - - -extern int d2char_convert(char const * account, char const * charname) -{ - FILE * fp; - char * file; - unsigned char buffer[MAX_SAVEFILE_SIZE]; - unsigned int status_offset; - unsigned char status; - unsigned int charstatus; - t_d2charinfo_file charinfo; - unsigned int size; - unsigned int version; - unsigned int checksum; - - ASSERT(account,-1); - ASSERT(charname,-1); - -/* Playing with a expanstion char on a classic realm - will cause the game server to crash, therefore - I recommed setting allow_convert = 0 in the d2cs.conf - We need to do this to prevent creating classic char - and converting to expantion on a classic realm. - LOD Char must be created on LOD realm */ - - if (!prefs_get_allow_convert()) { - eventlog(eventlog_level_info,__FUNCTION__,"Convert char has been disabled"); - return -1; - } - -/* Procedure is stopped here and returned if - allow_convet = 0 in d2cs.conf */ - - if (d2char_check_charname(charname)<0) { - eventlog(eventlog_level_error,__FUNCTION__,"got bad character name \"%s\"",charname); - return -1; - } - if (d2char_check_acctname(account)<0) { - eventlog(eventlog_level_error,__FUNCTION__,"got bad account name \"%s\"",account); - return -1; - } - file=xmalloc(strlen(prefs_get_charinfo_dir())+1+strlen(account)+1+strlen(charname)+1); - d2char_get_infofile_name(file,account,charname); - if (!(fp=fopen(file,"rb+"))) { - eventlog(eventlog_level_error,__FUNCTION__,"unable to open charinfo file \"%s\" for reading and writing (fopen: %s)",file,strerror(errno)); - xfree(file); - return -1; - } - xfree(file); - if (fread(&charinfo,1,sizeof(charinfo),fp)!=sizeof(charinfo)) { - eventlog(eventlog_level_error,__FUNCTION__,"error reading charinfo file for character \"%s\" (fread: %s)",charname,strerror(errno)); - fclose(fp); - return -1; - } - charstatus=bn_int_get(charinfo.summary.charstatus); - charstatus_set_expansion(charstatus,1); - bn_int_set(&charinfo.summary.charstatus,charstatus); - - status=bn_byte_get(charinfo.portrait.status); - charstatus_set_expansion(status,1); - bn_byte_set(&charinfo.portrait.status,status); - - fseek(fp,0,SEEK_SET); /* FIXME: check return */ - if (fwrite(&charinfo,1,sizeof(charinfo),fp)!=sizeof(charinfo)) { - eventlog(eventlog_level_error,__FUNCTION__,"error writing charinfo file for character \"%s\" (fwrite: %s)",charname,strerror(errno)); - fclose(fp); - return -1; - } - if (fclose(fp)<0) { - eventlog(eventlog_level_error,__FUNCTION__,"could not close charinfo file for character \"%s\" after writing (fclose: %s)",charname,strerror(errno)); - return -1; - } - - file=xmalloc(strlen(prefs_get_charsave_dir())+1+strlen(charname)+1); - d2char_get_savefile_name(file,charname); - if (!(fp=fopen(file,"rb+"))) { - eventlog(eventlog_level_error,__FUNCTION__,"could not open charsave file \"%s\" for reading and writing (fopen: %s)",file,strerror(errno)); - xfree(file); - return -1; - } - xfree(file); - size=fread(buffer,1,sizeof(buffer),fp); - if (!feof(fp)) { - eventlog(eventlog_level_error,__FUNCTION__,"error reading charsave file for character \"%s\" (fread: %s)",charname,strerror(errno)); - fclose(fp); - return -1; - } - version=bn_int_get(buffer+D2CHARSAVE_VERSION_OFFSET); - if (version>=0x0000005C) { - status_offset=D2CHARSAVE_STATUS_OFFSET_109; - } else { - status_offset=D2CHARSAVE_STATUS_OFFSET; - } - status=bn_byte_get(buffer+status_offset); - charstatus_set_expansion(status,1); - bn_byte_set((bn_byte *)(buffer+status_offset),status); /* FIXME: shouldn't abuse bn_*_set()... what's the best way to do this? */ - if (version>=0x0000005C) { - checksum=d2charsave_checksum(buffer,size,D2CHARSAVE_CHECKSUM_OFFSET); - bn_int_set((bn_int *)(buffer+D2CHARSAVE_CHECKSUM_OFFSET),checksum); /* FIXME: shouldn't abuse bn_*_set()... what's the best way to do this? */ - } - fseek(fp,0,SEEK_SET); /* FIXME: check return */ - if (fwrite(buffer,1,size,fp)!=size) { - eventlog(eventlog_level_error,__FUNCTION__,"error writing charsave file for character %s (fwrite: %s)",charname,strerror(errno)); - fclose(fp); - return -1; - } - if (fclose(fp)<0) { - eventlog(eventlog_level_error,__FUNCTION__,"could not close charsave file for character \"%s\" after writing (fclose: %s)",charname,strerror(errno)); - return -1; - } - eventlog(eventlog_level_info,__FUNCTION__,"character %s(*%s) converted to expansion",charname,account); - return 0; -} - - -extern int d2char_delete(char const * account, char const * charname) -{ - char * file; - - ASSERT(account,-1); - ASSERT(charname,-1); - if (d2char_check_charname(charname)<0) { - eventlog(eventlog_level_error,__FUNCTION__,"got bad character name \"%s\"",charname); - return -1; - } - if (d2char_check_acctname(account)<0) { - eventlog(eventlog_level_error,__FUNCTION__,"got bad account name \"%s\"",account); - return -1; - } - - /* charsave file */ - file=xmalloc(strlen(prefs_get_charinfo_dir())+1+strlen(account)+1+strlen(charname)+1); - d2char_get_infofile_name(file,account,charname); - if (remove(file)<0) { - eventlog(eventlog_level_error,__FUNCTION__,"failed to delete charinfo file \"%s\" (remove: %s)",file,strerror(errno)); - xfree(file); - return -1; - } - xfree(file); - - /* charinfo file */ - file=xmalloc(strlen(prefs_get_charsave_dir())+1+strlen(charname)+1); - d2char_get_savefile_name(file,charname); - if (remove(file)<0) { - eventlog(eventlog_level_error,__FUNCTION__,"failed to delete charsave file \"%s\" (remove: %s)",file,strerror(errno)); - } - xfree(file); - - /* bak charsave file */ - file=xmalloc(strlen(prefs_get_bak_charinfo_dir())+1+strlen(account)+1+strlen(charname)+1); - d2char_get_bak_infofile_name(file,account,charname); - if (access(file, F_OK) == 0) { - if (remove(file)<0) { - eventlog(eventlog_level_error,__FUNCTION__,"failed to delete bak charinfo file \"%s\" (remove: %s)",file,strerror(errno)); - } - } - xfree(file); - - /* bak charinfo file */ - file=xmalloc(strlen(prefs_get_bak_charsave_dir())+1+strlen(charname)+1); - d2char_get_bak_savefile_name(file,charname); - if (access(file, F_OK) == 0) { - if (remove(file)<0) { - eventlog(eventlog_level_error,__FUNCTION__,"failed to delete bak charsave file \"%s\" (remove: %s)",file,strerror(errno)); - } - } - xfree(file); - - eventlog(eventlog_level_info,__FUNCTION__,"character %s(*%s) deleted",charname,account); - return 0; -} - - -extern int d2char_get_summary(char const * account, char const * charname,t_d2charinfo_summary * charinfo) -{ - t_d2charinfo_file data; - - ASSERT(account,-1); - ASSERT(charname,-1); - ASSERT(charinfo,-1); - if (d2charinfo_load(account, charname, &data)<0) { - eventlog(eventlog_level_error,__FUNCTION__,"error loading character %s(*%s)",charname,account); - return -1; - } - memcpy(charinfo,&data.summary,sizeof(data.summary)); - eventlog(eventlog_level_info,__FUNCTION__,"character %s difficulty %d expansion %d hardcore %d dead %d loaded",charname, - d2charinfo_get_difficulty(charinfo), d2charinfo_get_expansion(charinfo), - d2charinfo_get_hardcore(charinfo),d2charinfo_get_dead(charinfo)); - return 0; -} - - -extern int d2charinfo_load(char const * account, char const * charname, t_d2charinfo_file * data) -{ - char * file; - unsigned int size; - - if (d2char_check_charname(charname)<0) { - eventlog(eventlog_level_error,__FUNCTION__,"got bad character name \"%s\"",charname); - return -1; - } - if (d2char_check_acctname(account)<0) { - eventlog(eventlog_level_error,__FUNCTION__,"got bad account name \"%s\"",account); - return -1; - } - file=xmalloc(strlen(prefs_get_charinfo_dir())+1+strlen(account)+1+strlen(charname)+1); - d2char_get_infofile_name(file,account,charname); - size=sizeof(t_d2charinfo_file); - if (file_read(file,data,&size)<0) { - eventlog(eventlog_level_error,__FUNCTION__,"error loading character file %s",file); - xfree(file); - return -1; - } - xfree(file); - if (size!=sizeof(t_d2charinfo_file)) { - eventlog(eventlog_level_error,__FUNCTION__,"got bad charinfo file %s (length %d)",charname,size); - return -1; - } - d2char_portrait_init(&data->portrait); - return d2charinfo_check(data); -} - - -extern int d2charinfo_check(t_d2charinfo_file * data) -{ - ASSERT(data,-1); - if (bn_int_get(data->header.magicword) != D2CHARINFO_MAGICWORD) { - eventlog(eventlog_level_error,__FUNCTION__,"info data check failed (header 0x%08X)",bn_int_get(data->header.magicword)); - return -1; - } - if (bn_int_get(data->header.version) != D2CHARINFO_VERSION) { - eventlog(eventlog_level_error,__FUNCTION__,"info data check failed (version 0x%08X)",bn_int_get(data->header.version)); - return -1; - } - return 0; -} - - -extern int d2char_portrait_init(t_d2charinfo_portrait * portrait) -{ - unsigned int i; - unsigned char * p; - - p=(unsigned char *)portrait; - for (i=0; i= MIN_NAME_LEN || i<= MAX_CHARNAME_LEN) return 0; - return -1; -} - - -extern int d2char_check_acctname(char const * name) -{ - unsigned int i; - unsigned char ch; - - if (!name) return -1; - if (!isalnum((int)name[0])) return -1; - - for (i=1; i<=MAX_CHARNAME_LEN; i++) { - ch=name[i]; - if (ch=='\0') break; - if (isalnum(ch)) continue; - if (strchr(prefs_get_d2cs_account_allowed_symbols(),ch)) continue; - return -1; - } - if (i >= MIN_NAME_LEN || i<= MAX_ACCTNAME_LEN) return 0; - return -1; -} - - -extern int d2char_get_savefile_name(char * filename, char const * charname) -{ - char tmpchar[MAX_CHARNAME_LEN]; - - ASSERT(filename,-1); - ASSERT(charname,-1); - strncpy(tmpchar,charname,sizeof(tmpchar)); - tmpchar[sizeof(tmpchar)-1]='\0'; - strtolower(tmpchar); - sprintf(filename,"%s/%s",prefs_get_charsave_dir(),tmpchar); - return 0; -} - - -extern int d2char_get_bak_savefile_name(char * filename, char const * charname) -{ - char tmpchar[MAX_CHARNAME_LEN]; - - ASSERT(filename,-1); - ASSERT(charname,-1); - strncpy(tmpchar,charname,sizeof(tmpchar)); - tmpchar[sizeof(tmpchar)-1]='\0'; - strtolower(tmpchar); - sprintf(filename,"%s/%s",prefs_get_bak_charsave_dir(),tmpchar); - return 0; -} - - -extern int d2char_get_infodir_name(char * filename, char const * account) -{ - char tmpacct[MAX_ACCTNAME_LEN]; - - ASSERT(filename,-1); - ASSERT(account,-1); - - strncpy(tmpacct,account,sizeof(tmpacct)); - tmpacct[sizeof(tmpacct)-1]='\0'; - strtolower(tmpacct); - sprintf(filename,"%s/%s",prefs_get_charinfo_dir(),tmpacct); - return 0; -} - - -extern int d2char_get_infofile_name(char * filename, char const * account, char const * charname) -{ - char tmpchar[MAX_CHARNAME_LEN]; - char tmpacct[MAX_ACCTNAME_LEN]; - - ASSERT(filename,-1); - ASSERT(account,-1); - ASSERT(charname,-1); - strncpy(tmpchar,charname,sizeof(tmpchar)); - tmpchar[sizeof(tmpchar)-1]='\0'; - strtolower(tmpchar); - - strncpy(tmpacct,account,sizeof(tmpacct)); - tmpchar[sizeof(tmpacct)-1]='\0'; - strtolower(tmpacct); - sprintf(filename,"%s/%s/%s",prefs_get_charinfo_dir(),tmpacct,tmpchar); - return 0; -} - - -extern int d2char_get_bak_infofile_name(char * filename, char const * account, char const * charname) -{ - char tmpchar[MAX_CHARNAME_LEN]; - char tmpacct[MAX_ACCTNAME_LEN]; - - ASSERT(filename,-1); - ASSERT(account,-1); - ASSERT(charname,-1); - strncpy(tmpchar,charname,sizeof(tmpchar)); - tmpchar[sizeof(tmpchar)-1]='\0'; - strtolower(tmpchar); - - strncpy(tmpacct,account,sizeof(tmpacct)); - tmpchar[sizeof(tmpacct)-1]='\0'; - strtolower(tmpacct); - sprintf(filename,"%s/%s/%s",prefs_get_bak_charinfo_dir(),tmpacct,tmpchar); - return 0; -} - - - -extern unsigned int d2charinfo_get_expansion(t_d2charinfo_summary const * charinfo) -{ - ASSERT(charinfo,0); - return charstatus_get_expansion(bn_int_get(charinfo->charstatus)); -} - - -extern unsigned int d2charinfo_get_level(t_d2charinfo_summary const * charinfo) -{ - ASSERT(charinfo,0); - return bn_int_get(charinfo->charlevel); -} - - -extern unsigned int d2charinfo_get_class(t_d2charinfo_summary const * charinfo) -{ - ASSERT(charinfo,0); - return bn_int_get(charinfo->charclass); -} - - -extern unsigned int d2charinfo_get_hardcore(t_d2charinfo_summary const * charinfo) -{ - ASSERT(charinfo,0); - return charstatus_get_hardcore(bn_int_get(charinfo->charstatus)); -} - - -extern unsigned int d2charinfo_get_dead(t_d2charinfo_summary const * charinfo) -{ - ASSERT(charinfo,0); - return charstatus_get_dead(bn_int_get(charinfo->charstatus)); -} - - -extern unsigned int d2charinfo_get_difficulty(t_d2charinfo_summary const * charinfo) -{ - unsigned int difficulty; - - ASSERT(charinfo,0); - if (d2charinfo_get_expansion(charinfo)) { - difficulty=charstatus_get_difficulty_expansion(bn_int_get(charinfo->charstatus)); - } else { - difficulty=charstatus_get_difficulty(bn_int_get(charinfo->charstatus)); - } - if (difficulty>2) difficulty=2; - return difficulty; -} - - -static int d2charsave_checksum(unsigned char const * data, unsigned int len,unsigned int offset) -{ - int checksum; - unsigned int i; - unsigned int ch; - - if (!data) return 0; - checksum=0; - for (i=0; i=offset && i> 0x08) & 0x0f )/4) -#define charstatus_get_difficulty_expansion(status) ((( status >> 0x08) & 0x0f )/5) - -#ifndef JUST_NEED_TYPES -#include "d2cs_d2gs_character.h" - -extern int d2char_create(char const * account, char const * charname, unsigned char class, - unsigned short status); -extern int d2char_delete(char const * account, char const * charname); -extern int d2char_get_summary(char const * account, char const * charname,t_d2charinfo_summary * charinfo); -extern int d2char_get_portrait(char const * account, char const * filename, t_d2charinfo_portrait * portrait); -extern int d2char_portrait_init(t_d2charinfo_portrait * portrait); -extern int d2charinfo_load(char const * account, char const * charname, t_d2charinfo_file * data); -extern int d2charinfo_check(t_d2charinfo_file * data); -extern unsigned int d2charinfo_get_expansion(t_d2charinfo_summary const * charinfo); -extern unsigned int d2charinfo_get_level(t_d2charinfo_summary const * charinfo); -extern unsigned int d2charinfo_get_class(t_d2charinfo_summary const * charinfo); -extern unsigned int d2charinfo_get_hardcore(t_d2charinfo_summary const * charinfo); -extern unsigned int d2charinfo_get_dead(t_d2charinfo_summary const * charinfo); -extern unsigned int d2charinfo_get_difficulty(t_d2charinfo_summary const * charinfo); -extern int d2char_convert(char const * account, char const * charname); -extern int d2char_find(char const * account, char const * charname); -extern int d2char_get_savefile_name(char * filename,char const * charname); -extern int d2char_get_infofile_name(char * filename,char const * account, char const * charname); -extern int d2char_get_bak_savefile_name(char * filename,char const * charname); -extern int d2char_get_bak_infofile_name(char * filename,char const * account, char const * charname); -extern int d2char_get_infodir_name(char * filename,char const * account); -extern int d2char_check_acctname(char const * name); -extern int d2char_check_charname(char const * name); - -extern int file_write(char const * filename, void * data, unsigned int size); -extern int file_read(char const * filename, void * data, unsigned int * size); -#endif - - -#endif diff --git a/d2pack109/src/d2cs/d2charlist.c b/d2pack109/src/d2cs/d2charlist.c deleted file mode 100644 index efba8cd..0000000 --- a/d2pack109/src/d2cs/d2charlist.c +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (C) 2004 ls_sons (ls@gamelife.org) - * Copyright (C) 2004 Olaf Freyer (aaron@cs.tu-berlin.de) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#include "common/setup_before.h" -#include "setup.h" - -#ifdef HAVE_STRING_H -# include -#else -# ifdef HAVE_STRINGS_H -# include -# endif -# ifdef HAVE_MEMORY_H -# include -# endif -#endif -#ifdef STDC_HEADERS -# include -#else -# ifdef HAVE_MALLOC_H -# include -# endif -#endif - -#include "connection.h" -#include "prefs.h" -#include "common/eventlog.h" -#include "compat/strcasecmp.h" -#include "compat/strncasecmp.h" -#include "compat/strdup.h" -#include "common/xalloc.h" -#include "common/elist.h" -#include "d2charlist.h" -#include "common/setup_after.h" - -extern int d2charlist_add_char(t_elist * list_head, t_d2charinfo_file * charinfo, unsigned int expiration_time) -{ - t_d2charlist * charlist, * ccharlist; - char const * d2char_sort; - t_elist * curr; - - d2char_sort = prefs_get_charlist_sort(); - charlist = xmalloc(sizeof(t_d2charlist)); - charlist->charinfo = charinfo; - charlist->expiration_time = expiration_time; - - if (elist_empty(list_head)) - elist_add(list_head,&charlist->list); - else - { - if (strcasecmp(d2char_sort, "name")==0) - { - elist_for_each(curr,list_head) - { - ccharlist = elist_entry(curr,t_d2charlist,list); - if (strncasecmp(charinfo->header.charname,ccharlist->charinfo->header.charname,strlen(charinfo->header.charname))<0) - break; - } - elist_add_tail(curr,&charlist->list); - } - else if (strcasecmp(d2char_sort, "mtime")==0) - { - elist_for_each(curr,list_head) - { - ccharlist = elist_entry(curr,t_d2charlist,list); - if (bn_int_get(charinfo->header.last_time) < bn_int_get(ccharlist->charinfo->header.last_time)) - break; - } - elist_add_tail(curr,&charlist->list); - } - else if (strcasecmp(d2char_sort, "level")==0) - { - elist_for_each(curr,list_head) - { - ccharlist = elist_entry(curr,t_d2charlist,list); - if (bn_int_get(charinfo->summary.experience) < bn_int_get(ccharlist->charinfo->summary.experience)) - break; - } - elist_add_tail(curr,&charlist->list); - } - else - { - eventlog(eventlog_level_debug,__FUNCTION__,"unsorted"); - elist_add_tail(list_head,&charlist->list); - } - } - return 0; -} - diff --git a/d2pack109/src/d2cs/d2charlist.h b/d2pack109/src/d2cs/d2charlist.h deleted file mode 100644 index e6794fa..0000000 --- a/d2pack109/src/d2cs/d2charlist.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (C) 2004 ls_sons (ls@gamelife.org) - * Copyright (C) 2004 Olaf Freyer (aaron@cs.tu-berlin.de) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "common/elist.h" -#include "d2cs_d2gs_character.h" - -typedef struct d2charlist{ - t_d2charinfo_file *charinfo; - int expiration_time; - t_elist list; -} t_d2charlist; - -extern int d2charlist_add_char(t_elist *, t_d2charinfo_file *i, unsigned int); diff --git a/d2pack109/src/d2cs/d2cs_bnetd_protocol.h b/d2pack109/src/d2cs/d2cs_bnetd_protocol.h deleted file mode 100644 index bcbb7d7..0000000 --- a/d2pack109/src/d2cs/d2cs_bnetd_protocol.h +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (C) 2000,2001 Onlyer (onlyer@263.net) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_D2CS_BNETD_PROTOCOL_H -#define INCLUDED_D2CS_BNETD_PROTOCOL_H - -#include "common/bn_type.h" - -typedef struct -{ - bn_short size; - bn_short type; - bn_int seqno; /* seqno, set by the sender */ -} t_d2cs_bnetd_header; - -typedef struct -{ - t_d2cs_bnetd_header h; -} t_d2cs_bnetd_generic; - -#define BNETD_D2CS_AUTHREQ 0x01 -typedef struct -{ - t_d2cs_bnetd_header h; - bn_int sessionnum; -} t_bnetd_d2cs_authreq; - -#define D2CS_BNETD_AUTHREPLY 0x02 -typedef struct -{ - t_d2cs_bnetd_header h; - bn_int version; - /* realm name */ -} t_d2cs_bnetd_authreply; - -#define BNETD_D2CS_AUTHREPLY 0x02 -typedef struct -{ - t_d2cs_bnetd_header h; - bn_int reply; -} t_bnetd_d2cs_authreply; -#define BNETD_D2CS_AUTHREPLY_SUCCEED 0x00 -#define BNETD_D2CS_AUTHREPLY_BAD_VERSION 0x01 - -#define D2CS_BNETD_ACCOUNTLOGINREQ 0x10 -typedef struct -{ - t_d2cs_bnetd_header h; - bn_int seqno; - bn_int sessionnum; - bn_int sessionkey; - bn_int secret_hash[5]; - /* account name */ -} t_d2cs_bnetd_accountloginreq; - -#define BNETD_D2CS_ACCOUNTLOGINREPLY 0x10 -typedef struct -{ - t_d2cs_bnetd_header h; - bn_int reply; -} t_bnetd_d2cs_accountloginreply; -#define BNETD_D2CS_ACCOUNTLOGINREPLY_SUCCEED 0x00 -#define BNETD_D2CS_ACCOUNTLOGINREPLY_FAILED 0x01 - -#define D2CS_BNETD_CHARLOGINREQ 0x11 -typedef struct -{ - t_d2cs_bnetd_header h; - bn_int sessionnum; - /* character name */ - /* character portrait */ -} t_d2cs_bnetd_charloginreq; - -#define BNETD_D2CS_CHARLOGINREPLY 0x11 -typedef struct -{ - t_d2cs_bnetd_header h; - bn_int reply; -} t_bnetd_d2cs_charloginreply; -#define BNETD_D2CS_CHARLOGINREPLY_SUCCEED 0x00 -#define BNETD_D2CS_CHARLOGINREPLY_FAILED 0x01 - -#define BNETD_D2CS_GAMEINFOREQ 0x12 -typedef struct -{ - t_d2cs_bnetd_header h; - /* gamename */ -} t_bnetd_d2cs_gameinforeq; - -#define D2CS_BNETD_GAMEINFOREPLY 0x12 -typedef struct -{ - t_d2cs_bnetd_header h; - bn_byte difficulty; - /* gamename */ -} t_d2cs_bnetd_gameinforeply; - -#endif diff --git a/d2pack109/src/d2cs/d2cs_d2dbs_ladder.h b/d2pack109/src/d2cs/d2cs_d2dbs_ladder.h deleted file mode 100644 index 981d7e1..0000000 --- a/d2pack109/src/d2cs/d2cs_d2dbs_ladder.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (C) 2000,2001 Onlyer (onlyer@263.net) - * Copyright (C) 2001 sousou (liupeng.cs@263.net) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_D2CS_D2DBS_LADDER_H -#define INCLUDED_D2CS_D2DBS_LADDER_H - -#include "common/bn_type.h" - -typedef struct -{ - bn_int type; - bn_int offset; - bn_int number; -} t_d2ladderfile_ladderindex; - -typedef struct -{ - bn_int experience; - bn_short status; - bn_byte level; - bn_byte class; - char charname[MAX_CHARNAME_LEN]; -} t_d2ladderfile_ladderinfo; - -typedef struct -{ - bn_int maxtype; - bn_int checksum; -} t_d2ladderfile_header; - - -#define LADDER_FILE_PREFIX "ladder" - -#define D2LADDER_HC_OVERALL 0x00 -#define D2LADDER_STD_OVERALL 0x09 -#define D2LADDER_EXP_HC_OVERALL 0x13 -#define D2LADDER_EXP_STD_OVERALL 0x1B -#define D2CHAR_CLASS_MAX 0x04 -#define D2CHAR_EXP_CLASS_MAX 0x06 - -#endif diff --git a/d2pack109/src/d2cs/d2cs_d2gs_character.h b/d2pack109/src/d2cs/d2cs_d2gs_character.h deleted file mode 100644 index 16c6a18..0000000 --- a/d2pack109/src/d2cs/d2cs_d2gs_character.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (C) 2000,2001 Onlyer (onlyer@263.net) - * Copyright (C) 2001 faster (lqx@cic.tsinghua.edu.cn) - * Copyright (C) 2001 sousou (liupeng.cs@263.net) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_D2CS_D2GS_CHARACTER_H -#define INCLUDED_D2CS_D2GS_CHARACTER_H - -#ifdef D2CS -# include "common/bn_type.h" -#endif - -#ifdef D2GS -# include "bn_types.h" -#pragma pack(push, character_h, 1) -#endif - -#define D2CHARINFO_MAGICWORD 0x12345678 -#define D2CHARINFO_VERSION 0x00010000 -#define D2CHARINFO_PORTRAIT_PADSIZE 30 - -typedef struct -{ - bn_int magicword; /* static for check */ - bn_int version; /* charinfo file version */ - bn_int create_time; /* character creation time */ - bn_int last_time; /* character last access time */ - bn_int checksum; - bn_int reserved[7]; - unsigned char charname[MAX_CHARNAME_LEN]; - unsigned char account[MAX_ACCTNAME_LEN]; - unsigned char realmname[MAX_REALMNAME_LEN]; -} t_d2charinfo_header; - -typedef struct -{ - bn_int experience; - bn_int charstatus; - bn_int charlevel; - bn_int charclass; -} t_d2charinfo_summary; - -typedef struct -{ - bn_short header; /* 0x84 0x80 */ - bn_byte gfx[11]; - bn_byte class; - bn_byte color[11]; - bn_byte level; - bn_byte status; - bn_byte u1[3]; - bn_byte u2[3]; - bn_byte end; /* 0x00 */ -} t_d2charinfo_portrait; - -typedef struct -{ - t_d2charinfo_header header; - t_d2charinfo_portrait portrait; - bn_byte pad[D2CHARINFO_PORTRAIT_PADSIZE]; - t_d2charinfo_summary summary; -} t_d2charinfo_file; - -#ifdef D2GS -#pragma pack(pop, character_h) -#endif - -#endif diff --git a/d2pack109/src/d2cs/d2cs_d2gs_protocol.h b/d2pack109/src/d2cs/d2cs_d2gs_protocol.h deleted file mode 100644 index 23b3e94..0000000 --- a/d2pack109/src/d2cs/d2cs_d2gs_protocol.h +++ /dev/null @@ -1,182 +0,0 @@ -/* - * Copyright (C) 2000,2001 Onlyer (onlyer@263.net) - * Copyright (C) 2001 faster (lqx@cic.tsinghua.edu.cn) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_D2CS_D2GS_PROTOCOL_H -#define INCLUDED_D2CS_D2GS_PROTOCOL_H -/* - * there is only little comments in this header file - * check the documents for more details -*/ - -/* include your own header files here */ -#ifdef D2CS -# include "common/bn_type.h" -#endif - -#ifdef D2GS -# include "bn_types.h" -#pragma pack(push, pack01, 1) -#endif - -typedef struct -{ - bn_short size; - bn_short type; - bn_int seqno; /* seqno, set by the sender */ -} t_d2cs_d2gs_header; - -typedef struct -{ - t_d2cs_d2gs_header h; -} t_d2cs_d2gs_generic; - -#define D2CS_D2GS_AUTHREQ 0x10 -typedef struct -{ - t_d2cs_d2gs_header h; - bn_int sessionnum; - /* realm name */ -} t_d2cs_d2gs_authreq; - -#define D2GS_D2CS_AUTHREPLY 0x11 -typedef struct -{ - t_d2cs_d2gs_header h; - bn_int version; - bn_int checksum; -} t_d2gs_d2cs_authreply; - -#define D2CS_D2GS_AUTHREPLY 0x11 -typedef struct -{ - t_d2cs_d2gs_header h; - bn_int reply; -} t_d2cs_d2gs_authreply; -#define D2CS_D2GS_AUTHREPLY_SUCCEED 0x00 -#define D2CS_D2GS_AUTHREPLY_BAD_VERSION 0x01 -#define D2CS_D2GS_AUTHREPLY_BAD_CHECKSUM 0x02 - -#define D2GS_D2CS_SETGSINFO 0x12 -typedef struct -{ - t_d2cs_d2gs_header h; - bn_int maxgame; - bn_int gameflag; -} t_d2gs_d2cs_setgsinfo; - -#define D2CS_D2GS_SETGSINFO 0x12 -typedef struct -{ - t_d2cs_d2gs_header h; - bn_int maxgame; - bn_int gameflag; -} t_d2cs_d2gs_setgsinfo; - -#define D2CS_D2GS_ECHOREQ 0x13 -typedef struct -{ - t_d2cs_d2gs_header h; -} t_d2cs_d2gs_echoreq; - -#define D2GS_D2CS_ECHOREPLY 0x13 -typedef struct -{ - t_d2cs_d2gs_header h; -} t_d2gs_d2cs_echoreply; - -#define D2CS_D2GS_CONTROL 0x14 -typedef struct -{ - t_d2cs_d2gs_header h; - bn_int cmd; - bn_int value; -} t_d2cs_d2gs_control; -#define D2CS_D2GS_CONTROL_CMD_RESTART 0x01 -#define D2CS_D2GS_CONTROL_CMD_SHUTDOWN 0x02 -#define D2CS_D2GS_CONTROL_VALUE_DEFAULT 0x00 - -#define D2CS_D2GS_CREATEGAMEREQ 0x20 -typedef struct -{ - t_d2cs_d2gs_header h; - bn_byte expansion; - bn_byte difficulty; - bn_byte hardcore; - /* gamename */ -} t_d2cs_d2gs_creategamereq; -#define D2GAME_DIFFICULTY_NORMAL 0 -#define D2GAME_DIFFICULTY_NIGHTMARE 1 -#define D2GAME_DIFFICULTY_HELL 2 - -#define D2GS_D2CS_CREATEGAMEREPLY 0x20 -typedef struct -{ - t_d2cs_d2gs_header h; - bn_int result; - bn_int gameid; -} t_d2gs_d2cs_creategamereply; -#define D2GS_D2CS_CREATEGAME_SUCCEED 0 -#define D2GS_D2CS_CREATEGAME_FAILED 1 -#define D2GS_D2CS_JOINGAME_GAME_FULL 2 - -#define D2CS_D2GS_JOINGAMEREQ 0x21 -typedef struct -{ - t_d2cs_d2gs_header h; - bn_int gameid; - bn_int token; - /* character name */ - /* account name */ -} t_d2cs_d2gs_joingamereq; - -#define D2GS_D2CS_JOINGAMEREPLY 0x21 -typedef struct -{ - t_d2cs_d2gs_header h; - bn_int result; - bn_int gameid; -} t_d2gs_d2cs_joingamereply; -#define D2GS_D2CS_JOINGAME_SUCCEED 0 -#define D2GS_D2CS_JOINGAME_FAILED 1 - -#define D2GS_D2CS_UPDATEGAMEINFO 0x22 -typedef struct -{ - t_d2cs_d2gs_header h; - bn_int flag; - bn_int gameid; - bn_int charlevel; - bn_int charclass; - /* charname */ -} t_d2gs_d2cs_updategameinfo; -#define D2GS_D2CS_UPDATEGAMEINFO_FLAG_UPDATE 0 -#define D2GS_D2CS_UPDATEGAMEINFO_FLAG_ENTER 1 -#define D2GS_D2CS_UPDATEGAMEINFO_FLAG_LEAVE 2 - -#define D2GS_D2CS_CLOSEGAME 0x23 -typedef struct -{ - t_d2cs_d2gs_header h; - bn_int gameid; -} t_d2gs_d2cs_closegame; - -#ifdef D2GS -#pragma pack(pop, pack01) -#endif - -#endif diff --git a/d2pack109/src/d2cs/d2cs_protocol.h b/d2pack109/src/d2cs/d2cs_protocol.h deleted file mode 100644 index ba21fe1..0000000 --- a/d2pack109/src/d2cs/d2cs_protocol.h +++ /dev/null @@ -1,350 +0,0 @@ -/* - * Copyright (C) 2000,2001 Onlyer (onlyer@263.net) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_D2CS_PROTOCOL_H -#define INCLUDED_D2CS_PROTOCOL_H - -#include "common/bn_type.h" - -typedef struct -{ - bn_short size; - bn_byte type; -} t_d2cs_client_header; - -typedef struct -{ - t_d2cs_client_header h; -} t_d2cs_client_generic; - -#define CLIENT_D2CS_LOGINREQ 0x01 -typedef struct -{ - t_d2cs_client_header h; - bn_int seqno; - bn_int u1; - bn_int bncs_addr1; - bn_int sessionnum; - bn_int sessionkey; /* always zero,self define */ - bn_int cdkey_id; - bn_int u5; - bn_int clienttag; - bn_int bnversion; - bn_int bncs_addr2; - bn_int u6; /* zero */ - bn_int secret_hash[5]; - /* account name */ -} t_client_d2cs_loginreq; - -#define D2CS_CLIENT_LOGINREPLY 0x01 -typedef struct -{ - t_d2cs_client_header h; - bn_int reply; -} t_d2cs_client_loginreply; -#define D2CS_CLIENT_LOGINREPLY_SUCCEED 0x00 -#define D2CS_CLIENT_LOGINREPLY_BADPASS 0x0c - -#define CLIENT_D2CS_CREATECHARREQ 0x02 -typedef struct -{ - t_d2cs_client_header h; - bn_short class; /* character class */ - bn_short u1; /* always zero */ - bn_short status; /* same as in .d2s file */ - /* character name */ -} t_client_d2cs_createcharreq; - -#define D2CS_CLIENT_CREATECHARREPLY 0x02 -typedef struct -{ - t_d2cs_client_header h; - bn_int reply; -} t_d2cs_client_createcharreply; -#define D2CS_CLIENT_CREATECHARREPLY_SUCCEED 0x00 -#define D2CS_CLIENT_CREATECHARREPLY_FAILED 0x01 -#define D2CS_CLIENT_CREATECHARREPLY_ALREADY_EXIST 0x14 - - -#define CLIENT_D2CS_CREATEGAMEREQ 0x03 -typedef struct -{ - t_d2cs_client_header h; - bn_short seqno; - bn_int gameflag; /* just difficulty is set here */ - bn_byte u1; /* always 1 */ - bn_byte leveldiff; /* Only allow people of +/- n level to join */ - bn_byte maxchar; /* Maximum number of chars allowed in game */ - /* game name */ - /* game pass */ - /* game desc */ -} t_client_d2cs_creategamereq; - -#define D2CS_CLIENT_CREATEGAMEREPLY 0x03 -typedef struct -{ - t_d2cs_client_header h; - bn_short seqno; - bn_short gameid; - bn_short u1; /* always zero */ - bn_int reply; -} t_d2cs_client_creategamereply; -#define D2CS_CLIENT_CREATEGAMEREPLY_SUCCEED 0x00 -#define D2CS_CLIENT_CREATEGAMEREPLY_FAILED 0x01 -#define D2CS_CLIENT_CREATEGAMEREPLY_INVALID_NAME 0x1e -#define D2CS_CLIENT_CREATEGAMEREPLY_NAME_EXIST 0x1f -#define D2CS_CLIENT_CREATEGAMEREPLY_SERVER_DOWN 0x20 -#define D2CS_CLIENT_CREATEGAMEREPLY_NOT_AVAILABLE 0x32 -#define D2CS_CLIENT_CREATEGAMEREPLY_U1 0x33 - -#define CLIENT_D2CS_JOINGAMEREQ 0x04 -typedef struct -{ - t_d2cs_client_header h; - bn_short seqno; - /* game name */ - /* game pass */ -} t_client_d2cs_joingamereq; - -#define D2CS_CLIENT_JOINGAMEREPLY 0x04 -typedef struct -{ - t_d2cs_client_header h; - bn_short seqno; - bn_short gameid; - bn_short u1; /* always zero */ - bn_int addr; - bn_int token; - bn_int reply; -} t_d2cs_client_joingamereply; -#define D2CS_CLIENT_JOINGAMEREPLY_SUCCEED 0x00 -#define D2CS_CLIENT_JOINGAMEREPLY_BAD_PASS 0x29 -#define D2CS_CLIENT_JOINGAMEREPLY_NOT_EXIST 0x2a -#define D2CS_CLIENT_JOINGAMEREPLY_GAME_FULL 0x2b -#define D2CS_CLIENT_JOINGAMEREPLY_LEVEL_LIMIT 0x2c -#define D2CS_CLIENT_JOINGAMEREPLY_HARDCORE_SOFTCORE 0x71 -#define D2CS_CLIENT_JOINGAMEREPLY_NORMAL_NIGHTMARE 0x73 -#define D2CS_CLIENT_JOINGAMEREPLY_NIGHTMARE_HELL 0x74 -#define D2CS_CLIENT_JOINGAMEREPLY_CLASSIC_EXPANSION 0x78 -#define D2CS_CLIENT_JOINGAMEREPLY_EXPANSION_CLASSIC 0x79 -#define D2CS_CLIENT_JOINGAMEREPLY_FAILED 0x01 - -#define CLIENT_D2CS_GAMELISTREQ 0x05 -typedef struct -{ - t_d2cs_client_header h; - bn_short seqno; - bn_int gameflag; /* only hardcore is set here */ - /* bn_byte u1; string game name to search? */ -} t_client_d2cs_gamelistreq; - -#define D2CS_CLIENT_GAMELISTREPLY 0x05 -typedef struct -{ - t_d2cs_client_header h; - bn_short seqno; - bn_int token; - bn_byte currchar; /* current number of characters in game */ - bn_int gameflag; /* 0x04 is always set here */ - /* game name */ - /* game desc */ -} t_d2cs_client_gamelistreply; - -#define CLIENT_D2CS_GAMEINFOREQ 0x06 -typedef struct -{ - t_d2cs_client_header h; - bn_short seqno; - /* game name */ -} t_client_d2cs_gameinforeq; - -#define D2CS_CLIENT_GAMEINFOREPLY 0x06 -typedef struct -{ - t_d2cs_client_header h; - bn_short seqno; - bn_int gameflag; - bn_int etime; - bn_byte charlevel; - bn_byte leveldiff; - bn_byte maxchar; - bn_byte currchar; - bn_byte class[16]; /* 16 character class */ - bn_byte level[16]; /* 16 character level */ - bn_byte u1; /* always zero */ - /* currchar number of character names */ -} t_d2cs_client_gameinforeply; - -#define CLIENT_D2CS_CHARLOGINREQ 0x07 -typedef struct -{ - t_d2cs_client_header h; - /* character name */ -} t_client_d2cs_charloginreq; - -#define D2CS_CLIENT_CHARLOGINREPLY 0x07 -typedef struct -{ - t_d2cs_client_header h; - bn_int reply; -} t_d2cs_client_charloginreply; -#define D2CS_CLIENT_CHARLOGINREPLY_SUCCEED 0x00 -#define D2CS_CLIENT_CHARLOGINREPLY_FAILED 0x01 -#define D2CS_CLIENT_CHARLOGINREPLY_NOT_FOUND 0x46 -#define D2CS_CLIENT_CHARLOGINREPLY_EXPIRED 0x7b - -#define CLIENT_D2CS_DELETECHARREQ 0x0a -typedef struct -{ - t_d2cs_client_header h; - bn_short u1; /* always zero */ - /* character name */ -} t_client_d2cs_deletecharreq; - -#define D2CS_CLIENT_DELETECHARREPLY 0x0a -typedef struct -{ - t_d2cs_client_header h; - bn_short u1; /* always zero */ - bn_int reply; -} t_d2cs_client_deletecharreply; -#define D2CS_CLIENT_DELETECHARREPLY_SUCCEED 0x00 -#define D2CS_CLIENT_DELETECHARREPLY_FAILED 0x01 - - -#define CLIENT_D2CS_LADDERREQ 0x11 -typedef struct -{ - t_d2cs_client_header h; - bn_byte type; /* jadder type request */ - bn_short start_pos; /* list ladder from what position */ -} t_client_d2cs_ladderreq; - -#define D2CS_CLIENT_LADDERREPLY 0x11 -typedef struct -{ - t_d2cs_client_header h; - bn_byte type; /* ladder type request */ - bn_short total_len; /* total length of the ladder data */ - - bn_short curr_len; /* length of ladder data in this packet */ - bn_short cont_len; /* length of ladder data in previous packets */ - /* length here include the header but - exclude this packet */ -} t_d2cs_client_ladderreply; - -typedef struct -{ - bn_short start_pos; /* start position of ladder */ - bn_short u1; /* always zero */ - bn_int count1; /* always 0x10 */ -} t_d2cs_client_ladderheader; - -typedef struct -{ - bn_int count2; /* 0x10 for first packet or 0x0 for continue */ -} t_d2cs_client_ladderinfoheader; - -typedef struct -{ - bn_int explow; - bn_int exphigh; /* always zero */ - bn_short status; - bn_byte level; - bn_byte u1; /* always zero */ - char charname[16]; -} t_d2cs_client_ladderinfo; -#define LADDERSTATUS_FLAG_DEAD 0x10 -#define LADDERSTATUS_FLAG_HARDCORE 0x20 -#define LADDERSTATUS_FLAG_EXPANSION 0x40 -#define LADDERSTATUS_FLAG_DIFFICULTY 0x0f00 - -#define CLIENT_D2CS_MOTDREQ 0x12 -typedef struct -{ - t_d2cs_client_header h; -} t_client_d2cs_motdreq; - -#define D2CS_CLIENT_MOTDREPLY 0x12 -typedef struct -{ - t_d2cs_client_header h; - bn_byte u1; - /* message */ -} t_d2cs_client_motdreply; - -#define CLIENT_D2CS_CANCELCREATEGAME 0x13 -typedef struct -{ - t_d2cs_client_header h; -} t_client_d2cs_cancelcreategame; - -#define D2CS_CLIENT_CREATEGAMEWAIT 0x14 -typedef struct -{ - t_d2cs_client_header h; - bn_int position; -} t_d2cs_client_creategamewait; - -#define D2CS_CLIENT_CHARLADDERREQ 0x16 -typedef struct -{ - t_d2cs_client_header h; - bn_int hardcore; - bn_int expansion; - /* character name */ -} t_client_d2cs_charladderreq; -/* use 0x11 LADDER reply for this request */ - -#define CLIENT_D2CS_CHARLISTREQ 0x17 -typedef struct -{ - t_d2cs_client_header h; - bn_short maxchar; - bn_short u1; -} t_client_d2cs_charlistreq; - -#define D2CS_CLIENT_CHARLISTREPLY 0x17 -typedef struct -{ - t_d2cs_client_header h; - bn_short maxchar; - bn_short currchar; - bn_short u1; /* always zero */ - bn_short currchar2; - /* character name */ - /* character portrait blocks */ - /* each block is 0x22 bytes static length */ -} t_d2cs_client_charlistreply; - -#define CLIENT_D2CS_CONVERTCHARREQ 0x18 -typedef struct -{ - t_d2cs_client_header h; - /* character name */ -} t_client_d2cs_convertcharreq; - -#define D2CS_CLIENT_CONVERTCHARREPLY 0x18 -typedef struct -{ - t_d2cs_client_header h; - bn_int reply; -} t_d2cs_client_convertcharreply; -#define D2CS_CLIENT_CONVERTCHARREPLY_SUCCEED 0x00 -#define D2CS_CLIENT_CONVERTCHARREPLY_FAILED 0x01 - -#endif diff --git a/d2pack109/src/d2cs/d2gs.c b/d2pack109/src/d2cs/d2gs.c deleted file mode 100644 index fb94ffb..0000000 --- a/d2pack109/src/d2cs/d2gs.c +++ /dev/null @@ -1,464 +0,0 @@ -/* - * Copyright (C) 2000,2001 Onlyer (onlyer@263.net) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#include "common/setup_before.h" -#include "setup.h" - -#ifdef HAVE_STDDEF_H -# include -#else -# ifndef NULL -# define NULL ((void *)0) -# endif -#endif -#ifdef STDC_HEADERS -# include -#else -# ifdef HAVE_MALLOC_H -# include -# endif -#endif -#ifdef HAVE_STRING_H -# include -#else -# ifdef HAVE_STRINGS_H -# include -# endif -#endif -#include "compat/strsep.h" -#include "compat/char_bit.h" -#ifdef HAVE_SYS_TYPES_H -# include /* needed to include netinet/in.h */ -#endif -#ifdef HAVE_SYS_SOCKET_H -# include -#endif -#include "compat/socket.h" -#ifdef HAVE_SYS_PARAM_H -# include -#endif -#ifdef HAVE_NETINET_IN_H -# include -#endif -#include "compat/netinet_in.h" -#ifdef HAVE_ARPA_INET_H -# include /* FIXME: probably not needed... do some systems put types in here or something? */ -#endif -#include "compat/psock.h" - -#include "d2gs.h" -#include "game.h" -#include "net.h" -#include "bit.h" -#include "prefs.h" -#include "connection.h" -#include "common/introtate.h" -#include "common/addr.h" -#include "common/list.h" -#include "common/eventlog.h" -#include "common/xalloc.h" -#include "common/setup_after.h" - -static t_list * d2gslist_head=NULL; -static unsigned int d2gs_id=0; -static unsigned int total_d2gs=0; - -extern t_list * d2gslist(void) -{ - return d2gslist_head; -} - -extern int d2gslist_create(void) -{ - d2gslist_head=list_create(); - return d2gslist_reload(prefs_get_d2gs_list()); -} - -extern int d2gslist_reload(char const * gslist) -{ - t_addrlist * gsaddrs; - t_d2gs * gs; - - if (!d2gslist_head) return -1; - - BEGIN_LIST_TRAVERSE_DATA(d2gslist_head,gs) - { - BIT_CLR_FLAG(gs->flag, D2GS_FLAG_VALID); - } - END_LIST_TRAVERSE_DATA() - - gsaddrs = addrlist_create(gslist, INADDR_ANY, 0); - if (gsaddrs) { - t_elem const *acurr; - t_addr * curr_laddr; - - LIST_TRAVERSE_CONST(gsaddrs, acurr) - { - curr_laddr = (t_addr*)elem_get_data(acurr); - if (!curr_laddr) { - eventlog(eventlog_level_error, __FUNCTION__, "found NULL value in gslist"); - continue; - } - if (!(gs=d2gslist_find_gs_by_ip(addr_get_ip(curr_laddr)))) - gs = d2gs_create(addr_num_to_ip_str(addr_get_ip(curr_laddr))); - if (gs) BIT_SET_FLAG(gs->flag, D2GS_FLAG_VALID); - } - addrlist_destroy(gsaddrs); - } - - BEGIN_LIST_TRAVERSE_DATA(d2gslist_head,gs) - { - if (!BIT_TST_FLAG(gs->flag, D2GS_FLAG_VALID)) { - d2gs_destroy(gs,&curr_elem_); - } - } - END_LIST_TRAVERSE_DATA() - return 0; -} - -extern int d2gslist_destroy(void) -{ - t_d2gs * gs; - - BEGIN_LIST_TRAVERSE_DATA_CONST(d2gslist_head,gs) - { - d2gs_destroy(gs,(t_elem **)&curr_elem_); - } - END_LIST_TRAVERSE_DATA_CONST() - d2cs_connlist_reap(); - - if (list_destroy(d2gslist_head)<0) { - eventlog(eventlog_level_error,__FUNCTION__,"error destroy d2gs list"); - return -1; - } - d2gslist_head=NULL; - return 0; -} - -extern t_d2gs * d2gslist_find_gs_by_ip(unsigned int ip) -{ - t_d2gs * gs; - - BEGIN_LIST_TRAVERSE_DATA_CONST(d2gslist_head,gs) - { - if (gs->ip==ip) return gs; - } - END_LIST_TRAVERSE_DATA_CONST() - return NULL; -} - -extern t_d2gs * d2gslist_find_gs(unsigned int id) -{ - t_d2gs * gs; - - BEGIN_LIST_TRAVERSE_DATA_CONST(d2gslist_head,gs) - { - if (gs->id==id) return gs; - } - END_LIST_TRAVERSE_DATA_CONST() - return NULL; -} - -extern t_d2gs * d2gs_create(char const * ipaddr) -{ - t_d2gs * gs; - unsigned int ip; - - ASSERT(ipaddr,NULL); - if ((ip=net_inet_addr(ipaddr))==~0U) { - eventlog(eventlog_level_error,__FUNCTION__,"got bad ip address %s",ipaddr); - return NULL; - } - if (d2gslist_find_gs_by_ip(ntohl(ip))) { - eventlog(eventlog_level_error,__FUNCTION__,"game server %s already in list",ipaddr); - return NULL; - } - gs=xmalloc(sizeof(t_d2gs)); - gs->ip=ntohl(ip); - gs->id=++d2gs_id; - gs->active=0; - gs->token=0; - gs->state=d2gs_state_none; - gs->gamenum=0; - gs->maxgame=0; - gs->connection=NULL; - - if (list_append_data(d2gslist_head,gs)<0) { - eventlog(eventlog_level_error,__FUNCTION__,"error add gs to list"); - xfree(gs); - return NULL; - } - eventlog(eventlog_level_info,__FUNCTION__,"added game server %s (id: %d) to list",ipaddr,gs->id); - return gs; -} - -extern int d2gs_destroy(t_d2gs * gs, t_elem ** curr) -{ - ASSERT(gs,-1); - if (list_remove_data(d2gslist_head,gs,curr)<0) { - eventlog(eventlog_level_error,__FUNCTION__,"error remove gs from list"); - return -1; - } - if (gs->active && gs->connection) { - d2cs_conn_set_state(gs->connection, conn_state_destroy); - d2gs_deactive(gs, gs->connection); - } - eventlog(eventlog_level_info,__FUNCTION__,"removed game server %s (id: %d) from list",addr_num_to_ip_str(gs->ip),gs->id); - xfree(gs); - return 0; -} - -extern t_d2gs * d2gslist_get_server_by_id(unsigned int id) -{ - t_d2gs * gs; - - BEGIN_LIST_TRAVERSE_DATA_CONST(d2gslist_head,gs) - { - if (gs->id==id) return gs; - } - END_LIST_TRAVERSE_DATA_CONST() - return NULL; -} - -extern t_d2gs * d2gslist_choose_server(void) -{ - t_d2gs * gs; - t_d2gs * ogs; - unsigned int percent; - unsigned int min_percent=100; - - ogs=NULL; - BEGIN_LIST_TRAVERSE_DATA_CONST(d2gslist_head,gs) - { - if (!gs->active) continue; - if (!gs->connection) continue; - if (gs->state!=d2gs_state_authed) continue; - if (!gs->maxgame) continue; - if (gs->gamenum>=gs->maxgame) continue; - percent=100*gs->gamenum/gs->maxgame; - if (percentstate=state; - return 0; -} - -extern t_d2gs_state d2gs_get_state(t_d2gs const * gs) -{ - ASSERT(gs,d2gs_state_none); - return gs->state; -} - -extern int d2gs_add_gamenum(t_d2gs * gs, int number) -{ - ASSERT(gs,-1); - gs->gamenum += number; - return 0; -} - -extern unsigned int d2gs_get_gamenum(t_d2gs const * gs) -{ - ASSERT(gs,0); - return gs->gamenum; -} - - -extern int d2gs_set_maxgame(t_d2gs * gs,unsigned int maxgame) -{ - ASSERT(gs,-1); - gs->maxgame=maxgame; - return 0; -} - -extern unsigned int d2gs_get_maxgame(t_d2gs const * gs) -{ - ASSERT(gs,0); - return gs->maxgame; -} - -extern unsigned int d2gs_get_id(t_d2gs const * gs) -{ - ASSERT(gs,0); - return gs->id; -} - -extern unsigned int d2gs_get_ip(t_d2gs const * gs) -{ - ASSERT(gs,0); - return gs->ip; -} - -extern unsigned int d2gs_get_token(t_d2gs const * gs) -{ - return gs->token; -} - -extern unsigned int d2gs_add_token(t_d2gs * gs) -{ - return ++(gs->token); -} - -extern t_connection * d2gs_get_connection(t_d2gs const * gs) -{ - ASSERT(gs,NULL); - return gs->connection; -} - -extern int d2gs_active(t_d2gs * gs, t_connection * c) -{ - ASSERT(gs,-1); - ASSERT(c,-1); - - if (gs->active && gs->connection) { - eventlog(eventlog_level_warn,__FUNCTION__,"game server %d is already actived, deactive previous connection first",gs->id); - d2gs_deactive(gs, gs->connection); - } - total_d2gs++; - eventlog(eventlog_level_info,__FUNCTION__,"game server %s (id: %d) actived (%d total)",addr_num_to_addr_str(d2cs_conn_get_addr(c), - d2cs_conn_get_port(c)),gs->id,total_d2gs); - gs->state=d2gs_state_authed; - gs->connection=c; - gs->active=1; - gs->gamenum=0; - gs->maxgame=0; - return 0; -} - -extern int d2gs_deactive(t_d2gs * gs, t_connection * c) -{ - t_game * game; - - ASSERT(gs,-1); - if (!gs->active || !gs->connection) { - eventlog(eventlog_level_warn,__FUNCTION__,"game server %d is not actived yet", gs->id); - return -1; - } - if (gs->connection != c) { - eventlog(eventlog_level_debug,__FUNCTION__,"game server %d connection mismatch,ignore it", gs->id); - return 0; - } - total_d2gs--; - eventlog(eventlog_level_info,__FUNCTION__,"game server %s (id: %d) deactived (%d left)",addr_num_to_addr_str(d2cs_conn_get_addr(gs->connection),d2cs_conn_get_port(gs->connection)),gs->id,total_d2gs); - gs->state=d2gs_state_none; - gs->connection=NULL; - gs->active=0; - gs->maxgame=0; - eventlog(eventlog_level_info,__FUNCTION__,"destroying all games on game server %d",gs->id); - BEGIN_LIST_TRAVERSE_DATA(d2cs_gamelist(),game) - { - if (game_get_d2gs(game)==gs) game_destroy(game,&curr_elem_); - } - END_LIST_TRAVERSE_DATA() - if (gs->gamenum!=0) { - eventlog(eventlog_level_error,__FUNCTION__,"game server %d deactived but still with games left",gs->id); - } - gs->gamenum=0; - return 0; -} - -extern unsigned int d2gs_calc_checksum(t_connection * c) -{ - unsigned int sessionnum, checksum, port, addr; - unsigned int i, len, ch; - char const * realmname; - char const * password; - - ASSERT(c,0); - sessionnum=d2cs_conn_get_sessionnum(c); - checksum=prefs_get_d2gs_checksum(); - port=d2cs_conn_get_port(c); - addr=d2cs_conn_get_addr(c); - realmname=prefs_get_realmname(); - password=prefs_get_d2gs_password(); - - len=strlen(realmname); - for (i=0; iu.d2cs_d2gs.h.seqno,0); - BEGIN_LIST_TRAVERSE_DATA(d2gslist_head,gs) - { - if (gs->active && gs->connection) { - conn_push_outqueue(gs->connection,packet); - } - } - END_LIST_TRAVERSE_DATA() - packet_del_ref(packet); - return 0; -} - -extern int d2gs_restart_all_gs(void) -{ - t_packet * packet; - t_d2gs * gs; - - if (!(packet=packet_create(packet_class_d2gs))) { - eventlog(eventlog_level_error, __FUNCTION__, "error creating packet"); - return -1; - } - packet_set_size(packet,sizeof(t_d2cs_d2gs_control)); - packet_set_type(packet,D2CS_D2GS_CONTROL); - /* FIXME: sequence number not set */ - bn_int_set(&packet->u.d2cs_d2gs.h.seqno,0); - bn_int_set(&packet->u.d2cs_d2gs_control.cmd, D2CS_D2GS_CONTROL_CMD_RESTART); - bn_int_set(&packet->u.d2cs_d2gs_control.value, prefs_get_d2gs_restart_delay()); - - BEGIN_LIST_TRAVERSE_DATA(d2gslist_head,gs) - { - if (gs->connection && gs->d2gs_version > 0x1090007) { - conn_push_outqueue(gs->connection,packet); - } - } - - END_LIST_TRAVERSE_DATA() - packet_del_ref(packet); - return 0; -} - diff --git a/d2pack109/src/d2cs/d2gs.h b/d2pack109/src/d2cs/d2gs.h deleted file mode 100644 index 6f89adb..0000000 --- a/d2pack109/src/d2cs/d2gs.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (C) 2000,2001 Onlyer (onlyer@263.net) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_D2GS_H -#define INCLUDED_D2GS_H - -#include "common/list.h" -#include "connection.h" - -typedef enum -{ - d2gs_state_none, - d2gs_state_connected, - d2gs_state_authed -} t_d2gs_state; - -typedef struct d2gs -{ - unsigned int ip; - unsigned int id; - unsigned int flag; - unsigned int active; - unsigned int token; - t_d2gs_state state; - unsigned int maxgame; - unsigned int gamenum; - t_connection * connection; - unsigned int d2gs_version; -} t_d2gs; - -#define D2GS_FLAG_VALID 0x01 - -extern t_list * d2gslist(void); -extern int d2gslist_create(void); -extern int d2gslist_destroy(void); -extern int d2gslist_reload(char const * gslist); -extern t_d2gs * d2gs_create(char const * ip); -extern int d2gs_destroy(t_d2gs * gs,t_elem ** curr); -extern t_d2gs * d2gslist_get_server_by_id(unsigned int id); -extern t_d2gs * d2gslist_choose_server(void); -extern t_d2gs * d2gslist_find_gs(unsigned int id); -extern t_d2gs * d2gslist_find_gs_by_ip(unsigned int ip); -extern unsigned int d2gs_get_id(t_d2gs const * gs); -extern unsigned int d2gs_get_ip(t_d2gs const * gs); -extern t_d2gs_state d2gs_get_state(t_d2gs const * gs); -extern int d2gs_set_state(t_d2gs * gs, t_d2gs_state state); -extern unsigned int d2gs_get_maxgame(t_d2gs const * gs); -extern int d2gs_set_maxgame(t_d2gs * gs,unsigned int maxgame); -extern unsigned int d2gs_get_gamenum(t_d2gs const * gs); -extern int d2gs_add_gamenum(t_d2gs * gs,int number); -extern unsigned int d2gs_get_token(t_d2gs const * gs); -extern unsigned int d2gs_add_token(t_d2gs * gs); -extern t_connection * d2gs_get_connection(t_d2gs const * gs); -extern int d2gs_active(t_d2gs * gs, t_connection * c); -extern int d2gs_deactive(t_d2gs * gs, t_connection * c); -extern unsigned int d2gs_calc_checksum(t_connection * c); -extern int d2gs_keepalive(void); -extern int d2gs_restart_all_gs(void); - -#endif diff --git a/d2pack109/src/d2cs/d2ladder.c b/d2pack109/src/d2cs/d2ladder.c deleted file mode 100644 index ca67a61..0000000 --- a/d2pack109/src/d2cs/d2ladder.c +++ /dev/null @@ -1,280 +0,0 @@ -/* - * Copyright (C) 2000,2001 Onlyer (onlyer@263.net) - * Copyright (C) 2001 sousou (liupeng.cs@263.net) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#include "common/setup_before.h" -#include "setup.h" - -#ifdef HAVE_STDDEF_H -# include -#else -# ifndef NULL -# define NULL ((void *)0) -# endif -#endif -#include -#ifdef HAVE_STRING_H -# include -#else -# ifdef HAVE_STRINGS_H -# include -# endif -# ifdef HAVE_MEMORY_H -# include -# endif -#endif -#include "compat/strcasecmp.h" -#include "compat/memset.h" -#include -#include "compat/strerror.h" -#ifdef STDC_HEADERS -# include -#else -# ifdef HAVE_MALLOC_H -# include -# endif -#endif - -#include "prefs.h" -#include "d2charfile.h" -#include "d2ladder.h" -#include "d2cs_protocol.h" -#include "common/tag.h" -#include "common/eventlog.h" -#include "common/xalloc.h" -#include "common/setup_after.h" - -static t_d2ladder * ladder_data=NULL; -static unsigned int max_ladder_type=0; - -static int d2ladderlist_create(unsigned int maxtype); -static int d2ladder_create(unsigned int type, unsigned int len); -static int d2ladder_append_ladder(unsigned int type, t_d2ladderfile_ladderinfo * info); -static int d2ladder_readladder(void); - -extern int d2ladder_init(void) -{ - if (d2ladder_readladder()<0) { - eventlog(eventlog_level_error,__FUNCTION__,"failed to initialize ladder data"); - return -1; - } - eventlog(eventlog_level_info,__FUNCTION__,"ladder data initialized"); - return 0; -} - -static int d2ladder_readladder(void) -{ - FILE * fp; - t_d2ladderfile_ladderindex * ladderheader; - t_d2ladderfile_ladderinfo * ladderinfo; - char * ladderfile; - t_d2ladderfile_header header; - unsigned int i, n, temp, count, type, number; - - ladderfile=xmalloc(strlen(prefs_get_ladder_dir())+1+strlen(LADDER_FILE_PREFIX)+1+ - strlen(CLIENTTAG_DIABLO2DV)+1); - sprintf(ladderfile,"%s/%s.%s",prefs_get_ladder_dir(),LADDER_FILE_PREFIX,CLIENTTAG_DIABLO2DV); - if (!(fp=fopen(ladderfile,"rb"))) { - eventlog(eventlog_level_error,__FUNCTION__,"error opening ladder file \"%s\" for reading (fopen: %s)",ladderfile,strerror(errno)); - xfree(ladderfile); - return -1; - } - xfree(ladderfile); - if (fread(&header,1,sizeof(header),fp)!=sizeof(header)) { - eventlog(eventlog_level_error,__FUNCTION__,"error reading ladder file"); - fclose(fp); - return -1; - } - max_ladder_type= bn_int_get(header.maxtype); - if (d2ladderlist_create(max_ladder_type)<0) { - eventlog(eventlog_level_error,__FUNCTION__,"error create ladder list"); - fclose(fp); - return -1; - } - temp= max_ladder_type * sizeof(*ladderheader); - ladderheader=xmalloc(temp); - if (fread(ladderheader,1,temp,fp)!=temp) { - eventlog(eventlog_level_error,__FUNCTION__,"error read ladder file"); - xfree(ladderheader); - fclose(fp); - return -1; - } - for (i=0, count=0; i< max_ladder_type ; i++) { - type=bn_int_get(ladderheader[i].type); - number=bn_int_get(ladderheader[i].number); - if (d2ladder_create(type,number)<0) { - eventlog(eventlog_level_error,__FUNCTION__,"error create ladder %d",type); - continue; - } - fseek(fp,bn_int_get(ladderheader[i].offset),SEEK_SET); - temp=number * sizeof(*ladderinfo); - ladderinfo=xmalloc(temp); - if (fread(ladderinfo,1,temp,fp)!=temp) { - eventlog(eventlog_level_error,__FUNCTION__,"error read ladder file"); - xfree(ladderinfo); - continue; - } - for (n=0; n< number; n++) { - d2ladder_append_ladder(type,ladderinfo+n); - } - xfree(ladderinfo); - if (number) count++; - } - xfree(ladderheader); - fclose(fp); - eventlog(eventlog_level_info,__FUNCTION__,"ladder file loaded successfully (%d types %d maxtype)",count,max_ladder_type); - return 0; -} - -static int d2ladderlist_create(unsigned int maxtype) -{ - ladder_data=xmalloc(maxtype * sizeof(*ladder_data)); - memset(ladder_data,0, maxtype * sizeof(*ladder_data)); - return 0; -} - -extern int d2ladder_refresh(void) -{ - d2ladder_destroy(); - return d2ladder_readladder(); -} - -static int d2ladder_create(unsigned int type, unsigned int len) -{ - if (type>max_ladder_type) { - eventlog(eventlog_level_error,__FUNCTION__,"ladder type %d exceed max ladder type %d",type,max_ladder_type); - return -1; - } - ladder_data[type].info=xmalloc(sizeof(t_d2cs_client_ladderinfo) * len); - ladder_data[type].len=len; - ladder_data[type].type=type; - ladder_data[type].curr_len=0; - return 0; -} - -static int d2ladder_append_ladder(unsigned int type, t_d2ladderfile_ladderinfo * info) -{ - t_d2cs_client_ladderinfo * ladderinfo; - unsigned short ladderstatus; - unsigned short status; - unsigned char class; - - if (!info) { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL info"); - return -1; - } - if (type > max_ladder_type) { - eventlog(eventlog_level_error,__FUNCTION__,"ladder type %d exceed max ladder type %d",type,max_ladder_type); - return -1; - } - if (!ladder_data[type].info) { - eventlog(eventlog_level_error,__FUNCTION__,"ladder data info not initialized"); - return -1; - } - if (ladder_data[type].curr_len >= ladder_data[type].len) { - eventlog(eventlog_level_error,__FUNCTION__,"ladder data overflow %d > %d", ladder_data[type].curr_len, ladder_data[type].len); - return -1; - } - status = bn_short_get(info->status); - class = bn_byte_get(info->class); - ladderstatus = (status & LADDERSTATUS_FLAG_DIFFICULTY); - if (charstatus_get_hardcore(status)) { - ladderstatus |= LADDERSTATUS_FLAG_HARDCORE; - if (charstatus_get_dead(status)) { - ladderstatus |= LADDERSTATUS_FLAG_DEAD; - } - } - if (charstatus_get_expansion(status)) { - ladderstatus |= LADDERSTATUS_FLAG_EXPANSION; - ladderstatus |= min(class,D2CHAR_EXP_CLASS_MAX); - } else { - ladderstatus |= min(class,D2CHAR_CLASS_MAX); - } - ladderinfo=ladder_data[type].info+ladder_data[type].curr_len; - bn_int_set(&ladderinfo->explow, bn_int_get(info->experience)); - bn_int_set(&ladderinfo->exphigh,0); - bn_short_set(&ladderinfo->status,ladderstatus); - bn_byte_set(&ladderinfo->level, bn_int_get(info->level)); - bn_byte_set(&ladderinfo->u1, 0); - strncpy(ladderinfo->charname, info->charname, MAX_CHARNAME_LEN); - ladder_data[type].curr_len++; - return 0; -} - -extern int d2ladder_destroy(void) -{ - unsigned int i; - - if (ladder_data) { - for (i=0; i< max_ladder_type; i++) { - if (ladder_data[i].info) { - xfree(ladder_data[i].info); - ladder_data[i].info=NULL; - } - } - xfree(ladder_data); - ladder_data=NULL; - } - max_ladder_type=0; - return 0; -} - -extern int d2ladder_get_ladder(unsigned int * from, unsigned int * count, unsigned int type, - t_d2cs_client_ladderinfo const * * info) -{ - t_d2ladder * ladder; - - if (!ladder_data) return -1; - ladder=ladder_data+type; - if (!ladder->curr_len || !ladder->info) { - eventlog(eventlog_level_warn,__FUNCTION__,"ladder type %d not found",type); - return -1; - } - if (ladder->type != type) { - eventlog(eventlog_level_error,__FUNCTION__,"got bad ladder data"); - return -1; - } - if (ladder->curr_len < *count) { - *from = 0; - *count=ladder->curr_len; - } else if (*from + *count> ladder->curr_len) { - *from= ladder->curr_len - *count; - } - *info = ladder->info+ *from; - return 0; -} - -extern int d2ladder_find_character_pos(unsigned int type, char const * charname) -{ - unsigned int i; - t_d2ladder * ladder; - - if (!ladder_data) return -1; - ladder=ladder_data+type; - if (!ladder->curr_len || !ladder->info) { - eventlog(eventlog_level_warn,__FUNCTION__,"ladder type %d not found",type); - return -1; - } - if (ladder->type != type) { - eventlog(eventlog_level_error,__FUNCTION__,"got bad ladder data"); - return -1; - } - for (i=0; i< ladder->curr_len; i++) { - if (!strcasecmp(ladder->info[i].charname,charname)) return i; - } - return -1; -} diff --git a/d2pack109/src/d2cs/d2ladder.h b/d2pack109/src/d2cs/d2ladder.h deleted file mode 100644 index 9a9af3d..0000000 --- a/d2pack109/src/d2cs/d2ladder.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2000,2001 Onlyer (onlyer@263.net) - * Copyright (C) 2001 sousou (liupeng.cs@263.net) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_D2LADDER_H -#define INCLUDED_D2LADDER_H - -#include "common/bn_type.h" -#include "d2cs_protocol.h" -#include "d2cs_d2dbs_ladder.h" - -typedef struct -{ - unsigned int type; - unsigned int len; - unsigned int curr_len; - t_d2cs_client_ladderinfo * info; -} t_d2ladder; - -extern int d2ladder_init(void); -extern int d2ladder_refresh(void); -extern int d2ladder_destroy(void); -extern int d2ladder_get_ladder(unsigned int * from, unsigned int * count, unsigned int type, - t_d2cs_client_ladderinfo const * * info); -extern int d2ladder_find_character_pos(unsigned int type, char const * charname); - -#endif diff --git a/d2pack109/src/d2cs/game.c b/d2pack109/src/d2cs/game.c deleted file mode 100644 index def652f..0000000 --- a/d2pack109/src/d2cs/game.c +++ /dev/null @@ -1,517 +0,0 @@ -/* - * Copyright (C) 2000,2001 Onlyer (onlyer@263.net) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#include "common/setup_before.h" -#include "setup.h" - -#ifdef STDC_HEADERS -# include -#else -# ifdef HAVE_MALLOC_H -# include -# endif -#endif -#ifdef HAVE_STRING_H -# include -#else -# ifdef HAVE_STRINGS_H -# include -# endif -# ifdef HAVE_MEMORY_H -# include -# endif -#endif -#include "compat/strcasecmp.h" -#include "compat/strdup.h" -#ifdef TIME_WITH_SYS_TIME -# include -# include -#else -# ifdef HAVE_SYS_TIME_H -# include -# else -# include -# endif -#endif - -#include "prefs.h" -#include "game.h" -#include "common/list.h" -#include "common/eventlog.h" -#include "common/xalloc.h" -#include "common/setup_after.h" - -static t_list * gamelist_head=NULL; -static t_elem const * gamelist_curr_elem=NULL; -static unsigned int total_game=0; -static unsigned int game_id=0; -static t_game_charinfo * game_find_character(t_game * game, char const * charname); - -extern t_list * d2cs_gamelist(void) -{ - return gamelist_head; -} - -extern t_elem const * gamelist_get_curr_elem(void) -{ - return gamelist_curr_elem; -} - -extern void gamelist_set_curr_elem(t_elem const * elem) -{ - gamelist_curr_elem=elem; - return; -} - -extern int d2cs_gamelist_create(void) -{ - gamelist_head=list_create(); - return 0; -} - -extern int d2cs_gamelist_destroy(void) -{ - t_game * game; - - BEGIN_LIST_TRAVERSE_DATA(gamelist_head, game) - { - game_destroy(game,&curr_elem_); - } - END_LIST_TRAVERSE_DATA(); - - if (list_destroy(gamelist_head)<0) { - eventlog(eventlog_level_error,__FUNCTION__,"error destroy connection list"); - return -1; - } - gamelist_head=NULL; - return 0; -} - -extern t_game * d2cs_gamelist_find_game(char const * gamename) -{ - t_game * game; - - ASSERT(gamename,NULL); - BEGIN_LIST_TRAVERSE_DATA(gamelist_head,game) - { - if (!strcasecmp(game->name,gamename)) return game; - } - END_LIST_TRAVERSE_DATA() - return NULL; -} - -extern t_game * gamelist_find_game_by_id(unsigned int id) -{ - t_game * game; - - BEGIN_LIST_TRAVERSE_DATA(gamelist_head,game) - { - if (game->id==id) return game; - } - END_LIST_TRAVERSE_DATA() - return NULL; -} - -extern t_game * gamelist_find_game_by_d2gs_and_id(unsigned int d2gs_id, unsigned int d2gs_gameid) -{ - t_game * game; - - BEGIN_LIST_TRAVERSE_DATA(gamelist_head,game) - { - if (!game->created) continue; - if (game->d2gs_gameid!=d2gs_gameid) continue; - if (d2gs_get_id(game->d2gs) != d2gs_id) continue; - return game; - } - END_LIST_TRAVERSE_DATA() - return NULL; -} - -extern t_game * gamelist_find_character(char const * charname) -{ - t_game * game; - - ASSERT(charname,NULL); - BEGIN_LIST_TRAVERSE_DATA(gamelist_head, game) - { - if (game_find_character(game,charname)) return game; - } - END_LIST_TRAVERSE_DATA(); - return NULL; -} - -extern void d2cs_gamelist_check_voidgame(void) -{ - t_game * game; - time_t now; - int timeout; - - timeout=prefs_get_max_game_idletime(); - if (!timeout) return; - now=time(NULL); - BEGIN_LIST_TRAVERSE_DATA(gamelist_head, game) - { - if (!game->currchar) { - if ((now-game->lastaccess_time)>timeout) { - eventlog(eventlog_level_info,__FUNCTION__,"game %s is empty too long time,destroying it",game->name); - game_destroy(game,&curr_elem_); - } - } - } - END_LIST_TRAVERSE_DATA() -} - -extern t_game * d2cs_game_create(char const * gamename, char const * gamepass, char const * gamedesc, - unsigned int gameflag) -{ - t_game * game; - time_t now; - - ASSERT(gamename,NULL); - ASSERT(gamepass,NULL); - ASSERT(gamedesc,NULL); - if (d2cs_gamelist_find_game(gamename)) { - eventlog(eventlog_level_error,__FUNCTION__,"game %s already exist",gamename); - return NULL; - } - game=xmalloc(sizeof(t_game)); - game->name=xstrdup(gamename); - game->pass=xstrdup(gamepass); - game->desc=xstrdup(gamedesc); - game->charlist=list_create(); - now=time(NULL); - game_id++; - if (game_id==0) game_id=1; - game->id=game_id; - game->created=0; - game->create_time=now; - game->lastaccess_time=now; - game->gameflag=gameflag; - game->charlevel=0; - game->leveldiff=0; - game->d2gs_gameid=0; - game->d2gs=NULL; - game->maxchar=MAX_CHAR_PER_GAME; - game->currchar=0; - list_prepend_data(gamelist_head,game); - total_game++; - eventlog(eventlog_level_info,__FUNCTION__,"game %s pass=%s desc=%s gameflag=0x%08X created (%d total)",gamename,gamepass, - gamedesc,gameflag,total_game); - return game; -} - -extern int game_destroy(t_game * game, t_elem ** elem) -{ - t_elem * curr; - t_game_charinfo * charinfo; - - ASSERT(game,-1); - if (gamelist_curr_elem && (game==elem_get_data(gamelist_curr_elem))) { - gamelist_curr_elem=elem_get_next_const(gamelist_head,gamelist_curr_elem); - } - if (list_remove_data(gamelist_head,game,elem)<0) { - eventlog(eventlog_level_error,__FUNCTION__,"error remove game %s on game list",game->name); - return -1; - } - total_game--; - eventlog(eventlog_level_info,__FUNCTION__,"game %s removed from game list (%d left)",game->name,total_game); - LIST_TRAVERSE(game->charlist,curr) - { - if ((charinfo=elem_get_data(curr))) { - if (charinfo->charname) xfree((void *)charinfo->charname); - xfree(charinfo); - } - list_remove_elem(game->charlist,&curr); - } - list_destroy(game->charlist); - - if (game->d2gs) { - d2gs_add_gamenum(game->d2gs,-1); - if (d2gs_get_gamenum(game->d2gs) < d2gs_get_maxgame(game->d2gs)) { - gqlist_check_creategame(); - } - } - if (game->desc) xfree((void *)game->desc); - if (game->pass) xfree((void *)game->pass); - if (game->name) xfree((void *)game->name); - xfree(game); - return 0; -} - -static t_game_charinfo * game_find_character(t_game * game, char const * charname) -{ - t_game_charinfo * charinfo; - - ASSERT(game,NULL); - ASSERT(charname,NULL); - if (!game->charlist) { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL character list in game %s",game->name); - return NULL; - } - BEGIN_LIST_TRAVERSE_DATA(game->charlist,charinfo) - { - if (!charinfo->charname) continue; - if (!strcmp_charname(charinfo->charname,charname)) return charinfo; - } - END_LIST_TRAVERSE_DATA() - return NULL; -} - -extern int game_add_character(t_game * game, char const * charname, unsigned char class, - unsigned char level) -{ - t_game_charinfo * charinfo; - - ASSERT(game,-1); - ASSERT(charname,-1); - charinfo=game_find_character(game,charname); - if (charinfo) { - eventlog(eventlog_level_info,__FUNCTION__,"updating character %s (game %s) status", charname,game->name); - charinfo->class=class; - charinfo->level=level; - return 0; - } - charinfo=xmalloc(sizeof(t_game_charinfo)); - charinfo->charname=xstrdup(charname); - charinfo->class=class; - charinfo->level=level; - list_append_data(game->charlist,charinfo); - game->currchar++; - game->lastaccess_time=time(NULL); - eventlog(eventlog_level_info,__FUNCTION__,"added character %s to game %s (%d total)",charname,game->name,game->currchar); - return 0; -} - -extern int game_del_character(t_game * game, char const * charname) -{ - t_game_charinfo * charinfo; - t_elem * elem; - - ASSERT(game,-1); - ASSERT(charname,-1); - if (!(charinfo=game_find_character(game,charname))) { - eventlog(eventlog_level_error,__FUNCTION__,"character %s not found in game %s",charname,game->name); - return -1; - } - if (list_remove_data(game->charlist,charinfo,&elem)) { - eventlog(eventlog_level_error,__FUNCTION__,"error remove character %s from game %s",charname,game->name); - return -1; - } - if (charinfo->charname) xfree((void *)charinfo->charname); - xfree(charinfo); - game->currchar--; - game->lastaccess_time=time(NULL); - eventlog(eventlog_level_info,__FUNCTION__,"removed character %s from game %s (%d left)",charname,game->name,game->currchar); - return 0; -} - -extern int game_set_d2gs_gameid(t_game * game, unsigned int d2gs_gameid) -{ - ASSERT(game,-1); - game->d2gs_gameid=d2gs_gameid; - return 0; -} - -extern unsigned int game_get_d2gs_gameid(t_game const * game) -{ - ASSERT(game,0); - return game->d2gs_gameid; -} - -extern unsigned int d2cs_game_get_id(t_game const * game) -{ - ASSERT(game,0); - return game->id; -} - -extern int game_set_d2gs(t_game * game, t_d2gs * gs) -{ - ASSERT(game,-1); - game->d2gs=gs; - return 0; -} - -extern t_d2gs * game_get_d2gs(t_game const * game) -{ - ASSERT(game,NULL); - return game->d2gs; -} - -extern int game_set_leveldiff(t_game * game, unsigned int leveldiff) -{ - ASSERT(game,-1); - game->leveldiff=leveldiff; - return 0; -} - -extern int game_set_charlevel(t_game * game, unsigned int charlevel) -{ - ASSERT(game,-1); - game->charlevel=charlevel; - return 0; -} - -extern unsigned int game_get_charlevel(t_game const * game) -{ - ASSERT(game,0); - return game->charlevel; -} - -extern unsigned int game_get_leveldiff(t_game const * game) -{ - ASSERT(game,0); - return game->leveldiff; -} - -extern unsigned int game_get_maxlevel(t_game const * game) -{ - int maxlevel; - - ASSERT(game,0); - maxlevel=game->charlevel+game->leveldiff; - if (maxlevel>0xff) maxlevel=0xff; - return maxlevel; -} - -extern unsigned int game_get_minlevel(t_game const * game) -{ - int minlevel; - - ASSERT(game,0); - minlevel=game->charlevel-game->leveldiff; - if (minlevel<0) minlevel=0; - return minlevel; -} - -extern unsigned int game_get_gameflag_expansion(t_game const * game) -{ - ASSERT(game,0); - return gameflag_get_expansion(game->gameflag); -} - -extern unsigned int game_get_gameflag_hardcore(t_game const * game) -{ - ASSERT(game,0); - return gameflag_get_hardcore(game->gameflag); -} - -extern unsigned int game_get_gameflag_difficulty(t_game const * game) -{ - ASSERT(game,0); - return gameflag_get_difficulty(game->gameflag); -} - -extern int game_set_gameflag_expansion(t_game * game, unsigned int expansion) -{ - ASSERT(game,-1); - gameflag_set_expansion(game->gameflag,expansion); - return 0; -} - -extern int game_set_gameflag_hardcore(t_game * game, unsigned int hardcore) -{ - ASSERT(game,-1); - gameflag_set_hardcore(game->gameflag,hardcore); - return 0; -} - -extern int game_set_gameflag_difficulty(t_game * game, unsigned int difficulty) -{ - ASSERT(game,-1); - gameflag_set_difficulty(game->gameflag,difficulty); - return 0; -} - -extern unsigned int game_get_created(t_game const * game) -{ - ASSERT(game,0); - return game->created; -} - -extern int game_set_created(t_game * game, unsigned int created) -{ - ASSERT(game,-1); - game->created=created; - return 0; -} - -extern unsigned int game_get_maxchar(t_game const * game) -{ - ASSERT(game,0); - return game->maxchar; -} - -extern int game_set_maxchar(t_game * game, unsigned int maxchar) -{ - ASSERT(game,-1); - game->maxchar=maxchar; - return 0; -} - -extern unsigned int game_get_currchar(t_game const * game) -{ - ASSERT(game,0); - return game->currchar; -} - -extern char const * d2cs_game_get_name(t_game const * game) -{ - ASSERT(game,NULL); - return game->name; -} - -extern char const * game_get_desc(t_game const * game) -{ - ASSERT(game,NULL); - return game->desc; -} - -extern char const * d2cs_game_get_pass(t_game const * game) -{ - ASSERT(game,NULL); - return game->pass; -} - -extern unsigned int game_get_gameflag(t_game const * game) -{ - ASSERT(game,0); - return game->gameflag; -} - -extern int d2cs_game_get_create_time(t_game const * game) -{ - ASSERT(game,-1); - return game->create_time; -} - -extern int game_set_create_time(t_game * game, int create_time) -{ - ASSERT(game,-1); - game->create_time=create_time; - return 0; -} - -extern t_list * game_get_charlist(t_game const * game) -{ - ASSERT(game,NULL); - return game->charlist; -} - -extern unsigned int gamelist_get_totalgame(void) -{ - return total_game; -} diff --git a/d2pack109/src/d2cs/game.h b/d2pack109/src/d2cs/game.h deleted file mode 100644 index 0cbd703..0000000 --- a/d2pack109/src/d2cs/game.h +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (C) 2000,2001 Onlyer (onlyer@263.net) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_GAME_H -#define INCLUDED_GAME_H - -#include "d2gs.h" -#include "connection.h" - -typedef struct -{ - unsigned char class; - unsigned char level; - char const * charname; -} t_game_charinfo; - -typedef struct -{ - unsigned int id; - char const * name; - char const * pass; - char const * desc; - int create_time; - int lastaccess_time; - unsigned int created; - unsigned int gameflag; - unsigned int charlevel; - unsigned int leveldiff; - unsigned int d2gs_gameid; - unsigned int maxchar; - unsigned int currchar; - t_list * charlist; - t_d2gs * d2gs; -} t_game; - -#define gameflag_get_difficulty(gameflag) ( (gameflag >> 0x0C) & 0x07 ) -#define gameflag_get_expansion(gameflag) tf( gameflag & 0x100000 ) -#define gameflag_get_hardcore(gameflag) tf( gameflag & 0x800 ) - -#define gameflag_set_difficulty(gameflag,n) ( gameflag |= ((n & 0x07) << 0x0C) ) -#define gameflag_set_expansion(gameflag,n) ( gameflag |= (n ? 0x100000 : 0)) -#define gameflag_set_hardcore(gameflag,n) ( gameflag |= (n ? 0x800 : 0)) - -#define gameflag_create(e,h,d) (0x04|(e?0x100000:0) | (h?0x800:0) | ((d & 0x07) << 0x0c)) - - -extern t_list * d2cs_gamelist(void); -extern int d2cs_gamelist_destroy(void); -extern int d2cs_gamelist_create(void); -extern t_game * d2cs_gamelist_find_game(char const * gamename); -extern t_game * gamelist_find_game_by_id(unsigned int id); -extern t_game * gamelist_find_game_by_d2gs_and_id(unsigned int d2gs_id, unsigned int d2gs_gameid); -extern void d2cs_gamelist_check_voidgame(void); -extern t_game * d2cs_game_create(char const * gamename, char const * gamepass, char const * gamedesc, - unsigned int gameflag); -extern int game_destroy(t_game * game, t_elem ** elem); -extern int game_add_character(t_game * game, char const * charname, - unsigned char class, unsigned char level); -extern int game_del_character(t_game * game, char const * charname); - -extern t_d2gs * game_get_d2gs(t_game const * game); -extern int game_set_d2gs(t_game * game, t_d2gs * gs); -extern int game_set_d2gs_gameid(t_game * game, unsigned int gameid); -extern unsigned int game_get_d2gs_gameid(t_game const * game); -extern int game_set_id(t_game * game, unsigned int id); -extern unsigned int d2cs_game_get_id(t_game const * game); -extern int game_set_created(t_game * game, unsigned int created); -extern unsigned int game_get_created(t_game const * game); -extern int game_set_leveldiff(t_game * game, unsigned int leveldiff); -extern int game_set_charlevel(t_game * game, unsigned int charlevel); -extern unsigned int game_get_charlevel(t_game const * game); -extern unsigned int game_get_leveldiff(t_game const * game); -extern unsigned int game_get_maxlevel(t_game const * game); -extern unsigned int game_get_minlevel(t_game const * game); -extern int game_set_gameflag_expansion(t_game * game, unsigned int hardcore); -extern int game_set_gameflag_hardcore(t_game * game, unsigned int hardcore); -extern int game_set_gameflag_difficulty(t_game * game, unsigned int hardcore); -extern unsigned int game_get_gameflag_expansion(t_game const * game); -extern unsigned int game_get_gameflag_hardcore(t_game const * game); -extern unsigned int game_get_gameflag_difficulty(t_game const * game); -extern int game_set_maxchar(t_game * game, unsigned int maxchar); -extern unsigned int game_get_maxchar(t_game const * game); -extern unsigned int game_get_currchar(t_game const * game); -extern char const * d2cs_game_get_name(t_game const * game); -extern char const * d2cs_game_get_pass(t_game const * game); -extern char const * game_get_desc(t_game const * game); -extern unsigned int game_get_gameflag(t_game const * game); -extern int d2cs_game_get_create_time(t_game const * game); -extern int game_set_create_time(t_game * game,int create_time); -extern t_list * game_get_charlist(t_game const * game); -extern t_game * gamelist_find_character(char const * charname); -extern unsigned int gamelist_get_totalgame(void); -extern t_elem const * gamelist_get_curr_elem(void); -extern void gamelist_set_curr_elem(t_elem const * elem); - -#endif diff --git a/d2pack109/src/d2cs/gamequeue.c b/d2pack109/src/d2cs/gamequeue.c deleted file mode 100644 index dec7ed7..0000000 --- a/d2pack109/src/d2cs/gamequeue.c +++ /dev/null @@ -1,196 +0,0 @@ -/* - * Copyright (C) 2000,2001 Onlyer (onlyer@263.net) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#include "common/setup_before.h" -#include "setup.h" - -#ifdef STDC_HEADERS -# include -#else -# ifdef HAVE_MALLOC_H -# include -# endif -#endif -#ifdef HAVE_STRING_H -# include -#else -# ifdef HAVE_STRINGS_H -# include -# endif -# ifdef HAVE_MEMORY_H -# include -# endif -#endif -#include "compat/strcasecmp.h" - -#include "connection.h" -#include "gamequeue.h" -#include "handle_d2cs.h" -#include "common/packet.h" -#include "common/list.h" -#include "common/eventlog.h" -#include "common/xalloc.h" -#include "common/setup_after.h" - -static t_list * gqlist_head=NULL; -static unsigned int gqlist_seqno=0; - -extern t_list * gqlist(void) -{ - return gqlist_head; -} - -extern int gqlist_create(void) -{ - gqlist_head=list_create(); - return 0; -} - -extern int gqlist_destroy(void) -{ - t_gq * gq; - - BEGIN_LIST_TRAVERSE_DATA(gqlist_head,gq) - { - gq_destroy(gq,(t_elem **)curr_elem_); - } - END_LIST_TRAVERSE_DATA() - - if (list_destroy(gqlist_head)<0) { - eventlog(eventlog_level_error,__FUNCTION__,"error destroy game queue list"); - return -1; - } - gqlist_head=NULL; - return 0; -} - -extern t_gq * gq_create(unsigned int clientid, t_packet * packet, char const * gamename) -{ - t_gq * gq; - - gq=xmalloc(sizeof(t_gq)); - gq->seqno=++gqlist_seqno; - gq->clientid=clientid; - gq->packet=packet; - strncpy(gq->gamename, gamename, MAX_GAMENAME_LEN); - if (packet) packet_add_ref(packet); - list_append_data(gqlist_head,gq); - return gq; -} - -extern int gq_destroy(t_gq * gq, t_elem ** elem) -{ - ASSERT(gq,-1); - if (list_remove_data(gqlist_head,gq,elem)<0) { - eventlog(eventlog_level_error,__FUNCTION__,"error remove game queue from list"); - return -1; - } - if (gq->packet) packet_del_ref(gq->packet); - xfree(gq); - return 0; -} - -extern unsigned int gq_get_clientid(t_gq const * gq) -{ - ASSERT(gq,0); - return gq->clientid; -} - -extern int gqlist_check_creategame(void) -{ - t_connection * c; - t_gq * gq; - - BEGIN_LIST_TRAVERSE_DATA(gqlist_head,gq) - { - c=d2cs_connlist_find_connection_by_sessionnum(gq->clientid); - if (!c) { - eventlog(eventlog_level_error,__FUNCTION__,"client %d not found (gamename: %s)",gq->clientid,gq->gamename); - gq_destroy(gq,&curr_elem_); - continue; - } else if (!conn_get_gamequeue(c)) { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL game queue for client %s",d2cs_conn_get_account(c)); - gq_destroy(gq,&curr_elem_); - continue; - } else { - eventlog(eventlog_level_info,__FUNCTION__,"try create game %s for account %s",gq->gamename,d2cs_conn_get_account(c)); - d2cs_handle_client_creategame(c,gq->packet); - conn_set_gamequeue(c,NULL); - gq_destroy(gq,&curr_elem_); - break; - } - } - END_LIST_TRAVERSE_DATA() - return 0; -} - -extern int gqlist_update_all_clients(void) -{ - t_connection * c; - t_gq * gq; - unsigned int n; - - n=0; - BEGIN_LIST_TRAVERSE_DATA(gqlist_head,gq) - { - c=d2cs_connlist_find_connection_by_sessionnum(gq->clientid); - if (!c) { - eventlog(eventlog_level_error,__FUNCTION__,"client %d not found (gamename: %s)",gq->clientid,gq->gamename); - gq_destroy(gq,&curr_elem_); - continue; - } else { - n++; - eventlog(eventlog_level_debug,__FUNCTION__,"update client %s position to %d",d2cs_conn_get_account(c),n); - d2cs_send_client_creategamewait(c,n); - } - } - END_LIST_TRAVERSE_DATA() - if (n) eventlog(eventlog_level_info,__FUNCTION__,"total %d game queues",n); - return 0; -} - -extern unsigned int gqlist_get_gq_position(t_gq * gq) -{ - t_gq * tmp; - unsigned int pos; - - pos=0; - BEGIN_LIST_TRAVERSE_DATA(gqlist_head,tmp) - { - pos++; - if (tmp==gq) return pos; - } - END_LIST_TRAVERSE_DATA() - return 0; -} - -extern unsigned int gqlist_get_length(void) -{ - return list_get_length(gqlist_head); -} - -extern t_gq * gqlist_find_game(char const * gamename) -{ - t_gq * gq; - - BEGIN_LIST_TRAVERSE_DATA(gqlist_head,gq) - { - if (!strcasecmp(gq->gamename,gamename)) return gq; - } - END_LIST_TRAVERSE_DATA() - return NULL; -} diff --git a/d2pack109/src/d2cs/gamequeue.h b/d2pack109/src/d2cs/gamequeue.h deleted file mode 100644 index 95166f6..0000000 --- a/d2pack109/src/d2cs/gamequeue.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2000,2001 Onlyer (onlyer@263.net) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_GAMEQUEUE_H -#define INCLUDED_GAMEQUEUE_H - -#include "common/packet.h" -#include "common/list.h" - -typedef struct -{ - unsigned int seqno; - unsigned int clientid; - t_packet * packet; - char gamename[MAX_GAMENAME_LEN]; -} t_gq; - -extern unsigned int gq_get_clientid(t_gq const * gq); -extern int gq_destroy(t_gq * gq, t_elem ** elem); -extern t_gq * gq_create(unsigned int clientid, t_packet * packet, char const * gamename); -extern int gqlist_destroy(void); -extern int gqlist_create(void); -extern t_list * gqlist(void); -extern unsigned int gqlist_get_gq_position(t_gq * gq); -extern int gqlist_update_all_clients(void); -extern int gqlist_check_creategame(void); -extern t_gq * gqlist_find_game(char const * gamename); -extern unsigned int gqlist_get_length(void); - -#endif diff --git a/d2pack109/src/d2cs/handle_bnetd.c b/d2pack109/src/d2cs/handle_bnetd.c deleted file mode 100644 index 87edc1c..0000000 --- a/d2pack109/src/d2cs/handle_bnetd.c +++ /dev/null @@ -1,296 +0,0 @@ -/* - * Copyright (C) 2000,2001 Onlyer (onlyer@263.net) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#include "common/setup_before.h" -#include "setup.h" - -#ifdef STDC_HEADERS -# include -#else -# ifdef HAVE_MALLOC_H -# include -# endif -#endif - -#include "connection.h" -#include "handle_bnetd.h" -#include "serverqueue.h" -#include "d2cs_bnetd_protocol.h" -#include "d2cs_protocol.h" -#include "version.h" -#include "prefs.h" -#include "game.h" -#include "common/init_protocol.h" -#include "common/packet.h" -#include "common/eventlog.h" -#include "common/setup_after.h" - -DECLARE_PACKET_HANDLER(on_bnetd_accountloginreply) -DECLARE_PACKET_HANDLER(on_bnetd_charloginreply) -DECLARE_PACKET_HANDLER(on_bnetd_authreq) -DECLARE_PACKET_HANDLER(on_bnetd_authreply) -DECLARE_PACKET_HANDLER(on_bnetd_gameinforeq) - -static t_packet_handle_table bnetd_packet_handle_table[]={ -/* 0x00 */ { 0, conn_state_none, NULL }, -/* 0x01 */ { sizeof(t_bnetd_d2cs_authreq), conn_state_connected, on_bnetd_authreq }, -/* 0x02 */ { sizeof(t_bnetd_d2cs_authreply), conn_state_connected, on_bnetd_authreply }, -/* 0x03 */ { 0, conn_state_none, NULL }, -/* 0x04 */ { 0, conn_state_none, NULL }, -/* 0x05 */ { 0, conn_state_none, NULL }, -/* 0x06 */ { 0, conn_state_none, NULL }, -/* 0x07 */ { 0, conn_state_none, NULL }, -/* 0x08 */ { 0, conn_state_none, NULL }, -/* 0x09 */ { 0, conn_state_none, NULL }, -/* 0x0a */ { 0, conn_state_none, NULL }, -/* 0x0b */ { 0, conn_state_none, NULL }, -/* 0x0c */ { 0, conn_state_none, NULL }, -/* 0x0d */ { 0, conn_state_none, NULL }, -/* 0x03 */ { 0, conn_state_none, NULL }, -/* 0x0f */ { 0, conn_state_none, NULL }, -/* 0x10 */ { sizeof(t_bnetd_d2cs_accountloginreply), conn_state_authed, on_bnetd_accountloginreply }, -/* 0x11 */ { sizeof(t_bnetd_d2cs_charloginreply), conn_state_authed, on_bnetd_charloginreply }, -/* 0x12 */ { sizeof(t_bnetd_d2cs_gameinforeq), conn_state_authed, on_bnetd_gameinforeq } -}; - -extern int handle_bnetd_packet(t_connection * c, t_packet * packet) -{ - conn_process_packet(c,packet,bnetd_packet_handle_table,NELEMS(bnetd_packet_handle_table)); - return 0; -} - -extern int handle_bnetd_init(t_connection * c) -{ - t_packet * packet; - - packet=packet_create(packet_class_init); - packet_set_size(packet,sizeof(t_client_initconn)); - bn_byte_set(&packet->u.client_initconn.class, CLIENT_INITCONN_CLASS_D2CS_BNETD); - conn_push_outqueue(c,packet); - packet_del_ref(packet); - d2cs_conn_set_state(c,conn_state_connected); - eventlog(eventlog_level_info,__FUNCTION__,"sent init class packet to bnetd"); - return 0; -} - -static int on_bnetd_authreq(t_connection * c, t_packet * packet) -{ - t_packet * rpacket; - unsigned int sessionnum; - - sessionnum=bn_int_get(packet->u.bnetd_d2cs_authreq.sessionnum); - eventlog(eventlog_level_info,__FUNCTION__,"received bnetd sessionnum %d",sessionnum); - if ((rpacket=packet_create(packet_class_d2cs_bnetd))) { - packet_set_size(rpacket,sizeof(t_d2cs_bnetd_authreply)); - packet_set_type(rpacket,D2CS_BNETD_AUTHREPLY); - bn_int_set(&rpacket->u.d2cs_bnetd_authreply.h.seqno,1); - bn_int_set(&rpacket->u.d2cs_bnetd_authreply.version,D2CS_VERSION_NUMBER); - packet_append_string(rpacket,prefs_get_realmname()); - conn_push_outqueue(c,rpacket); - packet_del_ref(rpacket); - } - return 0; -} - -static int on_bnetd_authreply(t_connection * c, t_packet * packet) -{ - unsigned int reply; - - reply=bn_int_get(packet->u.bnetd_d2cs_authreply.reply); - if (reply == BNETD_D2CS_AUTHREPLY_SUCCEED) { - eventlog(eventlog_level_info,__FUNCTION__,"authed by bnetd"); - d2cs_conn_set_state(c,conn_state_authed); - } else { - eventlog(eventlog_level_error,__FUNCTION__,"failed to auth by bnetd (error=%d)",reply); - d2cs_conn_set_state(c,conn_state_destroy); - } - return 0; -} - -static int on_bnetd_accountloginreply(t_connection * c, t_packet * packet) -{ - unsigned int seqno; - t_sq * sq; - t_packet * opacket, * rpacket; - t_connection * client; - int result, reply; - char const * account; - t_elem * elem; - - if (!packet || !c) - return -1; - - seqno=bn_int_get(packet->u.d2cs_bnetd.h.seqno); - if (!(sq=sqlist_find_sq(seqno))) { - eventlog(eventlog_level_error,__FUNCTION__,"seqno %d not found",seqno); - return -1; - } - if (!(client=d2cs_connlist_find_connection_by_sessionnum(sq_get_clientid(sq)))) { - eventlog(eventlog_level_error,__FUNCTION__,"client %d not found",sq_get_clientid(sq)); - sq_destroy(sq,&elem); - return -1; - } - if (!(opacket=sq_get_packet(sq))) { - eventlog(eventlog_level_error,__FUNCTION__,"previous packet missing (seqno: %d)",seqno); - sq_destroy(sq,&elem); - return -1; - } - result=bn_int_get(packet->u.bnetd_d2cs_accountloginreply.reply); - if (result==BNETD_D2CS_CHARLOGINREPLY_SUCCEED) { - reply=D2CS_CLIENT_LOGINREPLY_SUCCEED; - account=packet_get_str_const(opacket,sizeof(t_client_d2cs_loginreq),MAX_CHARNAME_LEN); - d2cs_conn_set_account(client,account); - d2cs_conn_set_state(client,conn_state_authed); - eventlog(eventlog_level_info,__FUNCTION__,"account %s authed",account); - } else { - eventlog(eventlog_level_warn,__FUNCTION__,"client %d login request was rejected by bnetd",sq_get_clientid(sq)); - reply=D2CS_CLIENT_LOGINREPLY_BADPASS; - } - if ((rpacket=packet_create(packet_class_d2cs))) { - packet_set_size(rpacket,sizeof(t_d2cs_client_loginreply)); - packet_set_type(rpacket,D2CS_CLIENT_LOGINREPLY); - bn_int_set(&rpacket->u.d2cs_client_loginreply.reply,reply); - conn_push_outqueue(client,rpacket); - packet_del_ref(rpacket); - } - sq_destroy(sq,&elem); - return 0; -} - -static int on_bnetd_charloginreply(t_connection * c, t_packet * packet) -{ - unsigned int seqno; - t_sq * sq; - t_connection * client; - t_packet * opacket, * rpacket; - int result, reply, type; - char const * charname; - t_elem * elem; - - if (!packet || !c) - return -1; - - seqno=bn_int_get(packet->u.d2cs_bnetd.h.seqno); - if (!(sq=sqlist_find_sq(seqno))) { - eventlog(eventlog_level_error,__FUNCTION__,"seqno %d not found",seqno); - return -1; - } - if (!(client=d2cs_connlist_find_connection_by_sessionnum(sq_get_clientid(sq)))) { - eventlog(eventlog_level_error,__FUNCTION__,"client %d not found",sq_get_clientid(sq)); - sq_destroy(sq,&elem); - return -1; - } - if (!(opacket=sq_get_packet(sq))) { - eventlog(eventlog_level_error,__FUNCTION__,"previous packet missing (seqno: %d)",seqno); - sq_destroy(sq,&elem); - return -1; - } - type=packet_get_type(opacket); - result=bn_int_get(packet->u.bnetd_d2cs_charloginreply.reply); - if (type==CLIENT_D2CS_CREATECHARREQ) { - charname=packet_get_str_const(opacket,sizeof(t_client_d2cs_createcharreq),MAX_CHARNAME_LEN); - if (result==BNETD_D2CS_CHARLOGINREPLY_SUCCEED) { - if (conn_check_multilogin(client,charname)<0) { - eventlog(eventlog_level_error,__FUNCTION__,"character %s is already logged in",charname); - reply = D2CS_CLIENT_CHARLOGINREPLY_FAILED; - } else { - reply= D2CS_CLIENT_CREATECHARREPLY_SUCCEED; - eventlog(eventlog_level_info,__FUNCTION__,"character %s authed",charname); - d2cs_conn_set_charname(client,charname); - d2cs_conn_set_state(client,conn_state_char_authed); - } - } else { - reply = D2CS_CLIENT_CREATECHARREPLY_FAILED; - eventlog(eventlog_level_error,__FUNCTION__,"failed to auth character %s",charname); - } - if ((rpacket=packet_create(packet_class_d2cs))) { - packet_set_size(rpacket,sizeof(t_d2cs_client_createcharreply)); - packet_set_type(rpacket,D2CS_CLIENT_CREATECHARREPLY); - bn_int_set(&rpacket->u.d2cs_client_createcharreply.reply,reply); - conn_push_outqueue(client,rpacket); - packet_del_ref(rpacket); - } - } else if (type==CLIENT_D2CS_CHARLOGINREQ) { - charname=packet_get_str_const(opacket,sizeof(t_client_d2cs_charloginreq),MAX_CHARNAME_LEN); - if (result==BNETD_D2CS_CHARLOGINREPLY_SUCCEED) { - if (conn_check_multilogin(client,charname)<0) { - eventlog(eventlog_level_error,__FUNCTION__,"character %s is already logged in",charname); - reply = D2CS_CLIENT_CHARLOGINREPLY_FAILED; - } else { - reply = D2CS_CLIENT_CHARLOGINREPLY_SUCCEED; - eventlog(eventlog_level_info,__FUNCTION__,"character %s authed",charname); - d2cs_conn_set_charname(client,charname); - d2cs_conn_set_state(client,conn_state_char_authed); - } - } else { - reply = D2CS_CLIENT_CHARLOGINREPLY_FAILED; - eventlog(eventlog_level_error,__FUNCTION__,"failed to auth character %s",charname); - } - if ((rpacket=packet_create(packet_class_d2cs))) { - packet_set_size(rpacket,sizeof(t_d2cs_client_charloginreply)); - packet_set_type(rpacket,D2CS_CLIENT_CHARLOGINREPLY); - bn_int_set(&rpacket->u.d2cs_client_charloginreply.reply,reply); - conn_push_outqueue(client,rpacket); - packet_del_ref(rpacket); - } - } else { - eventlog(eventlog_level_error,__FUNCTION__,"got bad packet type %d",type); - sq_destroy(sq,&elem); - return -1; - } - sq_destroy(sq,&elem); - return 0; -} - -int on_bnetd_gameinforeq(t_connection * c, t_packet * packet) -{ - t_packet * rpacket; - t_game * game; - - char const * gamename; - - if (!(c)) { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL connection"); - return -1; - } - - if (!(gamename = packet_get_str_const(packet,sizeof(t_bnetd_d2cs_gameinforeq),GAME_NAME_LEN))) - { - eventlog(eventlog_level_error,__FUNCTION__,"missing or too long gamename"); - return -1; - } - - if (!(game = d2cs_gamelist_find_game(gamename))) - { - eventlog(eventlog_level_error,__FUNCTION__,"request for unknown game \"%s\"",gamename); - return -1; - } - - if ((rpacket=packet_create(packet_class_d2cs_bnetd))) { - packet_set_size(rpacket, sizeof(t_d2cs_bnetd_gameinforeply)); - packet_set_type(rpacket, D2CS_BNETD_GAMEINFOREPLY); - bn_int_set(&rpacket->u.d2cs_bnetd_gameinforeply.h.seqno,0); - packet_append_string(rpacket, gamename); - - bn_byte_set(&rpacket->u.d2cs_bnetd_gameinforeply.difficulty, game_get_gameflag_difficulty(game)); - - conn_push_outqueue(c,rpacket); - packet_del_ref(rpacket); - } - return 0; -} - diff --git a/d2pack109/src/d2cs/handle_bnetd.h b/d2pack109/src/d2cs/handle_bnetd.h deleted file mode 100644 index 75a9f5b..0000000 --- a/d2pack109/src/d2cs/handle_bnetd.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) 2000,2001 Onlyer (onlyer@263.net) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_HANDLE_BNETD_H -#define INCLUDED_HANDLE_BNETD_H - -#include "connection.h" -#include "common/packet.h" - -extern int handle_bnetd_packet(t_connection * c, t_packet * packet); -extern int handle_bnetd_init(t_connection * c); - -#endif diff --git a/d2pack109/src/d2cs/handle_d2cs.c b/d2pack109/src/d2cs/handle_d2cs.c deleted file mode 100644 index df726d6..0000000 --- a/d2pack109/src/d2cs/handle_d2cs.c +++ /dev/null @@ -1,984 +0,0 @@ -/* - * Copyright (C) 2000,2001 Onlyer (onlyer@263.net) - * Copyright (C) 2004 Olaf Freyer (aaron@cs.tu-berlin.de) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#include "common/setup_before.h" -#include "setup.h" - -#include -#ifdef HAVE_STRING_H -# include -#else -# ifdef HAVE_STRINGS_H -# include -# endif -# ifdef HAVE_MEMORY_H -# include -# endif -#endif -#ifdef STDC_HEADERS -# include -#else -# ifdef HAVE_MALLOC_H -# include -# endif -#endif -#include "compat/memcpy.h" -#ifdef TIME_WITH_SYS_TIME -# include -# include -#else -# ifdef HAVE_SYS_TIME_H -# include -# else -# include -# endif -#endif -#ifdef HAVE_UNISTD_H -# include -#endif -#ifdef HAVE_SYS_STAT_H -# include -#endif - -#include "compat/pdir.h" -#include "compat/mkdir.h" -#include "d2charfile.h" -#include "connection.h" -#include "game.h" -#include "bnetd.h" -#include "d2cs_protocol.h" -#include "d2cs_bnetd_protocol.h" -#include "handle_d2cs.h" -#include "d2ladder.h" -#include "gamequeue.h" -#include "serverqueue.h" -#include "prefs.h" -#include "common/bn_type.h" -#include "common/queue.h" -#include "common/packet.h" -#include "common/eventlog.h" -#include "d2charlist.h" -#include "common/elist.h" -#include "common/xalloc.h" -#include "common/setup_after.h" - - -static int d2cs_send_client_ladder(t_connection * c, unsigned char type, unsigned short from); -static unsigned int d2cs_try_joingame(t_connection const * c, t_game const * game, char const * gamepass); - -DECLARE_PACKET_HANDLER(on_client_loginreq) -DECLARE_PACKET_HANDLER(on_client_createcharreq) -DECLARE_PACKET_HANDLER(on_client_creategamereq) -DECLARE_PACKET_HANDLER(on_client_joingamereq) -DECLARE_PACKET_HANDLER(on_client_gamelistreq) -DECLARE_PACKET_HANDLER(on_client_gameinforeq) -DECLARE_PACKET_HANDLER(on_client_charloginreq) -DECLARE_PACKET_HANDLER(on_client_deletecharreq) -DECLARE_PACKET_HANDLER(on_client_ladderreq) -DECLARE_PACKET_HANDLER(on_client_motdreq) -DECLARE_PACKET_HANDLER(on_client_cancelcreategame) -DECLARE_PACKET_HANDLER(on_client_charladderreq) -DECLARE_PACKET_HANDLER(on_client_charlistreq) -DECLARE_PACKET_HANDLER(on_client_convertcharreq) - - -static t_packet_handle_table d2cs_packet_handle_table[]={ -/* 0x00 */ { 0, conn_state_none, NULL }, -/* 0x01 */ { sizeof(t_client_d2cs_loginreq), conn_state_connected, on_client_loginreq }, -/* 0x02 */ { sizeof(t_client_d2cs_createcharreq), conn_state_authed|conn_state_char_authed, on_client_createcharreq }, -/* 0x03 */ { sizeof(t_client_d2cs_creategamereq), conn_state_char_authed, on_client_creategamereq }, -/* 0x04 */ { sizeof(t_client_d2cs_joingamereq), conn_state_char_authed, on_client_joingamereq }, -/* 0x05 */ { sizeof(t_client_d2cs_gamelistreq), conn_state_char_authed, on_client_gamelistreq }, -/* 0x06 */ { sizeof(t_client_d2cs_gameinforeq), conn_state_char_authed, on_client_gameinforeq }, -/* 0x07 */ { sizeof(t_client_d2cs_charloginreq), conn_state_authed|conn_state_char_authed, on_client_charloginreq }, -/* 0x08 */ { 0, conn_state_none, NULL }, -/* 0x09 */ { 0, conn_state_none, NULL }, -/* 0x0a */ { sizeof(t_client_d2cs_deletecharreq), conn_state_authed|conn_state_char_authed, on_client_deletecharreq }, -/* 0x0b */ { 0, conn_state_none, NULL }, -/* 0x0c */ { 0, conn_state_none, NULL }, -/* 0x0d */ { 0, conn_state_none, NULL }, -/* 0x0e */ { 0, conn_state_none, NULL }, -/* 0x0f */ { 0, conn_state_none, NULL }, -/* 0x10 */ { 0, conn_state_none, NULL }, -/* 0x11 */ { sizeof(t_client_d2cs_ladderreq), conn_state_char_authed, on_client_ladderreq }, -/* 0x12 */ { sizeof(t_client_d2cs_motdreq), conn_state_char_authed, on_client_motdreq }, -/* 0x13 */ { sizeof(t_client_d2cs_cancelcreategame),conn_state_char_authed, on_client_cancelcreategame}, -/* 0x14 */ { 0, conn_state_none, NULL }, -/* 0x15 */ { 0, conn_state_none, NULL }, -/* 0x16 */ { sizeof(t_client_d2cs_charladderreq), conn_state_char_authed, on_client_charladderreq }, -/* 0x17 */ { sizeof(t_client_d2cs_charlistreq), conn_state_authed|conn_state_char_authed, on_client_charlistreq }, -/* 0x18 */ { sizeof(t_client_d2cs_convertcharreq), conn_state_authed|conn_state_char_authed, on_client_convertcharreq } -}; - - -extern int d2cs_handle_d2cs_packet(t_connection * c, t_packet * packet) -{ - return conn_process_packet(c,packet,d2cs_packet_handle_table,NELEMS(d2cs_packet_handle_table)); -} - -static int on_client_loginreq(t_connection * c, t_packet * packet) -{ - t_packet * bnpacket; - char const * account; - t_sq * sq; - unsigned int sessionnum; - - if (!(account=packet_get_str_const(packet,sizeof(t_client_d2cs_loginreq),MAX_CHARNAME_LEN))) { - eventlog(eventlog_level_error,__FUNCTION__,"got bad account name"); - return -1; - } - if (d2char_check_acctname(account)<0) { - eventlog(eventlog_level_error,__FUNCTION__,"got bad account name"); - return -1; - } - if (!bnetd_conn()) { - eventlog(eventlog_level_warn,__FUNCTION__,"d2cs is offline with bnetd, login request will be rejected"); - return -1; - } - sessionnum=bn_int_get(packet->u.client_d2cs_loginreq.sessionnum); - conn_set_bnetd_sessionnum(c,sessionnum); - eventlog(eventlog_level_info,__FUNCTION__,"got client (*%s) login request sessionnum=0x%X",account,sessionnum); - if ((bnpacket=packet_create(packet_class_d2cs_bnetd))) { - if ((sq=sq_create(d2cs_conn_get_sessionnum(c),packet,0))) { - packet_set_size(bnpacket,sizeof(t_d2cs_bnetd_accountloginreq)); - packet_set_type(bnpacket,D2CS_BNETD_ACCOUNTLOGINREQ); - bn_int_set(&bnpacket->u.d2cs_bnetd_accountloginreq.h.seqno,sq_get_seqno(sq)); - bn_int_set(&bnpacket->u.d2cs_bnetd_accountloginreq.seqno, - bn_int_get(packet->u.client_d2cs_loginreq.seqno)); - bn_int_set(&bnpacket->u.d2cs_bnetd_accountloginreq.sessionkey, - bn_int_get(packet->u.client_d2cs_loginreq.sessionkey)); - bn_int_set(&bnpacket->u.d2cs_bnetd_accountloginreq.sessionnum,sessionnum); - memcpy(bnpacket->u.d2cs_bnetd_accountloginreq.secret_hash, - packet->u.client_d2cs_loginreq.secret_hash, - sizeof(bnpacket->u.d2cs_bnetd_accountloginreq.secret_hash)); - packet_append_string(bnpacket,account); - conn_push_outqueue(bnetd_conn(),bnpacket); - } - packet_del_ref(bnpacket); - } - return 0; -} - -static int on_client_createcharreq(t_connection * c, t_packet * packet) -{ - t_packet * rpacket, * bnpacket; - char const * charname; - char const * account; - char * path; - t_pdir * dir; - t_sq * sq; - unsigned int reply; - unsigned short status, class; - t_d2charinfo_file data; - - if (!(charname=packet_get_str_const(packet,sizeof(t_client_d2cs_createcharreq),MAX_CHARNAME_LEN))) { - eventlog(eventlog_level_error,__FUNCTION__,"got bad character name"); - return -1; - } - if (!(account=d2cs_conn_get_account(c))) { - eventlog(eventlog_level_error,__FUNCTION__,"missing account for character %s",charname); - return -1; - } - class=bn_short_get(packet->u.client_d2cs_createcharreq.class); - status=bn_short_get(packet->u.client_d2cs_createcharreq.status); - - path=xmalloc(strlen(prefs_get_charinfo_dir())+1+strlen(account)+1); - d2char_get_infodir_name(path,account); - if (!(dir=p_opendir(path))) { - eventlog(eventlog_level_info,__FUNCTION__,"(*%s) charinfo directory do not exist, building it",account); - p_mkdir(path,S_IRWXU); - } else p_closedir(dir); - xfree(path); - - if (d2char_create(account,charname,class,status)<0) { - eventlog(eventlog_level_warn,__FUNCTION__,"error create character %s for account %s",charname,account); - reply=D2CS_CLIENT_CREATECHARREPLY_ALREADY_EXIST; - } else if (d2charinfo_load(account,charname,&data)<0) { - eventlog(eventlog_level_error,__FUNCTION__,"error loading charinfo for character %s(*%s)",charname,account); - reply=D2CS_CLIENT_CREATECHARREPLY_FAILED; - } else { - eventlog(eventlog_level_info,__FUNCTION__,"character %s(*%s) created",charname,account); - reply=D2CS_CLIENT_CREATECHARREPLY_SUCCEED; - conn_set_charinfo(c,&data.summary); - if ((bnpacket=packet_create(packet_class_d2cs_bnetd))) { - if ((sq=sq_create(d2cs_conn_get_sessionnum(c),packet,0))) { - packet_set_size(bnpacket,sizeof(t_d2cs_bnetd_charloginreq)); - packet_set_type(bnpacket,D2CS_BNETD_CHARLOGINREQ); - bn_int_set(&bnpacket->u.d2cs_bnetd_charloginreq.h.seqno,sq_get_seqno(sq)); - bn_int_set(&bnpacket->u.d2cs_bnetd_charloginreq.sessionnum, - conn_get_bnetd_sessionnum(c)); - packet_append_string(bnpacket,charname); - packet_append_string(bnpacket,(char const *)&data.portrait); - conn_push_outqueue(bnetd_conn(),bnpacket); - } - packet_del_ref(bnpacket); - } - return 0; - } - if ((rpacket=packet_create(packet_class_d2cs))) { - packet_set_size(rpacket,sizeof(t_d2cs_client_createcharreply)); - packet_set_type(rpacket,D2CS_CLIENT_CREATECHARREPLY); - bn_int_set(&rpacket->u.d2cs_client_createcharreply.reply,reply); - conn_push_outqueue(c,rpacket); - packet_del_ref(rpacket); - } - return 0; -} - -static int on_client_creategamereq(t_connection * c, t_packet * packet) -{ - char const * gamename; - char const * gamepass; - char const * gamedesc; - t_game * game; - t_d2gs * gs; - t_gq * gq; - unsigned int tempflag,gameflag; - unsigned int leveldiff, maxchar, difficulty, expansion, hardcore; - unsigned int seqno, reply; - unsigned int pos; - t_elem * elem; - - pos=sizeof(t_client_d2cs_creategamereq); - if (!(gamename=packet_get_str_const(packet,pos,MAX_GAMENAME_LEN))) { - eventlog(eventlog_level_error,__FUNCTION__,"got bad game name"); - return -1; - } - pos+=strlen(gamename)+1; - if (!(gamepass=packet_get_str_const(packet,pos,MAX_GAMEPASS_LEN))) { - eventlog(eventlog_level_error,__FUNCTION__,"got bad game pass"); - return -1; - } - pos+=strlen(gamepass)+1; - if (!(gamedesc=packet_get_str_const(packet,pos,MAX_GAMEDESC_LEN))) { - eventlog(eventlog_level_error,__FUNCTION__,"got bad game desc"); - return -1; - } - tempflag=bn_int_get(packet->u.client_d2cs_creategamereq.gameflag); - leveldiff=bn_byte_get(packet->u.client_d2cs_creategamereq.leveldiff); - maxchar=bn_byte_get(packet->u.client_d2cs_creategamereq.maxchar); - difficulty=gameflag_get_difficulty(tempflag); - if (difficulty > conn_get_charinfo_difficulty(c)) { - eventlog(eventlog_level_error,__FUNCTION__,"game difficulty exceed character limit %d %d",difficulty, - conn_get_charinfo_difficulty(c)); - return 0; - } - expansion=conn_get_charinfo_expansion(c); - hardcore=conn_get_charinfo_hardcore(c); - gameflag=gameflag_create(expansion,hardcore,difficulty); - - gs = NULL; - game = NULL; - gq=conn_get_gamequeue(c); - if (d2cs_gamelist_find_game(gamename)) { - eventlog(eventlog_level_info,__FUNCTION__,"game name %s is already exist in gamelist",gamename); - reply=D2CS_CLIENT_CREATEGAMEREPLY_NAME_EXIST; - } else if (!gq && gqlist_find_game(gamename)) { - eventlog(eventlog_level_info,__FUNCTION__,"game name %s is already exist in game queue",gamename); - reply=D2CS_CLIENT_CREATEGAMEREPLY_NAME_EXIST; - } else if (!(gs=d2gslist_choose_server())) { - if (gq) { - eventlog(eventlog_level_error,__FUNCTION__,"client %d is already in game queue",d2cs_conn_get_sessionnum(c)); - conn_set_gamequeue(c,NULL); - gq_destroy(gq,&elem); - return 0; - } else if ((gq=gq_create(d2cs_conn_get_sessionnum(c), packet, gamename))) { - conn_set_gamequeue(c,gq); - d2cs_send_client_creategamewait(c,gqlist_get_length()); - return 0; - } - reply=D2CS_CLIENT_CREATEGAMEREPLY_FAILED; - } else if (hardcore && conn_get_charinfo_dead(c)) { - reply=D2CS_CLIENT_CREATEGAMEREPLY_FAILED; - } else if (!(game=d2cs_game_create(gamename,gamepass,gamedesc,gameflag))) { - reply=D2CS_CLIENT_CREATEGAMEREPLY_NAME_EXIST; - } else { - reply=D2CS_CLIENT_CREATEGAMEREPLY_SUCCEED; - game_set_d2gs(game,gs); - d2gs_add_gamenum(gs, 1); - game_set_gameflag_expansion(game,expansion); - game_set_created(game,0); - game_set_leveldiff(game,leveldiff); - game_set_charlevel(game,conn_get_charinfo_level(c)); - game_set_maxchar(game,maxchar); - game_set_gameflag_difficulty(game,difficulty); - game_set_gameflag_hardcore(game,hardcore); - } - - seqno=bn_short_get(packet->u.client_d2cs_creategamereq.seqno); - if (reply!=D2CS_CLIENT_CREATEGAMEREPLY_SUCCEED) { - t_packet * rpacket; - - if ((rpacket=packet_create(packet_class_d2cs))) { - packet_set_size(rpacket,sizeof(t_d2cs_client_creategamereply)); - packet_set_type(rpacket,D2CS_CLIENT_CREATEGAMEREPLY); - bn_short_set(&rpacket->u.d2cs_client_creategamereply.seqno,seqno); - bn_short_set(&rpacket->u.d2cs_client_creategamereply.u1,0); - bn_short_set(&rpacket->u.d2cs_client_creategamereply.gameid,0); - bn_int_set(&rpacket->u.d2cs_client_creategamereply.reply,reply); - conn_push_outqueue(c,rpacket); - packet_del_ref(rpacket); - } - } else { - t_packet * gspacket; - t_sq * sq; - - if ((gspacket=packet_create(packet_class_d2gs))) { - if ((sq=sq_create(d2cs_conn_get_sessionnum(c),packet,d2cs_game_get_id(game)))) { - packet_set_size(gspacket,sizeof(t_d2cs_d2gs_creategamereq)); - packet_set_type(gspacket,D2CS_D2GS_CREATEGAMEREQ); - bn_int_set(&gspacket->u.d2cs_d2gs_creategamereq.h.seqno,sq_get_seqno(sq)); - bn_byte_set(&gspacket->u.d2cs_d2gs_creategamereq.difficulty,difficulty); - bn_byte_set(&gspacket->u.d2cs_d2gs_creategamereq.hardcore,hardcore); - bn_byte_set(&gspacket->u.d2cs_d2gs_creategamereq.expansion,expansion); - packet_append_string(gspacket,gamename); - conn_push_outqueue(d2gs_get_connection(gs),gspacket); - } - packet_del_ref(gspacket); - eventlog(eventlog_level_info,__FUNCTION__,"request create game %s on gs %d",gamename,d2gs_get_id(gs)); - } - } - return 0; -} - -static int on_client_joingamereq(t_connection * c, t_packet * packet) -{ - char const * gamename; - char const * gamepass; - char const * charname; - char const * account; - t_game * game; - t_d2gs * gs; - int reply; - unsigned int pos; - unsigned int seqno; - - gs = NULL; - pos=sizeof(t_client_d2cs_joingamereq); - if (!(gamename=packet_get_str_const(packet,pos,MAX_GAMENAME_LEN))) { - eventlog(eventlog_level_error,__FUNCTION__,"got bad game name"); - return -1; - } - pos+=strlen(gamename)+1; - if (!(gamepass=packet_get_str_const(packet,pos,MAX_GAMEPASS_LEN))) { - eventlog(eventlog_level_error,__FUNCTION__,"got bad game pass"); - return -1; - } - if (!(charname=d2cs_conn_get_charname(c))) { - eventlog(eventlog_level_error,__FUNCTION__,"missing character name for connection"); - return -1; - } - if (!(account=d2cs_conn_get_account(c))) { - eventlog(eventlog_level_error,__FUNCTION__,"missing account for connection"); - return -1; - } - if (conn_check_multilogin(c,charname)<0) { - eventlog(eventlog_level_error,__FUNCTION__,"character %s is already logged in",charname); - return -1; - } - if (!(game=d2cs_gamelist_find_game(gamename))) { - eventlog(eventlog_level_info,__FUNCTION__,"game %s not found",gamename); - reply=D2CS_CLIENT_JOINGAMEREPLY_NOT_EXIST; - } else if (!(gs=game_get_d2gs(game))) { - eventlog(eventlog_level_error,__FUNCTION__,"missing game server for game %s",gamename); - reply=D2CS_CLIENT_JOINGAMEREPLY_NOT_EXIST; - } else { - reply=d2cs_try_joingame(c,game,gamepass); - } - - seqno=bn_short_get(packet->u.client_d2cs_joingamereq.seqno); - if (reply!=D2CS_CLIENT_JOINGAMEREPLY_SUCCEED) { - t_packet * rpacket; - - if ((rpacket=packet_create(packet_class_d2cs))) { - packet_set_size(rpacket,sizeof(t_d2cs_client_joingamereply)); - packet_set_type(rpacket,D2CS_CLIENT_JOINGAMEREPLY); - bn_short_set(&rpacket->u.d2cs_client_joingamereply.seqno,seqno); - bn_short_set(&rpacket->u.d2cs_client_joingamereply.u1,0); - bn_short_set(&rpacket->u.d2cs_client_joingamereply.gameid,0); - bn_int_set(&rpacket->u.d2cs_client_joingamereply.addr,0); - bn_int_set(&rpacket->u.d2cs_client_joingamereply.token,0); - bn_int_set(&rpacket->u.d2cs_client_joingamereply.reply,reply); - conn_push_outqueue(c,rpacket); - packet_del_ref(rpacket); - } - } else { - t_packet * gspacket; - t_sq * sq; - - if ((gspacket=packet_create(packet_class_d2gs))) { - if ((sq=sq_create(d2cs_conn_get_sessionnum(c),packet,d2cs_game_get_id(game)))) { - packet_set_size(gspacket,sizeof(t_d2cs_d2gs_joingamereq)); - packet_set_type(gspacket,D2CS_D2GS_JOINGAMEREQ); - bn_int_set(&gspacket->u.d2cs_d2gs_joingamereq.h.seqno,sq_get_seqno(sq)); - bn_int_set(&gspacket->u.d2cs_d2gs_joingamereq.gameid, - game_get_d2gs_gameid(game)); - sq_set_gametoken(sq,d2gs_add_token(gs)); - bn_int_set(&gspacket->u.d2cs_d2gs_joingamereq.token,sq_get_gametoken(sq)); - packet_append_string(gspacket,charname); - packet_append_string(gspacket,account); - conn_push_outqueue(d2gs_get_connection(gs),gspacket); - } - packet_del_ref(gspacket); - eventlog(eventlog_level_info,__FUNCTION__,"request join game %s for character %s on gs %d",gamename, - charname,d2gs_get_id(gs)); - } - } - return 0; -} - -static int on_client_gamelistreq(t_connection * c, t_packet * packet) -{ - t_packet * rpacket; - t_game * game; - unsigned int count; - unsigned int seqno; - time_t now; - int maxlifetime; - t_elem const * start_elem; - t_elem const * elem; - - seqno=bn_short_get(packet->u.client_d2cs_gamelistreq.seqno); - /* if (seqno%2) return 0; */ - count=0; - now=time(NULL); - maxlifetime=prefs_get_game_maxlifetime(); - - elem=start_elem=gamelist_get_curr_elem(); - if (!elem) elem=list_get_first_const(d2cs_gamelist()); - else elem=elem_get_next_const(d2cs_gamelist(),elem); - - for (; elem != start_elem; elem=elem_get_next_const(d2cs_gamelist(),elem)) { - if (!elem) { - elem=list_get_first_const(d2cs_gamelist()); - if (elem == start_elem) break; - } - if (!(game=elem_get_data(elem))) { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL game"); - break; - } - if (maxlifetime && (now-game->create_time>maxlifetime)) continue; - if (!game_get_currchar(game)) continue; - if (!prefs_allow_gamelist_showall()) { - if (conn_get_charinfo_difficulty(c)!=game_get_gameflag_difficulty(game)) continue; - } - if (d2cs_try_joingame(c,game,"")!=D2CS_CLIENT_JOINGAMEREPLY_SUCCEED) continue; - if ((rpacket=packet_create(packet_class_d2cs))) { - packet_set_size(rpacket,sizeof(t_d2cs_client_gamelistreply)); - packet_set_type(rpacket,D2CS_CLIENT_GAMELISTREPLY); - bn_short_set(&rpacket->u.d2cs_client_gamelistreply.seqno,seqno); - bn_int_set(&rpacket->u.d2cs_client_gamelistreply.token,d2cs_game_get_id(game)); - bn_byte_set(&rpacket->u.d2cs_client_gamelistreply.currchar,game_get_currchar(game)); - bn_int_set(&rpacket->u.d2cs_client_gamelistreply.gameflag,game_get_gameflag(game)); - packet_append_string(rpacket,d2cs_game_get_name(game)); - packet_append_string(rpacket,game_get_desc(game)); - conn_push_outqueue(c,rpacket); - packet_del_ref(rpacket); - count++; - if (prefs_get_maxgamelist() && count>=prefs_get_maxgamelist()) break; - } - } - gamelist_set_curr_elem(elem); - if (count) { - if ((rpacket=packet_create(packet_class_d2cs))) { - packet_set_size(rpacket,sizeof(t_d2cs_client_gamelistreply)); - packet_set_type(rpacket,D2CS_CLIENT_GAMELISTREPLY); - bn_short_set(&rpacket->u.d2cs_client_gamelistreply.seqno,seqno); - bn_int_set(&rpacket->u.d2cs_client_gamelistreply.token,0); - bn_byte_set(&rpacket->u.d2cs_client_gamelistreply.currchar,0); - bn_int_set(&rpacket->u.d2cs_client_gamelistreply.gameflag,0); - packet_append_string(rpacket,""); - packet_append_string(rpacket,""); - packet_append_string(rpacket,""); - conn_push_outqueue(c,rpacket); - packet_del_ref(rpacket); - } - } - return 0; -} - -static int on_client_gameinforeq(t_connection * c, t_packet * packet) -{ - t_game_charinfo * info; - t_packet * rpacket; - char const * gamename; - t_game * game; - unsigned int seqno, n; - - if (!(gamename=packet_get_str_const(packet,sizeof(t_client_d2cs_gameinforeq),MAX_GAMENAME_LEN))) { - eventlog(eventlog_level_error,__FUNCTION__,"got bad game name"); - return -1; - } - if (!(game=d2cs_gamelist_find_game(gamename))) { - eventlog(eventlog_level_error,__FUNCTION__,"game %s not found",gamename); - return 0; - } - seqno=bn_short_get(packet->u.client_d2cs_gameinforeq.seqno); - if ((rpacket=packet_create(packet_class_d2cs))) { - packet_set_size(rpacket,sizeof(t_d2cs_client_gameinforeply)); - packet_set_type(rpacket,D2CS_CLIENT_GAMEINFOREPLY); - bn_short_set(&rpacket->u.d2cs_client_gameinforeply.seqno,seqno); - bn_int_set(&rpacket->u.d2cs_client_gameinforeply.gameflag,game_get_gameflag(game)); - bn_int_set(&rpacket->u.d2cs_client_gameinforeply.etime,time(NULL)-d2cs_game_get_create_time(game)); - bn_byte_set(&rpacket->u.d2cs_client_gameinforeply.charlevel,game_get_charlevel(game)); - bn_byte_set(&rpacket->u.d2cs_client_gameinforeply.leveldiff,game_get_leveldiff(game)); - bn_byte_set(&rpacket->u.d2cs_client_gameinforeply.maxchar,game_get_maxchar(game)); - bn_byte_set(&rpacket->u.d2cs_client_gameinforeply.u1,0); - - n=0; - BEGIN_LIST_TRAVERSE_DATA_CONST(game_get_charlist(game),info) - { - if (!info->charname) { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL charname in game %s char list",gamename); - continue; - } - packet_append_string(rpacket,info->charname); - bn_byte_set(&rpacket->u.d2cs_client_gameinforeply.class[n],info->class); - bn_byte_set(&rpacket->u.d2cs_client_gameinforeply.level[n],info->level); - n++; - } - END_LIST_TRAVERSE_DATA_CONST() - - bn_byte_set(&rpacket->u.d2cs_client_gameinforeply.currchar,n); - if (n!=game_get_currchar(game)) { - eventlog(eventlog_level_error,__FUNCTION__,"game %s character list corrupted",gamename); - } - conn_push_outqueue(c,rpacket); - packet_del_ref(rpacket); - } - return 0; -} - -static int on_client_charloginreq(t_connection * c, t_packet * packet) -{ - t_packet * bnpacket; - char const * charname; - char const * account; - t_sq * sq; - t_d2charinfo_file data; - - if (!(charname=packet_get_str_const(packet,sizeof(t_client_d2cs_charloginreq),MAX_CHARNAME_LEN))) { - eventlog(eventlog_level_error,__FUNCTION__,"got bad character name"); - return -1; - } - if (!(account=d2cs_conn_get_account(c))) { - eventlog(eventlog_level_error,__FUNCTION__,"missing account for connection"); - return -1; - } - if (d2charinfo_load(account,charname,&data)<0) { - eventlog(eventlog_level_error,__FUNCTION__,"error loading charinfo for character %s(*%s)",charname,account); - return -1; - } else if (!bnetd_conn()) { - eventlog(eventlog_level_error,__FUNCTION__,"no bnetd connection available,character login rejected"); - return -1; - } - conn_set_charinfo(c,&data.summary); - eventlog(eventlog_level_info,__FUNCTION__,"got character %s(*%s) login request",charname,account); - if ((bnpacket=packet_create(packet_class_d2cs_bnetd))) { - if ((sq=sq_create(d2cs_conn_get_sessionnum(c),packet,0))) { - packet_set_size(bnpacket,sizeof(t_d2cs_bnetd_charloginreq)); - packet_set_type(bnpacket,D2CS_BNETD_CHARLOGINREQ); - bn_int_set(&bnpacket->u.d2cs_bnetd_charloginreq.h.seqno,sq_get_seqno(sq)); - bn_int_set(&bnpacket->u.d2cs_bnetd_charloginreq.sessionnum, - conn_get_bnetd_sessionnum(c)); - packet_append_string(bnpacket,charname); - packet_append_string(bnpacket,(char const *)&data.portrait); - conn_push_outqueue(bnetd_conn(),bnpacket); - } - packet_del_ref(bnpacket); - } - return 0; -} - -static int on_client_deletecharreq(t_connection * c, t_packet * packet) -{ - t_packet * rpacket; - char const * charname; - char const * account; - unsigned int reply; - - if (!(charname=packet_get_str_const(packet,sizeof(t_client_d2cs_deletecharreq),MAX_CHARNAME_LEN))) { - eventlog(eventlog_level_error,__FUNCTION__,"got bad character name"); - return -1; - } - if (conn_check_multilogin(c,charname)<0) { - eventlog(eventlog_level_error,__FUNCTION__,"character %s is already logged in",charname); - return -1; - } - d2cs_conn_set_charname(c,NULL); - account=d2cs_conn_get_account(c); - if (d2char_delete(account,charname)<0) { - eventlog(eventlog_level_error,__FUNCTION__,"failed to delete character %s(*%s)",charname,account); - reply = D2CS_CLIENT_DELETECHARREPLY_FAILED; - } else { - reply = D2CS_CLIENT_DELETECHARREPLY_SUCCEED; - } - if ((rpacket=packet_create(packet_class_d2cs))) { - packet_set_size(rpacket,sizeof(t_d2cs_client_deletecharreply)); - packet_set_type(rpacket,D2CS_CLIENT_DELETECHARREPLY); - bn_short_set(&rpacket->u.d2cs_client_deletecharreply.u1,0); - bn_int_set(&rpacket->u.d2cs_client_deletecharreply.reply,reply); - conn_push_outqueue(c,rpacket); - packet_del_ref(rpacket); - } - return 0; -} - -static int on_client_ladderreq(t_connection * c, t_packet * packet) -{ - unsigned char type; - unsigned short start_pos; - - type=bn_byte_get(packet->u.client_d2cs_ladderreq.type); - start_pos=bn_short_get(packet->u.client_d2cs_ladderreq.start_pos); - d2cs_send_client_ladder(c,type,start_pos); - return 0; -} - -static int d2cs_send_client_ladder(t_connection * c, unsigned char type, unsigned short from) -{ - t_packet * rpacket; - t_d2cs_client_ladderinfo const * ladderinfo; - unsigned int curr_len, cont_len, total_len; - t_d2cs_client_ladderheader ladderheader; - t_d2cs_client_ladderinfoheader infoheader; - unsigned int start_pos, count, count_per_packet, npacket; - unsigned int i, n, curr_pos; - - start_pos=from; - count=prefs_get_ladderlist_count(); - if (d2ladder_get_ladder(&start_pos,&count,type,&ladderinfo)<0) { - eventlog(eventlog_level_error,__FUNCTION__,"error get ladder for type %d start_pos %d",type,from); - return 0; - } - - count_per_packet=14; - npacket=count/count_per_packet; - if (count % count_per_packet) npacket++; - - curr_len=0; - cont_len=0; - total_len = count * sizeof(*ladderinfo) + sizeof(ladderheader) + sizeof(infoheader) * npacket; - total_len -= 4; - bn_short_set(&ladderheader.start_pos,start_pos); - bn_short_set(&ladderheader.u1,0); - bn_int_set(&ladderheader.count1,count); - - for (i=0; i< npacket; i++) { - curr_len=0; - if ((rpacket=packet_create(packet_class_d2cs))) { - packet_set_size(rpacket,sizeof(t_d2cs_client_ladderreply)); - packet_set_type(rpacket,D2CS_CLIENT_LADDERREPLY); - bn_byte_set(&rpacket->u.d2cs_client_ladderreply.type, type); - bn_short_set(&rpacket->u.d2cs_client_ladderreply.total_len, total_len); - bn_short_set(&rpacket->u.d2cs_client_ladderreply.cont_len,cont_len); - if (i==0) { - bn_int_set(&infoheader.count2,count); - packet_append_data(rpacket,&ladderheader,sizeof(ladderheader)); - curr_len += sizeof(ladderheader); - } else { - bn_int_set(&infoheader.count2,0); - } - packet_append_data(rpacket,&infoheader,sizeof(infoheader)); - curr_len += sizeof(infoheader); - for (n=0; n< count_per_packet; n++) { - curr_pos = n + i * count_per_packet; - if (curr_pos >= count) break; - packet_append_data(rpacket, ladderinfo+curr_pos, sizeof(*ladderinfo)); - curr_len += sizeof(*ladderinfo); - } - if (i==0) { - packet_set_size(rpacket, packet_get_size(rpacket)-4); - curr_len -= 4; - } - bn_short_set(&rpacket->u.d2cs_client_ladderreply.curr_len,curr_len); - conn_push_outqueue(c,rpacket); - packet_del_ref(rpacket); - } - cont_len += curr_len; - } - return 0; -} - -static int on_client_motdreq(t_connection * c, t_packet * packet) -{ - t_packet * rpacket; - - if (!packet) - return -1; - - if ((rpacket=packet_create(packet_class_d2cs))) { - packet_set_size(rpacket,sizeof(t_d2cs_client_motdreply)); - packet_set_type(rpacket,D2CS_CLIENT_MOTDREPLY); - bn_byte_set(&rpacket->u.d2cs_client_motdreply.u1,0); - packet_append_string(rpacket,prefs_get_motd()); - conn_push_outqueue(c,rpacket); - packet_del_ref(rpacket); - } - return 0; -} - -static int on_client_cancelcreategame(t_connection * c, t_packet * packet) -{ - t_gq * gq; - t_elem * elem; - - if (!packet) - return -1; - - if (!(gq=conn_get_gamequeue(c))) { - return 0; - } - conn_set_gamequeue(c,NULL); - gq_destroy(gq,&elem); - return 0; -} - -static int on_client_charladderreq(t_connection * c, t_packet * packet) -{ - t_packet * rpacket; - char const * charname; - unsigned int expansion, hardcore, type; - int pos; - - if (!(charname=packet_get_str_const(packet,sizeof(t_client_d2cs_charladderreq),MAX_CHARNAME_LEN))) { - eventlog(eventlog_level_error,__FUNCTION__,"got bad character name"); - return -1; - } - expansion=bn_int_get(packet->u.client_d2cs_charladderreq.expansion); - hardcore=bn_int_get(packet->u.client_d2cs_charladderreq.hardcore); - type=0; /* avoid warning */ - if (hardcore && expansion) { - type=D2LADDER_EXP_HC_OVERALL; - } else if (!hardcore && expansion) { - type=D2LADDER_EXP_STD_OVERALL; - } else if (hardcore && !expansion) { - type=D2LADDER_HC_OVERALL; - } else if (!hardcore && !expansion) { - type=D2LADDER_STD_OVERALL; - } - if ((pos=d2ladder_find_character_pos(type,charname))<0) { - if ((rpacket=packet_create(packet_class_d2cs))) { - packet_set_size(rpacket,sizeof(t_d2cs_client_ladderreply)); - packet_set_type(rpacket,D2CS_CLIENT_LADDERREPLY); - bn_byte_set(&rpacket->u.d2cs_client_ladderreply.type, type); - bn_short_set(&rpacket->u.d2cs_client_ladderreply.total_len,0); - bn_short_set(&rpacket->u.d2cs_client_ladderreply.curr_len,0); - bn_short_set(&rpacket->u.d2cs_client_ladderreply.cont_len,0); - conn_push_outqueue(c,rpacket); - packet_del_ref(rpacket); - } - return 0; - } - pos -= prefs_get_ladderlist_count()/2; - if (pos < 0) pos=0; - d2cs_send_client_ladder(c,type,pos); - return 0; -} - -static int on_client_charlistreq(t_connection * c, t_packet * packet) -{ - t_packet * rpacket; - t_pdir * dir; - char const * account; - char const * charname; - char * path; - t_d2charinfo_file * charinfo; - unsigned int n, maxchar; - t_elist charlist_head; - char const * charlist_sort_order; - - if (!packet) - return -1; - - if (!(account=d2cs_conn_get_account(c))) { - eventlog(eventlog_level_error,__FUNCTION__,"missing account for connection"); - return -1; - } - path=xmalloc(strlen(prefs_get_charinfo_dir())+1+strlen(account)+1); - charlist_sort_order = prefs_get_charlist_sort_order(); - - elist_init(&charlist_head); - - d2char_get_infodir_name(path,account); - if (prefs_allow_newchar()) - maxchar=prefs_get_maxchar(); - else - maxchar=0; - - if ((rpacket=packet_create(packet_class_d2cs))) { - packet_set_size(rpacket,sizeof(t_d2cs_client_charlistreply)); - packet_set_type(rpacket,D2CS_CLIENT_CHARLISTREPLY); - bn_short_set(&rpacket->u.d2cs_client_charlistreply.u1,0); - n=0; - if (!(dir=p_opendir(path))) { - eventlog(eventlog_level_info,__FUNCTION__,"(*%s) charinfo directory do not exist, building it",account); - p_mkdir(path,S_IRWXU); - } else { - while ((charname=p_readdir(dir))) { - if (charname[0]=='.') continue; - charinfo = xmalloc(sizeof(t_d2charinfo_file)); - if (d2charinfo_load(account,charname,charinfo)<0) { - eventlog(eventlog_level_error,__FUNCTION__,"error loading charinfo for %s(*%s)",charname,account); - xfree((void *)charinfo); - continue; - } - eventlog(eventlog_level_debug,__FUNCTION__,"adding char %s (*%s)", charname, account); - d2charlist_add_char(&charlist_head,charinfo,0); - n++; - if (n>=maxchar) break; - } - if (prefs_allow_newchar() && (nu.d2cs_client_charlistreply.maxchar,maxchar); - } else { - bn_short_set(&rpacket->u.d2cs_client_charlistreply.maxchar,0); - } - if (n>=maxchar) - maxchar = 0; - - p_closedir(dir); - if (!strcmp(charlist_sort_order, "ASC")) - { - t_elist * curr, * safe; - t_d2charlist * ccharlist; - - elist_for_each_safe(curr,&charlist_head,safe) - { - ccharlist = elist_entry(curr,t_d2charlist,list); - packet_append_string(rpacket,ccharlist->charinfo->header.charname); - packet_append_string(rpacket,(char *)&ccharlist->charinfo->portrait); - xfree((void *)ccharlist->charinfo); - xfree((void *)ccharlist); - } - } - else - { - t_elist * curr, * safe; - t_d2charlist * ccharlist; - - elist_for_each_safe_rev(curr,&charlist_head,safe) - { - ccharlist = elist_entry(curr,t_d2charlist,list); - packet_append_string(rpacket,ccharlist->charinfo->header.charname); - packet_append_string(rpacket,(char *)&ccharlist->charinfo->portrait); - xfree((void *)ccharlist->charinfo); - xfree((void *)ccharlist); - - } - } - } - bn_short_set(&rpacket->u.d2cs_client_charlistreply.currchar,n); - bn_short_set(&rpacket->u.d2cs_client_charlistreply.currchar2,n); - bn_short_set(&rpacket->u.d2cs_client_charlistreply.maxchar,maxchar); - - conn_push_outqueue(c,rpacket); - packet_del_ref(rpacket); - } - xfree(path); - return 0; -} - -static int on_client_convertcharreq(t_connection * c, t_packet * packet) -{ - t_packet * rpacket; - char const * charname; - char const * account; - unsigned int reply; - - if (!(charname=packet_get_str_const(packet,sizeof(t_client_d2cs_convertcharreq),MAX_CHARNAME_LEN))) { - eventlog(eventlog_level_error,__FUNCTION__,"got bad character name"); - return -1; - } - if (conn_check_multilogin(c,charname)<0) { - eventlog(eventlog_level_error,__FUNCTION__,"character %s is already logged in",charname); - return -1; - } - account=d2cs_conn_get_account(c); - if (d2char_convert(account,charname)<0) { - eventlog(eventlog_level_error,__FUNCTION__,"failed to convert character %s(*%s)",charname,account); - reply = D2CS_CLIENT_CONVERTCHARREPLY_FAILED; - } else { - reply = D2CS_CLIENT_CONVERTCHARREPLY_SUCCEED; - } - if ((rpacket=packet_create(packet_class_d2cs))) { - packet_set_size(rpacket,sizeof(t_d2cs_client_convertcharreply)); - packet_set_type(rpacket,D2CS_CLIENT_CONVERTCHARREPLY); - bn_int_set(&rpacket->u.d2cs_client_convertcharreply.reply,reply); - conn_push_outqueue(c,rpacket); - packet_del_ref(rpacket); - } - return 0; -} - -extern int d2cs_send_client_creategamewait(t_connection * c, unsigned int position) -{ - t_packet * packet; - - ASSERT(c,-1); - if ((packet=packet_create(packet_class_d2cs))) { - packet_set_size(packet,sizeof(t_d2cs_client_creategamewait)); - packet_set_type(packet,D2CS_CLIENT_CREATEGAMEWAIT); - bn_int_set(&packet->u.d2cs_client_creategamewait.position,position); - conn_push_outqueue(c,packet); - packet_del_ref(packet); - } - return 0; -} - -extern int d2cs_handle_client_creategame(t_connection * c, t_packet * packet) -{ - return on_client_creategamereq(c,packet); -} - -static unsigned int d2cs_try_joingame(t_connection const * c, t_game const * game, char const * gamepass) -{ - unsigned int reply; - - ASSERT(c,D2CS_CLIENT_JOINGAMEREPLY_NOT_EXIST); - ASSERT(game,D2CS_CLIENT_JOINGAMEREPLY_NOT_EXIST); - if (!game_get_created(game)) { - reply=D2CS_CLIENT_JOINGAMEREPLY_NOT_EXIST; - } else if (!game_get_d2gs(game)) { - reply=D2CS_CLIENT_JOINGAMEREPLY_NOT_EXIST; - } else if (conn_get_charinfo_expansion(c) != game_get_gameflag_expansion(game)) { - reply=D2CS_CLIENT_JOINGAMEREPLY_LEVEL_LIMIT; - } else if (conn_get_charinfo_hardcore(c) != game_get_gameflag_hardcore(game)) { - reply=D2CS_CLIENT_JOINGAMEREPLY_LEVEL_LIMIT; - } else if (conn_get_charinfo_difficulty(c) < game_get_gameflag_difficulty(game)) { - reply=D2CS_CLIENT_JOINGAMEREPLY_LEVEL_LIMIT; - } else if (prefs_allow_gamelimit()) { - if (game_get_maxchar(game) <= game_get_currchar(game)) { - reply=D2CS_CLIENT_JOINGAMEREPLY_GAME_FULL; - } else if (conn_get_charinfo_level(c) > game_get_maxlevel(game)) { - reply=D2CS_CLIENT_JOINGAMEREPLY_LEVEL_LIMIT; - } else if (conn_get_charinfo_level(c) < game_get_minlevel(game)) { - reply=D2CS_CLIENT_JOINGAMEREPLY_LEVEL_LIMIT; - } else if (strcmp(d2cs_game_get_pass(game),gamepass)) { - reply=D2CS_CLIENT_JOINGAMEREPLY_BAD_PASS; - } else { - reply=D2CS_CLIENT_JOINGAMEREPLY_SUCCEED; - } - } else { - if (game_get_currchar(game) >= MAX_CHAR_PER_GAME) { - reply=D2CS_CLIENT_JOINGAMEREPLY_GAME_FULL; - } else { - reply=D2CS_CLIENT_JOINGAMEREPLY_SUCCEED; - } - } - return reply; -} diff --git a/d2pack109/src/d2cs/handle_d2cs.h b/d2pack109/src/d2cs/handle_d2cs.h deleted file mode 100644 index f81ba0f..0000000 --- a/d2pack109/src/d2cs/handle_d2cs.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2000,2001 Onlyer (onlyer@263.net) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_HANDLE_D2CS_H -#define INCLUDED_HANDLE_D2CS_H - -#include "connection.h" -#include "common/packet.h" - -extern int d2cs_handle_d2cs_packet(t_connection * c, t_packet * packet); -extern int d2cs_handle_client_creategame(t_connection * c, t_packet * packet); -extern int d2cs_send_client_creategamewait(t_connection * c, unsigned int position); - -#endif diff --git a/d2pack109/src/d2cs/handle_d2gs.c b/d2pack109/src/d2cs/handle_d2gs.c deleted file mode 100644 index fe44580..0000000 --- a/d2pack109/src/d2cs/handle_d2gs.c +++ /dev/null @@ -1,435 +0,0 @@ -/* - * Copyright (C) 2000,2001 Onlyer (onlyer@263.net) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#include "common/setup_before.h" -#include "setup.h" - -#ifdef STDC_HEADERS -# include -#else -# ifdef HAVE_MALLOC_H -# include -# endif -#endif -#ifdef HAVE_SYS_TYPES_H -# include /* needed to include netinet/in.h */ -#endif -#ifdef HAVE_SYS_SOCKET_H -# include -#endif -#include "compat/socket.h" -#ifdef HAVE_NETINET_IN_H -# include -#endif -#include "compat/netinet_in.h" -#ifdef HAVE_ARPA_INET_H -# include /* FIXME: probably not needed... do some systems put types in here or something? */ -#endif -#include "compat/psock.h" - -#include "d2gs.h" -#include "handle_d2gs.h" -#include "serverqueue.h" -#include "game.h" -#include "connection.h" -#include "prefs.h" -#include "d2cs_d2gs_protocol.h" -#include "common/trans.h" -#include "common/addr.h" -#include "common/eventlog.h" -#include "common/queue.h" -#include "common/bn_type.h" -#include "common/packet.h" -#include "common/xalloc.h" -#include "common/setup_after.h" - -DECLARE_PACKET_HANDLER(on_d2gs_authreply) -DECLARE_PACKET_HANDLER(on_d2gs_setgsinfo) -DECLARE_PACKET_HANDLER(on_d2gs_echoreply) -DECLARE_PACKET_HANDLER(on_d2gs_creategamereply) -DECLARE_PACKET_HANDLER(on_d2gs_joingamereply) -DECLARE_PACKET_HANDLER(on_d2gs_updategameinfo) -DECLARE_PACKET_HANDLER(on_d2gs_closegame) - -static t_packet_handle_table d2gs_packet_handle_table[]={ -/* 0x00 */ { 0, conn_state_none, NULL }, -/* 0x01 */ { 0, conn_state_none, NULL }, -/* 0x02 */ { 0, conn_state_none, NULL }, -/* 0x03 */ { 0, conn_state_none, NULL }, -/* 0x04 */ { 0, conn_state_none, NULL }, -/* 0x05 */ { 0, conn_state_none, NULL }, -/* 0x06 */ { 0, conn_state_none, NULL }, -/* 0x07 */ { 0, conn_state_none, NULL }, -/* 0x08 */ { 0, conn_state_none, NULL }, -/* 0x09 */ { 0, conn_state_none, NULL }, -/* 0x0a */ { 0, conn_state_none, NULL }, -/* 0x0b */ { 0, conn_state_none, NULL }, -/* 0x0c */ { 0, conn_state_none, NULL }, -/* 0x0d */ { 0, conn_state_none, NULL }, -/* 0x0e */ { 0, conn_state_none, NULL }, -/* 0x0f */ { 0, conn_state_none, NULL }, -/* 0x10 */ { 0, conn_state_none, NULL }, -/* FIXME: shouldn't these three be at 0x10-0x12? (But I'm pretty sure I preserved the padding) */ -/* 0x11 */ { sizeof(t_d2gs_d2cs_authreply), conn_state_connected, on_d2gs_authreply }, -/* 0x12 */ { sizeof(t_d2gs_d2cs_setgsinfo), conn_state_authed, on_d2gs_setgsinfo }, -/* 0x13 */ { sizeof(t_d2gs_d2cs_echoreply), conn_state_any, on_d2gs_echoreply }, -/* 0x14 */ { 0, conn_state_none, NULL }, -/* 0x15 */ { 0, conn_state_none, NULL }, -/* 0x16 */ { 0, conn_state_none, NULL }, -/* 0x17 */ { 0, conn_state_none, NULL }, -/* 0x18 */ { 0, conn_state_none, NULL }, -/* 0x19 */ { 0, conn_state_none, NULL }, -/* 0x1a */ { 0, conn_state_none, NULL }, -/* 0x1b */ { 0, conn_state_none, NULL }, -/* 0x1c */ { 0, conn_state_none, NULL }, -/* 0x1d */ { 0, conn_state_none, NULL }, -/* 0x1e */ { 0, conn_state_none, NULL }, -/* 0x1f */ { 0, conn_state_none, NULL }, -/* 0x20 */ { sizeof(t_d2gs_d2cs_creategamereply),conn_state_authed, on_d2gs_creategamereply }, -/* 0x21 */ { sizeof(t_d2gs_d2cs_joingamereply), conn_state_authed, on_d2gs_joingamereply }, -/* 0x22 */ { sizeof(t_d2gs_d2cs_updategameinfo), conn_state_authed, on_d2gs_updategameinfo }, -/* 0x23 */ { sizeof(t_d2gs_d2cs_closegame), conn_state_authed, on_d2gs_closegame }, -}; - - -static int on_d2gs_authreply(t_connection * c, t_packet * packet) -{ - t_d2gs * gs; - t_packet * rpacket; - unsigned int reply; - unsigned int try_checksum, checksum; - unsigned int version; - - if (!(gs=d2gslist_find_gs(conn_get_d2gs_id(c)))) { - eventlog(eventlog_level_error,__FUNCTION__,"game server %d not found",conn_get_d2gs_id(c)); - return -1; - } - - version=bn_int_get(packet->u.d2gs_d2cs_authreply.version); - try_checksum=bn_int_get(packet->u.d2gs_d2cs_authreply.checksum); - checksum=d2gs_calc_checksum(c); - if (prefs_get_d2gs_version() && (version != prefs_get_d2gs_version())) { - eventlog(eventlog_level_error,__FUNCTION__,"game server %d version mismatch 0x%X - 0x%X",conn_get_d2gs_id(c), - version,prefs_get_d2gs_version()); - reply=D2CS_D2GS_AUTHREPLY_BAD_VERSION; - } else if (prefs_get_d2gs_checksum() && try_checksum != checksum) { - eventlog(eventlog_level_error,__FUNCTION__,"game server %d checksum mismach 0x%X - 0x%X",conn_get_d2gs_id(c),try_checksum,checksum); - reply=D2CS_D2GS_AUTHREPLY_BAD_CHECKSUM; - } else { - reply=D2CS_D2GS_AUTHREPLY_SUCCEED; - } - - if (reply==D2CS_D2GS_AUTHREPLY_SUCCEED) { - eventlog(eventlog_level_info,__FUNCTION__,"game server %s authed",addr_num_to_ip_str(d2cs_conn_get_addr(c))); - d2cs_conn_set_state(c,conn_state_authed); - d2gs_active(gs,c); - } else { - eventlog(eventlog_level_error,__FUNCTION__,"game server %s failed to auth",addr_num_to_ip_str(d2cs_conn_get_addr(c))); - /* - d2cs_conn_set_state(c,conn_state_destroy); - */ - } - if ((rpacket=packet_create(packet_class_d2gs))) { - packet_set_size(rpacket,sizeof(t_d2cs_d2gs_authreply)); - packet_set_type(rpacket,D2CS_D2GS_AUTHREPLY); - bn_int_set(&rpacket->u.d2cs_d2gs_authreply.h.seqno,1); - bn_int_set(&rpacket->u.d2cs_d2gs_authreply.reply,reply); - conn_push_outqueue(c,rpacket); - packet_del_ref(rpacket); - } - - // set d2gs version - gs->d2gs_version = version; - - return 0; -} - -static int on_d2gs_setgsinfo(t_connection * c, t_packet * packet) -{ - t_d2gs * gs; - t_packet * rpacket; - unsigned int maxgame, prev_maxgame; - unsigned int currgame, gameflag; - - if (!(gs=d2gslist_find_gs(conn_get_d2gs_id(c)))) { - eventlog(eventlog_level_error,__FUNCTION__,"game server %d not found",conn_get_d2gs_id(c)); - return -1; - } - maxgame=bn_int_get(packet->u.d2gs_d2cs_setgsinfo.maxgame); - prev_maxgame=d2gs_get_maxgame(gs); - currgame = d2gs_get_gamenum(gs); - eventlog(eventlog_level_info, __FUNCTION__, "change game server %s max game from %d to %d (%d current)",addr_num_to_ip_str(d2cs_conn_get_addr(c)),prev_maxgame, maxgame, currgame); - d2gs_set_maxgame(gs,maxgame); - - if(gs->d2gs_version > 0x1090007) - { - gameflag=bn_int_get(packet->u.d2gs_d2cs_setgsinfo.gameflag); - - if ((rpacket=packet_create(packet_class_d2gs))) { - packet_set_size(rpacket,sizeof(t_d2cs_d2gs_setgsinfo)); - packet_set_type(rpacket,D2CS_D2GS_SETGSINFO); - bn_int_set(&rpacket->u.d2cs_d2gs_setgsinfo.h.seqno,1); - bn_int_set(&rpacket->u.d2cs_d2gs_setgsinfo.maxgame,maxgame); - bn_int_set(&rpacket->u.d2cs_d2gs_setgsinfo.gameflag,gameflag); - conn_push_outqueue(c,rpacket); - packet_del_ref(rpacket); - } - } - - gqlist_check_creategame(); - return 0; -} - -static int on_d2gs_echoreply(t_connection * c, t_packet * packet) -{ - if (!c || !packet) - return 0; - return 0; -} - -static int on_d2gs_creategamereply(t_connection * c, t_packet * packet) -{ - t_packet * opacket, * rpacket; - t_sq * sq; - t_connection * client; - t_game * game; - int result; - int reply; - int seqno; - t_elem * curr; - - seqno=bn_int_get(packet->u.d2cs_d2gs.h.seqno); - if (!(sq=sqlist_find_sq(seqno))) { - eventlog(eventlog_level_error,__FUNCTION__,"seqno %d not found",seqno); - return 0; - } - if (!(client=d2cs_connlist_find_connection_by_sessionnum(sq_get_clientid(sq)))) { - eventlog(eventlog_level_error,__FUNCTION__,"client %d not found",sq_get_clientid(sq)); - sq_destroy(sq,&curr); - return 0; - } - if (!(game=gamelist_find_game_by_id(sq_get_gameid(sq)))) { - eventlog(eventlog_level_error,__FUNCTION__,"game %d not found",sq_get_gameid(sq)); - sq_destroy(sq,&curr); - return 0; - } - if (!(opacket=sq_get_packet(sq))) { - eventlog(eventlog_level_error,__FUNCTION__,"previous packet not found (seqno: %d)",seqno); - sq_destroy(sq,&curr); - return 0; - } - - result=bn_int_get(packet->u.d2gs_d2cs_creategamereply.result); - if (result==D2GS_D2CS_CREATEGAME_SUCCEED) { - game_set_d2gs_gameid(game,bn_int_get(packet->u.d2gs_d2cs_creategamereply.gameid)); - game_set_created(game,1); - eventlog(eventlog_level_info,__FUNCTION__,"game %s created on gs %d",d2cs_game_get_name(game),conn_get_d2gs_id(c)); - reply=D2CS_CLIENT_CREATEGAMEREPLY_SUCCEED; - } else if (result==D2GS_D2CS_JOINGAME_GAME_FULL) { - eventlog(eventlog_level_info, __FUNCTION__, "failed to add %s to game %s on gs %d (game full)",d2cs_conn_get_charname(client),d2cs_game_get_name(game),conn_get_d2gs_id(c)); - reply=D2CS_CLIENT_JOINGAMEREPLY_GAME_FULL; - } else { - eventlog(eventlog_level_warn,__FUNCTION__,"failed to create game %s on gs %d",d2cs_game_get_name(game),conn_get_d2gs_id(c)); - game_destroy(game,&curr); - reply=D2CS_CLIENT_CREATEGAMEREPLY_FAILED; - } - - if ((rpacket=packet_create(packet_class_d2cs))) { - packet_set_size(rpacket,sizeof(t_d2cs_client_creategamereply)); - packet_set_type(rpacket,D2CS_CLIENT_CREATEGAMEREPLY); - bn_short_set(&rpacket->u.d2cs_client_creategamereply.seqno, - bn_short_get(opacket->u.client_d2cs_creategamereq.seqno)); - bn_short_set(&rpacket->u.d2cs_client_creategamereply.gameid,1); - bn_short_set(&rpacket->u.d2cs_client_creategamereply.u1,1); - bn_int_set(&rpacket->u.d2cs_client_creategamereply.reply,reply); - conn_push_outqueue(client,rpacket); - packet_del_ref(rpacket); - } - sq_destroy(sq,&curr); - return 0; -} - -static int on_d2gs_joingamereply(t_connection * c, t_packet * packet) -{ - t_sq * sq; - t_d2gs * gs; - t_connection * client; - t_game * game; - t_packet * opacket, * rpacket; - int result; - int reply; - int seqno; - unsigned int gsaddr; - t_elem * curr; - unsigned short gsport; - - - seqno=bn_int_get(packet->u.d2cs_d2gs.h.seqno); - if (!(sq=sqlist_find_sq(seqno))) { - eventlog(eventlog_level_error,__FUNCTION__,"seqno %d not found",seqno); - return 0; - } - if (!(client=d2cs_connlist_find_connection_by_sessionnum(sq_get_clientid(sq)))) { - eventlog(eventlog_level_error,__FUNCTION__,"client %d not found",sq_get_clientid(sq)); - sq_destroy(sq,&curr); - return 0; - } - if (!(game=gamelist_find_game_by_id(sq_get_gameid(sq)))) { - eventlog(eventlog_level_error,__FUNCTION__,"game %d not found",sq_get_gameid(sq)); - sq_destroy(sq,&curr); - return 0; - } - if (!(gs=game_get_d2gs(game))) { - eventlog(eventlog_level_error,__FUNCTION__,"try join game without game server set"); - sq_destroy(sq,&curr); - return 0; - } - if (!(opacket=sq_get_packet(sq))) { - eventlog(eventlog_level_error,__FUNCTION__,"previous packet not found (seqno: %d)",seqno); - sq_destroy(sq,&curr); - return 0; - } - - result=bn_int_get(packet->u.d2gs_d2cs_joingamereply.result); - if (result==D2GS_D2CS_JOINGAME_SUCCEED) { - eventlog(eventlog_level_info,__FUNCTION__,"added %s to game %s on gs %d",d2cs_conn_get_charname(client), - d2cs_game_get_name(game),conn_get_d2gs_id(c)); - reply=D2CS_CLIENT_JOINGAMEREPLY_SUCCEED; - } else { - eventlog(eventlog_level_info,__FUNCTION__,"failed to add %s to game %s on gs %d",d2cs_conn_get_charname(client), - d2cs_game_get_name(game),conn_get_d2gs_id(c)); - reply=D2CS_CLIENT_JOINGAMEREPLY_FAILED; - } - - if ((rpacket=packet_create(packet_class_d2cs))) { - packet_set_size(rpacket,sizeof(t_d2cs_client_joingamereply)); - packet_set_type(rpacket,D2CS_CLIENT_JOINGAMEREPLY); - bn_short_set(&rpacket->u.d2cs_client_joingamereply.seqno, - bn_short_get(opacket->u.client_d2cs_joingamereq.seqno)); - bn_short_set(&rpacket->u.d2cs_client_joingamereply.gameid,game_get_d2gs_gameid(game)); - bn_short_set(&rpacket->u.d2cs_client_joingamereply.u1,0); - bn_int_set(&rpacket->u.d2cs_client_joingamereply.reply,reply); - if (reply == D2CS_CLIENT_JOINGAMEREPLY_SUCCEED) { - bn_int_set(&rpacket->u.d2cs_client_joingamereply.token,sq_get_gametoken(sq)); - - gsaddr = d2gs_get_ip(gs); - gsport = 4000; - trans_net(d2cs_conn_get_addr(client), &gsaddr, &gsport); - - if(d2gs_get_ip(gs)!=gsaddr) - { - eventlog(eventlog_level_info,__FUNCTION__,"translated gameserver %s -> %s",addr_num_to_ip_str(d2gs_get_ip(gs)),addr_num_to_ip_str(gsaddr)); - } else { - eventlog(eventlog_level_info,__FUNCTION__,"no translation required for gamserver %s",addr_num_to_ip_str(gsaddr)); - } - - bn_int_nset(&rpacket->u.d2cs_client_joingamereply.addr,gsaddr); - - } else { - bn_int_set(&rpacket->u.d2cs_client_joingamereply.token,0); - bn_int_set(&rpacket->u.d2cs_client_joingamereply.addr,0); - } - conn_push_outqueue(client,rpacket); - packet_del_ref(rpacket); - } - sq_destroy(sq,&curr); - return 0; -} - -static int on_d2gs_updategameinfo(t_connection * c, t_packet * packet) -{ - unsigned int flag; - char const * charname; - t_game * game; - unsigned int charclass; - unsigned int charlevel; - unsigned int d2gs_gameid; - unsigned int d2gs_id; - - if (!(charname=packet_get_str_const(packet,sizeof(t_d2gs_d2cs_updategameinfo),MAX_CHARNAME_LEN))) { - eventlog(eventlog_level_error,__FUNCTION__,"got bad charname"); - return 0; - } - d2gs_id=conn_get_d2gs_id(c); - d2gs_gameid=bn_int_get(packet->u.d2gs_d2cs_updategameinfo.gameid); - charclass=bn_int_get(packet->u.d2gs_d2cs_updategameinfo.charclass); - charlevel=bn_int_get(packet->u.d2gs_d2cs_updategameinfo.charlevel); - flag=bn_int_get(packet->u.d2gs_d2cs_updategameinfo.flag); - if (!(game=gamelist_find_game_by_d2gs_and_id(d2gs_id,d2gs_gameid))) { - eventlog(eventlog_level_error,__FUNCTION__,"game %d not found on gs %d",d2gs_gameid,d2gs_id); - return -1; - } - if (flag==D2GS_D2CS_UPDATEGAMEINFO_FLAG_ENTER) { - game_add_character(game,charname,charclass,charlevel); - } else if (flag==D2GS_D2CS_UPDATEGAMEINFO_FLAG_LEAVE) { - game_del_character(game,charname); - } else if (flag==D2GS_D2CS_UPDATEGAMEINFO_FLAG_UPDATE) { - game_add_character(game,charname,charclass,charlevel); - } else { - eventlog(eventlog_level_error,__FUNCTION__,"got bad updategameinfo flag %d",flag); - } - return 0; -} - -static int on_d2gs_closegame(t_connection * c, t_packet * packet) -{ - t_game * game; - t_elem * curr; - - if (!(game=gamelist_find_game_by_d2gs_and_id(conn_get_d2gs_id(c), - bn_int_get(packet->u.d2gs_d2cs_closegame.gameid)))) { - return 0; - } - game_destroy(game, &curr); - return 0; -} - -extern int handle_d2gs_packet(t_connection * c, t_packet * packet) -{ - int type; - t_d2gs * gs; - - type=packet_get_type(packet); - - // ugly d2gs hack, used in backward campability... - if(type == D2GS_D2CS_SETGSINFO) - { - gs=d2gslist_find_gs(conn_get_d2gs_id(c)); - if(gs->d2gs_version <= 0x1090007) - d2gs_packet_handle_table[type].size = sizeof(t_d2gs_d2cs_setgsinfo) - sizeof(bn_int); - } - - conn_process_packet(c,packet,d2gs_packet_handle_table,NELEMS(d2gs_packet_handle_table)); - return 0; -} - -extern int handle_d2gs_init(t_connection * c) -{ - t_packet * packet; - - if ((packet=packet_create(packet_class_d2gs))) { - packet_set_size(packet,sizeof(t_d2cs_d2gs_authreq)); - packet_set_type(packet,D2CS_D2GS_AUTHREQ); - bn_int_set(&packet->u.d2cs_d2gs_authreq.h.seqno,1); - bn_int_set(&packet->u.d2cs_d2gs_authreq.sessionnum,d2cs_conn_get_sessionnum(c)); - packet_append_string(packet,prefs_get_realmname()); - conn_push_outqueue(c,packet); - packet_del_ref(packet); - } - eventlog(eventlog_level_info,__FUNCTION__,"sent init packet to d2gs %d (sessionnum=%d)",conn_get_d2gs_id(c),d2cs_conn_get_sessionnum(c)); - return 0; -} diff --git a/d2pack109/src/d2cs/handle_d2gs.h b/d2pack109/src/d2cs/handle_d2gs.h deleted file mode 100644 index 9b6652b..0000000 --- a/d2pack109/src/d2cs/handle_d2gs.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2000,2001 Onlyer (onlyer@263.net) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_HANDLE_D2GS_H -#define INCLUDED_HANDLE_D2GS_H - -#include "connection.h" -#include "common/packet.h" - -/* FIXME: why include the time stuff? */ -#ifdef TIME_WITH_SYS_TIME -# include -# include -#else -# ifdef HAVE_SYS_TIME_H -# include -# else -# include -# endif -#endif - - -extern int handle_d2gs_packet(t_connection * c, t_packet * packet); -extern int handle_d2gs_init(t_connection * c); - -#endif diff --git a/d2pack109/src/d2cs/handle_init.c b/d2pack109/src/d2cs/handle_init.c deleted file mode 100644 index e3f6dcc..0000000 --- a/d2pack109/src/d2cs/handle_init.c +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (C) 2000,2001 Onlyer (onlyer@263.net) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#include "common/setup_before.h" -#include "setup.h" - -#ifdef STDC_HEADERS -# include -#else -# ifdef HAVE_MALLOC_H -# include -# endif -#endif - -#include "connection.h" -#include "handle_init.h" -#include "handle_d2gs.h" -#include "d2gs.h" -#include "prefs.h" -#include "common/init_protocol.h" -#include "common/addr.h" -#include "common/packet.h" -#include "common/queue.h" -#include "common/eventlog.h" -#include "common/bn_type.h" -#include "common/setup_after.h" - -static int on_d2gs_initconn(t_connection * c); -static int on_d2cs_initconn(t_connection * c); - -extern int d2cs_handle_init_packet(t_connection * c, t_packet * packet) -{ - int class; - int retval; - - ASSERT(c,-1); - ASSERT(packet,-1); - class=bn_byte_get(packet->u.client_initconn.class); - switch (class) { - case CLIENT_INITCONN_CLASS_D2CS: - retval=on_d2cs_initconn(c); - break; - case CLIENT_INITCONN_CLASS_D2GS: - retval=on_d2gs_initconn(c); - break; - default: - eventlog(eventlog_level_error,__FUNCTION__,"got bad connection class %d",class); - retval=-1; - break; - } - return retval; -} - -static int on_d2gs_initconn(t_connection * c) -{ - t_d2gs * gs; - - eventlog(eventlog_level_info,__FUNCTION__,"[%d] client initiated d2gs connection",d2cs_conn_get_socket(c)); - if (!(gs=d2gslist_find_gs_by_ip(d2cs_conn_get_addr(c)))) { - // reload list and see if any dns addy's has changed - if (d2gslist_reload(prefs_get_d2gs_list())<0) { - eventlog(eventlog_level_error,__FUNCTION__,"error reloading game server list,exitting"); - return -1; - } - //recheck - if (!(gs=d2gslist_find_gs_by_ip(d2cs_conn_get_addr(c)))) { - eventlog(eventlog_level_error,__FUNCTION__,"d2gs connection from invalid ip address %s",addr_num_to_ip_str(d2cs_conn_get_addr(c))); - return -1; - } - } - d2cs_conn_set_class(c,conn_class_d2gs); - d2cs_conn_set_state(c,conn_state_connected); - conn_set_d2gs_id(c,d2gs_get_id(gs)); - if (handle_d2gs_init(c)<0) { - eventlog(eventlog_level_error,__FUNCTION__,"failed to init d2gs connection"); - return -1; - } - return 0; -} - -static int on_d2cs_initconn(t_connection * c) -{ - eventlog(eventlog_level_info,__FUNCTION__,"[%d] client initiated d2cs connection",d2cs_conn_get_socket(c)); - d2cs_conn_set_class(c,conn_class_d2cs); - d2cs_conn_set_state(c,conn_state_connected); - return 0; -} diff --git a/d2pack109/src/d2cs/handle_init.h b/d2pack109/src/d2cs/handle_init.h deleted file mode 100644 index 535a918..0000000 --- a/d2pack109/src/d2cs/handle_init.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (C) 2000,2001 Onlyer (onlyer@263.net) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_HANDLE_INIT_H -#define INCLUDED_HANDLE_INIT_H - -#include "connection.h" -#include "common/packet.h" - -extern int d2cs_handle_init_packet(t_connection * c, t_packet * packet); - -#endif diff --git a/d2pack109/src/d2cs/handle_signal.c b/d2pack109/src/d2cs/handle_signal.c deleted file mode 100644 index 170244f..0000000 --- a/d2pack109/src/d2cs/handle_signal.c +++ /dev/null @@ -1,242 +0,0 @@ -/* - * Copyright (C) 2000,2001 Onlyer (onlyer@263.net) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#include "common/setup_before.h" -#include "setup.h" - -#ifdef STDC_HEADERS -# include -#else -# ifdef HAVE_MALLOC_H -# include -# endif -#endif -#include -#ifdef HAVE_STRING_H -# include -#else -# ifdef HAVE_STRINGS_H -# include -# endif -# ifdef HAVE_MEMORY_H -# include -# endif -#endif -#include "compat/strdup.h" -#ifdef TIME_WITH_SYS_TIME -# include -# include -#else -# ifdef HAVE_SYS_TIME_H -# include -# else -# include -# endif -#endif -#ifdef DO_POSIXSIG -# include -# include "compat/signal.h" -#endif -#ifdef HAVE_FCNTL_H -# include -#else -# ifdef HAVE_SYS_FILE_H -# include -# endif -#endif -#ifdef HAVE_UNISTD_H -# include -#endif - -#include "d2gs.h" -#include "game.h" -#include "prefs.h" -#include "d2ladder.h" -#include "cmdline_parse.h" -#include "handle_signal.h" -#include "common/trans.h" -#include "common/eventlog.h" -#include "common/xalloc.h" -#include "common/setup_after.h" - -static void on_signal(int s); - -static volatile struct -{ - unsigned char do_quit; - unsigned char cancel_quit; - unsigned char reload_config; - unsigned char reload_ladder; - unsigned char restart_d2gs; - unsigned int exit_time; -} signal_data ={ 0, 0, 0, 0, 0, 0 }; - -extern int handle_signal(void) -{ - time_t now; - char const * levels; - char * temp; - char const * tok; - - - if (signal_data.cancel_quit) { - signal_data.cancel_quit=0; - if (!signal_data.exit_time) { - eventlog(eventlog_level_info,__FUNCTION__,"there is no previous shutdown to be canceled"); - } else { - signal_data.exit_time=0; - eventlog(eventlog_level_info,__FUNCTION__,"shutdown was canceled due to signal"); - } - } - if (signal_data.do_quit) { - signal_data.do_quit=0; - now=time(NULL); - if (!signal_data.exit_time) { - signal_data.exit_time=now+d2cs_prefs_get_shutdown_delay(); - } else { - signal_data.exit_time-=d2cs_prefs_get_shutdown_decr(); - } - eventlog(eventlog_level_info,__FUNCTION__,"the server is going to shutdown in %lu minutes",(signal_data.exit_time-now)/60); - } - if (signal_data.exit_time) { - now=time(NULL); - if (now >= (signed)signal_data.exit_time) { - signal_data.exit_time=0; - eventlog(eventlog_level_info,__FUNCTION__,"shutdown server due to signal"); - return -1; - } - } - if (signal_data.reload_config) { - signal_data.reload_config=0; - eventlog(eventlog_level_info,__FUNCTION__,"reloading configuartion file due to signal"); - if (prefs_reload(cmdline_get_prefs_file())<0) { - eventlog(eventlog_level_error,__FUNCTION__,"error reload configuration file,exitting"); - return -1; - } - if (d2gslist_reload(prefs_get_d2gs_list())<0) { - eventlog(eventlog_level_error,__FUNCTION__,"error reloading game server list,exitting"); - return -1; - } - if (trans_reload(d2cs_prefs_get_transfile(),TRANS_D2CS)<0) { - eventlog(eventlog_level_error,__FUNCTION__,"could not reload trans list"); - } - - eventlog_clear_level(); - if ((levels = d2cs_prefs_get_loglevels())) - { - temp = xstrdup(levels); - tok = strtok(temp,","); /* strtok modifies the string it is passed */ - - while (tok) - { - if (eventlog_add_level(tok)<0) - eventlog(eventlog_level_error,__FUNCTION__,"could not add log level \"%s\"",tok); - tok = strtok(NULL,","); - } - - xfree(temp); - } - - if (!cmdline_get_debugmode()) eventlog_open(d2cs_prefs_get_logfile()); - } - if (signal_data.reload_ladder) { - signal_data.reload_ladder=0; - eventlog(eventlog_level_info,__FUNCTION__,"reloading ladder data due to signal"); - d2ladder_refresh(); - } - - if (signal_data.restart_d2gs) { - signal_data.restart_d2gs=0; - eventlog(eventlog_level_info,__FUNCTION__,"restarting all game servers due to signal"); - d2gs_restart_all_gs(); - } - - return 0; -} - -#ifdef WIN32 -extern void signal_quit_wrapper(void) -{ - signal_data.do_quit=1; -} - -extern void signal_reload_config_wrapper(void) -{ - signal_data.reload_config = 1; -} - -extern void signal_load_ladder_wrapper(void) -{ - signal_data.reload_ladder = 1; -} - -extern void signal_exit_wrapper(void) -{ - signal_data.exit_time = 1; -} - -extern void signal_restart_d2gs_wrapper(void) -{ - signal_data.restart_d2gs = 1; -} -#else -extern int handle_signal_init(void) -{ - signal(SIGINT,on_signal); - signal(SIGTERM,on_signal); - signal(SIGABRT,on_signal); - signal(SIGHUP,on_signal); - signal(SIGUSR1,on_signal); - signal(SIGUSR2,on_signal); - signal(SIGPIPE,on_signal); - return 0; -} - -static void on_signal(int s) -{ - switch (s) { - case SIGINT: - eventlog(eventlog_level_debug,__FUNCTION__,"sigint received"); - signal_data.do_quit=1; - break; - case SIGTERM: - eventlog(eventlog_level_debug,__FUNCTION__,"sigint received"); - signal_data.do_quit=1; - break; - case SIGABRT: - eventlog(eventlog_level_debug,__FUNCTION__,"sigabrt received"); - signal_data.cancel_quit=1; - break; - case SIGHUP: - eventlog(eventlog_level_debug,__FUNCTION__,"sighup received"); - signal_data.reload_config=1; - break; - case SIGUSR1: - eventlog(eventlog_level_debug,__FUNCTION__,"sigusr1 received"); - signal_data.reload_ladder=1; - break; - case SIGUSR2: - eventlog(eventlog_level_debug,__FUNCTION__,"sigusr2 received"); - signal_data.restart_d2gs=1; - break; - case SIGPIPE: - eventlog(eventlog_level_debug,__FUNCTION__,"sigpipe received"); - break; - } - signal(s,on_signal); -} -#endif diff --git a/d2pack109/src/d2cs/handle_signal.h b/d2pack109/src/d2cs/handle_signal.h deleted file mode 100644 index 39b22c9..0000000 --- a/d2pack109/src/d2cs/handle_signal.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 2000,2001 Onlyer (onlyer@263.net) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_HANDLE_SIGNAL_H -#define INCLUDED_HANDLE_SIGNAL_H - -#ifndef WIN32 -extern int handle_signal_init(void); -#else -extern void signal_quit_wrapper(void); -extern void signal_reload_config_wrapper(void); -extern void signal_load_ladder_wrapper(void); -extern void signal_exit_wrapper(void); -extern void signal_restart_d2gs_wrapper(void); -#endif - -extern int handle_signal(void); - -#endif diff --git a/d2pack109/src/d2cs/main.c b/d2pack109/src/d2cs/main.c deleted file mode 100644 index 4835fae..0000000 --- a/d2pack109/src/d2cs/main.c +++ /dev/null @@ -1,261 +0,0 @@ -/* - * Copyright (C) 2000,2001 Onlyer (onlyer@263.net) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#include "common/setup_before.h" -#include "setup.h" - -#include -#ifdef STDC_HEADERS -# include -#else -# ifdef HAVE_MALLOC_H -# include -# endif -#endif -#ifdef HAVE_UNISTD_H -# include -#endif -#ifdef HAVE_STRING_H -# include -#else -# ifdef HAVE_STRINGS_H -# include -# endif -# ifdef HAVE_MEMORY_H -# include -# endif -#endif -#include "compat/strdup.h" -#include -#include "compat/strerror.h" -#ifdef HAVE_SYS_STAT_H -# include -#endif -#ifdef HAVE_SYS_TYPES_H -# include -#endif - -#include "server.h" -#include "game.h" -#include "connection.h" -#include "serverqueue.h" -#include "d2gs.h" -#include "prefs.h" -#include "cmdline_parse.h" -#include "d2ladder.h" -#include "version.h" -#include "common/trans.h" -#include "common/fdwatch.h" -#include "common/eventlog.h" -#include "common/xalloc.h" -#ifdef WIN32 -# include "win32/service.h" -#endif -#ifdef WIN32_GUI -# include "win32/winmain.h" -#endif -#include "common/setup_after.h" - -char serviceLongName[] = "d2cs109 service"; -char serviceName[] = "d2cs109"; -char serviceDescription[] = "Diablo 2 (109) Character Server"; - -int g_ServiceStatus = -1; - -static int init(void); -static int cleanup(void); -static int config_init(int argc, char * * argv); -static int config_cleanup(void); -static int setup_daemon(void); - - -#ifdef DO_DAEMONIZE -static int setup_daemon(void) -{ - int pid; - - if (chdir("/")<0) { - eventlog(eventlog_level_error,__FUNCTION__,"can not change working directory to root directory (chdir: %s)",strerror(errno)); - return -1; - } - close(STDIN_FILENO); - close(STDOUT_FILENO); - if (!cmdline_get_debugmode()) { - close(STDERR_FILENO); - } - switch ((pid = fork())) { - case 0: - break; - case -1: - eventlog(eventlog_level_error,__FUNCTION__,"error create child process (fork: %s)",strerror(errno)); - return -1; - default: - return pid; - } - umask(0); - setsid(); - return 0; -} -#endif - -static int init(void) -{ - d2cs_connlist_create(); - d2cs_gamelist_create(); - sqlist_create(); - d2gslist_create(); - gqlist_create(); - d2ladder_init(); - if(trans_load(d2cs_prefs_get_transfile(),TRANS_D2CS)<0) - eventlog(eventlog_level_error,__FUNCTION__,"could not load trans list"); - fdwatch_init(prefs_get_max_connections()); - return 0; -} - - -static int cleanup(void) -{ - d2ladder_destroy(); - d2cs_connlist_destroy(); - d2cs_gamelist_destroy(); - sqlist_destroy(); - d2gslist_destroy(); - gqlist_destroy(); - trans_unload(); - fdwatch_close(); - return 0; -} - - -static int config_init(int argc, char * * argv) -{ - char const * levels; - char * temp; - char const * tok; - int pid; - - if (cmdline_parse(argc, argv)<0) { - return -1; - } -#ifdef WIN32 - if (cmdline_get_run_as_service()) { - Win32_ServiceRun(); - return 1; - } -#endif - if (cmdline_get_version()) { - cmdline_show_version(); - return -1; - } - if (cmdline_get_help()) { - cmdline_show_help(); - return -1; - } -#ifdef DO_DAEMONIZE - if (!cmdline_get_foreground()) { - if (!((pid = setup_daemon()) == 0)) { - return pid; - } - } -#endif -#ifdef WIN32 - if (cmdline_get_make_service()) { - if (strcmp(cmdline_get_make_service(), "install") == 0) { - fprintf(stderr, "Installing service\n"); - Win32_ServiceInstall(); - return 1; - } - if (strcmp(cmdline_get_make_service(), "uninstall") == 0) { - fprintf(stderr, "Uninstalling service\n"); - Win32_ServiceUninstall(); - return 1; - } - } -#endif - - if (d2cs_prefs_load(cmdline_get_prefs_file())<0) { - eventlog(eventlog_level_error,__FUNCTION__,"error loading configuration file %s",cmdline_get_prefs_file()); - return -1; - } - - eventlog_clear_level(); - if ((levels = d2cs_prefs_get_loglevels())) - { - temp = xstrdup(levels); - tok = strtok(temp,","); /* strtok modifies the string it is passed */ - - while (tok) - { - if (eventlog_add_level(tok)<0) - eventlog(eventlog_level_error,__FUNCTION__,"could not add log level \"%s\"",tok); - tok = strtok(NULL,","); - } - - xfree(temp); - } - - if (cmdline_get_debugmode()) { - eventlog_set(stderr); - } else if (cmdline_get_logfile()) { - if (eventlog_open(cmdline_get_logfile())<0) { - eventlog(eventlog_level_error,__FUNCTION__,"error open eventlog file %s",cmdline_get_logfile()); - return -1; - } - } else { - if (eventlog_open(d2cs_prefs_get_logfile())<0) { - eventlog(eventlog_level_error,__FUNCTION__,"error open eventlog file %s",d2cs_prefs_get_logfile()); - return -1; - } - } - return 0; -} - - -static int config_cleanup(void) -{ - d2cs_prefs_unload(); - cmdline_cleanup(); - return 0; -} - -#ifdef WIN32_GUI -extern int server_main(int argc, char * * argv) -#else -extern int main(int argc, char * * argv) -#endif -{ - int pid; - eventlog_set(stderr); - if (!((pid = config_init(argc, argv)) == 0)) { - return pid; - } - eventlog(eventlog_level_info,__FUNCTION__,D2CS_VERSION); - if (init()<0) { - eventlog(eventlog_level_error,__FUNCTION__,"failed to init"); - return -1; - } else { - eventlog(eventlog_level_info,__FUNCTION__,"server initialized"); - } - if (d2cs_server_process()<0) { - eventlog(eventlog_level_error,__FUNCTION__,"failed to run server"); - return -1; - } - cleanup(); - config_cleanup(); - eventlog_close(); - return 0; -} diff --git a/d2pack109/src/d2cs/net.c b/d2pack109/src/d2cs/net.c deleted file mode 100644 index ab92f12..0000000 --- a/d2pack109/src/d2cs/net.c +++ /dev/null @@ -1,287 +0,0 @@ -/* - * Copyright (C) 2000,2001 Onlyer (onlyer@263.net) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#include "common/setup_before.h" -#include "setup.h" - -#ifdef HAVE_STDDEF_H -# include -#else -# ifndef NULL -# define NULL ((void *)0) -# endif -#endif -#include -#ifdef HAVE_STRING_H -# include -#else -# ifdef HAVE_STRINGS_H -# include -# endif -# ifdef HAVE_MEMORY_H -# include -# endif -#endif -#ifdef STDC_HEADERS -# include -#else -# ifdef HAVE_MALLOC_H -# include -# endif -#endif -#include "compat/memset.h" -#include -#include "compat/strerror.h" -#ifdef HAVE_UNISTD_H -# include -#endif -#ifdef HAVE_FCNTL_H -# include -#else -# ifdef HAVE_SYS_FILE_H -# include -# endif -#endif -#ifdef HAVE_SYS_TYPES_H -# include -#endif -#ifdef HAVE_SYS_SOCKET_H -# include -#endif -#include "compat/socket.h" -#ifdef HAVE_SYS_PARAM_H -# include -#endif -#ifdef HAVE_NETINET_IN_H -# include -#endif -#include "compat/netinet_in.h" -#ifdef HAVE_ARPA_INET_H -# include -#endif -#ifdef HAVE_NETDB_H -# include -#endif -#include "compat/psock.h" - -#include "net.h" -#include "common/eventlog.h" -#include "common/setup_after.h" - - -/* FIXME: use addr.h code to do this and make a separate error - * return path so that 255.255.255.255 isn't an error. - */ -extern unsigned long int net_inet_addr(char const * host) -{ - struct hostent * hp; - - if (isdigit((int)host[0])) { - return inet_addr(host); - } else { - hp=gethostbyname(host); - if (!hp || !(hp->h_addr_list)) { - return ~0UL; - } - return *(unsigned long *)hp->h_addr_list[0]; - } -} - -extern int net_socket(int type) -{ - int sock; - int val; - int ipproto; - - if (type==PSOCK_SOCK_STREAM) { - ipproto = PSOCK_IPPROTO_TCP; - } else { - ipproto = PSOCK_IPPROTO_UDP; - } - if ((sock=psock_socket(PSOCK_PF_INET, type, ipproto))<0) { - eventlog(eventlog_level_error,__FUNCTION__,"error creating socket (psock_socket: %s)", strerror(psock_errno())); - return -1; - } - val=1; - if (psock_setsockopt(sock,PSOCK_SOL_SOCKET, PSOCK_SO_KEEPALIVE, &val, sizeof(val))<0) { - eventlog(eventlog_level_error,__FUNCTION__,"error set socket option KEEPALIVE (psock_setsockopt: %s)",strerror(psock_errno())); - } - if (psock_ctl(sock,PSOCK_NONBLOCK)<0) { - eventlog(eventlog_level_error,__FUNCTION__,"error set socket mode to non-block (psock_ctl: %s)",strerror(psock_errno())); - psock_close(sock); - return -1; - } - return sock; -} - -extern int net_check_connected(int sock) -{ - int err; - psock_t_socklen errlen; - - err = 0; - errlen = sizeof(err); - if (psock_getsockopt(sock,PSOCK_SOL_SOCKET, PSOCK_SO_ERROR, &err, &errlen)<0) { - eventlog(eventlog_level_error,__FUNCTION__,"error get socket option SO_ERROR (psock_getsockopt: %s)",strerror(psock_errno())); - return -1; - } - if (errlen && err) - return -1; - return 0; -} - - -extern int net_listen(unsigned int ip, unsigned int port, int type) -{ - int sock; - int val; - struct sockaddr_in addr; - int ipproto; - - if (type==PSOCK_SOCK_STREAM) { - ipproto = PSOCK_IPPROTO_TCP; - } else { - ipproto = PSOCK_IPPROTO_UDP; - } - if ((sock=psock_socket(PSOCK_PF_INET, type, ipproto))<0) { - eventlog(eventlog_level_error,__FUNCTION__,"error create listen socket"); - return -1; - } - val=1; - if (psock_setsockopt(sock,PSOCK_SOL_SOCKET,PSOCK_SO_REUSEADDR,&val,sizeof(int))<0) { - eventlog(eventlog_level_error,__FUNCTION__,"error set socket option SO_REUSEADDR"); - } - memset(&addr,0,sizeof(addr)); - addr.sin_family=PSOCK_AF_INET; - addr.sin_port=htons(port); - addr.sin_addr.s_addr=htonl(ip); - if (psock_bind(sock,(struct sockaddr *)&addr, sizeof(addr))<0) { - eventlog(eventlog_level_error,__FUNCTION__,"error bind listen socket"); - psock_close(sock); - return -1; - } - if (psock_listen(sock,LISTEN_QUEUE)<0) { - eventlog(eventlog_level_error,__FUNCTION__,"error listen socket"); - psock_close(sock); - return -1; - } - return sock; -} - -extern int net_send_data(int sock, char * buff, int buffsize, int * pos, int * currsize) -{ - int nsend; - - ASSERT(buff,-1); - ASSERT(pos,-1); - if (*pos>buffsize) { - eventlog(eventlog_level_error,__FUNCTION__,"[%d] send buffer overflow pos=%d buffsize=%d",sock,*pos,buffsize); - return -1; - } - if (*currsize>*pos) { - eventlog(eventlog_level_error,__FUNCTION__,"[%d] send buffer error currsize=%d pos=%d",sock,*currsize,*pos); - return -1; - } - nsend=psock_send(sock,buff+*pos-*currsize,*currsize,0); - if (nsend==0) { - eventlog(eventlog_level_error,__FUNCTION__,"[%d] no data sent (close connection)",sock); - return -1; - } - if (nsend<0) { - if ( -#ifdef PSOCK_EINTR - psock_errno()==PSOCK_EINTR || -#endif -#ifdef PSOCK_EAGAIN - psock_errno()==PSOCK_EAGAIN || -#endif -#ifdef PSOCK_EWOULDBLOCK - psock_errno()==PSOCK_EWOULDBLOCK || -#endif -#ifdef PSOCK_NOBUFS - psock_errno()==PSOCK_ENOBUFS || -#endif -#ifdef PSOCK_ENOMEM - psock_errno()==ENOMEM || -#endif - 0) - return 0; - - eventlog(eventlog_level_error,__FUNCTION__,"[%d] error sent data (closing connection) (psock_send: %s)",sock,strerror(psock_errno())); - return -1; - } - *currsize -= nsend; - return 1; -} - -extern int net_recv_data(int sock, char * buff, int buffsize, int * pos, int * currsize) -{ - int nrecv; - - ASSERT(buff,-1); - ASSERT(pos,-1); - if (*pos>buffsize) { - eventlog(eventlog_level_error,__FUNCTION__,"[%d] recv buffer overflow pos=%d buffsize=%d",sock,*pos,buffsize); - return -1; - } - if (*currsize>*pos) { - eventlog(eventlog_level_error,__FUNCTION__,"[%d] recv buffer error currsize=%d pos=%d",sock,*currsize,*pos); - return -1; - } - if (*pos==buffsize) { - memmove(buff,buff+*pos,*currsize); - *pos=0; - } - nrecv=psock_recv(sock,buff+*pos,buffsize-*pos,0); - if (nrecv==0) { - eventlog(eventlog_level_info,__FUNCTION__,"[%d] remote host closed connection",sock); - return -1; - } - if (nrecv<0) { - if ( -#ifdef PSOCK_EINTR - psock_errno()==PSOCK_EINTR || -#endif -#ifdef PSOCK_EAGAIN - psock_errno()==PSOCK_EAGAIN || -#endif -#ifdef PSOCK_EWOULDBLOCK - psock_errno()==PSOCK_EWOULDBLOCK || -#endif -#ifdef PSOCK_ENOMEM - psock_errno()==ENOMEM || -#endif - 0) - return 0; - - if ( -#ifdef PSOCK_ENOTCONN - psock_errno()==PSOCK_ENOTCONN || -#endif -#ifdef PSOCK_ECONNRESET - psock_errno()==PSOCK_ECONNRESET || -#endif - 0) { - eventlog(eventlog_level_error,__FUNCTION__,"[%d] remote host closed connection (psock_recv: %s)",sock,strerror(psock_errno())); - return -1; - } - eventlog(eventlog_level_error,__FUNCTION__,"[%d] recv error (closing connection) (psock_recv: %s)",sock,strerror(psock_errno())); - return -1; - } - * currsize += nrecv; - return 1; -} diff --git a/d2pack109/src/d2cs/net.h b/d2pack109/src/d2cs/net.h deleted file mode 100644 index a6b3cca..0000000 --- a/d2pack109/src/d2cs/net.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2000,2001 Onlyer (onlyer@263.net) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_NET_H -#define INCLUDED_NET_H - -extern int net_socket(int type); -extern unsigned long int net_inet_addr(char const * host); -extern int net_check_connected(int sock); -extern int net_listen(unsigned int ip, unsigned int port, int type); -extern int net_send_data(int sock, char * buff, int buffsize, int * pos, int * currsize); -extern int net_recv_data(int sock, char * buff, int buffsize, int * pos, int * currsize); - -#endif diff --git a/d2pack109/src/d2cs/prefs.c b/d2pack109/src/d2cs/prefs.c deleted file mode 100644 index e58c61f..0000000 --- a/d2pack109/src/d2cs/prefs.c +++ /dev/null @@ -1,345 +0,0 @@ -/* - * Copyright (C) 2000,2001 Onlyer (onlyer@263.net) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#include "common/setup_before.h" -#include "setup.h" - -#ifdef HAVE_STDDEF_H -# include -#else -# ifndef NULL -# define NULL ((void *)0) -# endif -#endif -#ifdef HAVE_STRING_H -# include -#else -# ifdef HAVE_STRINGS_H -# include -# endif -# ifdef HAVE_MEMORY_H -# include -# endif -#endif -#include "compat/memset.h" - -#include "conf.h" -#include "prefs.h" -#include "common/eventlog.h" -#include "common/setup_after.h" - -static t_conf_table prefs_conf_table[]={ - { "logfile", offsetof(t_prefs,logfile), conf_type_str, 0, DEFAULT_LOG_FILE }, - { "loglevels", offsetof(t_prefs,loglevels), conf_type_str, 0, DEFAULT_LOG_LEVELS }, - { "servaddrs", offsetof(t_prefs,servaddrs), conf_type_str, 0, D2CS_SERVER_ADDRS }, - { "gameservlist", offsetof(t_prefs,gameservlist), conf_type_str, 0, D2GS_SERVER_LIST }, - { "bnetdaddr", offsetof(t_prefs,bnetdaddr), conf_type_str, 0, BNETD_SERVER_LIST }, - { "charsavedir", offsetof(t_prefs,charsavedir), conf_type_str, 0, D2CS_CHARSAVE_DIR }, - { "charinfodir", offsetof(t_prefs,charinfodir), conf_type_str, 0, D2CS_CHARINFO_DIR }, - { "bak_charsavedir", offsetof(t_prefs,bak_charsavedir), conf_type_str, 0, D2CS_BAK_CHARSAVE_DIR }, - { "bak_charinfodir", offsetof(t_prefs,bak_charinfodir), conf_type_str, 0, D2CS_BAK_CHARINFO_DIR }, - { "ladderdir", offsetof(t_prefs,ladderdir), conf_type_str, 0, D2CS_LADDER_DIR }, - { "ladder_refresh_interval",offsetof(t_prefs,ladder_refresh_interval),conf_type_int,3600, NULL }, - { "newbiefile", offsetof(t_prefs,newbiefile), conf_type_str, 0, D2CS_CHARSAVE_NEWBIE }, - { "transfile", offsetof(t_prefs,transfile), conf_type_str, 0, D2CS_TRANS_FILE }, - { "motd", offsetof(t_prefs,motd), conf_type_hexstr, 0, D2CS_MOTD }, - { "realmname", offsetof(t_prefs,realmname), conf_type_str, 0, DEFAULT_REALM_NAME }, - { "maxchar", offsetof(t_prefs,maxchar), conf_type_int, MAX_CHAR_PER_ACCT, NULL }, - { "listpurgeinterval", offsetof(t_prefs,listpurgeinterval), conf_type_int, LIST_PURGE_INTERVAL, NULL }, - { "gqcheckinterval", offsetof(t_prefs,gqcheckinterval), conf_type_int, GAMEQUEUE_CHECK_INTERVAL, NULL }, - { "maxgamelist", offsetof(t_prefs,maxgamelist), conf_type_int, MAX_GAME_LIST, NULL }, - { "max_game_idletime", offsetof(t_prefs,max_game_idletime), conf_type_int, MAX_GAME_IDLE_TIME, NULL }, - { "gamelist_showall", offsetof(t_prefs,gamelist_showall), conf_type_bool, 0, NULL }, - { "game_maxlifetime", offsetof(t_prefs,game_maxlifetime), conf_type_int, 0, NULL }, - { "allow_gamelimit", offsetof(t_prefs,allow_gamelimit), conf_type_bool, 1, NULL }, - { "allow_newchar", offsetof(t_prefs,allow_newchar), conf_type_bool, 1, NULL }, - { "idletime", offsetof(t_prefs,idletime), conf_type_int, MAX_CLIENT_IDLETIME, NULL }, - { "shutdown_delay", offsetof(t_prefs,shutdown_delay), conf_type_int, DEFAULT_SHUTDOWN_DELAY, NULL }, - { "shutdown_decr", offsetof(t_prefs,shutdown_decr), conf_type_int, DEFAULT_SHUTDOWN_DECR, NULL }, - { "s2s_retryinterval", offsetof(t_prefs,s2s_retryinterval), conf_type_int, DEFAULT_S2S_RETRYINTERVAL, NULL }, - { "s2s_timeout", offsetof(t_prefs,s2s_timeout), conf_type_int, DEFAULT_S2S_TIMEOUT, NULL }, - { "sq_checkinterval", offsetof(t_prefs,sq_checkinterval), conf_type_int, DEFAULT_SQ_CHECKINTERVAL, NULL }, - { "sq_timeout", offsetof(t_prefs,sq_timeout), conf_type_int, DEFAULT_SQ_TIMEOUT, NULL }, - { "d2gs_checksum", offsetof(t_prefs,d2gs_checksum), conf_type_int, 0, NULL }, - { "d2gs_version", offsetof(t_prefs,d2gs_version), conf_type_int, 0, NULL }, - { "d2gs_password", offsetof(t_prefs,d2gs_password), conf_type_str, 0, "" }, - { "check_multilogin", offsetof(t_prefs,check_multilogin), conf_type_int, 1, NULL }, - { "s2s_idletime", offsetof(t_prefs,s2s_idletime), conf_type_int, DEFAULT_S2S_IDLETIME, NULL }, - { "s2s_keepalive_interval", offsetof(t_prefs,s2s_keepalive_interval),conf_type_int,DEFAULT_S2S_KEEPALIVE_INTERVAL, NULL}, - { "timeout_checkinterval", offsetof(t_prefs,timeout_checkinterval), conf_type_int,DEFAULT_TIMEOUT_CHECKINTERVAL, NULL}, - { "lod_realm", offsetof(t_prefs,lod_realm), conf_type_int, 2, NULL }, - { "allow_convert", offsetof(t_prefs,allow_convert), conf_type_int, 0, NULL }, - { "account_allowed_symbols",offsetof(t_prefs,account_allowed_symbols),conf_type_str,0, DEFAULT_ACC_ALLOWED_SYMBOLS}, - { "d2gs_restart_delay", offsetof(t_prefs,d2gs_restart_delay),conf_type_int, DEFAULT_D2GS_RESTART_DELAY, NULL }, - { "charlist_sort", offsetof(t_prefs,charlist_sort), conf_type_str, 0, "none" }, - { "charlist_sort_order", offsetof(t_prefs,charlist_sort_order), conf_type_str, 0, "ASC" }, - { "max_connections", offsetof(t_prefs,max_connections), conf_type_int, BNETD_MAX_SOCKETS, NULL }, - { NULL, 0, conf_type_none, 0, NULL } -}; - -static t_prefs prefs_conf; - -extern int d2cs_prefs_load(char const * filename) -{ - memset(&prefs_conf,0,sizeof(prefs_conf)); - if (conf_load_file(filename,prefs_conf_table,&prefs_conf,sizeof(prefs_conf))<0) { - return -1; - } - return 0; -} - -extern int prefs_reload(char const * filename) -{ - d2cs_prefs_unload(); - if (d2cs_prefs_load(filename)<0) return -1; - return 0; -} - -extern int d2cs_prefs_unload(void) -{ - return conf_cleanup(prefs_conf_table, &prefs_conf, sizeof(prefs_conf)); -} - -extern char const * prefs_get_servaddrs(void) -{ - return prefs_conf.servaddrs; -} - -extern char const * prefs_get_charsave_dir(void) -{ - return prefs_conf.charsavedir; -} - -extern char const * prefs_get_charinfo_dir(void) -{ - return prefs_conf.charinfodir; -} - -extern char const * prefs_get_bak_charsave_dir(void) -{ - return prefs_conf.bak_charsavedir; -} - -extern char const * prefs_get_bak_charinfo_dir(void) -{ - return prefs_conf.bak_charinfodir; -} - -extern char const * prefs_get_charsave_newbie(void) -{ - return prefs_conf.newbiefile; -} - -extern char const * prefs_get_motd(void) -{ - return prefs_conf.motd; -} - -extern char const * prefs_get_d2gs_list(void) -{ - return prefs_conf.gameservlist; -} - -extern unsigned int prefs_get_maxchar(void) -{ - return (prefs_conf.maxchar>MAX_MAX_CHAR_PER_ACCT)?MAX_MAX_CHAR_PER_ACCT:prefs_conf.maxchar; -} - -extern unsigned int prefs_get_list_purgeinterval(void) -{ - return prefs_conf.listpurgeinterval; -} - -extern unsigned int prefs_get_gamequeue_checkinterval(void) -{ - return prefs_conf.gqcheckinterval; -} - -extern unsigned int prefs_get_maxgamelist(void) -{ - return prefs_conf.maxgamelist; -} - -extern unsigned int prefs_allow_newchar(void) -{ - return prefs_conf.allow_newchar; -} - -extern unsigned int prefs_get_idletime(void) -{ - return prefs_conf.idletime; -} - -extern char const * d2cs_prefs_get_logfile(void) -{ - return prefs_conf.logfile; -} - -extern unsigned int d2cs_prefs_get_shutdown_delay(void) -{ - return prefs_conf.shutdown_delay; -} - -extern unsigned int d2cs_prefs_get_shutdown_decr(void) -{ - return prefs_conf.shutdown_decr; -} - -extern char const * prefs_get_bnetdaddr(void) -{ - return prefs_conf.bnetdaddr; -} - -extern char const * prefs_get_realmname(void) -{ - return prefs_conf.realmname; -} - -extern unsigned int prefs_get_s2s_retryinterval(void) -{ - return prefs_conf.s2s_retryinterval; -} - -extern unsigned int prefs_get_s2s_timeout(void) -{ - return prefs_conf.s2s_timeout; -} - -extern unsigned int prefs_get_sq_timeout(void) -{ - return prefs_conf.sq_timeout; -} - -extern unsigned int prefs_get_sq_checkinterval(void) -{ - return prefs_conf.sq_checkinterval; -} - -extern unsigned int prefs_get_d2gs_checksum(void) -{ - return prefs_conf.d2gs_checksum; -} - -extern unsigned int prefs_get_d2gs_version(void) -{ - return prefs_conf.d2gs_version; -} - -extern unsigned int prefs_get_ladderlist_count(void) -{ - return 0x10; -} - -extern unsigned int prefs_get_d2ladder_refresh_interval(void) -{ - return prefs_conf.ladder_refresh_interval; -} - -extern unsigned int prefs_get_game_maxlifetime(void) -{ - return prefs_conf.game_maxlifetime; -} - -extern char const * prefs_get_ladder_dir(void) -{ - return prefs_conf.ladderdir; -} - -extern char const * d2cs_prefs_get_loglevels(void) -{ - return prefs_conf.loglevels; -} - -extern unsigned int prefs_allow_gamelist_showall(void) -{ - return prefs_conf.gamelist_showall; -} - -extern unsigned int prefs_allow_gamelimit(void) -{ - return prefs_conf.allow_gamelimit; -} - -extern unsigned int prefs_check_multilogin(void) -{ - return prefs_conf.check_multilogin; -} - -extern char const * prefs_get_d2gs_password(void) -{ - return prefs_conf.d2gs_password; -} - -extern unsigned int prefs_get_s2s_idletime(void) -{ - return prefs_conf.s2s_idletime; -} - -extern unsigned int prefs_get_s2s_keepalive_interval(void) -{ - return prefs_conf.s2s_keepalive_interval; -} - -extern unsigned int prefs_get_timeout_checkinterval(void) -{ - return prefs_conf.timeout_checkinterval; -} - -extern unsigned int prefs_get_max_game_idletime(void) -{ - return prefs_conf.max_game_idletime; -} - -extern unsigned int prefs_get_lod_realm(void) -{ - return prefs_conf.lod_realm; -} - -extern unsigned int prefs_get_allow_convert(void) -{ - return prefs_conf.allow_convert; -} - -extern char const * d2cs_prefs_get_transfile(void) -{ - return prefs_conf.transfile; -} - -extern char const * prefs_get_d2cs_account_allowed_symbols(void) -{ - return prefs_conf.account_allowed_symbols; -} - -extern unsigned int prefs_get_d2gs_restart_delay(void) -{ - return prefs_conf.d2gs_restart_delay; -} - -extern char const * prefs_get_charlist_sort(void) -{ - return prefs_conf.charlist_sort; -} - -extern char const * prefs_get_charlist_sort_order(void) -{ - return prefs_conf.charlist_sort_order; -} - -extern unsigned int prefs_get_max_connections(void) -{ - return prefs_conf.max_connections; -} diff --git a/d2pack109/src/d2cs/prefs.h b/d2pack109/src/d2cs/prefs.h deleted file mode 100644 index bb98e85..0000000 --- a/d2pack109/src/d2cs/prefs.h +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (C) 2000,2001 Onlyer (onlyer@263.net) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_PREFS_H -#define INCLUDED_PREFS_H - -typedef struct -{ - char const * logfile; - char const * loglevels; - char const * servaddrs; - char const * gameservlist; - char const * bnetdaddr; - char const * charsavedir; - char const * charinfodir; - char const * bak_charsavedir; - char const * bak_charinfodir; - char const * ladderdir; - char const * newbiefile; - char const * motd; - char const * realmname; - char const * d2gs_password; - char const * transfile; - char const * account_allowed_symbols; - unsigned int ladder_refresh_interval; - unsigned int maxchar; - unsigned int listpurgeinterval; - unsigned int gqcheckinterval; - unsigned int s2s_retryinterval; - unsigned int s2s_timeout; - unsigned int s2s_idletime; - unsigned int sq_checkinterval; - unsigned int sq_timeout; - unsigned int maxgamelist; - unsigned int max_game_idletime; - unsigned int gamelist_showall; - unsigned int game_maxlifetime; - unsigned int allow_gamelimit; - unsigned int allow_newchar; - unsigned int idletime; - unsigned int shutdown_delay; - unsigned int shutdown_decr; - unsigned int d2gs_checksum; - unsigned int d2gs_version; - unsigned int check_multilogin; - unsigned int timeout_checkinterval; - unsigned int s2s_keepalive_interval; - unsigned int lod_realm; - unsigned int allow_convert; - unsigned int d2gs_restart_delay; - char const * charlist_sort; - char const * charlist_sort_order; - unsigned int max_connections; -} t_prefs; - -extern int d2cs_prefs_load(char const * filename); -extern int prefs_reload(char const * filename); -extern int d2cs_prefs_unload(void); - -extern char const * d2cs_prefs_get_transfile(void); -extern char const * d2cs_prefs_get_logfile(void); -extern char const * prefs_get_servaddrs(void); -extern char const * prefs_get_charsave_dir(void); -extern char const * prefs_get_charinfo_dir(void); -extern char const * prefs_get_bak_charsave_dir(void); -extern char const * prefs_get_bak_charinfo_dir(void); -extern char const * prefs_get_charsave_newbie(void); -extern char const * prefs_get_motd(void); -extern char const * prefs_get_realmname(void); -extern char const * prefs_get_d2gs_list(void); -extern unsigned int prefs_get_maxchar(void); -extern unsigned int prefs_get_list_purgeinterval(void); -extern unsigned int prefs_get_maxgamelist(void); -extern unsigned int prefs_allow_newchar(void); -extern unsigned int prefs_get_gamequeue_checkinterval(void); -extern unsigned int prefs_get_idletime(void); -extern unsigned int d2cs_prefs_get_shutdown_delay(void); -extern unsigned int d2cs_prefs_get_shutdown_decr(void); -extern char const * prefs_get_bnetdaddr(void); -extern unsigned int prefs_get_s2s_retryinterval(void); -extern unsigned int prefs_get_s2s_timeout(void); -extern unsigned int prefs_get_sq_timeout(void); -extern unsigned int prefs_get_sq_checkinterval(void); -extern unsigned int prefs_get_d2gs_checksum(void); -extern unsigned int prefs_get_d2gs_version(void); -extern unsigned int prefs_get_ladderlist_count(void); -extern unsigned int prefs_get_d2ladder_refresh_interval(void); -extern unsigned int prefs_get_game_maxlifetime(void); -extern char const * prefs_get_ladder_dir(void); -extern char const * d2cs_prefs_get_loglevels(void); -extern unsigned int prefs_allow_gamelist_showall(void); -extern unsigned int prefs_allow_gamelimit(void); -extern unsigned int prefs_check_multilogin(void); -extern char const * prefs_get_d2gs_password(void); -extern unsigned int prefs_get_s2s_idletime(void); -extern unsigned int prefs_get_s2s_keepalive_interval(void); -extern unsigned int prefs_get_timeout_checkinterval(void); -extern unsigned int prefs_get_max_game_idletime(void); -extern unsigned int prefs_get_lod_realm(void); -extern unsigned int prefs_get_allow_convert(void); -extern char const * prefs_get_d2cs_account_allowed_symbols(void); -extern unsigned int prefs_get_d2gs_restart_delay(void); -extern char const * prefs_get_charlist_sort(void); -extern char const * prefs_get_charlist_sort_order(void); -extern unsigned int prefs_get_max_connections(void); - -#endif diff --git a/d2pack109/src/d2cs/s2s.c b/d2pack109/src/d2cs/s2s.c deleted file mode 100644 index ccc60cf..0000000 --- a/d2pack109/src/d2cs/s2s.c +++ /dev/null @@ -1,184 +0,0 @@ -/* - * Copyright (C) 2000,2001 Onlyer (onlyer@263.net) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#include "common/setup_before.h" -#include "setup.h" - -#ifdef HAVE_STDDEF_H -# include -#else -# ifndef NULL -# define NULL ((void *)0) -# endif -#endif -#include -#ifdef HAVE_STRING_H -# include -#else -# ifdef HAVE_STRINGS_H -# include -# endif -# ifdef HAVE_MEMORY_H -# include -# endif -#endif -#include "compat/memset.h" -#include "compat/strdup.h" -#ifdef STDC_HEADERS -# include -#else -# ifdef HAVE_MALLOC_H -# include -# endif -#endif -#include -#include "compat/strerror.h" -#ifdef HAVE_UNISTD_H -# include -#endif -#ifdef HAVE_SYS_TYPES_H -# include -#endif -#ifdef HAVE_SYS_SOCKET_H -# include -#endif -#include "compat/psock.h" -#ifdef HAVE_NETINET_IN_H -# include -#endif -#include "compat/netinet_in.h" -#include - -#include "compat/psock.h" -#include "compat/strtoul.h" -#include "connection.h" -#include "bnetd.h" -#include "net.h" -#include "s2s.h" -#include "common/fdwatch.h" -#include "server.h" -#include "common/eventlog.h" -#include "common/xalloc.h" -#include "common/setup_after.h" - -extern int s2s_check(void) -{ - bnetd_check(); - return 0; -} - -extern int s2s_init(void) -{ - bnetd_init(); - return 0; -} - -extern t_connection * s2s_create(char const * server, unsigned short def_port, t_conn_class class) -{ - struct sockaddr_in addr, laddr; - psock_t_socklen laddr_len; - unsigned int ip; - unsigned short port; - int sock, connected; - t_connection * c; - char * p, * tserver; - - ASSERT(server,NULL); - tserver=xstrdup(server); - p=strchr(tserver,':'); - if (p) { - port=(unsigned short)strtoul(p+1,NULL,10); - *p='\0'; - } else { - port=def_port; - } - - if ((sock=net_socket(PSOCK_SOCK_STREAM))<0) { - eventlog(eventlog_level_error,__FUNCTION__,"error creating s2s socket"); - xfree(tserver); - return NULL; - } - - memset(&addr,0,sizeof(addr)); - addr.sin_family = PSOCK_AF_INET; - addr.sin_port = htons(port); - addr.sin_addr.s_addr= net_inet_addr(tserver); - xfree(tserver); - - eventlog(eventlog_level_info,__FUNCTION__,"try make s2s connection to %s",server); - if (psock_connect(sock,(struct sockaddr *)&addr,sizeof(addr))<0) { - if (psock_errno()!=PSOCK_EWOULDBLOCK && psock_errno() != PSOCK_EINPROGRESS) { - eventlog(eventlog_level_error,__FUNCTION__,"error connecting to %s (psock_connect: %s)",server,strerror(psock_errno())); - psock_close(sock); - return NULL; - } - connected=0; - eventlog(eventlog_level_info,__FUNCTION__,"connection to s2s server %s is in progress",server); - } else { - connected=1; - eventlog(eventlog_level_info,__FUNCTION__,"connected to s2s server %s",server); - } - laddr_len=sizeof(laddr); - memset(&laddr,0,sizeof(laddr)); - ip=port=0; - if (psock_getsockname(sock,(struct sockaddr *)&laddr,&laddr_len)<0) { - eventlog(eventlog_level_error,__FUNCTION__,"unable to get local socket info"); - } else { - if (laddr.sin_family != PSOCK_AF_INET) { - eventlog(eventlog_level_error,__FUNCTION__,"got bad socket family %d",laddr.sin_family); - } else { - ip=ntohl(laddr.sin_addr.s_addr); - port=ntohs(laddr.sin_port); - } - } - if (!(c=d2cs_conn_create(sock,ip,port, ntohl(addr.sin_addr.s_addr), ntohs(addr.sin_port)))) { - eventlog(eventlog_level_error,__FUNCTION__,"error create s2s connection"); - psock_close(sock); - return NULL; - } - if (connected) { - if (conn_add_fd(c,fdwatch_type_read, d2cs_server_handle_tcp)<0) { - eventlog(eventlog_level_error, __FUNCTION__, "error adding socket %d to fdwatch pool (max sockets?)",sock); - d2cs_conn_set_state(c,conn_state_destroy); - return NULL; - } - d2cs_conn_set_state(c,conn_state_init); - } else { - if (conn_add_fd(c, fdwatch_type_write, d2cs_server_handle_tcp)<0) { - eventlog(eventlog_level_error, __FUNCTION__, "error adding socket %d to fdwatch pool (max sockets?)",sock); - d2cs_conn_set_state(c,conn_state_destroy); - return NULL; - } - d2cs_conn_set_state(c,conn_state_connecting); - } - d2cs_conn_set_class(c,class); - return c; -} - -extern int s2s_destroy(t_connection * c) -{ - ASSERT(c,-1); - switch (d2cs_conn_get_class(c)) { - case conn_class_bnetd: - bnetd_destroy(c); - break; - default: - eventlog(eventlog_level_error,__FUNCTION__,"got bad s2s connection class %d",d2cs_conn_get_class(c)); - return -1; - } - return 0; -} diff --git a/d2pack109/src/d2cs/s2s.h b/d2pack109/src/d2cs/s2s.h deleted file mode 100644 index 9c87ba2..0000000 --- a/d2pack109/src/d2cs/s2s.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2000,2001 Onlyer (onlyer@263.net) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_S2S_H -#define INCLUDED_S2S_H - -#include "connection.h" - -extern int s2s_init(void); -extern int s2s_check(void); -extern t_connection * s2s_create(char const * server, unsigned short def_port, t_conn_class class); -extern int s2s_destroy(t_connection * s2s); - -#endif diff --git a/d2pack109/src/d2cs/server.c b/d2pack109/src/d2cs/server.c deleted file mode 100644 index 0483a9a..0000000 --- a/d2pack109/src/d2cs/server.c +++ /dev/null @@ -1,355 +0,0 @@ -/* - * Copyright (C) 2000,2001 Onlyer (onlyer@263.net) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#include "common/setup_before.h" -#include "setup.h" - -#ifdef HAVE_STRING_H -# include -#else -# ifdef HAVE_STRINGS_H -# include -# endif -# ifdef HAVE_MEMORY_H -# include -# endif -#endif -#ifdef STDC_HEADERS -# include -#else -# ifdef HAVE_MALLOC_H -# include -# endif -#endif -#include "compat/memset.h" -#include -#include "compat/strerror.h" -#ifdef TIME_WITH_SYS_TIME -# include -# include -#else -# ifdef HAVE_SYS_TIME_H -# include -# else -# include -# endif -#endif -#ifdef HAVE_FCNTL_H -# include -#else -# ifdef HAVE_SYS_FILE_H -# include -# endif -#endif -#ifdef HAVE_UNISTD_H -# include -#endif -#ifdef HAVE_SYS_SOCKET_H -# include -#endif -#include "compat/psock.h" -#ifdef HAVE_SYS_TYPES_H -# include -#endif -#ifdef HAVE_NETINET_IN_H -# include -#endif -#include "compat/netinet_in.h" -#ifdef HAVE_ARPA_INET_H -# include -#endif -#include "compat/inet_ntoa.h" -#include "compat/psock.h" - -#include "d2gs.h" -#include "net.h" -#include "s2s.h" -#include "gamequeue.h" -#include "game.h" -#include "connection.h" -#include "serverqueue.h" -#include "common/fdwatch.h" -#include "server.h" -#include "prefs.h" -#include "d2ladder.h" -#include "handle_signal.h" -#include "common/addr.h" -#include "common/list.h" -#include "common/hashtable.h" -#include "common/eventlog.h" -#ifdef WIN32 -# include /* for kbhit() and getch() */ -#endif -#include "common/setup_after.h" - -static int server_listen(void); -static int server_accept(int sock); -static int server_handle_timed_event(void); -static int server_handle_socket(void); -static int server_loop(void); -static int server_cleanup(void); - -t_addrlist * server_listen_addrs; - -extern int g_ServiceStatus; - -static int server_listen(void) -{ - t_addr * curr_laddr; - t_addr_data laddr_data; - int sock; - - if (!(server_listen_addrs=addrlist_create(prefs_get_servaddrs(),INADDR_ANY,D2CS_SERVER_PORT))) { - eventlog(eventlog_level_error,__FUNCTION__,"error create listening address list"); - return -1; - } - BEGIN_LIST_TRAVERSE_DATA(server_listen_addrs,curr_laddr) - { - sock=net_listen(addr_get_ip(curr_laddr),addr_get_port(curr_laddr),PSOCK_SOCK_STREAM); - if (sock<0) { - eventlog(eventlog_level_error,__FUNCTION__,"error listen socket"); - return -1; - } - - if (psock_ctl(sock,PSOCK_NONBLOCK)<0) { - eventlog(eventlog_level_error,__FUNCTION__,"error set listen socket in non-blocking mode"); - } - - laddr_data.i = sock; - addr_set_data(curr_laddr,laddr_data); - - if (fdwatch_add_fd(sock, fdwatch_type_read, d2cs_server_handle_accept, curr_laddr)<0) { - eventlog(eventlog_level_error,__FUNCTION__,"error adding socket %d to fdwatch pool (max sockets?)",sock); - psock_close(sock); - return -1; - } - - eventlog(eventlog_level_info,__FUNCTION__,"listen on %s", addr_num_to_addr_str(addr_get_ip(curr_laddr),addr_get_port(curr_laddr))); - } - END_LIST_TRAVERSE_DATA() - return 0; -} - -static int server_accept(int sock) -{ - int csock; - struct sockaddr_in caddr, raddr; - psock_t_socklen caddr_len, raddr_len; - int val; - unsigned int ip; - unsigned short port; - t_connection *cc; - - caddr_len=sizeof(caddr); - memset(&caddr,0,sizeof(caddr)); - csock=psock_accept(sock,(struct sockaddr *)&caddr,&caddr_len); - if (csock<0) { - eventlog(eventlog_level_error,__FUNCTION__,"error accept new connection"); - return -1; - } else eventlog(eventlog_level_info,__FUNCTION__,"accept connection from %s",inet_ntoa(caddr.sin_addr)); - - val=1; - if (psock_setsockopt(csock, PSOCK_SOL_SOCKET, PSOCK_SO_KEEPALIVE, &val,sizeof(val))<0) { - eventlog(eventlog_level_warn,__FUNCTION__,"error set sock option keep alive"); - } - if (psock_ctl(csock, PSOCK_NONBLOCK)<0) { - eventlog(eventlog_level_error,__FUNCTION__,"error set socket to non-blocking mode"); - psock_close(csock); - return -1; - } - - raddr_len=sizeof(raddr); - memset(&raddr,0,sizeof(raddr)); - ip=port=0; - if (psock_getsockname(csock,(struct sockaddr *)&raddr,&raddr_len)<0) { - eventlog(eventlog_level_warn,__FUNCTION__,"unable to get local socket info"); - } else { - if (raddr.sin_family!=PSOCK_AF_INET) { - eventlog(eventlog_level_warn,__FUNCTION__,"got bad socket family %d",raddr.sin_family); - } else { - ip=ntohl(raddr.sin_addr.s_addr); - port=ntohs(raddr.sin_port); - } - } - if (!(cc = d2cs_conn_create(csock,ip,port,ntohl(caddr.sin_addr.s_addr),ntohs(caddr.sin_port)))) { - eventlog(eventlog_level_error,__FUNCTION__,"error create new connection"); - psock_close(csock); - return -1; - } - if (conn_add_fd(cc, fdwatch_type_read, d2cs_server_handle_tcp)<0) { - eventlog(eventlog_level_error,__FUNCTION__,"error adding socket %d to fdwatch pool (max sockets?)",csock); - d2cs_conn_set_state(cc,conn_state_destroy); - return -1; - } - - return 0; -} - -static int server_handle_timed_event(void) -{ - static time_t prev_list_purgetime=0; - static time_t prev_gamequeue_checktime=0; - static time_t prev_s2s_checktime=0; - static time_t prev_sq_checktime=0; - static time_t prev_d2ladder_refresh_time=0; - static time_t prev_s2s_keepalive_time=0; - static time_t prev_timeout_checktime; - time_t now; - - now=time(NULL); - if (now-prev_list_purgetime>(signed)prefs_get_list_purgeinterval()) { - hashtable_purge(d2cs_connlist()); - d2cs_gamelist_check_voidgame(); - prev_list_purgetime=now; - } - if (now-prev_gamequeue_checktime>(signed)prefs_get_gamequeue_checkinterval()) { - gqlist_update_all_clients(); - prev_gamequeue_checktime=now; - } - if (now-prev_s2s_checktime>(signed)prefs_get_s2s_retryinterval()) { - s2s_check(); - prev_s2s_checktime=now; - } - if (now-prev_sq_checktime>(signed)prefs_get_sq_checkinterval()) { - sqlist_check_timeout(); - prev_sq_checktime=now; - } - if (now-prev_d2ladder_refresh_time>(signed)prefs_get_d2ladder_refresh_interval()) { - d2ladder_refresh(); - prev_d2ladder_refresh_time=now; - } - if (now-prev_s2s_keepalive_time>(signed)prefs_get_s2s_keepalive_interval()) { - d2gs_keepalive(); - prev_s2s_keepalive_time=now; - } - if (now-prev_timeout_checktime>(signed)prefs_get_timeout_checkinterval()) { - connlist_check_timeout(); - prev_timeout_checktime=now; - } - return 0; -} - -extern int d2cs_server_handle_accept(void *data, t_fdwatch_type rw) -{ - int sock; - - sock = addr_get_data((t_addr *)data).i; - server_accept(sock); - return 0; -} - -extern int d2cs_server_handle_tcp(void *data, t_fdwatch_type rw) -{ - t_connection *c = (t_connection *)data; - - if (rw & fdwatch_type_read) conn_add_socket_flag(c,SOCKET_FLAG_READ); - if (rw & fdwatch_type_write) conn_add_socket_flag(c,SOCKET_FLAG_WRITE); - if (conn_handle_socket(c)<0) - d2cs_conn_set_state(c, conn_state_destroy); - - return 0; -} - -static int server_handle_socket(void) -{ - switch (fdwatch(BNETD_POLL_INTERVAL)) { - case -1: - if ( -#ifdef PSOCK_EINTR - psock_errno()!=PSOCK_EINTR && -#endif - 1) { - eventlog(eventlog_level_error,__FUNCTION__,"select failed (select: %s)",strerror(psock_errno())); - return -1; - } - /* fall through */ - case 0: - return 0; - default: - break; - } - - fdwatch_handle(); - - return 0; -} - -static int server_loop(void) -{ - unsigned int count; - - count=0; - while (1) { -#ifdef WIN32 - if (g_ServiceStatus<0 && kbhit() && getch()=='q') - signal_quit_wrapper(); - - if (g_ServiceStatus == 0) signal_quit_wrapper(); - - while (g_ServiceStatus == 2) Sleep(1000); -#endif - - if (handle_signal()<0) break; - if (++count>=(1000/BNETD_POLL_INTERVAL)) { - server_handle_timed_event(); - count=0; - } - server_handle_socket(); - d2cs_connlist_reap(); - } - return 0; -} - -static int server_cleanup(void) -{ - t_addr * curr_laddr; - int sock; - - BEGIN_LIST_TRAVERSE_DATA(server_listen_addrs,curr_laddr) - { - sock=addr_get_data(curr_laddr).i; - psock_close(sock); - } - END_LIST_TRAVERSE_DATA() - addrlist_destroy(server_listen_addrs); - return 0; -} - -extern int d2cs_server_process(void) -{ -#ifndef WIN32 - handle_signal_init(); -#endif - if (psock_init()<0) { - eventlog(eventlog_level_error,__FUNCTION__,"failed to init network"); - return -1; - } - eventlog(eventlog_level_info,__FUNCTION__,"network initialized"); - if (s2s_init()<0) { - eventlog(eventlog_level_error,__FUNCTION__,"failed to init s2s connection"); - return -1; - } - if (server_listen()<0) { - eventlog(eventlog_level_error,__FUNCTION__,"failed to setup listen socket"); - return -1; - } - eventlog(eventlog_level_info,__FUNCTION__,"entering server loop"); - server_loop(); - eventlog(eventlog_level_info,__FUNCTION__,"exit from server loop,cleanup"); - server_cleanup(); - return 0; -} diff --git a/d2pack109/src/d2cs/server.h b/d2pack109/src/d2cs/server.h deleted file mode 100644 index 42a0be2..0000000 --- a/d2pack109/src/d2cs/server.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) 2000,2001 Onlyer (onlyer@263.net) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_SERVER_H -#define INCLUDED_SERVER_H - -#include "common/fdwatch.h" - -extern int d2cs_server_process(void); -extern int d2cs_server_handle_tcp(void*,t_fdwatch_type); -extern int d2cs_server_handle_accept(void*,t_fdwatch_type); - -#endif diff --git a/d2pack109/src/d2cs/serverqueue.c b/d2pack109/src/d2cs/serverqueue.c deleted file mode 100644 index d459032..0000000 --- a/d2pack109/src/d2cs/serverqueue.c +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Copyright (C) 2000,2001 Onlyer (onlyer@263.net) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#include "common/setup_before.h" -#include "setup.h" - -#ifdef STDC_HEADERS -# include -#else -# ifdef HAVE_MALLOC_H -# include -# endif -#endif -#ifdef TIME_WITH_SYS_TIME -# include -# include -#else -# ifdef HAVE_SYS_TIME_H -# include -# else -# include -# endif -#endif - -#include "prefs.h" -#include "serverqueue.h" -#include "common/packet.h" -#include "common/list.h" -#include "common/eventlog.h" -#include "common/xalloc.h" -#include "common/setup_after.h" - -static t_list * sqlist_head=NULL; -static unsigned int sqlist_seqno=0; - -extern t_list * sqlist(void) -{ - return sqlist_head; -} - -extern int sqlist_create(void) -{ - sqlist_head=list_create(); - return 0; -} - -extern int sqlist_destroy(void) -{ - t_sq * sq; - - BEGIN_LIST_TRAVERSE_DATA_CONST(sqlist_head,sq) - { - sq_destroy(sq,(t_elem **)curr_elem_); - } - END_LIST_TRAVERSE_DATA_CONST() - - if (list_destroy(sqlist_head)<0) { - eventlog(eventlog_level_error,__FUNCTION__,"error destroy server queue list"); - return -1; - } - sqlist_head=NULL; - return 0; -} - -extern int sqlist_check_timeout(void) -{ - t_sq * sq; - time_t now; - - now=time(NULL); - BEGIN_LIST_TRAVERSE_DATA(sqlist_head, sq) - { - if (now - sq->ctime > prefs_get_sq_timeout()) { - eventlog(eventlog_level_info,__FUNCTION__,"destroying expired server queue %d",sq->seqno); - sq_destroy(sq,&curr_elem_); - } - } - END_LIST_TRAVERSE_DATA() - return 0; -} - -extern t_sq * sqlist_find_sq(unsigned int seqno) -{ - t_sq * sq; - - BEGIN_LIST_TRAVERSE_DATA_CONST(sqlist_head,sq) - { - if (sq->seqno==seqno) return sq; - } - END_LIST_TRAVERSE_DATA_CONST() - return NULL; -} - -extern t_sq * sq_create(unsigned int clientid, t_packet * packet,unsigned int gameid ) -{ - t_sq * sq; - - sq=xmalloc(sizeof(t_sq)); - sq->seqno=++sqlist_seqno; - sq->ctime=time(NULL); - sq->clientid=clientid; - sq->gameid=gameid; - sq->packet=packet; - sq->gametoken=0; - if (packet) packet_add_ref(packet); - list_append_data(sqlist_head,sq); - return sq; -} - -extern int sq_destroy(t_sq * sq,t_elem ** curr) -{ - ASSERT(sq,-1); - if (list_remove_data(sqlist_head,sq,curr)<0) { - eventlog(eventlog_level_error,__FUNCTION__,"error remove server queue from list"); - return -1; - } - if (sq->packet) packet_del_ref(sq->packet); - xfree(sq); - return 0; -} - -extern unsigned int sq_get_clientid(t_sq const * sq) -{ - ASSERT(sq,0); - return sq->clientid; -} - -extern t_packet * sq_get_packet(t_sq const * sq) -{ - ASSERT(sq,NULL); - return sq->packet; -} - -extern unsigned int sq_get_gameid(t_sq const * sq) -{ - ASSERT(sq,0); - return sq->gameid; -} - -extern unsigned int sq_get_seqno(t_sq const * sq) -{ - ASSERT(sq,0); - return sq->seqno; -} - -extern int sq_set_gametoken(t_sq * sq, unsigned int gametoken) -{ - ASSERT(sq,-1); - sq->gametoken=gametoken; - return 0; -} - -extern unsigned int sq_get_gametoken(t_sq const * sq) -{ - ASSERT(sq,0); - return sq->gametoken; -} - diff --git a/d2pack109/src/d2cs/serverqueue.h b/d2pack109/src/d2cs/serverqueue.h deleted file mode 100644 index af036ca..0000000 --- a/d2pack109/src/d2cs/serverqueue.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2000,2001 Onlyer (onlyer@263.net) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_SERVERQUEUE_H -#define INCLUDED_SERVERQUEUE_H - -#include "common/list.h" -#include "common/packet.h" - - -typedef struct serverqueue -{ - unsigned int seqno; - unsigned int ctime; - unsigned int clientid; - t_packet * packet; - unsigned int gameid; - unsigned int gametoken; -} t_sq; - -extern t_list * sqlist(void); -extern int sqlist_create(void); -extern int sqlist_destroy(void); - -extern int sq_destroy(t_sq * sq,t_elem ** curr); -extern int sqlist_check_timeout(void); -extern t_sq * sqlist_find_sq(unsigned int seqno); -extern t_sq * sq_create(unsigned int clientid, t_packet * packet,unsigned int gameid); - -extern unsigned int sq_get_clientid(t_sq const * sq); -extern unsigned int sq_get_gameid(t_sq const * sq); -extern unsigned int sq_get_seqno(t_sq const * sq); -extern int sq_set_gametoken(t_sq * sq, unsigned int gametoken); -extern unsigned int sq_get_gametoken(t_sq const * sq); -extern t_packet * sq_get_packet(t_sq const * sq); - -#endif diff --git a/d2pack109/src/d2cs/setup.h b/d2pack109/src/d2cs/setup.h deleted file mode 100644 index 780e870..0000000 --- a/d2pack109/src/d2cs/setup.h +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Copyright (C) 2000,2001 Onlyer (onlyer@263.net) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_D2CS_SETUP_H -#define INCLUDED_D2CS_SETUP_H - -/* FIXME: what is this for? */ -#ifndef D2CS -# define D2CS -#endif - - -#ifndef min -# define min(a,b) (((a)>(b))?(b):(a)) -#endif -#ifndef max -# define max(a,b) (((a)>(b))?(a):(b)) -#endif - -#define tf(a) ((a)?1:0) - -#define strcmp_charname strcasecmp -#define strncmp_charname strncasencmp - -#define BEGIN_LIST_TRAVERSE_DATA(list,data) \ -{\ - t_elem * curr_elem_;\ - for (curr_elem_=list_get_first(list); curr_elem_ && (data=elem_get_data(curr_elem_)); \ - curr_elem_=elem_get_next(list,curr_elem_)) - -#define END_LIST_TRAVERSE_DATA() \ -} - -#define BEGIN_LIST_TRAVERSE_DATA_CONST(list,data)\ -{\ - t_elem const * curr_elem_;\ - for (curr_elem_=list_get_first_const(list); curr_elem_ && (data=elem_get_data(curr_elem_)); \ - curr_elem_=elem_get_next_const(list,curr_elem_)) - -#define END_LIST_TRAVERSE_DATA_CONST() \ -} - -#define BEGIN_HASHTABLE_TRAVERSE_DATA(hashtable,data)\ -{\ - t_entry * curr_entry_;\ - for (curr_entry_=hashtable_get_first(hashtable); curr_entry_ && (data=entry_get_data(curr_entry_));\ - curr_entry_=entry_get_next(curr_entry_)) - -#define END_HASHTABLE_TRAVERSE_DATA() \ -} - -#define BEGIN_HASHTABLE_TRAVERSE_MATCHING_DATA(hashtable,data,hash)\ -{\ - t_entry * curr_entry_;\ - for (curr_entry_=hashtable_get_first_matching(hashtable,hash); \ - curr_entry_ && (data=entry_get_data(curr_entry_)); \ - curr_entry_ = entry_get_next_matching(curr_entry_)) - -#define END_HASHTABLE_TRAVERSE_DATA() \ -} - -#define CASE(condition,func) case condition:\ - func;\ - break;\ - -#define ASSERT(var,retval) if (!var) { eventlog(eventlog_level_error,__FUNCTION__,"got NULL " #var); return retval; } -#define DECLARE_PACKET_HANDLER(handler) static int handler(t_connection *, t_packet *); -#define NELEMS(s) sizeof(s)/sizeof(s[0]) - -#define MAX_SAVEFILE_SIZE 32 * 1024 -#define MAX_CHARNAME_LEN 16 -#define MAX_GAMENAME_LEN 16 -#define MAX_GAMEPASS_LEN 16 -#define MAX_GAMEDESC_LEN 32 -#define MAX_ACCTNAME_LEN 16 -#define MAX_REALMNAME_LEN 32 -#define MIN_NAME_LEN 2 -#define MAX_CHAR_PER_GAME 8 -#define D2CS_SERVER_PORT 6113 -#define MAX_GAME_IDLE_TIME 0 -#define DEFAULT_S2S_RETRYINTERVAL 60 -#define DEFAULT_S2S_TIMEOUT 60 -#define DEFAULT_SQ_CHECKINTERVAL 300 -#define DEFAULT_SQ_TIMEOUT 300 -#define DEFAULT_REALM_NAME "D2CS" -#define DEFAULT_SHUTDOWN_DELAY 300 -#define DEFAULT_SHUTDOWN_DECR 60 -#define DEFAULT_S2S_IDLETIME 300 -#define DEFAULT_S2S_KEEPALIVE_INTERVAL 60 -#define DEFAULT_TIMEOUT_CHECKINTERVAL 60 -#define DEFAULT_ACC_ALLOWED_SYMBOLS "-_[]" -#define DEFAULT_D2GS_RESTART_DELAY 300 - -#ifndef D2CS_DEFAULT_CONF_FILE -# define D2CS_DEFAULT_CONF_FILE "conf/d2cs.conf" -#endif - -#define DEFAULT_LOG_FILE "/usr/local/var/d2cs.log" -#define DEFAULT_LOG_LEVELS "info,warn,error" -#define DEFAULT_MEMLOG_FILE "/tmp/d2cs-mem.log" - -#define D2CS_SERVER_ADDRS "0.0.0.0" -#define D2GS_SERVER_LIST "192.168.0.1" -#define BNETD_SERVER_LIST "192.168.0.1" -#define MAX_D2GAME_NUMBER 30 -#define MAX_CHAR_PER_ACCT 8 -// MAX_MAX_CHAR_PER_ACCT is needed cause D2 client can only handle 21 character -#define MAX_MAX_CHAR_PER_ACCT 21 -#define MAX_CLIENT_IDLETIME 30 * 60 - -#define D2CS_CHARINFO_DIR "/usr/local/var/charinfo" -#define D2CS_CHARSAVE_DIR "/usr/local/var/charsave" -#define D2CS_BAK_CHARINFO_DIR "/usr/local/var/bak/charinfo" -#define D2CS_BAK_CHARSAVE_DIR "/usr/local/var/bak/charsave" -#define D2CS_CHARSAVE_NEWBIE "/usr/local/var/files/newbie.save" -#define D2CS_TRANS_FILE "/usr/local/etc/address_translation.conf" -#define D2CS_LADDER_DIR "/usr/local/var/ladders" - -#define D2CS_MOTD "No MOTD yet" - -#define LIST_PURGE_INTERVAL 300 -#define GAMEQUEUE_CHECK_INTERVAL 60 - -#define MAX_GAME_LIST 20 - -#endif diff --git a/d2pack109/src/d2cs/version.h b/d2pack109/src/d2cs/version.h deleted file mode 100644 index c34fa80..0000000 --- a/d2pack109/src/d2cs/version.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (C) 2000,2001 Onlyer (onlyer@263.net) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_VERSION_H -#define INCLUDED_VERSION_H - -#define D2CS_VERSION_NUMBER 0x00010004 -#define D2CS_VERSION_STRING "0.1.0b4" -#define D2CS_VERSION "D2CS Version " D2CS_VERSION_STRING " Built " __DATE__ - -#endif diff --git a/d2pack109/src/d2cs/xstring.c b/d2pack109/src/d2cs/xstring.c deleted file mode 100644 index 3e0c576..0000000 --- a/d2pack109/src/d2cs/xstring.c +++ /dev/null @@ -1,269 +0,0 @@ -/* - * Copyright (C) 2000,2001 Onlyer (onlyer@263.net) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#include "common/setup_before.h" -#include "setup.h" - -#include -#include -#ifdef HAVE_STRING_H -# include -#else -# ifdef HAVE_STRINGS_H -# include -# endif -# ifdef HAVE_MEMORY_H -# include -# endif -#endif -#ifdef STDC_HEADERS -# include -#else -# ifdef HAVE_MALLOC_H -# include -# endif -#endif -#include "compat/memcpy.h" -#include "compat/memmove.h" -#include "compat/strdup.h" - -#include "common/xalloc.h" -#include "xstring.h" -#include "common/setup_after.h" - -extern char * strtolower(char * str) -{ - unsigned int i; - unsigned char ch; - - if (!str) return NULL; - for (i=0; (ch=str[i]); i++) { - if ((isupper(ch))) str[i]=ch+('a'-'A'); - } - return str; -} - -extern unsigned char xtoi(unsigned char ch) -{ - unsigned char retval; - - if (isalpha(ch)) retval=tolower(ch); - else retval=ch; - if (retval < 'A') retval -= ('0'-0); - else retval -= ('a' - 0xa); - return retval; -} - -extern char * str_strip_affix(char * str, char const * affix) -{ - unsigned int i, j, n; - int match; - - if (!str) return NULL; - if (!affix) return str; - for (i=0; str[i]; i++) { - match=0; - for (n=0; affix[n]; n++) { - if (str[i]==affix[n]) { - match=1; - break; - } - } - if (!match) break; - } - for (j=strlen(str)-1; j>=i; j--) { - match=0; - for (n=0; affix[n]; n++) { - if (str[j]==affix[n]) { - match=1; - break; - } - } - if (!match) break; - } - if (i>j) { - str[0]='\0'; - } else { - memmove(str,str+i,j-i+1); - str[j-i+1]='\0'; - } - return str; -} - -extern char * hexstrdup(unsigned char const * src) -{ - char * dest; - int len; - - if (!src) return NULL; - dest=xstrdup(src); - len=hexstrtoraw(src,dest,strlen(dest)+1); - dest[len]='\0'; - return dest; -} - -extern unsigned int hexstrtoraw(unsigned char const * src, char * data, unsigned int datalen) -{ - unsigned char ch; - unsigned int i, j; - - for (i=0, j=0; j=n ) { - n += SPLIT_STRING_INCREASEMENT; - pindex=(int *)xrealloc(pindex,n * sizeof(int)); - } - pindex[*count]=j; - (*count)++; - if (str[i]=='"') { - i++; - while (str[i]) { - if (str[i]=='\\') { - i++; - if (!str[i]) break; - } else if (str[i]=='"') { - i++; - break; - } - temp[j++]=str[i++]; - } - } else { - while (str[i] && str[i] != ' ' && str[i] != '\t') { - temp[j++]=str[i++]; - } - } - temp[j++]='\0'; - } - index_size= *count * sizeof(char *); - if (!index_size) { - xfree(temp); - xfree(pindex); - return NULL; - } - result=xmalloc(j+index_size); - memcpy(result+index_size,temp,j); - - ptrindex=xmalloc(*count * sizeof (char*)); - for (i=0; i< *count; i++) { - ptrindex[i] = result + index_size + pindex[i]; - } - memcpy(result,ptrindex,index_size); - xfree(temp); - xfree(pindex); - xfree(ptrindex); - return (char * *)result; -} - -#define COMBINE_STRING_INIT_LEN 1024 -#define COMBINE_STRING_INCREASEMENT 1024 -extern char * arraytostr(char * * array, char const * delim, int count) -{ - int i; - unsigned int n; - char * result; - int need_delim; - - if (!delim || !array) return NULL; - - n=COMBINE_STRING_INIT_LEN; - result=xmalloc(n); - result[0]='\0'; - - need_delim=0; - for (i=0; i=n) { - n+=COMBINE_STRING_INCREASEMENT; - result=xrealloc(result,n); - } - if (need_delim) { - strcat(result,delim); - } - strcat(result,array[i]); - need_delim=1; - } - result=xrealloc(result,strlen(result)+1); - return result; -} - diff --git a/d2pack109/src/d2cs/xstring.h b/d2pack109/src/d2cs/xstring.h deleted file mode 100644 index 54f4018..0000000 --- a/d2pack109/src/d2cs/xstring.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (C) 2000,2001 Onlyer (onlyer@263.net) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_XSTRING_H -#define INCLUDED_XSTRING_H - -extern char * strtolower(char * str); -extern char * hexstrdup(unsigned char const * src); -extern unsigned int hexstrtoraw(unsigned char const * src, char * data, unsigned int datalen); -extern unsigned char xtoi(unsigned char ch); -extern char * * strtoargv(char const * str, unsigned int * count); -extern char * arraytostr(char * * array, char const * delim, int count); -extern char * str_strip_affix(char * str, char const * affix); - -#endif diff --git a/d2pack109/src/d2dbs/charlock.c b/d2pack109/src/d2dbs/charlock.c deleted file mode 100644 index cadbf5e..0000000 --- a/d2pack109/src/d2dbs/charlock.c +++ /dev/null @@ -1,267 +0,0 @@ -/* - * Copyright (C) 2001 faster (lqx@cic.tsinghua.edu.cn) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#include "common/setup_before.h" -#include "setup.h" - -#include -#ifdef STDC_HEADERS -# include -#else -# ifdef HAVE_MALLOC_H -# include -# endif -#endif -#ifdef HAVE_STRING_H -# include -#else -# ifdef HAVE_STRINGS_H -# include -# endif -# ifdef HAVE_MEMORY_H -# include -# endif -#endif -#include "compat/strcasecmp.h" -#include -#ifdef HAVE_LIMITS_H -# include -#endif - -#include "charlock.h" -#include "common/introtate.h" -#include "common/xalloc.h" -#include "common/setup_after.h" - -/* FIXME: for simplification, no multiple realm support now */ - -/* local functions */ -static int cl_insert_to_gsq_list(unsigned int gsid, t_charlockinfo *pcl); -static int cl_delete_from_gsq_list(t_charlockinfo *pcl); -static unsigned int string_hash(char const *string); - - -/* variables */ -static unsigned int clitbl_len = 0; -static unsigned int gsqtbl_len = 0; -static t_charlockinfo * * clitbl = NULL; -static t_charlockinfo * * gsqtbl = NULL; - - -int cl_init(unsigned int tbllen, unsigned int maxgs) -{ - if (!tbllen || !maxgs) return -1; - cl_destroy(); - - clitbl = (t_charlockinfo**)xmalloc(tbllen*sizeof(t_charlockinfo**)); - gsqtbl = (t_charlockinfo**)xmalloc(maxgs*sizeof(t_charlockinfo**)); - memset(clitbl, 0, tbllen*sizeof(t_charlockinfo**)); - memset(gsqtbl, 0, maxgs*sizeof(t_charlockinfo**)); - clitbl_len = tbllen; - gsqtbl_len = maxgs; - return 0; -} - - -int cl_destroy(void) -{ - unsigned int i; - t_charlockinfo * ptl, * ptmp; - - if (clitbl) { - for (i=0; inext; - xfree(ptmp); - } - } - xfree(clitbl); - } - if (gsqtbl) xfree(gsqtbl); - clitbl = gsqtbl = NULL; - clitbl_len = gsqtbl_len = 0; - return 0; -} - - -int cl_query_charlock_status(unsigned char *charname, - unsigned char *realmname, unsigned int *gsid) -{ - t_charlockinfo *pcl; - unsigned int hashval; - - if (!charname || !realmname) return -1; - if (!clitbl_len || !gsqtbl) return -1; - if (strlen(charname)>=MAX_CHARNAME_LEN) return -1; - - hashval = string_hash(charname) % clitbl_len; - pcl = clitbl[hashval]; - while(pcl) - { - if (strcasecmp(pcl->charname, charname) == 0) { - *gsid = pcl->gsid; - return 1; /* found the char, it is locked */ - } - pcl = pcl->next; - } - return 0; /* not found, it is unlocked */ -} - - -int cl_lock_char(unsigned char *charname, - unsigned char *realmname, unsigned int gsid) -{ - t_charlockinfo *pcl, *ptmp; - unsigned int hashval; - - if (!charname || !realmname) return -1; - if (!clitbl_len || !gsqtbl) return -1; - if (strlen(charname)>=MAX_CHARNAME_LEN) return -1; - - hashval = string_hash(charname) % clitbl_len; - pcl = clitbl[hashval]; - ptmp = NULL; - while(pcl) - { - if (strcasecmp(pcl->charname, charname) == 0) - return 0; /* found the char is already locked */ - ptmp = pcl; - pcl = pcl->next; - } - - /* not found, locked it */ - pcl = (t_charlockinfo*)xmalloc(sizeof(t_charlockinfo)); - memset(pcl, 0, sizeof(t_charlockinfo)); - strncpy(pcl->charname, charname, MAX_CHARNAME_LEN-1); - strncpy(pcl->realmname, realmname, MAX_REALMNAME_LEN-1); - pcl->gsid = gsid; - - /* add to hash table link list */ - if (ptmp) ptmp->next = pcl; - else clitbl[hashval] = pcl; - /* add to gs specified link list */ - cl_insert_to_gsq_list(gsid, pcl); - - return 0; -} - - -int cl_unlock_char(unsigned char *charname, unsigned char *realmname) -{ - t_charlockinfo *pcl, *ptmp; - unsigned int hashval; - - if (!charname || !realmname) return -1; - if (!clitbl_len || !gsqtbl) return 0; - if (strlen(charname)>=MAX_CHARNAME_LEN) return -1; - - hashval = string_hash(charname) % clitbl_len; - pcl = clitbl[hashval]; - ptmp = NULL; - while(pcl) - { - if (strcasecmp(pcl->charname, charname) == 0) { - cl_delete_from_gsq_list(pcl); - if (ptmp) ptmp->next = pcl->next; - else clitbl[hashval] = pcl->next; - xfree(pcl); - return 0; - } - ptmp = pcl; - pcl = pcl->next; - } - return 0; -} - - -int cl_unlock_all_char_by_gsid(unsigned int gsid) -{ - unsigned int index_pos; - t_charlockinfo *pcl, *pnext; - - index_pos = gsid % gsqtbl_len; - pcl = gsqtbl[index_pos]; - while(pcl) - { - pnext = pcl->gsqnext; - cl_unlock_char(pcl->charname, pcl->realmname); - pcl = pnext; - } - return 0; -} - - -static int cl_insert_to_gsq_list(unsigned int gsid, t_charlockinfo *pcl) -{ - unsigned int index_pos; - t_charlockinfo *ptmp; - - if (!pcl) return -1; - - index_pos = gsid % gsqtbl_len; - ptmp = gsqtbl[index_pos]; - gsqtbl[index_pos] = pcl; - if (ptmp) { - pcl->gsqnext = ptmp; - ptmp->gsqprev = pcl; - } - return 0; -} - - -static int cl_delete_from_gsq_list(t_charlockinfo *pcl) -{ - unsigned int index_pos; - t_charlockinfo *pprev, *pnext; - - if (!pcl) return -1; - - index_pos = (pcl->gsid) % gsqtbl_len; - pprev = pcl->gsqprev; - pnext = pcl->gsqnext; - if (pprev) pprev->gsqnext = pnext; - else gsqtbl[index_pos] = pnext; - if (pnext) pnext->gsqprev = pprev; - - return 0; -} - - -static unsigned int string_hash(char const *string) -{ - unsigned int i; - unsigned int pos; - unsigned int hash; - unsigned int ch; - - if (!string) return 0; - - for (hash=0,pos=0,i=0; i -#else -# ifndef NULL -# define NULL ((void *)0) -# endif -#endif -#include -#ifdef HAVE_STRING_H -# include -#else -# ifdef HAVE_STRINGS_H -# include -# endif -# ifdef HAVE_MEMORY_H -# include -# endif -#endif - -#include "version.h" -#include "cmdline_parse.h" -#include "d2cs/conf.h" -#include "common/eventlog.h" -#include "common/setup_after.h" - -static t_conf_table param_conf_table[]={ - { "-c", offsetof(t_param,prefs_file), conf_type_str, 0, D2DBS_DEFAULT_CONF_FILE}, - { "-l", offsetof(t_param,logfile), conf_type_str, 0, NULL }, - { "-h", offsetof(t_param,help), conf_type_bool,0, NULL }, - { "--help", offsetof(t_param,help), conf_type_bool,0, NULL }, - { "-v", offsetof(t_param,version), conf_type_bool,0, NULL }, - { "--version", offsetof(t_param,version), conf_type_bool,0, NULL }, - { "-f", offsetof(t_param,foreground), conf_type_bool,0, NULL }, - { "--foreground",offsetof(t_param,foreground), conf_type_bool,0, NULL }, - { "-D", offsetof(t_param,debugmode), conf_type_bool,0, NULL }, - { "--debug", offsetof(t_param,debugmode), conf_type_bool,0, NULL }, -#ifdef WIN32 - { "--service", offsetof(t_param,run_as_service),conf_type_bool,0, NULL }, - { "-s", offsetof(t_param,make_service), conf_type_str, 0, NULL }, -#endif - { NULL, 0, conf_type_none,0, NULL } -}; - -static t_param cmdline_param; - -static char help_message[]="Usage: d2dbs []\n" -" -m : set memory debug logging file to FILE\n" -" -c : set configuration file to FILE\n" -" -l : set log to FILE\n" -" -h, --help: show this help message and exit\n" -" -v, --version: show version information and exit\n" -" -f, --foreground: start in foreground mode (don`t daemonize)\n" -" -D, --debug: run in debug mode (run in foreground and log to stdout)\n" -#ifdef WIN32 -" Running as service functions:\n" -" --service run as service\n" -" -s install install service\n" -" -s uninstall uninstall service\n" -#endif -"\n" -"Notes:\n" -" 1.You should always use absolute path here for all FILE names\n\n"; - -extern void d2dbs_cmdline_show_help(void) -{ - fprintf(stderr,help_message); - return; -} - -extern void d2dbs_cmdline_show_version(void) -{ - fprintf(stderr,D2DBS_VERSION); - fprintf(stderr,"\n\n"); - return; -} - -extern int d2dbs_cmdline_parse(int argc, char ** argv) -{ - memset(&cmdline_param,0, sizeof(cmdline_param)); - if (conf_parse_param(argc, argv, param_conf_table, &cmdline_param, sizeof(cmdline_param))<0) { - return -1; - } - return 0; -} - -extern int d2dbs_cmdline_cleanup(void) -{ - return conf_cleanup(param_conf_table, &cmdline_param, sizeof(cmdline_param)); -} - -extern char const * d2dbs_cmdline_get_prefs_file(void) -{ - return cmdline_param.prefs_file; -} - -extern unsigned int d2dbs_cmdline_get_help(void) -{ - return cmdline_param.help; -} - -extern unsigned int d2dbs_cmdline_get_version(void) -{ - return cmdline_param.version; -} - -extern unsigned int d2dbs_cmdline_get_foreground(void) -{ - return cmdline_param.foreground; -} - -extern char const * d2dbs_cmdline_get_logfile(void) -{ - return cmdline_param.logfile; -} - -extern unsigned int d2dbs_cmdline_get_debugmode(void) -{ - return cmdline_param.debugmode; -} - -#ifdef WIN32 -extern unsigned int d2dbs_cmdline_get_run_as_service(void) -{ - return cmdline_param.run_as_service; -} - -extern char const * d2dbs_cmdline_get_make_service(void) -{ - return cmdline_param.make_service; -} - -#endif diff --git a/d2pack109/src/d2dbs/cmdline_parse.h b/d2pack109/src/d2dbs/cmdline_parse.h deleted file mode 100644 index a445d25..0000000 --- a/d2pack109/src/d2dbs/cmdline_parse.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) 2000,2001 Onlyer (onlyer@263.net) - * Copyright (C) 2001 sousou (liupeng.cs@263.net) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_CMDLINE_PARSE_H -#define INCLUDED_CMDLINE_PARSE_H - -typedef struct -{ - char const * prefs_file; - char const * logfile; - unsigned int foreground; - unsigned int help; - unsigned int version; - unsigned int debugmode; - unsigned int run_as_service; - char const * make_service; -} t_param; - -extern int d2dbs_cmdline_parse(int argc, char ** argv); -extern int d2dbs_cmdline_cleanup(void); -extern void d2dbs_cmdline_show_help(void); -extern void d2dbs_cmdline_show_version(void); -extern char const * d2dbs_cmdline_get_prefs_file(void); -extern char const * d2dbs_cmdline_get_logfile(void); -extern unsigned int d2dbs_cmdline_get_version(void); -extern unsigned int d2dbs_cmdline_get_help(void); -extern unsigned int d2dbs_cmdline_get_foreground(void); -extern unsigned int d2dbs_cmdline_get_debugmode(void); -#ifdef WIN32 -extern unsigned int d2dbs_cmdline_get_run_as_service(void); -extern char const * d2dbs_cmdline_get_make_service(void); -#endif - -#endif diff --git a/d2pack109/src/d2dbs/d2ladder.c b/d2pack109/src/d2dbs/d2ladder.c deleted file mode 100644 index d30fc5c..0000000 --- a/d2pack109/src/d2dbs/d2ladder.c +++ /dev/null @@ -1,965 +0,0 @@ -/* - * Copyright (C) 2001 sousou (liupeng.cs@263.net) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#include "common/setup_before.h" -#include "setup.h" - -#ifdef HAVE_STDDEF_H -# include -#else -# ifndef NULL -# define NULL ((void *)0) -# endif -#endif -#ifdef STDC_HEADERS -# include -#else -# ifdef HAVE_MALLOC_H -# include -# endif -#endif -#include -#include -#ifdef HAVE_STRING_H -# include -#else -# ifdef HAVE_STRINGS_H -# include -# endif -# ifdef HAVE_MEMORY_H -# include -# endif -#endif -#ifdef HAVE_SYS_TYPES_H -# include -#endif -#ifdef HAVE_SYS_STAT_H -# include -#endif -#ifdef HAVE_SYS_FILE_H -#include -#endif -#ifdef HAVE_FCNTL_H -# include -#else -# ifdef HAVE_SYS_FILE_H -# include -# endif -#endif -#ifdef HAVE_UNISTD_H -# include -#endif -#include "compat/rename.h" -#include "d2ladder.h" -#include "prefs.h" -#include "common/tag.h" -#include "common/list.h" -#include "common/eventlog.h" -#include "compat/strncasecmp.h" -#include "d2cs/d2charfile.h" -#include "common/xalloc.h" -#include "common/setup_after.h" - -char * d2ladder_ladder_file = NULL; -char * d2ladder_backup_file = NULL; - -t_d2ladderlist * d2ladder_list = NULL; -unsigned long d2ladder_maxtype; -int d2ladder_change_count=0; -int d2ladder_need_rebuild = 0; -char * XMLname = "d2ladder.xml"; - - -int d2ladderlist_init(void); -int d2ladderlist_destroy(void); -int d2ladder_empty(void); -int d2ladder_initladderfile(void); - -t_d2ladder * d2ladderlist_find_type(unsigned int type); - -int d2ladder_check(void); -int d2ladder_readladder(void); - -int d2ladder_insert(t_d2ladder * d2ladder,t_d2ladder_info * pcharladderinfo); -int d2ladder_find_char_all(t_d2ladder * d2ladder, t_d2ladder_info * info); -int d2ladder_find_pos(t_d2ladder * d2ladder, t_d2ladder_info * info); -int d2ladder_update_info_and_pos(t_d2ladder * d2ladder, t_d2ladder_info * info, int oldpos, int newpos); -int d2ladder_checksum(unsigned char const * data, unsigned int len,unsigned int offset); -int d2ladder_checksum_set(void); -int d2ladder_checksum_check(void); - - -extern int d2ladder_update(t_d2ladder_info * pcharladderinfo) -{ - t_d2ladder * d2ladder; - unsigned short hardcore,expansion,status; - unsigned char class; - unsigned int ladder_overall_type,ladder_class_type; - - if (!pcharladderinfo->charname[0]) return 0; - class=pcharladderinfo->class; - status=pcharladderinfo->status; - - hardcore=charstatus_get_hardcore(status); - expansion=charstatus_get_expansion(status); - ladder_overall_type=0; - if (!expansion && class> D2CHAR_CLASS_MAX ) return -1; - if (expansion && class> D2CHAR_EXP_CLASS_MAX ) return -1; - if (hardcore && expansion) { - ladder_overall_type=D2LADDER_EXP_HC_OVERALL; - } else if (!hardcore && expansion) { - ladder_overall_type=D2LADDER_EXP_STD_OVERALL; - } else if (hardcore && !expansion) { - ladder_overall_type=D2LADDER_HC_OVERALL; - } else if (!hardcore && !expansion) { - ladder_overall_type=D2LADDER_STD_OVERALL; - } - - ladder_class_type=ladder_overall_type + class+1; - - d2ladder=d2ladderlist_find_type(ladder_overall_type); - if(d2ladder_insert(d2ladder,pcharladderinfo)==1) { - d2ladder_change_count++; - } - - d2ladder=d2ladderlist_find_type(ladder_class_type); - if(d2ladder_insert(d2ladder,pcharladderinfo)==1) { - d2ladder_change_count++; - } - return 0; -} - -int d2ladder_initladderfile(void) -{ - FILE * fdladder; - t_d2ladderfile_ladderindex lhead[D2LADDER_MAXTYPE]; - t_d2ladderfile_header fileheader; - int start; - unsigned long maxtype; - t_d2ladderfile_ladderinfo emptydata; - unsigned int i,j, number; - - maxtype=D2LADDER_MAXTYPE; - start=sizeof(t_d2ladderfile_header)+sizeof(lhead); - for(i=0;iD2LADDER_HC_OVERALL && i<=D2LADDER_HC_OVERALL+D2CHAR_CLASS_MAX +1) || - (i>D2LADDER_STD_OVERALL && i<=D2LADDER_STD_OVERALL+D2CHAR_CLASS_MAX +1) || - (i>D2LADDER_EXP_HC_OVERALL && i<=D2LADDER_EXP_HC_OVERALL+D2CHAR_EXP_CLASS_MAX +1) || - (i>D2LADDER_EXP_STD_OVERALL && i<=D2LADDER_EXP_STD_OVERALL+D2CHAR_EXP_CLASS_MAX +1)) { - number=D2LADDER_MAXNUM; - } else { - number=0; - } - bn_int_set(&lhead[i].number,number); - start += number*sizeof(emptydata); - } - memset(&emptydata,0,sizeof(emptydata)); - if (!d2ladder_ladder_file) return -1; - fdladder=fopen(d2ladder_ladder_file,"wb"); - if(fdladder) { - bn_int_set(&fileheader.maxtype,maxtype); - bn_int_set(&fileheader.checksum,0); - fwrite(&fileheader,1,sizeof(fileheader),fdladder); - fwrite(lhead,1,sizeof(lhead),fdladder); - for(i=0;iexperience < prefs_get_ladderupdate_threshold()) return -1; - - i=d2ladder->len; - while (i--) { - if (d2ladder->info[i].experience > info->experience) { - if (strncasecmp(d2ladder->info[i].charname,info->charname, MAX_CHARNAME_LEN)) { - i++; - } - break; - } - if (i<=0) break; - } - return i; -} - - -int d2ladder_insert(t_d2ladder * d2ladder,t_d2ladder_info * info) -{ - int oldpos, newpos; - - newpos=d2ladder_find_pos(d2ladder,info); - /* we currectly do nothing when character is being kick out of ladder for simple */ - /* - if (newpos<0 || newpos >= d2ladder->len) return 0; - */ - oldpos=d2ladder_find_char_all(d2ladder,info); - return d2ladder_update_info_and_pos(d2ladder,info,oldpos,newpos); -} - -int d2ladder_find_char_all(t_d2ladder * d2ladder, t_d2ladder_info * info) -{ - int i; - t_d2ladder_info * ladderdata; - - if (!d2ladder || !info) return -1; - ladderdata=d2ladder->info; - if (!ladderdata) return -1; - i=d2ladder->len; - while (i--) { - if (!strncmp(ladderdata[i].charname,info->charname,MAX_CHARNAME_LEN)) return i; - } - return -1; -} - -int d2ladder_update_info_and_pos(t_d2ladder * d2ladder, t_d2ladder_info * info, int oldpos, int newpos) -{ - int i; - int direction; - int outflag; - t_d2ladder_info * ladderdata; - - if (!d2ladder || !info) return -1; - ladderdata=d2ladder->info; - if (!ladderdata) return -1; - - /* character not in ladder before */ - outflag=0; - if (oldpos < 0 || oldpos >= (signed)d2ladder->len) { - oldpos = d2ladder->len-1; - } - if (newpos < 0 || newpos >= (signed)d2ladder->len) { - newpos = d2ladder->len-1; - outflag = 1; - } - if ((oldpos == (signed)d2ladder->len -1) && outflag) { - return 0; - } - if (newpos > oldpos && !outflag ) newpos--; - direction = (newpos > oldpos)? 1: -1; - for (i=oldpos; i!=newpos; i+=direction) { - ladderdata[i] = ladderdata[i+direction]; - } - ladderdata[i]=*info; - return 1; -} - - -extern int d2ladder_rebuild(void) -{ - d2ladder_empty(); - d2ladder_need_rebuild = 0; - return 0; -} - -int d2ladder_check(void) -{ - if (!d2ladder_ladder_file) return -1; - if (!d2ladder_backup_file) return -1; - if(d2ladder_checksum_check()!=1) { - eventlog(eventlog_level_error,__FUNCTION__,"ladder file checksum error,try to use backup file"); - if (p_rename(d2ladder_backup_file,d2ladder_ladder_file)==-1) { - eventlog(eventlog_level_error,__FUNCTION__,"error rename %s to %s", d2ladder_backup_file,d2ladder_ladder_file); - } - if(d2ladder_checksum_check()!=1) { - eventlog(eventlog_level_error,__FUNCTION__,"ladder backup file checksum error,rebuild ladder"); - if (d2ladder_initladderfile()<0) return -1; - else { - d2ladder_need_rebuild=1; - return 0; - } - } - } - return 1; -} - - -t_d2ladder * d2ladderlist_find_type(unsigned int type) -{ - t_d2ladder * d2ladder; - t_elem const * elem; - - if (!d2ladder_list) { - eventlog(eventlog_level_error,__FUNCTION__,"got NULL d2ladder_list"); - return NULL; - } - - LIST_TRAVERSE_CONST(d2ladder_list,elem) - { - if (!(d2ladder=elem_get_data(elem))) continue; - if (d2ladder->type==type) return d2ladder; - } - eventlog(eventlog_level_error,__FUNCTION__,"could not find type %d in d2ladder_list",type); - return NULL; -} - -extern int d2dbs_d2ladder_init(void) -{ - d2ladder_change_count=0; - d2ladder_maxtype=0; - d2ladder_ladder_file=xmalloc(strlen(d2dbs_prefs_get_ladder_dir())+1+\ - strlen(LADDER_FILE_PREFIX)+1+strlen(CLIENTTAG_DIABLO2DV)+1+10); - d2ladder_backup_file=xmalloc(strlen(d2dbs_prefs_get_ladder_dir())+1+\ - strlen(LADDER_BACKUP_PREFIX)+1+strlen(CLIENTTAG_DIABLO2DV)+1+10); - if (!d2ladder_ladder_file) return -1; - if (!d2ladder_backup_file) return -1; - sprintf(d2ladder_ladder_file,"%s/%s.%s",d2dbs_prefs_get_ladder_dir(),\ - LADDER_FILE_PREFIX,CLIENTTAG_DIABLO2DV); - - sprintf(d2ladder_backup_file,"%s/%s.%s",d2dbs_prefs_get_ladder_dir(),\ - LADDER_BACKUP_PREFIX,CLIENTTAG_DIABLO2DV); - - if (d2ladderlist_init()<0) { - return -1; - } - if(d2ladder_check()<0) { - eventlog(eventlog_level_error,__FUNCTION__,"ladder file checking error"); - return -1; - } - if (d2ladder_readladder()<0) { - return -1; - } - if (d2ladder_need_rebuild) d2ladder_rebuild(); - d2ladder_saveladder(); - return 0; -} - -int d2ladderlist_init(void) -{ - t_d2ladder * d2ladder; - unsigned int i; - - - if (!d2ladder_ladder_file) return -1; - d2ladder_list=list_create(); - d2ladder_maxtype=D2LADDER_MAXTYPE; - for (i=0;itype=i; - d2ladder->info=NULL; - d2ladder->len=0; - list_append_data(d2ladder_list,d2ladder); - } - return 0; -} - -int d2ladder_readladder(void) -{ - t_d2ladder * d2ladder; - t_d2ladderfile_header fileheader; - FILE * fdladder; - t_d2ladderfile_ladderindex * lhead; - t_d2ladderfile_ladderinfo * ldata; - t_d2ladder_info * info; - t_d2ladder_info temp; - long leftsize,blocksize; - unsigned int laddertype; - unsigned int tempmaxtype; - int readlen; - unsigned int i, number; - - if (!d2ladder_ladder_file) return -1; - fdladder=fopen(d2ladder_ladder_file,"rb"); - if(!fdladder) { - eventlog(eventlog_level_error,__FUNCTION__,"canot open ladder file"); - return -1; - } - - fseek(fdladder,0,SEEK_END); - leftsize=ftell(fdladder); - rewind(fdladder); - - blocksize=sizeof(fileheader) ; - if (leftsizeD2LADDER_MAXTYPE) { - eventlog(eventlog_level_error,__FUNCTION__,"ladder type > D2LADDER_MAXTYPE error"); - fclose(fdladder); - return -1; - } - d2ladder_maxtype=tempmaxtype; - - blocksize=d2ladder_maxtype*sizeof(*lhead); - if (leftsize < blocksize ) { - eventlog(eventlog_level_error,__FUNCTION__,"file size error"); - fclose(fdladder); - return -1; - } - - if (!(lhead=xmalloc(blocksize))) { - eventlog(eventlog_level_error,__FUNCTION__,"could not allocate memory for lhead"); - fclose(fdladder); - return -1; - } - readlen=fread(lhead,1,d2ladder_maxtype*sizeof(*lhead),fdladder); - if (readlen<=0) { - eventlog(eventlog_level_error,__FUNCTION__,"file %s read error(read:%s)",d2ladder_ladder_file,strerror(errno)); - xfree(lhead); - fclose(fdladder); - return -1; - } - leftsize-=blocksize; - - blocksize=0; - for(i=0;iinfo=info; - d2ladder->len=number; - for (i=0; i< number; i++) { - if (!ldata[i].charname[0]) continue; - temp.experience=bn_int_get(ldata[i].experience); - temp.status=bn_short_get(ldata[i].status); - temp.level=bn_byte_get(ldata[i].level); - temp.class=bn_byte_get(ldata[i].class); - strncpy(temp.charname,ldata[i].charname,sizeof(info[i].charname)); - if (d2ladder_update_info_and_pos(d2ladder,&temp, - d2ladder_find_char_all(d2ladder,&temp), - d2ladder_find_pos(d2ladder,&temp))==1) { - d2ladder_change_count++; - } - } - xfree(ldata); - } - leftsize-=blocksize; - - xfree(lhead); - fclose(fdladder); - return 0; -} - -extern int d2dbs_d2ladder_destroy(void) -{ - unsigned int i; - t_d2ladder * d2ladder; - - d2ladder_saveladder(); - for (i=0;iinfo) - xfree(d2ladder->info); - d2ladder->info=NULL; - d2ladder->len=0; - } - } - d2ladderlist_destroy(); - if (d2ladder_ladder_file) { - xfree(d2ladder_ladder_file); - d2ladder_ladder_file=NULL; - } - if (d2ladder_backup_file) { - xfree(d2ladder_backup_file); - d2ladder_backup_file=NULL; - } - return 0; -} - -int d2ladderlist_destroy(void) -{ - t_d2ladder * d2ladder; - t_elem * elem; - - if (!d2ladder_list) return -1; - LIST_TRAVERSE(d2ladder_list,elem) - { - if (!(d2ladder=elem_get_data(elem))) continue; - xfree(d2ladder); - list_remove_elem(d2ladder_list,&elem); - } - list_destroy(d2ladder_list); - return 0; -} - -int d2ladder_empty(void) -{ - unsigned int i; - t_d2ladder * d2ladder; - - for (i=0;iinfo,0,d2ladder->len * sizeof(*d2ladder->info)); - } - } - return 0; -} - -const char * get_prefix(int type, int status, int class) -{ - int difficulty; - static char prefix [4][4][2][16] = - {{{"",""},{"",""},{"",""},{"",""}}, - - {{"Count" ,"Countess"} , {"Sir","Dame"}, - {"Destroyer","Destroyer"} , {"Slayer","Slayer"}}, - - {{"Duke" ,"Duchess"} , {"Lord","Lady"}, - {"Conqueror","Conqueror"} , {"Champion","Champion"}}, - - {{"King" ,"Queen"} , {"Baron","Baroness"}, - {"Guardian","Guardian"} , {"Patriarch","Matriarch"}}}; - - static int sex[11] = {0,1,1,0,0,0,0,1,0,0,0}; - - difficulty = ((status >> 0x08) & 0x0f) / 5; - - - return prefix[difficulty][type][sex[class]]; -} - -int d2ladder_print_XML(FILE *ladderstrm) -{ - // modified version of d2ladder_print - changes done by jfro with a little help of aaron - t_d2ladder * d2ladder; - t_d2ladder_info * ldata; - int overalltype,classtype; - unsigned int i,type; - char laddermode[4][20]={"Hardcore", "Standard","Expansion HC","Expansion" }; - char charclass[11][12]={"OverAll", "Amazon", "Sorceress", "Necromancer", "Paladin",\ - "Barbarian", "Druid", "Assassin", "","",""} ; - - fprintf(ladderstrm,"\n\n"); - for(type=0; type len<=0) - continue; - ldata=d2ladder->info; - - overalltype=0; - classtype=0; - - if(type<= D2LADDER_HC_OVERALL+D2CHAR_CLASS_MAX +1) - { - overalltype=0 ; - classtype=type-D2LADDER_HC_OVERALL; - } - else if(type >= D2LADDER_STD_OVERALL && type<= D2LADDER_STD_OVERALL+D2CHAR_CLASS_MAX +1) - { - overalltype=1; - classtype=type-D2LADDER_STD_OVERALL; - } - else if(type >= D2LADDER_EXP_HC_OVERALL && type<= D2LADDER_EXP_HC_OVERALL+D2CHAR_EXP_CLASS_MAX +1) - { - overalltype=2; - classtype=type-D2LADDER_EXP_HC_OVERALL; - } - else if(type >= D2LADDER_EXP_STD_OVERALL && type<= D2LADDER_EXP_STD_OVERALL+D2CHAR_EXP_CLASS_MAX +1) - { - overalltype=3; - classtype=type-D2LADDER_EXP_STD_OVERALL ; - } - - fprintf(ladderstrm,"\n\t%d\n\t%s\n\t%s\n", - type,laddermode[overalltype],charclass[classtype]); - for(i=0; ilen; i++) - { - if ((ldata[i].charname != NULL) && (ldata[i].charname[0] != '\0')) - { - fprintf(ladderstrm,"\t\n\t\t%2d\n\t\t%s\n\t\t%2d\n", - i+1,ldata[i].charname,ldata[i].level); - fprintf(ladderstrm,"\t\t%d\n\t\t%s\n", - ldata[i].experience,charclass[ldata[i].class+1]); - fprintf(ladderstrm,"\t\t%s\n", - get_prefix(overalltype,ldata[i].status,ldata[i].class+1)); - if (((ldata[i].status) & (D2CHARINFO_STATUS_FLAG_DEAD | D2CHARINFO_STATUS_FLAG_HARDCORE)) == - (D2CHARINFO_STATUS_FLAG_DEAD | D2CHARINFO_STATUS_FLAG_HARDCORE)) - fprintf(ladderstrm,"\t\tdead\n\t\n"); - else - fprintf(ladderstrm,"\t\talive\n\t\n"); - } - } - fprintf(ladderstrm,"\n"); - fflush(ladderstrm); - } - fprintf(ladderstrm,"\n"); - return 0; -} - -extern int d2ladder_saveladder(void) -{ - t_d2ladderfile_ladderindex lhead[D2LADDER_MAXTYPE]; - t_d2ladderfile_header fileheader; - FILE * fdladder; - int start; - unsigned int i,j, number; - t_d2ladder * d2ladder; - t_d2ladderfile_ladderinfo * ldata; - char * XMLfilename; - FILE * XMLfile; - -/* - if(!d2ladder_change_count) { - eventlog(eventlog_level_debug,__FUNCTION__,"ladder data unchanged, skip saving"); - return 0; - } -*/ - start=sizeof(fileheader)+sizeof(lhead); - - for(i=0;itype); - bn_int_set(&lhead[i].offset,start); - bn_int_set(&lhead[i].number,d2ladder->len); - start+=d2ladder->len*sizeof(*ldata); - } - - if (!d2ladder_ladder_file) return -1; - if (!d2ladder_backup_file) return -1; - - if(d2ladder_checksum_check()==1) { - eventlog(eventlog_level_info,__FUNCTION__,"backup ladder file"); - if (p_rename(d2ladder_ladder_file,d2ladder_backup_file)==-1) { - eventlog(eventlog_level_warn,__FUNCTION__,"error rename %s to %s", d2ladder_ladder_file, d2ladder_backup_file); - } - } - - fdladder=fopen(d2ladder_ladder_file,"wb"); - if(!fdladder) { - eventlog(eventlog_level_error,__FUNCTION__,"error open ladder file %s",d2ladder_ladder_file); - return -1; - } - - // aaron: add extra output for XML ladder here ---> - if (d2dbs_prefs_get_XML_output_ladder()) - { - XMLfilename = xmalloc(strlen(d2dbs_prefs_get_ladder_dir())+1+strlen(XMLname)+1); - if (!XMLfilename) - { - eventlog(eventlog_level_error,__FUNCTION__,"could not alloc mem for XML ladder filename"); - } - else - { - sprintf(XMLfilename,"%s/%s",d2dbs_prefs_get_ladder_dir(),XMLname); - if (!(XMLfile = fopen(XMLfilename,"w"))) - { - eventlog(eventlog_level_error,__FUNCTION__,"could not open XML ladder file for output"); - } - else - { - d2ladder_print_XML(XMLfile); - fclose(XMLfile); - xfree(XMLfilename); - } - } - } - - // <--- - - bn_int_set(&fileheader.maxtype,d2ladder_maxtype); - bn_int_set(&fileheader.checksum,0); - fwrite(&fileheader,1,sizeof(fileheader),fdladder); - fwrite(lhead,1,sizeof(lhead),fdladder); - for(i=0;iinfo[j].experience); - bn_short_set(&ldata[j].status, d2ladder->info[j].status); - bn_byte_set(&ldata[j].level, d2ladder->info[j].level); - bn_byte_set(&ldata[j].class, d2ladder->info[j].class); - strncpy(ldata[j].charname,d2ladder->info[j].charname,sizeof(ldata[j].charname)); - } - fwrite(ldata,1,number*sizeof(*ldata),fdladder); - xfree(ldata); - } - fclose(fdladder); - d2ladder_checksum_set(); - eventlog(eventlog_level_info,__FUNCTION__,"ladder file saved (%d changes)",d2ladder_change_count); - d2ladder_change_count=0; - return 0; -} - -int d2ladder_print(FILE *ladderstrm) -{ - t_d2ladder * d2ladder; - t_d2ladder_info * ldata; - unsigned int i,type; - int overalltype,classtype; - char laddermode[4][20]={"Hardcore", "Standard","Expansion HC","Expansion" }; - char charclass[11][12]={"OverAll", "Amazon", "Sorceress", "Necromancer", "Paladin",\ - "Barbarian", "Druid", "Assassin", "","",""} ; - - for(type=0; type len<=0) - continue; - ldata=d2ladder->info; - - overalltype=0; - classtype=0; - - if(type<= D2LADDER_HC_OVERALL+D2CHAR_CLASS_MAX +1) - { - overalltype=0 ; - classtype=type-D2LADDER_HC_OVERALL; - } - else if (type >= D2LADDER_STD_OVERALL && type<= D2LADDER_STD_OVERALL+D2CHAR_CLASS_MAX +1) - { - overalltype=1; - classtype=type-D2LADDER_STD_OVERALL; - } - else if (type >= D2LADDER_EXP_HC_OVERALL && type<= D2LADDER_EXP_HC_OVERALL+D2CHAR_EXP_CLASS_MAX +1) - { - overalltype=2; - classtype=type-D2LADDER_EXP_HC_OVERALL; - } - else if (type >= D2LADDER_EXP_STD_OVERALL && type<= D2LADDER_EXP_STD_OVERALL+D2CHAR_EXP_CLASS_MAX +1) - { - overalltype=3; - classtype=type- D2LADDER_EXP_STD_OVERALL ; - } - - fprintf(ladderstrm,"ladder type %d %s %s\n",type,laddermode[overalltype],charclass[classtype]); - fprintf(ladderstrm,"************************************************************************\n"); - fprintf(ladderstrm,"No character name level exp status title class \n"); - for(i=0; ilen; i++) - { - fprintf(ladderstrm,"NO.%2d %-16s %2d %10d %2X %1X %s\n", - i+1, - ldata[i].charname, - ldata[i].level, - ldata[i].experience, - ldata[i].status, - 1, - charclass[ldata[i].class+1]); - } - fprintf(ladderstrm,"************************************************************************\n"); - fflush(ladderstrm); - } - return 0; -} - -int d2ladder_checksum(unsigned char const * data, unsigned int len,unsigned int offset) -{ - int checksum; - unsigned int i; - unsigned int ch; - - if (!data) return 0; - checksum=0; - for (i=0; i=offset && i 2000) - len = 2000; - else - len = filesize-curlen; - readlen=fread(buffer+curlen,1,len,fdladder); - if (readlen<=0) { - xfree(buffer); - fclose(fdladder); - eventlog(eventlog_level_error,__FUNCTION__,"got bad save file or read error(read:%s)",strerror(errno)); - return -1; - } - curlen+=readlen; - } - - bn_int_set(&checksum,d2ladder_checksum(buffer,filesize,LADDERFILE_CHECKSUM_OFFSET)); - fseek(fdladder,LADDERFILE_CHECKSUM_OFFSET,SEEK_SET); - fwrite(&checksum,1,sizeof(checksum),fdladder); - xfree(buffer); - fclose(fdladder); - return 0; -} - -int d2ladder_checksum_check(void) -{ - FILE * fdladder; - off_t filesize; - int curlen,readlen,len; - unsigned char * buffer; - int checksum,oldchecksum; - t_d2ladderfile_header * header; - - if (!d2ladder_ladder_file) return -1; - fdladder=fopen(d2ladder_ladder_file,"rb"); - if(!fdladder) { - eventlog(eventlog_level_error,__FUNCTION__,"error open ladder file %s",d2ladder_ladder_file); - return -1; - } - fseek(fdladder,0,SEEK_END); - filesize=ftell(fdladder); - rewind(fdladder); - if(filesize==(off_t)-1) { - eventlog(eventlog_level_error,__FUNCTION__,"lseek() error in ladder file %s",d2ladder_ladder_file); - fclose(fdladder); - return -1; - } - if(filesize<(signed)sizeof(t_d2ladderfile_header)) { - eventlog(eventlog_level_error,__FUNCTION__,"ladder file size error :%s",d2ladder_ladder_file); - fclose(fdladder); - return -1; - } - if (!(buffer=xmalloc(filesize))) { - fclose(fdladder); - eventlog(eventlog_level_error,__FUNCTION__,"could not allocate memory for buffer"); - return -1; - } - header=(t_d2ladderfile_header *)buffer; - curlen=0; - while(curlen 2000) - len = 2000; - else - len = filesize-curlen; - readlen=fread(buffer+curlen,1,len,fdladder); - if (readlen<=0) { - xfree(buffer); - fclose(fdladder); - eventlog(eventlog_level_error,__FUNCTION__,"got bad save file or read error(read:%s)",strerror(errno)); - return -1; - } - curlen+=readlen; - } - fclose(fdladder); - - oldchecksum=bn_int_get(header->checksum); - checksum=d2ladder_checksum(buffer,filesize,LADDERFILE_CHECKSUM_OFFSET); - xfree(buffer); - - if(oldchecksum==checksum) { - eventlog(eventlog_level_info,__FUNCTION__,"ladder file check pass (checksum=0x%X)",checksum); - return 1; - } else { - eventlog(eventlog_level_debug,__FUNCTION__,"ladder file checksum mismatch 0x%X - 0x%X",oldchecksum, checksum); - return 0; - } -} diff --git a/d2pack109/src/d2dbs/d2ladder.h b/d2pack109/src/d2dbs/d2ladder.h deleted file mode 100644 index 26c9bf2..0000000 --- a/d2pack109/src/d2dbs/d2ladder.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (C) 2001 sousou (liupeng.cs@263.net) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_D2LADDER_H -#define INCLUDED_D2LADDER_H - -#include -#include "common/list.h" -#include "d2cs/d2cs_d2dbs_ladder.h" -#define JUST_NEED_TYPES -#include "d2cs/d2charfile.h" -#undef JUST_NEED_TYPES - -#define LADDER_BACKUP_PREFIX "ladderbk" -#define DEFAULT_LADDER_DIR "var/ladders" -#define LADDERFILE_CHECKSUM_OFFSET offsetof(t_d2ladderfile_header,checksum) - -typedef struct -{ - unsigned int experience; - unsigned short status; - unsigned char level; - unsigned char class; - char charname[MAX_CHARNAME_LEN]; -} t_d2ladder_info; - -typedef struct -{ - unsigned int type; - t_d2ladder_info * info; - unsigned int len; -} t_d2ladder; - -typedef t_list t_d2ladderlist; - -#define D2LADDER_MAXNUM 200 -#define D2LADDER_OVERALL_MAXNUM 1000 -#define D2LADDER_MAXTYPE 35 - -extern int d2dbs_d2ladder_init(void); -extern int d2dbs_d2ladder_destroy(void); -extern int d2ladder_rebuild(void); -extern int d2ladder_update(t_d2ladder_info * pcharladderinfo); -extern int d2ladder_print(FILE * ladderstrm); -extern int d2ladder_saveladder(void); - -#endif diff --git a/d2pack109/src/d2dbs/dbsdupecheck.c b/d2pack109/src/d2dbs/dbsdupecheck.c deleted file mode 100644 index ee51bb9..0000000 --- a/d2pack109/src/d2dbs/dbsdupecheck.c +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright (C) 2001 faster (lqx@cic.tsinghua.edu.cn) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#include "common/setup_before.h" -#include "setup.h" - -#include -#ifdef STDC_HEADERS -# include -#else -# ifdef HAVE_MALLOC_H -# include -# endif -#endif -#ifdef HAVE_STRING_H -# include -#else -# ifdef HAVE_STRINGS_H -# include -# endif -# ifdef HAVE_MEMORY_H -# include -# endif -#endif -#include "compat/strcasecmp.h" -#include -#ifdef HAVE_LIMITS_H -# include -#endif -#include "dbsdupecheck.h" -#include "common/setup_after.h" -#include "common/bn_type.h" -#include "common/eventlog.h" - -const char * delimiter = "JM"; - -int is_delimit(char * data) -{ - if ((data[0]==delimiter[0]) && (data[1]==delimiter[1])) return 1; - else return 0; -} - -void * find_delimiter(char * data, unsigned int datalen) -{ - char * datap = data; - unsigned int count; - for (count=1; count -#else -# ifndef NULL -# define NULL ((void *)0) -# endif -#endif -#include -#ifdef STDC_HEADERS -# include -#else -# ifdef HAVE_MALLOC_H -# include -# endif -#endif -#ifdef HAVE_UNISTD_H -# include -#endif -#ifdef HAVE_FCNTL_H -# include -#else -# ifdef HAVE_SYS_FILE_H -# include -# endif -#endif -#ifdef HAVE_STRING_H -# include -#else -# ifdef HAVE_STRINGS_H -# include -# endif -# ifdef HAVE_MEMORY_H -# include -# endif -#endif -#include "compat/memset.h" -#include -#include "compat/strerror.h" -#ifdef TIME_WITH_SYS_TIME -# include -# include -#else -# ifdef HAVE_SYS_TIME_H -# include -# else -# include -# endif -#endif -#ifdef HAVE_SYS_TYPES_H -# include -#endif -#ifdef HAVE_SYS_SOCKET_H -# include -#endif -#include "compat/socket.h" -#ifdef HAVE_SYS_PARAM_H -# include -#endif -#ifdef HAVE_NETINET_IN_H -# include -#endif -#include "compat/netinet_in.h" -#ifdef HAVE_ARPA_INET_H -# include -#endif -#include "compat/inet_ntoa.h" -#include "compat/psock.h" - -#include "dbserver.h" -#include "charlock.h" -#include "d2ladder.h" -#include "dbspacket.h" -#include "prefs.h" -#include "handle_signal.h" -#include "common/list.h" -#include "common/eventlog.h" -#include "common/addr.h" -#include "common/xalloc.h" -#ifdef WIN32 -# include /* for kbhit() and getch() */ -#endif -#include "common/setup_after.h" - - -static int dbs_packet_gs_id = 0; -static t_preset_d2gsid *preset_d2gsid_head = NULL; -t_list * dbs_server_connection_list = NULL; -int dbs_server_listen_socket=-1; - -extern int g_ServiceStatus; - -/* dbs_server_main - * The module's driver function -- we just call other functions and - * interpret their results. - */ - -static int dbs_handle_timed_events(void); -static void dbs_on_exit(void); - -int dbs_server_init(void); -void dbs_server_loop(int ListeningSocket); -int dbs_server_setup_fdsets(fd_set * pReadFDs, fd_set * pWriteFDs, - fd_set * pExceptFDs, int ListeningSocket ) ; -BOOL dbs_server_read_data(t_d2dbs_connection* conn) ; -BOOL dbs_server_write_data(t_d2dbs_connection* conn) ; -int dbs_server_list_add_socket(int sd, unsigned int ipaddr); -static int setsockopt_keepalive(int sock); -static unsigned int get_preset_d2gsid(unsigned int ipaddr); - - -int dbs_server_main(void) -{ - eventlog(eventlog_level_info,__FUNCTION__,"establishing the listener..."); - dbs_server_listen_socket = dbs_server_init(); - if (dbs_server_listen_socket<0) { - eventlog(eventlog_level_error,__FUNCTION__,"dbs_server_init error "); - return 3; - } - eventlog(eventlog_level_info,__FUNCTION__,"waiting for connections..."); - dbs_server_loop(dbs_server_listen_socket); - dbs_on_exit(); - return 0; -} - -/* dbs_server_init - * Sets up a listener on the given interface and port, returning the - * listening socket if successful; if not, returns -1. - */ -/* FIXME: No it doesn't! pcAddress is not ever referenced in this - * function. - * CreepLord: Fixed much better way (will accept dns hostnames) - */ -int dbs_server_init(void) -{ - int sd; - struct sockaddr_in sinInterface; - int val; - t_addr * servaddr; - - dbs_server_connection_list=list_create(); - - if (d2dbs_d2ladder_init()==-1) - { - eventlog(eventlog_level_error,__FUNCTION__,"d2ladder_init() failed"); - return -1; - } - - if (cl_init(DEFAULT_HASHTBL_LEN, DEFAULT_GS_MAX)==-1) - { - eventlog(eventlog_level_error,__FUNCTION__,"cl_init() failed"); - return -1; - } - - if (psock_init()<0) - { - eventlog(eventlog_level_error,__FUNCTION__,"psock_init() failed"); - return -1; - } - - sd = psock_socket(PSOCK_PF_INET, PSOCK_SOCK_STREAM, PSOCK_IPPROTO_TCP); - if (sd==-1) - { - eventlog(eventlog_level_error,__FUNCTION__,"psock_socket() failed : %s",strerror(psock_errno())); - return -1; - } - - val = 1; - if (psock_setsockopt(sd, PSOCK_SOL_SOCKET, PSOCK_SO_REUSEADDR, &val, sizeof(val)) < 0) - { - eventlog(eventlog_level_error,__FUNCTION__,"psock_setsockopt() failed : %s",strerror(psock_errno())); - } - - if (!(servaddr=addr_create_str(d2dbs_prefs_get_servaddrs(),INADDR_ANY,DEFAULT_LISTEN_PORT))) - { - eventlog(eventlog_level_error,__FUNCTION__,"could not get servaddr"); - return -1; - } - - sinInterface.sin_family = PSOCK_AF_INET; - sinInterface.sin_addr.s_addr = htonl(addr_get_ip(servaddr)); - sinInterface.sin_port = htons(addr_get_port(servaddr)); - if (psock_bind(sd, (struct sockaddr*)&sinInterface, (psock_t_socklen)sizeof(struct sockaddr_in)) < 0) - { - eventlog(eventlog_level_error,__FUNCTION__,"psock_bind() failed : %s",strerror(psock_errno())); - return -1; - } - if (psock_listen(sd, LISTEN_QUEUE) < 0) - { - eventlog(eventlog_level_error,__FUNCTION__,"psock_listen() failed : %s",strerror(psock_errno())); - return -1; - } - addr_destroy(servaddr); - return sd; -} - - -/* dbs_server_setup_fdsets - * Set up the three FD sets used with select() with the sockets in the - * connection list. Also add one for the listener socket, if we have - * one. - */ - -int dbs_server_setup_fdsets(t_psock_fd_set * pReadFDs, t_psock_fd_set * pWriteFDs, t_psock_fd_set * pExceptFDs, int lsocket) -{ - t_elem const * elem; - t_d2dbs_connection* it; - int highest_fd; - - PSOCK_FD_ZERO(pReadFDs); - PSOCK_FD_ZERO(pWriteFDs); - PSOCK_FD_ZERO(pExceptFDs); /* FIXME: don't check these... remove this code */ - /* Add the listener socket to the read and except FD sets, if there is one. */ - if (lsocket >= 0) { - PSOCK_FD_SET(lsocket, pReadFDs); - PSOCK_FD_SET(lsocket, pExceptFDs); - } - highest_fd=lsocket; - - LIST_TRAVERSE_CONST(dbs_server_connection_list,elem) - { - if (!(it=elem_get_data(elem))) continue; - if (it->nCharsInReadBuffer < (kBufferSize-kMaxPacketLength)) { - /* There's space in the read buffer, so pay attention to incoming data. */ - PSOCK_FD_SET(it->sd, pReadFDs); - } - if (it->nCharsInWriteBuffer > 0) { - PSOCK_FD_SET(it->sd, pWriteFDs); - } - PSOCK_FD_SET(it->sd, pExceptFDs); - if (highest_fd < it->sd) highest_fd=it->sd; - } - return highest_fd; -} - -/* dbs_server_read_data - * Data came in on a client socket, so read it into the buffer. Returns - * false on failure, or when the client closes its half of the - * connection. (EAGAIN doesn't count as a failure.) - */ -BOOL dbs_server_read_data(t_d2dbs_connection* conn) -{ - int nBytes; - - nBytes = psock_recv(conn->sd, - conn->ReadBuf + conn->nCharsInReadBuffer, - kBufferSize - conn->nCharsInReadBuffer, 0); - if (nBytes == 0) { - eventlog(eventlog_level_info,__FUNCTION__,"Socket %d was closed by the client. Shutting down.",conn->sd); - return FALSE; - } else if (nBytes < 0) { - int err; - psock_t_socklen errlen; - - err = 0; - errlen = sizeof(err); - if (psock_getsockopt(conn->sd, PSOCK_SOL_SOCKET, PSOCK_SO_ERROR, &err, &errlen)<0) - return TRUE; - if (errlen==0 || err==PSOCK_EAGAIN) { - return TRUE; - } else { - eventlog(eventlog_level_error,__FUNCTION__,"psock_recv() failed : %s",strerror(err)); - return FALSE; - } - } - conn->nCharsInReadBuffer += nBytes; - return TRUE; -} - - -/* dbs_server_write_data - * The connection is writable, so send any pending data. Returns - * false on failure. (EAGAIN doesn't count as a failure.) - */ -BOOL dbs_server_write_data(t_d2dbs_connection* conn) -{ - unsigned int sendlen; - int nBytes ; - - if (conn->nCharsInWriteBuffer>kMaxPacketLength) sendlen=kMaxPacketLength; - else sendlen=conn->nCharsInWriteBuffer; - nBytes = psock_send(conn->sd, conn->WriteBuf, sendlen, 0); - if (nBytes < 0) { - int err; - psock_t_socklen errlen; - - err = 0; - errlen = sizeof(err); - if (psock_getsockopt(conn->sd, PSOCK_SOL_SOCKET, PSOCK_SO_ERROR, &err, &errlen)<0) - return TRUE; - if (errlen==0 || err==PSOCK_EAGAIN) { - return TRUE; - } else { - eventlog(eventlog_level_error,__FUNCTION__,"psock_send() failed : %s",strerror(err)); - return FALSE; - } - } - if (nBytes == conn->nCharsInWriteBuffer) { - conn->nCharsInWriteBuffer = 0; - } else { - conn->nCharsInWriteBuffer -= nBytes; - memmove(conn->WriteBuf, conn->WriteBuf + nBytes, conn->nCharsInWriteBuffer); - } - return TRUE; -} - -int dbs_server_list_add_socket(int sd, unsigned int ipaddr) -{ - t_d2dbs_connection *it; - struct in_addr in; - - it=xmalloc(sizeof(t_d2dbs_connection)); - memset(it, 0, sizeof(t_d2dbs_connection)); - it->sd=sd; - it->ipaddr=ipaddr; - it->major=0; - it->minor=0; - it->type=0; - it->stats=0; - it->verified=0; - it->serverid=get_preset_d2gsid(ipaddr); - it->last_active=time(NULL); - it->nCharsInReadBuffer=0; - it->nCharsInWriteBuffer=0; - list_append_data(dbs_server_connection_list,it); - in.s_addr = htonl(ipaddr); - strncpy(it->serverip, inet_ntoa(in), sizeof(it->serverip)-1); - - return 1; -} - -static int dbs_handle_timed_events(void) -{ - static time_t prev_ladder_save_time=0; - static time_t prev_keepalive_save_time=0; - static time_t prev_timeout_checktime=0; - time_t now; - - now=time(NULL); - if (now-prev_ladder_save_time>(signed)prefs_get_laddersave_interval()) { - d2ladder_saveladder(); - prev_ladder_save_time=now; - } - if (now-prev_keepalive_save_time>(signed)prefs_get_keepalive_interval()) { - dbs_keepalive(); - prev_keepalive_save_time=now; - } - if (now-prev_timeout_checktime>(signed)d2dbs_prefs_get_timeout_checkinterval()) { - dbs_check_timeout(); - prev_timeout_checktime=now; - } - return 0; -} - -void dbs_server_loop(int lsocket) -{ - struct sockaddr_in sinRemote; - int sd ; - fd_set ReadFDs, WriteFDs, ExceptFDs; - t_elem * elem; - t_d2dbs_connection* it; - BOOL bOK ; - const char* pcErrorType ; - struct timeval tv; - int highest_fd; - psock_t_socklen nAddrSize = sizeof(sinRemote); - - while (1) { -#ifdef WIN32 - if (g_ServiceStatus<0 && kbhit() && getch()=='q') - d2dbs_signal_quit_wrapper(); - - if (g_ServiceStatus == 0) d2dbs_signal_quit_wrapper(); - - while (g_ServiceStatus == 2) Sleep(1000); -#endif - if (d2dbs_handle_signal()<0) break; - dbs_handle_timed_events(); - highest_fd=dbs_server_setup_fdsets(&ReadFDs, &WriteFDs, &ExceptFDs, lsocket); - - tv.tv_sec = 0; - tv.tv_usec = SELECT_TIME_OUT; - switch (psock_select(highest_fd+1, &ReadFDs, &WriteFDs, &ExceptFDs, &tv) ) { - case -1: - eventlog(eventlog_level_error,__FUNCTION__,"psock_select() failed : %s",strerror(psock_errno())); - continue; - case 0: - continue; - default: - break; - } - - if (PSOCK_FD_ISSET(lsocket, &ReadFDs)) { - sd = psock_accept(lsocket, (struct sockaddr*)&sinRemote, &nAddrSize); - if (sd == -1) { - eventlog(eventlog_level_error,__FUNCTION__,"psock_accept() failed : %s",strerror(psock_errno())); - return; - } - - eventlog(eventlog_level_info,__FUNCTION__,"accepted connection from %s:%d , socket %d .", - inet_ntoa(sinRemote.sin_addr) , ntohs(sinRemote.sin_port), sd); - eventlog_step(prefs_get_logfile_gs(),eventlog_level_info,__FUNCTION__,"accepted connection from %s:%d , socket %d .", - inet_ntoa(sinRemote.sin_addr) , ntohs(sinRemote.sin_port), sd); - setsockopt_keepalive(sd); - dbs_server_list_add_socket(sd, ntohl(sinRemote.sin_addr.s_addr)); - if (psock_ctl(sd,PSOCK_NONBLOCK)<0) { - eventlog(eventlog_level_error,__FUNCTION__,"could not set TCP socket [%d] to non-blocking mode (closing connection) (psock_ctl: %s)", sd,strerror(psock_errno())); - psock_close(sd); - } - } else if (PSOCK_FD_ISSET(lsocket, &ExceptFDs)) { - eventlog(eventlog_level_error,__FUNCTION__,"exception on listening socket"); - /* FIXME: exceptions are not errors with TCP, they are out-of-band data */ - return; - } - - LIST_TRAVERSE(dbs_server_connection_list,elem) - { - bOK = TRUE; - pcErrorType = 0; - - if (!(it=elem_get_data(elem))) continue; - if (PSOCK_FD_ISSET(it->sd, &ExceptFDs)) { - bOK = FALSE; - pcErrorType = "General socket error"; /* FIXME: no no no no no */ - PSOCK_FD_CLR(it->sd, &ExceptFDs); - } else { - - if (PSOCK_FD_ISSET(it->sd, &ReadFDs)) { - bOK = dbs_server_read_data(it); - pcErrorType = "Read error"; - PSOCK_FD_CLR(it->sd, &ReadFDs); - } - - if (PSOCK_FD_ISSET(it->sd, &WriteFDs)) { - bOK = dbs_server_write_data(it); - pcErrorType = "Write error"; - PSOCK_FD_CLR(it->sd, &WriteFDs); - } - } - - if (!bOK) { - int err; - psock_t_socklen errlen; - - err = 0; - errlen = sizeof(err); - if (psock_getsockopt(it->sd, PSOCK_SOL_SOCKET, PSOCK_SO_ERROR, &err, &errlen)==0) { - if (errlen && err!=0) { - eventlog(eventlog_level_error,__FUNCTION__,"data socket error : %s",strerror(err)); - } - } - dbs_server_shutdown_connection(it); - list_remove_elem(dbs_server_connection_list,&elem); - } else { - if (dbs_packet_handle(it)==-1) { - eventlog(eventlog_level_error,__FUNCTION__,"dbs_packet_handle() failed"); - dbs_server_shutdown_connection(it); - list_remove_elem(dbs_server_connection_list,&elem); - } - } - } - } -} - -static void dbs_on_exit(void) -{ - t_elem * elem; - t_d2dbs_connection * it; - - if (dbs_server_listen_socket>=0) - psock_close(dbs_server_listen_socket); - dbs_server_listen_socket=-1; - - LIST_TRAVERSE(dbs_server_connection_list,elem) - { - if (!(it=elem_get_data(elem))) continue; - dbs_server_shutdown_connection(it); - list_remove_elem(dbs_server_connection_list,&elem); - } - cl_destroy(); - d2dbs_d2ladder_destroy(); - list_destroy(dbs_server_connection_list); - if (preset_d2gsid_head) - { - t_preset_d2gsid * curr; - t_preset_d2gsid * next; - - for (curr=preset_d2gsid_head; curr; curr=next) - { - next = curr->next; - xfree(curr); - } - } - eventlog(eventlog_level_info,__FUNCTION__,"dbserver stopped"); -} - -int dbs_server_shutdown_connection(t_d2dbs_connection* conn) -{ - psock_shutdown(conn->sd, PSOCK_SHUT_RDWR) ; - psock_close(conn->sd); - if (conn->verified && conn->type==CONNECT_CLASS_D2GS_TO_D2DBS) { - eventlog(eventlog_level_info,__FUNCTION__,"unlock all characters on gs %s(%d)",conn->serverip,conn->serverid); - eventlog_step(prefs_get_logfile_gs(),eventlog_level_info,__FUNCTION__,"unlock all characters on gs %s(%d)",conn->serverip,conn->serverid); - eventlog_step(prefs_get_logfile_gs(),eventlog_level_info,__FUNCTION__,"close connection to gs on socket %d", conn->sd); - cl_unlock_all_char_by_gsid(conn->serverid); - } - xfree(conn); - return 1; -} - -static int setsockopt_keepalive(int sock) -{ - int optval; - psock_t_socklen optlen; - - optval = 1; - optlen = sizeof(optval); - if (psock_setsockopt(sock, PSOCK_SOL_SOCKET, PSOCK_SO_KEEPALIVE, &optval, optlen)) { - eventlog(eventlog_level_info,__FUNCTION__,"failed set KEEPALIVE for socket %d, errno=%d", sock, psock_errno()); - return -1; - } else { - eventlog(eventlog_level_info,__FUNCTION__,"set KEEPALIVE option for socket %d", sock); - return 0; - } -} - -static unsigned int get_preset_d2gsid(unsigned int ipaddr) -{ - t_preset_d2gsid *pgsid; - - pgsid = preset_d2gsid_head; - while (pgsid) - { - if (pgsid->ipaddr == ipaddr) - return pgsid->d2gsid; - pgsid = pgsid->next; - } - /* not found, build a new item */ - pgsid = xmalloc(sizeof(t_preset_d2gsid)); - pgsid->ipaddr = ipaddr; - pgsid->d2gsid = ++dbs_packet_gs_id; - /* add to list */ - pgsid->next = preset_d2gsid_head; - preset_d2gsid_head = pgsid; - return preset_d2gsid_head->d2gsid; -} diff --git a/d2pack109/src/d2dbs/dbserver.h b/d2pack109/src/d2dbs/dbserver.h deleted file mode 100644 index 1bb7aff..0000000 --- a/d2pack109/src/d2dbs/dbserver.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2001 sousou (liupeng.cs@263.net) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_DBSERVER_H -#define INCLUDED_DBSERVER_H - -#include "common/list.h" - -typedef struct { - int sd; - unsigned int ipaddr; - unsigned char major; - unsigned char minor; - unsigned char type; - unsigned char stats; - unsigned int serverid; - unsigned int verified; - unsigned char serverip[16]; - int last_active; - int nCharsInReadBuffer; - int nCharsInWriteBuffer; - char ReadBuf[kBufferSize]; - char WriteBuf[kBufferSize]; -} t_d2dbs_connection; - -typedef struct raw_preset_d2gsid { - unsigned int ipaddr; - unsigned int d2gsid; - struct raw_preset_d2gsid *next; -} t_preset_d2gsid; - -int dbs_server_main(void); -int dbs_server_shutdown_connection(t_d2dbs_connection* conn); - -extern t_list * dbs_server_connection_list; - -#endif diff --git a/d2pack109/src/d2dbs/dbspacket.c b/d2pack109/src/d2dbs/dbspacket.c deleted file mode 100644 index 81f64d0..0000000 --- a/d2pack109/src/d2dbs/dbspacket.c +++ /dev/null @@ -1,865 +0,0 @@ -/* - * Copyright (C) 2001 sousou (liupeng.cs@263.net) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#include "common/setup_before.h" -#include "setup.h" - -#ifdef HAVE_STDDEF_H -# include -#else -# ifndef NULL -# define NULL ((void *)0) -# endif -#endif -#include -#ifdef STDC_HEADERS -# include -#else -# ifdef HAVE_MALLOC_H -# include -# endif -#endif -#ifdef HAVE_UNISTD_H -# include -#endif -#ifdef HAVE_SYS_STAT_H -# include -#endif -#ifdef HAVE_FCNTL_H -# include -#else -# ifdef HAVE_SYS_FILE_H -# include -# endif -#endif -#include "compat/statmacros.h" -#include "compat/mkdir.h" -#ifdef HAVE_STRING_H -# include -#else -# ifdef HAVE_STRINGS_H -# include -# endif -# ifdef HAVE_MEMORY_H -# include -# endif -#endif -#include "compat/memcpy.h" -#include "compat/memmove.h" -#include "compat/strdup.h" -#include "compat/strsep.h" -#include -#include "compat/strerror.h" -#ifdef TIME_WITH_SYS_TIME -# include -# include -#else -# ifdef HAVE_SYS_TIME_H -# include -# else -# include -# endif -#endif -#ifdef HAVE_SYS_TYPES_H -# include -#endif -#ifdef HAVE_SYS_SOCKET_H -# include -#endif -#include "compat/socket.h" -#ifdef HAVE_SYS_PARAM_H -# include -#endif -#ifdef HAVE_NETINET_IN_H -# include -#endif -#include "compat/netinet_in.h" -#ifdef HAVE_ARPA_INET_H -# include -#endif -#include "compat/inet_ntoa.h" -#include "compat/psock.h" -#include "compat/access.h" -#include "compat/rename.h" -#include "dbserver.h" -#include "dbspacket.h" -#include "d2ladder.h" -#include "charlock.h" -#include "prefs.h" -#include "d2cs/xstring.h" -#include "d2cs/d2cs_d2gs_character.h" -#include "common/bn_type.h" -#include "common/list.h" -#include "common/eventlog.h" -#include "common/addr.h" -#include "common/xalloc.h" -#include "common/setup_after.h" - -static unsigned int dbs_packet_savedata_charsave(t_d2dbs_connection* conn,char * AccountName,char * CharName,char * data,unsigned int datalen); -static unsigned int dbs_packet_savedata_charinfo(t_d2dbs_connection* conn,char * AccountName,char * CharName,char * data,unsigned int datalen); -static unsigned int dbs_packet_getdata_charsave(t_d2dbs_connection* conn,char * AccountName,char * CharName,char * data,unsigned int bufsize); -static unsigned int dbs_packet_getdata_charinfo(t_d2dbs_connection* conn,char * AccountName,char * CharName,char * data,unsigned int bufsize); -static unsigned int dbs_packet_echoreply(t_d2dbs_connection* conn); -static unsigned int dbs_packet_getdata(t_d2dbs_connection* conn); -static unsigned int dbs_packet_savedata(t_d2dbs_connection* conn); -static unsigned int dbs_packet_charlock(t_d2dbs_connection* conn); -static unsigned int dbs_packet_updateladder(t_d2dbs_connection* conn); -static int dbs_verify_ipaddr(char const * addrlist,t_d2dbs_connection * c); - -static int dbs_packet_fix_charinfo(t_d2dbs_connection * conn,char * AccountName,char * CharName,char * charsave); -static void dbs_packet_set_charinfo_level(char * CharName,char * charinfo); - -static unsigned int dbs_packet_savedata_charsave(t_d2dbs_connection* conn, char * AccountName,char * CharName,char * data,unsigned int datalen) -{ - char filename[MAX_PATH]; - char savefile[MAX_PATH]; - char bakfile[MAX_PATH]; - unsigned short curlen,readlen,leftlen,writelen; - FILE * fd; - - strtolower(AccountName); - strtolower(CharName); - - sprintf(filename,"%s/.%s.tmp",d2dbs_prefs_get_charsave_dir(),CharName); - fd = fopen(filename, "wb"); - if (!fd) { - eventlog(eventlog_level_error,__FUNCTION__,"open() failed : %s",filename); - return 0; - } - curlen=0; - leftlen=datalen; - while(curlen2000) writelen=2000; - else writelen=leftlen; - readlen=fwrite(data+curlen,1,writelen,fd); - if (readlen<=0) { - fclose(fd); - eventlog(eventlog_level_error,__FUNCTION__,"write() failed error : %s",strerror(errno)); - return 0; - } - curlen+=readlen; - leftlen-=readlen; - } - fclose(fd); - - sprintf(bakfile,"%s/%s",prefs_get_charsave_bak_dir(),CharName); - sprintf(savefile,"%s/%s",d2dbs_prefs_get_charsave_dir(),CharName); - if (p_rename(savefile, bakfile)==-1) { - eventlog(eventlog_level_warn,__FUNCTION__,"error rename %s to %s", savefile, bakfile); - } - if (p_rename(filename, savefile)==-1) { - eventlog(eventlog_level_error,__FUNCTION__,"error rename %s to %s", filename, savefile); - return 0; - } - eventlog(eventlog_level_info,__FUNCTION__,"saved charsave %s(*%s) for gs %s(%d)", CharName, AccountName, conn->serverip, conn->serverid); - return datalen; -} - -static unsigned int dbs_packet_savedata_charinfo(t_d2dbs_connection* conn,char * AccountName,char * CharName,char * data,unsigned int datalen) -{ - char savefile[MAX_PATH]; - char bakfile[MAX_PATH]; - char filepath[MAX_PATH]; - char filename[MAX_PATH]; - FILE * fd; - unsigned short curlen,readlen,leftlen,writelen; - struct stat statbuf; - - strtolower(AccountName); - strtolower(CharName); - - sprintf(filepath,"%s/%s",prefs_get_charinfo_bak_dir(),AccountName); - if (stat(filepath,&statbuf)==-1) { - p_mkdir(filepath,S_IRWXU|S_IRWXG|S_IRWXO ); - eventlog(eventlog_level_info,__FUNCTION__,"created charinfo directory: %s",filepath); - } - - sprintf(filename,"%s/%s/.%s.tmp",d2dbs_prefs_get_charinfo_dir(),AccountName,CharName); - fd = fopen(filename, "wb"); - if (!fd) { - eventlog(eventlog_level_error,__FUNCTION__,"open() failed : %s",filename); - return 0; - } - - curlen=0; - leftlen=datalen; - while(curlen2000) writelen=2000; - else writelen=leftlen; - readlen=fwrite(data+curlen,1,writelen,fd); - if (readlen<=0) { - fclose(fd); - eventlog(eventlog_level_error,__FUNCTION__,"write() failed error : %s",strerror(errno)); - return 0; - } - curlen+=readlen; - leftlen-=readlen; - } - fclose(fd); - - sprintf(bakfile,"%s/%s/%s",prefs_get_charinfo_bak_dir(),AccountName,CharName); - sprintf(savefile,"%s/%s/%s",d2dbs_prefs_get_charinfo_dir(),AccountName,CharName); - if (p_rename(savefile, bakfile)==-1) { - eventlog(eventlog_level_info,__FUNCTION__,"error rename %s to %s", savefile, bakfile); - } - if (p_rename(filename, savefile)==-1) { - eventlog(eventlog_level_error,__FUNCTION__,"error rename %s to %s", filename, savefile); - return 0; - } - eventlog(eventlog_level_info,__FUNCTION__,"saved charinfo %s(*%s) for gs %s(%d)", CharName, AccountName, conn->serverip, conn->serverid); - return datalen; -} - -static unsigned int dbs_packet_getdata_charsave(t_d2dbs_connection* conn,char * AccountName,char * CharName,char * data,unsigned int bufsize) -{ - char filename[MAX_PATH]; - char filename_d2closed[MAX_PATH]; - FILE * fd; - unsigned short curlen,readlen,leftlen,writelen; - long filesize; - - strtolower(AccountName); - strtolower(CharName); - - sprintf(filename,"%s/%s",d2dbs_prefs_get_charsave_dir(),CharName); - sprintf(filename_d2closed,"%s/%s.d2s",d2dbs_prefs_get_charsave_dir(),CharName); - if ((access(filename, F_OK) < 0) && (access(filename_d2closed, F_OK) == 0)) - { - p_rename(filename_d2closed, filename); - } - fd = fopen(filename, "rb"); - if (!fd) { - eventlog(eventlog_level_error,__FUNCTION__,"open() failed : %s",filename); - return 0; - } - fseek(fd,0,SEEK_END); - filesize=ftell(fd); - rewind(fd); - if (filesize==-1) { - fclose(fd); - eventlog(eventlog_level_error,__FUNCTION__,"lseek() failed"); - return 0; - } - if ((signed)bufsize < filesize) { - fclose(fd); - eventlog(eventlog_level_error,__FUNCTION__,"not enough buffer"); - return 0; - } - - curlen=0; - leftlen=filesize; - while(curlen < filesize) { - if (leftlen>2000) writelen=2000; - else writelen=leftlen; - readlen=fread(data+curlen,1,writelen,fd); - if (readlen<=0) { - fclose(fd); - eventlog(eventlog_level_error,__FUNCTION__,"read() failed error : %s",strerror(errno)); - return 0; - } - leftlen-=readlen; - curlen+=readlen; - } - fclose(fd); - eventlog(eventlog_level_info,__FUNCTION__,"loaded charsave %s(*%s) for gs %s(%d)", CharName, AccountName, conn->serverip, conn->serverid); - return filesize; -} - -static unsigned int dbs_packet_getdata_charinfo(t_d2dbs_connection* conn,char * AccountName,char * CharName,char * data,unsigned int bufsize) -{ - char filename[MAX_PATH]; - FILE * fd; - unsigned short curlen,readlen,leftlen,writelen; - long filesize; - - strtolower(AccountName); - strtolower(CharName); - - sprintf(filename,"%s/%s/%s",d2dbs_prefs_get_charinfo_dir(),AccountName,CharName); - fd = fopen(filename, "rb"); - if (!fd) { - eventlog(eventlog_level_error,__FUNCTION__,"open() failed : %s",filename); - return 0; - } - fseek(fd,0,SEEK_END); - filesize=ftell(fd); - rewind(fd); - if (filesize==-1) { - fclose(fd); - eventlog(eventlog_level_error,__FUNCTION__,"lseek() failed"); - return 0; - } - if ((signed)bufsize < filesize) { - fclose(fd); - eventlog(eventlog_level_error,__FUNCTION__,"not enough buffer"); - return 0; - } - - curlen=0; - leftlen=filesize; - while(curlen < filesize) { - if (leftlen>2000) - writelen=2000; - else - writelen=leftlen; - readlen=fread(data+curlen,1,writelen,fd); - if (readlen<=0) - { - fclose(fd); - eventlog(eventlog_level_error,__FUNCTION__,"read() failed error : %s",strerror(errno)); - return 0; - } - leftlen-=readlen; - curlen+=readlen; - } - fclose(fd); - eventlog(eventlog_level_info,__FUNCTION__,"loaded charinfo %s(*%s) for gs %s(%d)", CharName, AccountName, conn->serverip, conn->serverid); - return filesize; -} - -static unsigned int dbs_packet_savedata(t_d2dbs_connection * conn) -{ - unsigned short writelen; - unsigned short datatype; - unsigned short datalen; - unsigned int result; - char AccountName[MAX_NAME_LEN+16]; - char CharName[MAX_NAME_LEN+16]; - char RealmName[MAX_NAME_LEN+16]; - t_d2gs_d2dbs_save_data_request * savecom; - t_d2dbs_d2gs_save_data_reply * saveret; - char * readpos; - unsigned char * writepos; - - readpos=conn->ReadBuf; - savecom=(t_d2gs_d2dbs_save_data_request *)readpos; - datatype=bn_short_get(savecom->datatype); - datalen=bn_short_get(savecom->datalen); - - readpos+=sizeof(*savecom); - strncpy(AccountName,readpos,MAX_NAME_LEN); - AccountName[MAX_NAME_LEN]=0; - readpos+=strlen(AccountName)+1; - strncpy(CharName,readpos,MAX_NAME_LEN); - CharName[MAX_NAME_LEN]=0; - readpos+=strlen(CharName)+1; - strncpy(RealmName,readpos,MAX_NAME_LEN); - RealmName[MAX_NAME_LEN]=0; - readpos+=strlen(RealmName)+1; - - if (readpos+datalen!=conn->ReadBuf+bn_short_get(savecom->h.size)) { - eventlog(eventlog_level_error,__FUNCTION__,"request packet size error"); - return -1; - } - - if (datatype==D2GS_DATA_CHARSAVE) { - if (dbs_packet_savedata_charsave(conn,AccountName,CharName,readpos,datalen)>0 && - dbs_packet_fix_charinfo(conn,AccountName,CharName,readpos)) { - result=D2DBS_SAVE_DATA_SUCCESS; - } else { - datalen=0; - result=D2DBS_SAVE_DATA_FAILED ; - } - } else if (datatype==D2GS_DATA_PORTRAIT) { - /* if level is > 255 , sets level to 255 */ - dbs_packet_set_charinfo_level(CharName,readpos); - if (dbs_packet_savedata_charinfo(conn,AccountName,CharName,readpos,datalen)>0) { - result=D2DBS_SAVE_DATA_SUCCESS; - } else { - datalen=0; - result=D2DBS_SAVE_DATA_FAILED; - } - } else { - eventlog(eventlog_level_error,__FUNCTION__,"unknown data type %d",datatype); - return -1; - } - writelen=sizeof(*saveret)+strlen(CharName)+1; - if (writelen > kBufferSize-conn->nCharsInWriteBuffer) return 0; - writepos=conn->WriteBuf+conn->nCharsInWriteBuffer; - saveret=(t_d2dbs_d2gs_save_data_reply *)writepos; - bn_short_set(&saveret->h.type, D2DBS_D2GS_SAVE_DATA_REPLY); - bn_short_set(&saveret->h.size,writelen); - bn_int_set(&saveret->h.seqno,bn_int_get(savecom->h.seqno)); - bn_short_set(&saveret->datatype,bn_short_get(savecom->datatype)); - bn_int_set(&saveret->result,result); - writepos+=sizeof(*saveret); - strncpy(writepos,CharName,MAX_NAME_LEN); - conn->nCharsInWriteBuffer += writelen; - return 1; -} - -static unsigned int dbs_packet_echoreply(t_d2dbs_connection * conn) -{ - conn->last_active=time(NULL); - return 1; -} - -static unsigned int dbs_packet_getdata(t_d2dbs_connection * conn) -{ - unsigned short writelen; - unsigned short datatype; - unsigned short datalen; - unsigned int result; - char AccountName[MAX_NAME_LEN+16]; - char CharName[MAX_NAME_LEN+16]; - char RealmName[MAX_NAME_LEN+16]; - t_d2gs_d2dbs_get_data_request * getcom; - t_d2dbs_d2gs_get_data_reply * getret; - char * readpos; - char * writepos; - char databuf[kBufferSize ]; - t_d2charinfo_file charinfo; - unsigned short charinfolen; - unsigned int gsid; - - readpos=conn->ReadBuf; - getcom=(t_d2gs_d2dbs_get_data_request *)readpos; - datatype=bn_short_get(getcom->datatype); - - readpos+=sizeof(*getcom); - strncpy(AccountName,readpos,MAX_NAME_LEN); - AccountName[MAX_NAME_LEN]=0; - readpos+=strlen(AccountName)+1; - strncpy(CharName,readpos,MAX_NAME_LEN); - CharName[MAX_NAME_LEN]=0; - readpos+=strlen(CharName)+1; - strncpy(RealmName,readpos,MAX_NAME_LEN); - RealmName[MAX_NAME_LEN]=0; - readpos+=strlen(RealmName)+1; - - if (readpos != conn->ReadBuf+bn_short_get(getcom->h.size)) { - eventlog(eventlog_level_error,__FUNCTION__,"request packet size error"); - return -1; - } - writepos=conn->WriteBuf+conn->nCharsInWriteBuffer; - getret=(t_d2dbs_d2gs_get_data_reply *)writepos; - datalen=0; - if (datatype==D2GS_DATA_CHARSAVE) { - if (cl_query_charlock_status(CharName,RealmName,&gsid)!=0) { - eventlog(eventlog_level_warn,__FUNCTION__,"char %s(*%s)@%s is already locked on gs %u",CharName,AccountName,RealmName,gsid); - result=D2DBS_GET_DATA_CHARLOCKED; - } else if (cl_lock_char(CharName,RealmName,conn->serverid) != 0) { - eventlog(eventlog_level_error,__FUNCTION__,"failed to lock char %s(*%s)@%s for gs %s(%d)",CharName,AccountName,RealmName,conn->serverip,conn->serverid); - result=D2DBS_GET_DATA_CHARLOCKED; - } else { - eventlog(eventlog_level_info,__FUNCTION__,"lock char %s(*%s)@%s for gs %s(%d)",CharName,AccountName,RealmName,conn->serverip,conn->serverid); - datalen=dbs_packet_getdata_charsave(conn,AccountName,CharName,databuf,kBufferSize ); - if (datalen>0) { - result=D2DBS_GET_DATA_SUCCESS; - charinfolen=dbs_packet_getdata_charinfo(conn,AccountName,CharName,(char *)&charinfo,sizeof(charinfo)); - if (charinfolen>0) { - result=D2DBS_GET_DATA_SUCCESS; - } else { - result=D2DBS_GET_DATA_FAILED; - if (cl_unlock_char(CharName,RealmName)!=0) { - eventlog(eventlog_level_error,__FUNCTION__,"failed to unlock char %s(*%s)@%s for gs %s(%d)",CharName,\ - AccountName,RealmName,conn->serverip,conn->serverid); - } else { - eventlog(eventlog_level_info,__FUNCTION__,"unlock char %s(*%s)@%s for gs %s(%d)",CharName,\ - AccountName,RealmName,conn->serverip,conn->serverid); - } - } - } else { - datalen=0; - result=D2DBS_GET_DATA_FAILED; - if (cl_unlock_char(CharName,RealmName)!=0) { - eventlog(eventlog_level_error,__FUNCTION__,"faled to unlock char %s(*%s)@%s for gs %s(%d)",CharName,\ - AccountName,RealmName,conn->serverip,conn->serverid); - } else { - eventlog(eventlog_level_info,__FUNCTION__,"unlock char %s(*%s)@%s for gs %s(%d)",CharName,\ - AccountName,RealmName,conn->serverip,conn->serverid); - } - - } - } - if (result==D2DBS_GET_DATA_SUCCESS) { - bn_int_set(&getret->charcreatetime,bn_int_get(charinfo.header.create_time)); - /* FIXME: this should be rewritten to support string formatted time */ - if (bn_int_get(charinfo.header.create_time)>=prefs_get_ladderinit_time()) { - bn_int_set(&getret->allowladder,1); - } else { - bn_int_set(&getret->allowladder,0); - } - } else { - bn_int_set(&getret->charcreatetime,0); - bn_int_set(&getret->allowladder,0); - } - } else if (datatype==D2GS_DATA_PORTRAIT) { - datalen=dbs_packet_getdata_charinfo(conn,AccountName,CharName,databuf,kBufferSize ); - if (datalen>0) result=D2DBS_GET_DATA_SUCCESS ; - else { - datalen=0; - result=D2DBS_GET_DATA_FAILED ; - } - } else { - eventlog(eventlog_level_error,__FUNCTION__,"unknown data type %d",datatype); - return -1; - } - writelen=datalen+sizeof(*getret)+strlen(CharName)+1; - if (writelen > kBufferSize-conn->nCharsInWriteBuffer) return 0; - bn_short_set(&getret->h.type,D2DBS_D2GS_GET_DATA_REPLY); - bn_short_set(&getret->h.size,writelen); - bn_int_set(&getret->h.seqno,bn_int_get(getcom->h.seqno)); - bn_short_set(&getret->datatype,bn_short_get(getcom->datatype)); - bn_int_set(&getret->result,result); - bn_short_set(&getret->datalen,datalen); - writepos+=sizeof(*getret); - strncpy(writepos,CharName,MAX_NAME_LEN); - writepos+=strlen(CharName)+1; - if (datalen) memcpy(writepos,databuf,datalen); - conn->nCharsInWriteBuffer += writelen; - return 1; -} - -static unsigned int dbs_packet_updateladder(t_d2dbs_connection * conn) -{ - char CharName[MAX_NAME_LEN+16]; - char RealmName[MAX_NAME_LEN+16]; - t_d2gs_d2dbs_update_ladder * updateladder; - char * readpos; - t_d2ladder_info charladderinfo; - - readpos=conn->ReadBuf; - updateladder=(t_d2gs_d2dbs_update_ladder *)readpos; - - readpos+=sizeof(*updateladder); - strncpy(CharName,readpos,MAX_NAME_LEN); - CharName[MAX_NAME_LEN]=0; - readpos+=strlen(CharName)+1; - strncpy(RealmName,readpos,MAX_NAME_LEN); - RealmName[MAX_NAME_LEN]=0; - readpos+=strlen(RealmName)+1; - if (readpos != conn->ReadBuf+bn_short_get(updateladder->h.size)) { - eventlog(eventlog_level_error,__FUNCTION__,"request packet size error"); - return -1; - } - - strcpy(charladderinfo.charname,CharName); - charladderinfo.experience=bn_int_get(updateladder->charexplow); - charladderinfo.level=bn_int_get(updateladder->charlevel); - charladderinfo.status=bn_short_get(updateladder->charstatus); - charladderinfo.class=bn_short_get(updateladder->charclass); - eventlog(eventlog_level_info,__FUNCTION__,"update ladder for %s@%s for gs %s(%d)",CharName,RealmName,conn->serverip,conn->serverid); - d2ladder_update(&charladderinfo); - return 1; -} - -static unsigned int dbs_packet_charlock(t_d2dbs_connection * conn) -{ - char CharName[MAX_NAME_LEN+16]; - char AccountName[MAX_NAME_LEN+16]; - char RealmName[MAX_NAME_LEN+16]; - t_d2gs_d2dbs_char_lock * charlock; - char * readpos; - - readpos=conn->ReadBuf; - charlock=(t_d2gs_d2dbs_char_lock*)readpos; - - readpos+=sizeof(*charlock); - strncpy(AccountName,readpos,MAX_NAME_LEN); - AccountName[MAX_NAME_LEN]=0; - readpos+=strlen(AccountName)+1; - strncpy(CharName,readpos,MAX_NAME_LEN); - CharName[MAX_NAME_LEN]=0; - readpos+=strlen(CharName)+1; - strncpy(RealmName,readpos,MAX_NAME_LEN); - RealmName[MAX_NAME_LEN]=0; - readpos+=strlen(RealmName)+1; - - if (readpos != conn->ReadBuf+ bn_short_get(charlock->h.size)) { - eventlog(eventlog_level_error,__FUNCTION__,"request packet size error"); - return -1; - } - - if (bn_int_get(charlock->lockstatus)) { - if (cl_lock_char(CharName,RealmName,conn->serverid)!=0) { - eventlog(eventlog_level_error,__FUNCTION__,"failed to lock character %s(*%s)@%s for gs %s(%d)",CharName,AccountName,RealmName,conn->serverip,conn->serverid); - } else { - eventlog(eventlog_level_info,__FUNCTION__,"lock character %s(*%s)@%s for gs %s(%d)",CharName,AccountName,RealmName,conn->serverip,conn->serverid); - } - } else { - if (cl_unlock_char(CharName,RealmName) != 0) { - eventlog(eventlog_level_error,__FUNCTION__,"failed to unlock character %s(*%s)@%s for gs %s(%d)",CharName,AccountName,RealmName,conn->serverip,conn->serverid); - } else { - eventlog(eventlog_level_info,__FUNCTION__,"unlock character %s(*%s)@%s for gs %s(%d)",CharName,AccountName,RealmName,conn->serverip,conn->serverid); - } - } - return 1; -} - -/* - return value: - 1 : process one or more packet - 0 : not get a whole packet,do nothing - -1 : error -*/ -extern int dbs_packet_handle(t_d2dbs_connection* conn) -{ - unsigned short readlen,writelen; - t_d2dbs_d2gs_header * readhead; - unsigned short retval; - - if (conn->stats==0) { - if (conn->nCharsInReadBuffer<(signed)sizeof(t_d2gs_d2dbs_connect)) { - return 0; - } - conn->stats=1; - conn->type=conn->ReadBuf[0]; - - if (conn->type==CONNECT_CLASS_D2GS_TO_D2DBS) { - if (dbs_verify_ipaddr(d2dbs_prefs_get_d2gs_list(),conn)<0) { - eventlog(eventlog_level_error,__FUNCTION__,"d2gs connection from unknown ip address"); - return -1; - } - readlen=1; - writelen=0; - eventlog(eventlog_level_info,__FUNCTION__,"set connection type for gs %s(%d) on socket %d", conn->serverip, conn->serverid, conn->sd); - eventlog_step(prefs_get_logfile_gs(),eventlog_level_info,"set connection type for gs %s(%d) on socket %d", conn->serverip, conn->serverid, conn->sd); - } else { - eventlog(eventlog_level_error,__FUNCTION__,"unknown connection type"); - return -1; - } - conn->nCharsInReadBuffer -= readlen; - memmove(conn->ReadBuf,conn->ReadBuf+readlen,conn->nCharsInReadBuffer); - } else if (conn->stats==1) { - if (conn->type==CONNECT_CLASS_D2GS_TO_D2DBS) { - while (conn->nCharsInReadBuffer >= (signed)sizeof(*readhead)) { - readhead=(t_d2dbs_d2gs_header *)conn->ReadBuf; - readlen=bn_short_get(readhead->size); - if (conn->nCharsInReadBuffer < readlen) break; - switch(bn_short_get(readhead->type)) { - case D2GS_D2DBS_SAVE_DATA_REQUEST: - retval=dbs_packet_savedata(conn); - break; - case D2GS_D2DBS_GET_DATA_REQUEST: - retval=dbs_packet_getdata(conn); - break; - case D2GS_D2DBS_UPDATE_LADDER: - retval=dbs_packet_updateladder(conn); - break; - case D2GS_D2DBS_CHAR_LOCK: - retval=dbs_packet_charlock(conn); - break; - case D2GS_D2DBS_ECHOREPLY: - retval=dbs_packet_echoreply(conn); - break; - default: - eventlog(eventlog_level_error,__FUNCTION__,"unknown request type %d",\ - bn_short_get(readhead->type)); - retval=-1; - } - if (retval!=1) return retval; - conn->nCharsInReadBuffer -= readlen; - memmove(conn->ReadBuf,conn->ReadBuf+readlen,conn->nCharsInReadBuffer); - } - } else { - eventlog(eventlog_level_error,__FUNCTION__,"unknown connection type %d",conn->type); - return -1; - } - } else { - eventlog(eventlog_level_error,__FUNCTION__,"unknown connection stats"); - return -1; - } - return 1; -} - -/* FIXME: we should save client ipaddr into c->ipaddr after accept */ -static int dbs_verify_ipaddr(char const * addrlist,t_d2dbs_connection * c) -{ - struct in_addr in; - char * adlist; - char const * ipaddr; - char * s, * temp; - t_elem * elem; - t_d2dbs_connection * tempc; - unsigned int valid; - unsigned int resolveipaddr; - - in.s_addr=htonl(c->ipaddr); - ipaddr=inet_ntoa(in); - adlist = xstrdup(addrlist); - temp=adlist; - valid=0; - while ((s=strsep(&temp, ","))) { - host_lookup(s, &resolveipaddr); - if(resolveipaddr == 0) continue; - - if (!strcmp(ipaddr, (const char *)addr_num_to_ip_str(resolveipaddr))) { - valid=1; - break; - } - } - xfree(adlist); - if (valid) { - eventlog(eventlog_level_info,__FUNCTION__,"ip address %s is valid",ipaddr); - LIST_TRAVERSE(dbs_server_connection_list,elem) - { - if (!(tempc=elem_get_data(elem))) continue; - if (tempc !=c && tempc->ipaddr==c->ipaddr) { - eventlog(eventlog_level_info,__FUNCTION__,"destroying previous connection %d",tempc->serverid); - dbs_server_shutdown_connection(tempc); - list_remove_elem(dbs_server_connection_list,&elem); - } - } - c->verified = 1; - return 0; - } else { - eventlog(eventlog_level_info,__FUNCTION__,"ip address %s is invalid",ipaddr); - } - return -1; -} - -int dbs_check_timeout(void) -{ - t_elem *elem; - t_d2dbs_connection *tempc; - time_t now; - int timeout; - - now=time(NULL); - timeout=d2dbs_prefs_get_idletime(); - LIST_TRAVERSE(dbs_server_connection_list,elem) - { - if (!(tempc=elem_get_data(elem))) continue; - if (now-tempc->last_active>timeout) { - eventlog(eventlog_level_debug,__FUNCTION__,"connection %d timed out",tempc->serverid); - dbs_server_shutdown_connection(tempc); - list_remove_elem(dbs_server_connection_list,&elem); - continue; - } - } - return 0; -} - -int dbs_keepalive(void) -{ - t_elem *elem; - t_d2dbs_connection *tempc; - t_d2dbs_d2gs_echorequest *echoreq; - unsigned short writelen; - unsigned char *writepos; - time_t now; - - writelen = sizeof(t_d2dbs_d2gs_echorequest); - now=time(NULL); - LIST_TRAVERSE(dbs_server_connection_list,elem) - { - if (!(tempc=elem_get_data(elem))) continue; - if (writelen > kBufferSize - tempc->nCharsInWriteBuffer) continue; - writepos = tempc->WriteBuf + tempc->nCharsInWriteBuffer; - echoreq = (t_d2dbs_d2gs_echorequest*)writepos; - bn_short_set(&echoreq->h.type, D2DBS_D2GS_ECHOREQUEST); - bn_short_set(&echoreq->h.size, writelen); - /* FIXME: sequence number not set */ - bn_int_set(&echoreq->h.seqno, 0); - tempc->nCharsInWriteBuffer += writelen; - } - return 0; -} - -/*************************************************************************************/ -#define CHARINFO_SIZE 0xC0 -#define CHARINFO_PORTRAIT_LEVEL_OFFSET 0x89 -#define CHARINFO_PORTRAIT_STATUS_OFFSET 0x8A -#define CHARINFO_SUMMARY_LEVEL_OFFSET 0xB8 -#define CHARINFO_SUMMARY_STATUS_OFFSET 0xB4 -#define CHARINFO_PORTRAIT_GFX_OFFSET 0x72 -#define CHARINFO_PORTRAIT_COLOR_OFFSET 0x7E - -#define CHARSAVE_LEVEL_OFFSET 0x2B -#define CHARSAVE_STATUS_OFFSET 0x24 -#define CHARSAVE_GFX_OFFSET 0x88 -#define CHARSAVE_COLOR_OFFSET 0x98 - -#define charstatus_to_portstatus(status) ((((status & 0xFF00) << 1) | (status & 0x00FF)) | 0x8080) -#define portstatus_to_charstatus(status) (((status & 0x7F00) >> 1) | (status & 0x007F)) - -static void dbs_packet_set_charinfo_level(char * CharName,char * charinfo) -{ - if (prefs_get_difficulty_hack()) { /* difficulty hack enabled */ - unsigned int level = bn_int_get(&charinfo[CHARINFO_SUMMARY_LEVEL_OFFSET]); - unsigned int plevel = bn_byte_get(&charinfo[CHARINFO_PORTRAIT_LEVEL_OFFSET]); - - /* levels 257 thru 355 */ - if (level != plevel) { - eventlog(eventlog_level_info,__FUNCTION__,"level mis-match for %s ( %u != %u ) setting to 255",CharName,level,plevel); - bn_byte_set((bn_byte *)&charinfo[CHARINFO_PORTRAIT_LEVEL_OFFSET],255); - bn_int_set((bn_int *)&charinfo[CHARINFO_SUMMARY_LEVEL_OFFSET],255); - } - } -} - -static int dbs_packet_fix_charinfo(t_d2dbs_connection * conn,char * AccountName,char * CharName,char * charsave) -{ - if (prefs_get_difficulty_hack()) { - unsigned char charinfo[CHARINFO_SIZE]; - unsigned int level = bn_byte_get(&charsave[CHARSAVE_LEVEL_OFFSET]); - unsigned short status = bn_short_get(&charsave[CHARSAVE_STATUS_OFFSET]); - unsigned short pstatus = charstatus_to_portstatus(status); - int i; - - /* - * charinfo is only updated from level 1 to 99 (d2gs issue) - * from 100 to 256 d2gs does not send it - * when value rolls over (level 256 = 0) - * and charactar reaches level 257 (rolled over to level 1) - * d2gs starts sending it agian until level 356 (rolled over to 100) - * is reached agian. etc. etc. etc. - */ - if (level == 0) /* level 256, 512, 768, etc */ - level = 255; - - if (level < 100) - return 1; /* d2gs will send charinfo - level will be set to 255 at that time if needed */ - - eventlog(eventlog_level_info,__FUNCTION__,"level %u > 99 for %s",level,CharName); - - if(!(dbs_packet_getdata_charinfo(conn,AccountName,CharName,charinfo,CHARINFO_SIZE))) { - eventlog(eventlog_level_error,__FUNCTION__,"unable to get charinfo for %s",CharName); - return 0; - } - - /* if level in charinfo file is already set to 255, - * then is must have been set when d2gs sent the charinfo - * and got a level mis-match (levels 257 - 355) - * or level is actually 255. In eather case we set to 255 - * this should work for any level mod - */ - if (bn_byte_get(&charinfo[CHARINFO_PORTRAIT_LEVEL_OFFSET]) == 255) - level = 255; - - eventlog(eventlog_level_info,__FUNCTION__,"updating charinfo for %s -> level = %u , status = 0x%04X , pstatus = 0x%04X",CharName,level,status,pstatus); - bn_byte_set((bn_byte *)&charinfo[CHARINFO_PORTRAIT_LEVEL_OFFSET],level); - bn_int_set((bn_int *)&charinfo[CHARINFO_SUMMARY_LEVEL_OFFSET],level); - bn_short_set((bn_short *)&charinfo[CHARINFO_PORTRAIT_STATUS_OFFSET],pstatus); - bn_int_set((bn_int *)&charinfo[CHARINFO_SUMMARY_STATUS_OFFSET],status); - - for (i=0;i<11;i++) { - bn_byte_set((bn_byte *)&charinfo[CHARINFO_PORTRAIT_GFX_OFFSET+i],bn_byte_get(&charsave[CHARSAVE_GFX_OFFSET+i])); - bn_byte_set((bn_byte *)&charinfo[CHARINFO_PORTRAIT_COLOR_OFFSET+i],bn_byte_get(&charsave[CHARSAVE_GFX_OFFSET+i])); - } - - if (!(dbs_packet_savedata_charinfo(conn,AccountName,CharName,charinfo,CHARINFO_SIZE))) { - eventlog(eventlog_level_error,__FUNCTION__,"unable to save charinfo for %s",CharName); - return 0; - } - - return 1; /* charinfo updated */ - } - - return 1; /* difficulty hack not enabled */ -} diff --git a/d2pack109/src/d2dbs/dbspacket.h b/d2pack109/src/d2dbs/dbspacket.h deleted file mode 100644 index 81da50b..0000000 --- a/d2pack109/src/d2dbs/dbspacket.h +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright (C) 2001 faster (lqx@cic.tsinghua.edu.cn) - * Copyright (C) 2001 sousou (liupeng.cs@263.net) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_DBSPACKET_H -#define INCLUDED_DBSPACKET_H - -#include "dbserver.h" -#include "common/bn_type.h" - -#pragma pack(1) - -typedef struct { - bn_short size; - bn_short type; - bn_int seqno; -} t_d2dbs_d2gs_header; - -typedef struct { - bn_byte class; -} t_d2gs_d2dbs_connect; -#define CONNECT_CLASS_D2GS_TO_D2DBS 0x65 - -#define D2GS_D2DBS_SAVE_DATA_REQUEST 0x30 -typedef struct { - t_d2dbs_d2gs_header h; - bn_short datatype; - bn_short datalen; - /* AccountName */ - /* CharName */ - /* data */ -} t_d2gs_d2dbs_save_data_request; -#define D2GS_DATA_CHARSAVE 0x01 -#define D2GS_DATA_PORTRAIT 0x02 - -#define D2DBS_D2GS_SAVE_DATA_REPLY 0x30 -typedef struct { - t_d2dbs_d2gs_header h; - bn_int result; - bn_short datatype; - /* CharName */ -} t_d2dbs_d2gs_save_data_reply; -#define D2DBS_SAVE_DATA_SUCCESS 0 -#define D2DBS_SAVE_DATA_FAILED 1 - -#define D2GS_D2DBS_GET_DATA_REQUEST 0x31 -typedef struct { - t_d2dbs_d2gs_header h; - bn_short datatype; - /* AccountName */ - /* CharName */ -} t_d2gs_d2dbs_get_data_request; - -#define D2DBS_D2GS_GET_DATA_REPLY 0x31 -typedef struct { - t_d2dbs_d2gs_header h; - bn_int result; - bn_int charcreatetime; - bn_int allowladder; - bn_short datatype; - bn_short datalen; - /* CharName */ - /* data */ -} t_d2dbs_d2gs_get_data_reply; - -#define D2DBS_GET_DATA_SUCCESS 0 -#define D2DBS_GET_DATA_FAILED 1 -#define D2DBS_GET_DATA_CHARLOCKED 2 - -#define D2GS_D2DBS_UPDATE_LADDER 0x32 -typedef struct { - t_d2dbs_d2gs_header h; - bn_int charlevel; - bn_int charexplow; - bn_int charexphigh; - bn_short charclass; - bn_short charstatus; - /* CharName */ - /* RealmName */ -} t_d2gs_d2dbs_update_ladder; - -#define D2GS_D2DBS_CHAR_LOCK 0x33 -typedef struct { - t_d2dbs_d2gs_header h; - bn_int lockstatus; - /* CharName */ - /* RealmName */ -} t_d2gs_d2dbs_char_lock; - -#define D2DBS_D2GS_ECHOREQUEST 0x34 -typedef struct { - t_d2dbs_d2gs_header h; -} t_d2dbs_d2gs_echorequest; - -#define D2GS_D2DBS_ECHOREPLY 0x34 -typedef struct { - t_d2dbs_d2gs_header h; -} t_d2gs_d2dbs_echoreply; - - -#endif - -extern int dbs_packet_handle(t_d2dbs_connection * conn); -extern int dbs_keepalive(void); -extern int dbs_check_timeout(void); - diff --git a/d2pack109/src/d2dbs/handle_signal.c b/d2pack109/src/d2dbs/handle_signal.c deleted file mode 100644 index 33a03a0..0000000 --- a/d2pack109/src/d2dbs/handle_signal.c +++ /dev/null @@ -1,213 +0,0 @@ -/* - * Copyright (C) 2000,2001 Onlyer (onlyer@263.net) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#include "common/setup_before.h" -#include "setup.h" - -#ifdef STDC_HEADERS -# include -#else -# ifdef HAVE_MALLOC_H -# include -# endif -#endif -#include -#ifdef HAVE_STRING_H -# include -#else -# ifdef HAVE_STRINGS_H -# include -# endif -# ifdef HAVE_MEMORY_H -# include -# endif -#endif -#include "compat/strdup.h" -#ifdef TIME_WITH_SYS_TIME -# include -# include -#else -# ifdef HAVE_SYS_TIME_H -# include -# else -# include -# endif -#endif -#ifdef DO_POSIXSIG -# include -# include "compat/signal.h" -#endif -#ifdef HAVE_FCNTL_H -# include -#else -# ifdef HAVE_SYS_FILE_H -# include -# endif -#endif -#ifdef HAVE_UNISTD_H -# include -#endif - -#include "dbserver.h" -#include "prefs.h" -#include "d2ladder.h" -#include "cmdline_parse.h" -#include "handle_signal.h" -#include "common/eventlog.h" -#include "common/xalloc.h" -#include "common/setup_after.h" - -static void on_signal(int s); - -static volatile struct -{ - unsigned char do_quit; - unsigned char cancel_quit; - unsigned char reload_config; - unsigned char save_ladder; - unsigned int exit_time; -} signal_data ={ 0, 0, 0, 0, 0 }; - -extern int d2dbs_handle_signal(void) -{ - time_t now; - char const * levels; - char * temp; - char const * tok; - - - if (signal_data.cancel_quit) { - signal_data.cancel_quit=0; - if (!signal_data.exit_time) { - eventlog(eventlog_level_info,__FUNCTION__,"there is no previous shutdown to be canceled"); - } else { - signal_data.exit_time=0; - eventlog(eventlog_level_info,__FUNCTION__,"shutdown was canceled due to signal"); - } - } - if (signal_data.do_quit) { - signal_data.do_quit=0; - now=time(NULL); - if (!signal_data.exit_time) { - signal_data.exit_time=now+d2dbs_prefs_get_shutdown_delay(); - } else { - signal_data.exit_time-=d2dbs_prefs_get_shutdown_decr(); - } - eventlog(eventlog_level_info,__FUNCTION__,"the server is going to shutdown in %lu minutes",(signal_data.exit_time-now)/60); - } - if (signal_data.exit_time) { - now=time(NULL); - if (now >= (signed)signal_data.exit_time) { - signal_data.exit_time=0; - eventlog(eventlog_level_info,__FUNCTION__,"shutdown server due to signal"); - return -1; - } - } - if (signal_data.reload_config) { - signal_data.reload_config=0; - eventlog(eventlog_level_info,__FUNCTION__,"reloading configuartion file due to signal"); - if (d2dbs_prefs_reload(d2dbs_cmdline_get_prefs_file())<0) { - eventlog(eventlog_level_error,__FUNCTION__,"error reload configuration file,exitting"); - return -1; - } - eventlog_clear_level(); - if ((levels = d2dbs_prefs_get_loglevels())) - { - temp = xstrdup(levels); - tok = strtok(temp,","); /* strtok modifies the string it is passed */ - - while (tok) - { - if (eventlog_add_level(tok)<0) - eventlog(eventlog_level_error,__FUNCTION__,"could not add log level \"%s\"",tok); - tok = strtok(NULL,","); - } - xfree(temp); - } - - if (!d2dbs_cmdline_get_debugmode()) eventlog_open(d2dbs_prefs_get_logfile()); - } - if (signal_data.save_ladder) { - signal_data.save_ladder=0; - eventlog(eventlog_level_info,__FUNCTION__,"save ladder data due to signal"); - d2ladder_saveladder(); - } - return 0; -} - -#ifdef WIN32 -extern void d2dbs_signal_quit_wrapper(void) -{ - signal_data.do_quit=1; -} - -extern void d2dbs_signal_reload_config_wrapper(void) -{ - signal_data.reload_config = 1; -} - -extern void d2dbs_signal_save_ladder_wrapper(void) -{ - signal_data.save_ladder = 1; -} - -extern void d2dbs_signal_exit_wrapper(void) -{ - signal_data.exit_time = 1; -} -#else -extern int d2dbs_handle_signal_init(void) -{ - signal(SIGINT,on_signal); - signal(SIGTERM,on_signal); - signal(SIGABRT,on_signal); - signal(SIGHUP,on_signal); - signal(SIGUSR1,on_signal); - signal(SIGPIPE,on_signal); - return 0; -} - -static void on_signal(int s) -{ - switch (s) { - case SIGINT: - eventlog(eventlog_level_debug,__FUNCTION__,"sigint received"); - signal_data.do_quit=1; - break; - case SIGTERM: - eventlog(eventlog_level_debug,__FUNCTION__,"sigint received"); - signal_data.do_quit=1; - break; - case SIGABRT: - eventlog(eventlog_level_debug,__FUNCTION__,"sigabrt received"); - signal_data.cancel_quit=1; - break; - case SIGHUP: - eventlog(eventlog_level_debug,__FUNCTION__,"sighup received"); - signal_data.reload_config=1; - break; - case SIGUSR1: - eventlog(eventlog_level_debug,__FUNCTION__,"sigusr1 received"); - signal_data.save_ladder=1; - break; - case SIGPIPE: - eventlog(eventlog_level_debug,__FUNCTION__,"sigpipe received"); - break; - } - signal(s,on_signal); -} -#endif diff --git a/d2pack109/src/d2dbs/handle_signal.h b/d2pack109/src/d2dbs/handle_signal.h deleted file mode 100644 index 2fde910..0000000 --- a/d2pack109/src/d2dbs/handle_signal.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2000,2001 Onlyer (onlyer@263.net) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_HANDLE_SIGNAL_H -#define INCLUDED_HANDLE_SIGNAL_H - -#ifndef WIN32 -extern int d2dbs_handle_signal_init(void); -#else -extern void d2dbs_signal_quit_wrapper(void); -extern void d2dbs_signal_reload_config_wrapper(void); -extern void d2dbs_signal_save_ladder_wrapper(void); -extern void d2dbs_signal_exit_wrapper(void); -#endif - -extern int d2dbs_handle_signal(void); - -#endif diff --git a/d2pack109/src/d2dbs/main.c b/d2pack109/src/d2dbs/main.c deleted file mode 100644 index 4083bba..0000000 --- a/d2pack109/src/d2dbs/main.c +++ /dev/null @@ -1,241 +0,0 @@ -/* - * Copyright (C) 2000,2001 Onlyer (onlyer@263.net) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#include "common/setup_before.h" -#include "setup.h" - -#include -#ifdef STDC_HEADERS -# include -#else -# ifdef HAVE_MALLOC_H -# include -# endif -#endif -#ifdef HAVE_UNISTD_H -# include -#endif -#include -#ifdef HAVE_STRING_H -# include -#else -# ifdef HAVE_STRINGS_H -# include -# endif -# ifdef HAVE_MEMORY_H -# include -# endif -#endif -#include "compat/strdup.h" -#ifdef HAVE_SYS_STAT_H -# include -#endif -#ifdef HAVE_SYS_TYPES_H -# include -#endif - -#include "prefs.h" -#include "cmdline_parse.h" -#include "version.h" -#include "common/eventlog.h" -#include "handle_signal.h" -#include "dbserver.h" -#include "common/xalloc.h" -#ifdef WIN32 -# include "win32/service.h" -#endif -#ifdef WIN32_GUI -# include "win32/winmain.h" -#endif -#include "common/setup_after.h" - -static FILE * eventlog_fp; - -char serviceLongName[] = "d2dbs109 service"; -char serviceName[] = "d2dbs109"; -char serviceDescription[] = "Diablo 2 (109) DataBase Server"; - -int g_ServiceStatus = -1; - -static int init(void); -static int cleanup(void); -static int config_init(int argc, char * * argv); -static int config_cleanup(void); -static int setup_daemon(void); - -#ifdef DO_DAEMONIZE -static int setup_daemon(void) -{ - int pid; - - if (chdir("/")<0) { - eventlog(eventlog_level_error,__FUNCTION__,"can not change working directory to root directory (chdir: %s)",strerror(errno)); - return -1; - } - - close(STDIN_FILENO); - close(STDOUT_FILENO); - if (!d2dbs_cmdline_get_debugmode()) { - close(STDERR_FILENO); - } - - switch ((pid=fork())) { - case 0: - break; - case -1: - eventlog(eventlog_level_error,__FUNCTION__,"error create child process (fork: %s)",strerror(errno)); - return -1; - default: - return pid; - } - umask(0); - setsid(); - return 0; -} -#endif - -static int init(void) -{ - return 0; -} - -static int cleanup(void) -{ - return 0; -} - -static int config_init(int argc, char * * argv) -{ - char const * levels; - char * temp; - char const * tok; - int pid; - - if (d2dbs_cmdline_parse(argc, argv)<0) { - return -1; - } -#ifdef WIN32 - if (d2dbs_cmdline_get_run_as_service()) { - Win32_ServiceRun(); - return 1; - } -#endif - if (d2dbs_cmdline_get_version()) { - d2dbs_cmdline_show_version(); - return -1; - } - if (d2dbs_cmdline_get_help()) { - d2dbs_cmdline_show_help(); - return -1; - } -#ifdef DO_DAEMONIZE - if (!d2dbs_cmdline_get_foreground()) { - if (!((pid = setup_daemon()) == 0)) { - return pid; - } - } -#endif -#ifdef WIN32 - if (d2dbs_cmdline_get_make_service()) - { - if (strcmp(d2dbs_cmdline_get_make_service(), "install") == 0) { - fprintf(stderr, "Installing service\n"); - Win32_ServiceInstall(); - return 1; - } - if (strcmp(d2dbs_cmdline_get_make_service(), "uninstall") == 0) { - fprintf(stderr, "Uninstalling service\n"); - Win32_ServiceUninstall(); - return 1; - } - } -#endif - if (d2dbs_prefs_load(d2dbs_cmdline_get_prefs_file())<0) { - eventlog(eventlog_level_error,__FUNCTION__,"error loading configuration file %s",d2dbs_cmdline_get_prefs_file()); - return -1; - } - - eventlog_clear_level(); - if ((levels = d2dbs_prefs_get_loglevels())) - { - temp = xstrdup(levels); - tok = strtok(temp,","); /* strtok modifies the string it is passed */ - - while (tok) - { - if (eventlog_add_level(tok)<0) - eventlog(eventlog_level_error,__FUNCTION__,"could not add log level \"%s\"",tok); - tok = strtok(NULL,","); - } - - xfree(temp); - } - - - if (d2dbs_cmdline_get_debugmode()) { - eventlog_set(stderr); - } else if (d2dbs_cmdline_get_logfile()) { - if (eventlog_open(d2dbs_cmdline_get_logfile())<0) { - eventlog(eventlog_level_error,__FUNCTION__,"error open eventlog file %s",d2dbs_cmdline_get_logfile()); - return -1; - } - } else { - if (eventlog_open(d2dbs_prefs_get_logfile())<0) { - eventlog(eventlog_level_error,__FUNCTION__,"error open eventlog file %s",d2dbs_prefs_get_logfile()); - return -1; - } - } - return 0; -} - -static int config_cleanup(void) -{ - d2dbs_prefs_unload(); - d2dbs_cmdline_cleanup(); - eventlog_close(); - if (eventlog_fp) fclose(eventlog_fp); - return 0; -} - -#ifdef WIN32_GUI -extern int server_main(int argc, char * * argv) -#else -extern int main(int argc, char * * argv) -#endif -{ - int pid; - - eventlog_set(stderr); - pid = config_init(argc, argv); - if (!(pid == 0)) { - return pid; - } - eventlog(eventlog_level_info,__FUNCTION__,D2DBS_VERSION); - if (init()<0) { - eventlog(eventlog_level_error,__FUNCTION__,"failed to init"); - return -1; - } else { - eventlog(eventlog_level_info,__FUNCTION__,"server initialized"); - } -#ifndef WIN32 - d2dbs_handle_signal_init(); -#endif - dbs_server_main(); - cleanup(); - config_cleanup(); - return 0; -} diff --git a/d2pack109/src/d2dbs/prefs.c b/d2pack109/src/d2dbs/prefs.c deleted file mode 100644 index c494c82..0000000 --- a/d2pack109/src/d2dbs/prefs.c +++ /dev/null @@ -1,190 +0,0 @@ -/* - * Copyright (C) 2000,2001 Onlyer (onlyer@263.net) - * Copyright (C) 2001 sousou (liupeng.cs@263.net) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#include "common/setup_before.h" -#include "setup.h" - -#ifdef HAVE_STDDEF_H -# include -#else -# ifndef NULL -# define NULL ((void *)0) -# endif -#endif -#ifdef HAVE_STRING_H -# include -#else -# ifdef HAVE_STRINGS_H -# include -# endif -# ifdef HAVE_MEMORY_H -# include -# endif -#endif - -#include "prefs.h" -#include "d2cs/conf.h" -#include "common/eventlog.h" -#include "common/setup_after.h" - -static t_conf_table prefs_conf_table[]={ - { "logfile", offsetof(t_prefs,logfile), conf_type_str, 0, DEFAULT_LOG_FILE }, - { "logfile-gs", offsetof(t_prefs,logfile_gs), conf_type_str, 0, DEFAULT_LOG_FILE_GS }, - { "loglevels", offsetof(t_prefs,loglevels), conf_type_str, 0, DEFAULT_LOG_LEVELS }, - { "servaddrs", offsetof(t_prefs,servaddrs), conf_type_str, 0, D2DBS_SERVER_ADDRS }, - { "gameservlist", offsetof(t_prefs,gameservlist), conf_type_str, 0, D2GS_SERVER_LIST }, - { "charsavedir", offsetof(t_prefs,charsavedir), conf_type_str, 0, D2DBS_CHARSAVE_DIR }, - { "charinfodir", offsetof(t_prefs,charinfodir), conf_type_str, 0, D2DBS_CHARINFO_DIR }, - { "bak_charsavedir", offsetof(t_prefs,charsavebakdir), conf_type_str, 0, D2DBS_CHARSAVEBAK_DIR }, - { "bak_charinfodir", offsetof(t_prefs,charinfobakdir), conf_type_str, 0, D2DBS_CHARINFOBAK_DIR }, - { "ladderdir", offsetof(t_prefs,ladderdir), conf_type_str, 0, D2DBS_LADDER_DIR }, - { "laddersave_interval", offsetof(t_prefs,laddersave_interval), conf_type_int, 3600, NULL }, - { "ladderinit_time", offsetof(t_prefs,ladderinit_time), conf_type_int, 0, NULL }, - { "shutdown_delay", offsetof(t_prefs,shutdown_delay), conf_type_int, DEFAULT_SHUTDOWN_DELAY, NULL }, - { "shutdown_decr", offsetof(t_prefs,shutdown_decr), conf_type_int, DEFAULT_SHUTDOWN_DECR, NULL }, - { "idletime", offsetof(t_prefs,idletime), conf_type_int, DEFAULT_IDLETIME, NULL }, - { "keepalive_interval", offsetof(t_prefs,keepalive_interval), conf_type_int, DEFAULT_KEEPALIVE_INTERVAL, NULL }, - { "timeout_checkinterval",offsetof(t_prefs,timeout_checkinterval),conf_type_int, DEFAULT_TIMEOUT_CHECKINTERVAL, NULL}, - { "XML_ladder_output" ,offsetof(t_prefs,XML_ladder_output), conf_type_int, 0, NULL }, - { "ladderupdate_threshold",offsetof(t_prefs,ladderupdate_threshold),conf_type_int,DEFAULT_LADDERUPDATE_THRESHOLD, NULL}, - { "difficulty_hack", offsetof(t_prefs,difficulty_hack), conf_type_int, 0, NULL }, - { NULL, 0, conf_type_none, 0, NULL } -}; - -static t_prefs prefs_conf; - -extern int d2dbs_prefs_load(char const * filename) -{ - memset(&prefs_conf,0,sizeof(prefs_conf)); - if (conf_load_file(filename,prefs_conf_table,&prefs_conf,sizeof(prefs_conf))<0) { - return -1; - } - return 0; -} - -extern int d2dbs_prefs_reload(char const * filename) -{ - d2dbs_prefs_unload(); - if (d2dbs_prefs_load(filename)<0) return -1; - return 0; -} - -extern int d2dbs_prefs_unload(void) -{ - return conf_cleanup(prefs_conf_table, &prefs_conf, sizeof(prefs_conf)); -} - -extern char const * d2dbs_prefs_get_servaddrs(void) -{ - return prefs_conf.servaddrs; -} - -extern char const * d2dbs_prefs_get_charsave_dir(void) -{ - return prefs_conf.charsavedir; -} - -extern char const * d2dbs_prefs_get_charinfo_dir(void) -{ - return prefs_conf.charinfodir; -} - -extern char const * d2dbs_prefs_get_d2gs_list(void) -{ - return prefs_conf.gameservlist; -} - -extern char const * d2dbs_prefs_get_ladder_dir(void) -{ - return prefs_conf.ladderdir; -} - -extern char const * d2dbs_prefs_get_logfile(void) -{ - return prefs_conf.logfile; -} - -extern char const * prefs_get_logfile_gs(void) -{ - return prefs_conf.logfile_gs; -} - -extern char const * prefs_get_charsave_bak_dir(void) -{ - return prefs_conf.charsavebakdir; -} - -extern char const * prefs_get_charinfo_bak_dir(void) -{ - return prefs_conf.charinfobakdir; -} - -extern unsigned int prefs_get_laddersave_interval(void) -{ - return prefs_conf.laddersave_interval; -} - -extern unsigned int prefs_get_ladderinit_time(void) -{ - return prefs_conf.ladderinit_time; -} - -extern char const * d2dbs_prefs_get_loglevels(void) -{ - return prefs_conf.loglevels; -} - -extern unsigned int d2dbs_prefs_get_shutdown_delay(void) -{ - return prefs_conf.shutdown_delay; -} - -extern unsigned int d2dbs_prefs_get_shutdown_decr(void) -{ - return prefs_conf.shutdown_decr; -} - -extern unsigned int prefs_get_keepalive_interval(void) -{ - return prefs_conf.keepalive_interval; -} - -extern unsigned int d2dbs_prefs_get_idletime(void) -{ - return prefs_conf.idletime; -} - -extern unsigned int d2dbs_prefs_get_timeout_checkinterval(void) -{ - return prefs_conf.timeout_checkinterval; -} - -extern unsigned int d2dbs_prefs_get_XML_output_ladder(void) -{ - return prefs_conf.XML_ladder_output; -} - -extern unsigned int prefs_get_ladderupdate_threshold(void) -{ - return prefs_conf.ladderupdate_threshold; -} - -extern unsigned int prefs_get_difficulty_hack(void) -{ - return prefs_conf.difficulty_hack; -} diff --git a/d2pack109/src/d2dbs/prefs.h b/d2pack109/src/d2dbs/prefs.h deleted file mode 100644 index 936edf8..0000000 --- a/d2pack109/src/d2dbs/prefs.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (C) 2000,2001 Onlyer (onlyer@263.net) - * Copyright (C) 2001 sousou (liupeng.cs@263.net) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_PREFS_H -#define INCLUDED_PREFS_H - -typedef struct -{ - char const * logfile; - char const * logfile_gs; - char const * loglevels; - char const * servaddrs; - char const * gameservlist; - char const * charsavedir; - char const * charsavebakdir; - char const * charinfodir; - char const * charinfobakdir; - char const * ladderdir; - unsigned int laddersave_interval; - unsigned int ladderinit_time; - unsigned int shutdown_delay; - unsigned int shutdown_decr; - unsigned int idletime; - unsigned int keepalive_interval; - unsigned int timeout_checkinterval; - unsigned int XML_ladder_output; - unsigned int ladderupdate_threshold; - unsigned int difficulty_hack; -} t_prefs; - -extern int d2dbs_prefs_load(char const * filename); -extern int d2dbs_prefs_reload(char const * filename); -extern int d2dbs_prefs_unload(void); - -extern char const * d2dbs_prefs_get_logfile(void); -extern char const * prefs_get_logfile_gs(void); -extern char const * d2dbs_prefs_get_servaddrs(void); -extern char const * d2dbs_prefs_get_charsave_dir(void); -extern char const * d2dbs_prefs_get_charinfo_dir(void); -extern char const * prefs_get_charsave_bak_dir(void); -extern char const * prefs_get_charinfo_bak_dir(void); -extern char const * d2dbs_prefs_get_ladder_dir(void); -extern char const * d2dbs_prefs_get_d2gs_list(void); -extern unsigned int prefs_get_laddersave_interval(void); -extern unsigned int prefs_get_ladderinit_time(void); -extern char const * d2dbs_prefs_get_loglevels(void); -extern unsigned int d2dbs_prefs_get_shutdown_delay(void); -extern unsigned int d2dbs_prefs_get_shutdown_decr(void); -extern unsigned int d2dbs_prefs_get_idletime(void); -extern unsigned int prefs_get_keepalive_interval(void); -extern unsigned int d2dbs_prefs_get_timeout_checkinterval(void); -extern unsigned int d2dbs_prefs_get_XML_output_ladder(void); -extern unsigned int prefs_get_ladderupdate_threshold(void); -extern unsigned int prefs_get_difficulty_hack(void); - -#endif diff --git a/d2pack109/src/d2dbs/setup.h b/d2pack109/src/d2dbs/setup.h deleted file mode 100644 index 4e19a3c..0000000 --- a/d2pack109/src/d2dbs/setup.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (C) 2001 sousou (liupeng.cs@263.net) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INLCUDED_D2DBS_SETUP_H -#define INLCUDED_D2DBS_SETUP_H - -#if !defined(MAX_PATH) && !defined(WIN32) -# define MAX_PATH 1024 -#endif - -#ifndef WIN32 -typedef unsigned int BOOL; -#endif - -#define TRUE 1 -#define FALSE 0 -#define tf(a) ((a)?1:0) -#define SELECT_TIME_OUT 20000 -#define kBufferSize (1024*20) -#define kMaxPacketLength (1024*5) -#define MAX_GAMEPASS_LEN 16 -#define MAX_GAMEDESC_LEN 32 - -#define MAX_NAME_LEN 16 -#define MAX_CHARNAME_LEN 16 -#define MAX_ACCTNAME_LEN 16 -#define MAX_GAMENAME_LEN 16 -#define MAX_REALMNAME_LEN 32 - -#define DEFAULT_LOG_FILE "/usr/local/var/d2dbs.log" -#define DEFAULT_LOG_FILE_GS "/usr/local/var/d2dbs-gs.log" -#define DEFAULT_LOG_LEVELS "info,warn,error" -#define D2DBS_CHARSAVE_DIR "/usr/local/var/charsave" -#define D2DBS_CHARINFO_DIR "/usr/local/var/charinfo" -#define D2DBS_CHARSAVEBAK_DIR "/usr/local/var/bak/charsave" -#define D2DBS_CHARINFOBAK_DIR "/usr/local/var/bak/charinfo" -#define D2DBS_LADDER_DIR "/usr/local/var/ladders" -#ifndef D2DBS_DEFAULT_CONF_FILE -# define D2DBS_DEFAULT_CONF_FILE "conf/d2dbs.conf" -#endif -#define DEFAULT_MEMLOG_FILE "/tmp/d2dbs-mem.log" -#define DEFAULT_LISTEN_PORT 6114 -#define D2DBS_SERVER_ADDRS "0.0.0.0" -#define D2GS_SERVER_LIST "192.168.0.1" -#define LOG_LEVEL LOG_MSG -#define DEFAULT_GS_MAX 256 -#define DEFAULT_SHUTDOWN_DELAY 300 -#define DEFAULT_SHUTDOWN_DECR 60 -#define DEFAULT_IDLETIME 300 -#define DEFAULT_KEEPALIVE_INTERVAL 60 -#define DEFAULT_TIMEOUT_CHECKINTERVAL 60 -#define DEFAULT_LADDERUPDATE_THRESHOLD 0 - -#endif diff --git a/d2pack109/src/d2dbs/version.h b/d2pack109/src/d2dbs/version.h deleted file mode 100644 index 9666e0b..0000000 --- a/d2pack109/src/d2dbs/version.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (C) 2001 sousou (liupeng.cs@263.net) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_VERSION_H -#define INCLUDED_VERSION_H - -#define D2DBS_VERSION_NUMBER "0.1.0b4" -#define D2DBS_VERSION "D2DBS Version " D2DBS_VERSION_NUMBER " Built " __DATE__ - -#endif diff --git a/d2pack109/src/win32/configwin.h b/d2pack109/src/win32/configwin.h deleted file mode 100644 index 7e3d733..0000000 --- a/d2pack109/src/win32/configwin.h +++ /dev/null @@ -1,394 +0,0 @@ -/* ../include/config.h.win32 Generated by hand from ../include/config.h.in. */ -/* ../include/config.h.in. Generated automatically from configure.in by autoheader. */ - -#ifdef __BORLANDC__ -# define __FUNCTION__ __FUNC__ -#endif - -/* Define if on AIX 3. - System headers sometimes define this. - We just want to avoid a redefinition error message. */ -#ifndef _ALL_SOURCE -/* #undef _ALL_SOURCE */ -#endif - -/* Define if the closedir function returns void instead of int. */ -/* #undef CLOSEDIR_VOID */ - -/* Define to empty if the keyword does not work. */ -/* #undef const */ - -/* Define if you don't have vprintf but do have _doprnt. */ -/* #undef HAVE_DOPRNT */ - -/* Define if you have the strftime function. */ -#define HAVE_STRFTIME 1 - -/* Define if you have the vprintf function. */ -#define HAVE_VPRINTF 1 - -/* Define if you have the _vsnprintf function. */ -#define HAVE__VSNPRINTF 1 - -/* Define if you have the _snprintf function. */ -#define HAVE__SNPRINTF 1 - -/* Define if on MINIX. */ -/* #undef _MINIX */ - -/* Define to `long' if doesn't define. */ -/* #undef off_t */ - -/* Define to `int' if doesn't define. */ -/* #undef pid_t */ - -/* Define if the system does not provide POSIX.1 features except - with this defined. */ -/* #undef _POSIX_1_SOURCE */ - -/* Define if you need to in order for stat and other things to work. */ -/* #undef _POSIX_SOURCE */ - -/* Define as the return type of signal handlers (int or void). */ -#define RETSIGTYPE void - -/* Define if the `setpgrp' function takes no argument. */ -/* #undef SETPGRP_VOID */ - -/* Define to `unsigned' if doesn't define. */ -/* #undef size_t */ - -/* Define if the `S_IS*' macros in do not work properly. */ -/* #undef STAT_MACROS_BROKEN */ - -/* Define if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* Define if you can safely include both and . */ -/* #undef TIME_WITH_SYS_TIME */ - -/* Define if your declares struct tm. */ -/* #undef TM_IN_SYS_TIME */ - -/* The number of bytes in a unsigned char. */ -#define SIZEOF_UNSIGNED_CHAR 1 - -/* The number of bytes in a unsigned int. */ -#define SIZEOF_UNSIGNED_INT 4 - -/* The number of bytes in a unsigned long. */ -#define SIZEOF_UNSIGNED_LONG 4 - -/* The number of bytes in a unsigned long long. */ -/* Borland doesn't do ull, but VC++ does */ -#ifdef __BORLANDC__ -# define SIZEOF_UNSIGNED_LONG_LONG 0 -#else -# define SIZEOF_UNSIGNED_LONG_LONG 8 -#endif - -/* The number of bytes in a unsigned short. */ -#define SIZEOF_UNSIGNED_SHORT 2 - -/* Define if you have the _mkdir function. */ -#define HAVE__MKDIR 1 - -/* Define if you have the bcopy function. */ -/* #undef HAVE_BCOPY */ - -/* Define if you have the chdir function. */ -/* #undef HAVE_CHDIR */ - -/* Define if you have the difftime function. */ -#define HAVE_DIFFTIME 1 - -/* Define if you have the fork function. */ -/* #undef HAVE_FORK */ - -/* Define if you have the ftime function. */ -#define HAVE_FTIME 1 - -/* Define if you have the getenv function. */ -#define HAVE_GETENV 1 - -/* Define if you have the getgid function. */ -/* #undef HAVE_GETGID */ - -/* Define if you have the getgrnam function. */ -/* #undef HAVE_GETGRNAM */ - -/* Define if you have the gethostbyname function. */ -#define HAVE_GETHOSTBYNAME 1 - -/* Define if you have the gethostname function. */ -#define HAVE_GETHOSTNAME 1 - -/* Define if you have the getlogin function. */ -/* #undef HAVE_GETLOGIN */ - -/* Define if you have the getpid function. */ -/* #undef HAVE_GETPID */ - -/* Define if you have the getpwnam function. */ -/* #undef HAVE_GETPWNAM */ - -/* Define if you have the getservbyname function. */ -#define HAVE_GETSERVBYNAME 1 - -/* Define if you have the gettimeofday function. */ -/* #undef HAVE_GETTIMEOFDAY */ - -/* Define if you have the getuid function. */ -/* #undef HAVE_GETUID */ - -/* Define if you have the index function. */ -/* #undef HAVE_INDEX */ - -/* Define if you have the inet_aton function. */ -/* #undef HAVE_INET_ATON */ - -/* Define if you have the inet_ntoa function. */ -#define HAVE_INET_NTOA 1 - -/* Define if you have the ioctl function. */ -/* #undef HAVE_IOCTL */ - -/* Define if you have the memcpy function. */ -#define HAVE_MEMCPY 1 - -/* Define if you have the memmove function. */ -#define HAVE_MEMMOVE 1 - -/* Define if you have the memset function. */ -#define HAVE_MEMSET 1 - -/* Define if you have the mkdir function. */ -#define HAVE_MKDIR - -/* Define if you have the mktime function. */ -#define HAVE_MKTIME 1 - -/* Define if you have the pipe function. */ -/* #undef HAVE_PIPE */ - -/* Define if you have the poll function. */ -/* #undef HAVE_POLL */ - -/* Define if you have the pow function. */ -#define HAVE_POW - -/* Define if you have the recv function. */ -#define HAVE_RECV 1 - -/* Define if you have the recvfrom function. */ -#define HAVE_RECVFROM 1 - -/* Define if you have the rindex function. */ -/* #undef HAVE_RINDEX */ - -/* Define if you have the select function. */ -#define HAVE_SELECT 1 - -/* Define if you have the send function. */ -#define HAVE_SEND 1 - -/* Define if you have the sendto function. */ -#define HAVE_SENDTO 1 - -/* Define if you have the setgid function. */ -/* #undef HAVE_SETGID */ - -/* Define if you have the setpgid function. */ -/* #undef HAVE_SETPGID */ - -/* Define if you have the setpgrp function. */ -/* #undef HAVE_SETPGRP */ - -/* Define if you have the setsid function. */ -/* #undef HAVE_SETSID */ - -/* Define if you have the setuid function. */ -/* #undef HAVE_SETUID */ - -/* Define if you have the sigaction function. */ -/* #undef HAVE_SIGACTION */ - -/* Define if you have the sigaddset function. */ -/* #undef HAVE_SIGADDSET */ - -/* Define if you have the sigprocmask function. */ -/* #undef HAVE_SIGPROCMASK */ - -/* Define if you have the socket function. */ -#define HAVE_SOCKET 1 - -/* Define if you have the strcasecmp function. */ -/* #undef HAVE_STRCASECMP */ - -/* Define if you have the strchr function. */ -#define HAVE_STRCHR 1 - -/* Define if you have the strsep function. */ -/* #undef HAVE_STRSEP */ - -/* Define if you have the strdup function. */ -#define HAVE_STRDUP 1 - -/* Define if you have the strerror function. */ -#define HAVE_STRERROR 1 - -/* Define if you have the stricmp function. */ -#define HAVE_STRICMP 1 - -/* Define if you have the strncasecmp function. */ -/* #undef HAVE_STRNCASECMP */ - -/* Define if you have the strnicmp function. */ -#define HAVE_STRNICMP 1 - -/* Define if you have the strrchr function. */ -#define HAVE_STRRCHR 1 - -/* Define if you have the strtoul function. */ -#define HAVE_STRTOUL 1 - -/* Define if you have the uname function. */ -/* #undef HAVE_UNAME */ - -/* Define if you have the wait function. */ -/* #undef HAVE_WAIT */ - -/* Define if you have the waitpid function. */ -/* #undef HAVE_WAITPID */ - -/* Define if you have the header file. */ -/* #undef HAVE_ARPA_INET_H */ - -#ifdef __BORLANDC__ -/* Define if you have the header file. */ -# define HAVE_DIR_H -#else -/* Define if you have the header file. */ -#define HAVE_DIRECT_H 1 -#endif - -/* Define if you have the header file. */ -/* #undef HAVE_DIRENT_H */ - -/* Define if you have the header file. */ -#define HAVE_FCNTL_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_GRP_H */ - -/* Define if you have the header file. */ -#define HAVE_LIMITS_H 1 - -/* Define if you have the header file. */ -#define HAVE_MALLOC_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_MEMORY_H */ - -/* Define if you have the header file. */ -/* #undef HAVE_NDIR_H */ - -/* Define if you have the header file. */ -/* #undef HAVE_NETDB_H */ - -/* Define if you have the header file. */ -/* #undef HAVE_NETINET_IN_H */ - -/* Define if you have the header file. */ -/* #undef HAVE_POLL_H */ - -/* Define if you have the header file. */ -/* #undef HAVE_PWD_H */ - -/* Define if you have the header file. */ -#define HAVE_STDARG_H 1 - -/* Define if you have the header file. */ -#define HAVE_STDDEF_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_STDINT_H */ - -/* Define if you have the header file. */ -#define HAVE_STRING_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_STRINGS_H */ - -/* Define if you have the header file. */ -/* #undef HAVE_STROPTS_H */ - -/* Define if you have the header file. */ -/* #undef HAVE_SYS_DIR_H */ - -/* Define if you have the header file. */ -/* #undef HAVE_SYS_FILE_H */ - -/* Define if you have the header file. */ -/* #undef HAVE_SYS_IOCTL_H */ - -/* Define if you have the header file. */ -/* #undef HAVE_SYS_NDIR_H */ - -/* Define if you have the header file. */ -/* #undef HAVE_SYS_PARAM_H */ - -/* Define if you have the header file. */ -/* #undef HAVE_SYS_POLL_H */ - -/* Define if you have the header file. */ -/* #undef HAVE_SYS_SELECT_H */ - -/* Define if you have the header file. */ -/* #undef HAVE_SYS_SOCKET_H */ - -/* Define if you have the header file. */ -#define HAVE_SYS_STAT_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_SYS_STROPTS_H */ - -/* Define if you have the header file. */ -/* #undef HAVE_SYS_TIME_H */ - -/* Define if you have the header file. */ -#define HAVE_SYS_TIMEB_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_TYPES_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_SYS_UTSNAME_H */ - -/* Define if you have the header file. */ -/* #undef HAVE_SYS_WAIT_H */ - -/* Define if you have the header file. */ -/* #undef HAVE_TERMIOS_H */ - -/* Define if mkdir takes only one argument. */ -#define MKDIR_TAKES_ONE_ARG 1 - -/* Define if you have the header file. */ -#define HAVE_VARARGS_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_UNISTD_H */ - -/* Define if you support inline */ -#define inline __inline - -/* Define if you support assertions */ -#define HAVE_ASSERT_H 1 - -/* Define if you have the memmove function. */ -#define HAVE_MEMMOVE 1 - -/* Define if you have the header file. */ -#define HAVE_TIME_H 1 - diff --git a/d2pack109/src/win32/d2cs_winmain.c b/d2pack109/src/win32/d2cs_winmain.c deleted file mode 100644 index 1778f92..0000000 --- a/d2pack109/src/win32/d2cs_winmain.c +++ /dev/null @@ -1,374 +0,0 @@ -/* - * Copyright (C) 2004 CreepLord (creeplord@pvpgn.org) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifdef WIN32_GUI - -#include "common/setup_before.h" -#include -#include -#include -#include -#include "d2cs_resource.h" -#include "common/eventlog.h" -#include "d2cs/version.h" -#include "d2cs/handle_signal.h" -#include "service.h" -#include "winmain.h" -#include "common/setup_after.h" - -#define WM_SHELLNOTIFY (WM_USER+1) - -extern int server_main(int argc, char *argv[]); /* d2cs main function in d2cs/main.c */ - -static void d2cs(void * dummy); /* thread function for d2cs */ - -static void guiAddText(const char *str, COLORREF clr); -static void KillTrayIcon(HWND hwnd); -static int OnShellNotify(HWND hwnd, int uID, int uMessage); -static void OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify); -static BOOL OnCreate(HWND hwnd, LPCREATESTRUCT lpCreateStruct); -static void OnClose(HWND hwnd); -static void OnSize(HWND hwnd, UINT state, int cx, int cy); - -LRESULT CALLBACK WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); -BOOL CALLBACK DlgProcAbout(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); - -HWND ghwndConsole; /* hwnd for eventlog output */ - -static int gui_run = TRUE; /* default state: run gui */ -static int d2cs_run = TRUE; /* default state: run d2cs */ -static int d2cs_running = FALSE; /* currect state: not running */ - -int fprintf(FILE *stream, const char *format, ...) -{ - va_list args; - va_start(args, format); - if(stream == stderr || stream == stdout) - return gui_lvprintf(eventlog_level_error, format, args); - else - return vfprintf(stream, format, args); -} - -static void KillTrayIcon(HWND hwnd) -{ - NOTIFYICONDATA dta; - - dta.cbSize = sizeof(NOTIFYICONDATA); - dta.hWnd = hwnd; - dta.uID = ID_TRAY; - dta.uFlags = 0; - Shell_NotifyIcon(NIM_DELETE, &dta); -} - -int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, - LPSTR lpszCmdLine, int nCmdShow) -{ - WNDCLASSEX wc; - HWND hwnd; - MSG msg; - - /* if running as a service skip starting the GUI and go straight to starting d2cs */ - if (__argc==2 && strcmp(__argv[1],"--service")==0) - { - Win32_ServiceRun(); - return 1; - } - - LoadLibrary("RichEd20.dll"); - - wc.cbSize = sizeof(WNDCLASSEX); - wc.style = 0; - wc.lpfnWndProc = WndProc; - wc.cbClsExtra = 0; - wc.cbWndExtra = sizeof(LPVOID); - wc.hInstance = hInstance; - wc.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(ID_ICON1)); - wc.hCursor = LoadCursor(NULL, IDC_ARROW); - wc.hbrBackground = (HBRUSH)COLOR_WINDOW; - wc.lpszMenuName = MAKEINTRESOURCE(ID_MENU); - wc.lpszClassName = "BnetWndClass"; - - if(!RegisterClassEx( &wc )) - RegisterClass((LPWNDCLASS)&wc.style); - - hwnd = CreateWindow(TEXT("BnetWndClass"),"Diablo II Character Server", - WS_OVERLAPPEDWINDOW, - CW_USEDEFAULT, CW_USEDEFAULT, - CW_USEDEFAULT, CW_USEDEFAULT, - NULL, - LoadMenu(hInstance, MAKEINTRESOURCE(ID_MENU)), - hInstance,NULL); - - if(hwnd) { - ShowWindow(hwnd, nCmdShow); - UpdateWindow(hwnd); - } - - while(GetMessage(&msg, NULL, 0, 0)) { - TranslateMessage( &msg ); - DispatchMessage( &msg ); - - if(!d2cs_running && d2cs_run && gui_run) { - d2cs_running = TRUE; - _beginthread(d2cs, 0, NULL); - } - - if(!gui_run && !d2cs_running) { - KillTrayIcon(hwnd); - exit(0); - } - } - return ((int) msg.wParam); -} - -LRESULT CALLBACK WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - switch(uMsg) { - HANDLE_MSG(hwnd, WM_CREATE, OnCreate); - HANDLE_MSG(hwnd, WM_SIZE, OnSize); - HANDLE_MSG(hwnd, WM_COMMAND, OnCommand); - HANDLE_MSG(hwnd, WM_CLOSE, OnClose); - case WM_SHELLNOTIFY: - return OnShellNotify(hwnd, wParam, lParam); - } - return DefWindowProc(hwnd, uMsg, wParam, lParam); -} - -static BOOL OnCreate(HWND hwnd, LPCREATESTRUCT lpCreateStruct) -{ - ghwndConsole = CreateWindowEx(WS_EX_CLIENTEDGE, RICHEDIT_CLASS, NULL, - WS_CHILD|WS_VISIBLE|ES_READONLY|ES_MULTILINE| - WS_VSCROLL|WS_HSCROLL|ES_NOHIDESEL, - 0, 0, - 0, 0, hwnd, 0, - 0, NULL); - - if(!ghwndConsole) - return FALSE; - - return TRUE; -} - -static void OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify) -{ - switch (id) { - case ID_RESTORE: - OnShellNotify(hwnd, ID_TRAY, WM_LBUTTONDBLCLK); - break; - case ID_START_D2CS: - fprintf(stderr,"Sending Start Signal to d2cs\n"); - d2cs_run = TRUE; - break; - case ID_SHUTDOWN_D2CS: - fprintf(stderr,"Sending Shutdown Signal to d2cs\n"); - d2cs_run = FALSE; - signal_quit_wrapper(); - break; - case ID_RESTART_D2CS: - fprintf(stderr,"Sending Restart Signal To d2cs\n"); - d2cs_run = TRUE; - signal_quit_wrapper(); - break; - case ID_EDITCONFIG_D2CS: - ShellExecute(NULL, "open", "notepad.exe", "conf\\d2cs.conf", NULL, SW_SHOW ); - break; - case ID_LOADCONFIG_D2CS: - fprintf(stderr,"Sending Reload Config Signal To d2cs\n"); - signal_reload_config_wrapper(); - break; - case ID_LADDER_LOAD: - fprintf(stderr,"Sending Reload Ladder Signal To d2cs\n"); - signal_load_ladder_wrapper(); - break; - case ID_RESTART_D2GS: - fprintf(stderr,"Sending Restart d2gs Signal To d2cs\n"); - signal_restart_d2gs_wrapper(); - break; - case ID_EXIT: - OnClose(hwnd); - break; - case ID_CLEAR: - SendMessage(ghwndConsole, WM_SETTEXT, 0, 0); - break; - case ID_ABOUT: - DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(ID_ABOUT_BOX), hwnd, (DLGPROC)DlgProcAbout); - break; - } -} - -static int OnShellNotify(HWND hwnd, int uID, int uMessage) -{ - if(uID == ID_TRAY) { - if(uMessage == WM_LBUTTONDBLCLK) { - if(!IsWindowVisible(hwnd)) - ShowWindow(hwnd, SW_RESTORE); - - SetForegroundWindow(hwnd); - } - } - return 0; -} - -static void OnClose(HWND hwnd) -{ - fprintf(stderr,"Sending Exit Signal To d2cs\n"); - gui_run = FALSE; - d2cs_run = FALSE; - signal_exit_wrapper(); -} - -static void OnSize(HWND hwnd, UINT state, int cx, int cy) -{ - NOTIFYICONDATA dta; - - if( state == SIZE_MINIMIZED ) { - dta.cbSize = sizeof(NOTIFYICONDATA); - dta.hWnd = hwnd; - dta.uID = ID_TRAY; - dta.uFlags = NIF_ICON|NIF_MESSAGE|NIF_TIP; - dta.uCallbackMessage = WM_SHELLNOTIFY; - dta.hIcon = LoadIcon(GetWindowInstance(hwnd), MAKEINTRESOURCE(ID_ICON1)); - strcpy(dta.szTip, "D2CS Version"); - strcat(dta.szTip, " "); - strcat(dta.szTip, D2CS_VERSION_STRING); - - Shell_NotifyIcon(NIM_ADD, &dta); - ShowWindow(hwnd, SW_HIDE); - return; - } - - MoveWindow(ghwndConsole, 0, 0, cx, cy, TRUE); -} - -BOOL CALLBACK DlgProcAbout(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - switch (uMsg) { - case WM_CLOSE: - EndDialog(hwnd, TRUE); - return TRUE; - case WM_INITDIALOG: - return TRUE; - case WM_COMMAND: - switch ((int)wParam) { - case IDOK: - EndDialog(hwnd, TRUE); - return TRUE; - } - } - return FALSE; -} - -extern int gui_lprintf(t_eventlog_level l, const char *format, ...) -{ - va_list arglist; - va_start(arglist, format); - - return gui_lvprintf(l, format, arglist); -} - -extern int gui_lvprintf(t_eventlog_level l, const char *format, va_list arglist) -{ - char buff[4096]; - int result; - COLORREF clr; - - result = vsprintf(buff, format, arglist); - - switch(l) - { - case eventlog_level_none: - clr = RGB(0, 0, 0); - break; - case eventlog_level_trace: - clr = RGB(255, 0, 255); - break; - case eventlog_level_debug: - clr = RGB(0, 0, 255); - break; - case eventlog_level_info: - clr = RGB(0, 0, 0); - break; - case eventlog_level_warn: - clr = RGB(255, 128, 64); - break; - case eventlog_level_error: - clr = RGB(255, 0, 0); - break; - case eventlog_level_fatal: - clr = RGB(255, 0, 0); - break; - default: - clr = RGB(0, 0, 0); - } - guiAddText(buff, clr); - return result; -} - -static void guiAddText(const char *str, COLORREF clr) -{ - int start_lines, text_length, end_lines; - CHARRANGE cr; - CHARRANGE ds; - CHARFORMAT fmt; - - text_length = SendMessage(ghwndConsole, WM_GETTEXTLENGTH, 0, 0); - - if (text_length > 30000) - { - ds.cpMin = 0; - ds.cpMax = text_length - 30000; - SendMessage(ghwndConsole, EM_EXSETSEL, 0, (LPARAM)&ds); - SendMessage(ghwndConsole, EM_REPLACESEL, FALSE, 0); - } - - cr.cpMin = text_length; - cr.cpMax = text_length; - SendMessage(ghwndConsole, EM_EXSETSEL, 0, (LPARAM)&cr); - - fmt.cbSize = sizeof(CHARFORMAT); - fmt.dwMask = CFM_COLOR|CFM_FACE|CFM_SIZE|CFM_BOLD|CFM_ITALIC|CFM_STRIKEOUT|CFM_UNDERLINE; - fmt.yHeight = 160; - fmt.dwEffects = 0; - fmt.crTextColor = clr; - strcpy(fmt.szFaceName,"Courier New"); - - SendMessage(ghwndConsole, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&fmt); - SendMessage(ghwndConsole, EM_REPLACESEL, FALSE, (LPARAM)str); -} - -#define EXIT_ERROR -1 -#define EXIT_OK 0 -#define EXIT_SERVICE 1 - -static void d2cs(void * dummy) -{ - switch (server_main(__argc, __argv)) - { - case EXIT_SERVICE: - gui_run = FALSE; /* close gui */ - case EXIT_ERROR: - d2cs_run = FALSE; /* don't restart */ - case EXIT_OK: - ; /* do nothing */ - } - - fprintf(stderr,"Server Stopped\n"); - d2cs_running = FALSE; -} - -#endif diff --git a/d2pack109/src/win32/d2dbs_winmain.c b/d2pack109/src/win32/d2dbs_winmain.c deleted file mode 100644 index 7d7ee83..0000000 --- a/d2pack109/src/win32/d2dbs_winmain.c +++ /dev/null @@ -1,370 +0,0 @@ -/* - * Copyright (C) 2004 CreepLord (creeplord@pvpgn.org) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifdef WIN32_GUI - -#include "common/setup_before.h" -#include -#include -#include -#include -#include "d2dbs_resource.h" -#include "common/eventlog.h" -#include "d2dbs/version.h" -#include "d2dbs/handle_signal.h" -#include "service.h" -#include "winmain.h" -#include "common/setup_after.h" - -#define WM_SHELLNOTIFY (WM_USER+1) - -extern int server_main(int argc, char *argv[]); /* d2dbs main function in d2dbs/main.c */ - -static void d2dbs(void * dummy); /* thread function for d2dbs */ - -static void guiAddText(const char *str, COLORREF clr); -static void KillTrayIcon(HWND hwnd); -static int OnShellNotify(HWND hwnd, int uID, int uMessage); -static void OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify); -static BOOL OnCreate(HWND hwnd, LPCREATESTRUCT lpCreateStruct); -static void OnClose(HWND hwnd); -static void OnSize(HWND hwnd, UINT state, int cx, int cy); - -LRESULT CALLBACK WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); -BOOL CALLBACK DlgProcAbout(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); - -HWND ghwndConsole; /* hwnd for eventlog output */ - -static int gui_run = TRUE; /* default state: run gui */ -static int d2dbs_run = TRUE; /* default state: run d2dbs */ -static int d2dbs_running = FALSE; /* currect state: not running */ - -int fprintf(FILE *stream, const char *format, ...) -{ - va_list args; - va_start(args, format); - if(stream == stderr || stream == stdout) - return gui_lvprintf(eventlog_level_error, format, args); - else - return vfprintf(stream, format, args); -} - -static void KillTrayIcon(HWND hwnd) -{ - NOTIFYICONDATA dta; - - dta.cbSize = sizeof(NOTIFYICONDATA); - dta.hWnd = hwnd; - dta.uID = ID_TRAY; - dta.uFlags = 0; - Shell_NotifyIcon(NIM_DELETE, &dta); -} - -int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, - LPSTR lpszCmdLine, int nCmdShow) -{ - WNDCLASSEX wc; - HWND hwnd; - MSG msg; - - /* if running as a service skip starting the GUI and go straight to starting d2dbs */ - if (__argc==2 && strcmp(__argv[1],"--service")==0) - { - Win32_ServiceRun(); - return 1; - } - - LoadLibrary("RichEd20.dll"); - - wc.cbSize = sizeof(WNDCLASSEX); - wc.style = 0; - wc.lpfnWndProc = WndProc; - wc.cbClsExtra = 0; - wc.cbWndExtra = sizeof(LPVOID); - wc.hInstance = hInstance; - wc.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(ID_ICON1)); - wc.hCursor = LoadCursor(NULL, IDC_ARROW); - wc.hbrBackground = (HBRUSH)COLOR_WINDOW; - wc.lpszMenuName = MAKEINTRESOURCE(ID_MENU); - wc.lpszClassName = "BnetWndClass"; - - if(!RegisterClassEx( &wc )) - RegisterClass((LPWNDCLASS)&wc.style); - - hwnd = CreateWindow(TEXT("BnetWndClass"),"Diablo II DataBase Server", - WS_OVERLAPPEDWINDOW, - CW_USEDEFAULT,CW_USEDEFAULT, - CW_USEDEFAULT,CW_USEDEFAULT, - NULL, - LoadMenu(hInstance, MAKEINTRESOURCE(ID_MENU)), - hInstance,NULL); - - if(hwnd) { - ShowWindow(hwnd, nCmdShow); - UpdateWindow(hwnd); - } - - while(GetMessage(&msg, NULL, 0, 0)) { - TranslateMessage( &msg ); - DispatchMessage( &msg ); - - if(!d2dbs_running && d2dbs_run && gui_run) { - d2dbs_running = TRUE; - _beginthread(d2dbs, 0, NULL); - } - - if(!gui_run && !d2dbs_running) { - KillTrayIcon(hwnd); - exit(0); - } - } - return ((int) msg.wParam); -} - -LRESULT CALLBACK WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - switch(uMsg) { - HANDLE_MSG(hwnd, WM_CREATE, OnCreate); - HANDLE_MSG(hwnd, WM_SIZE, OnSize); - HANDLE_MSG(hwnd, WM_COMMAND, OnCommand); - HANDLE_MSG(hwnd, WM_CLOSE, OnClose); - case WM_SHELLNOTIFY: - return OnShellNotify(hwnd, wParam, lParam); - } - return DefWindowProc(hwnd, uMsg, wParam, lParam); -} - -static BOOL OnCreate(HWND hwnd, LPCREATESTRUCT lpCreateStruct) -{ - ghwndConsole = CreateWindowEx(WS_EX_CLIENTEDGE, RICHEDIT_CLASS, NULL, - WS_CHILD|WS_VISIBLE|ES_READONLY|ES_MULTILINE| - WS_VSCROLL|WS_HSCROLL|ES_NOHIDESEL, - 0, 0, - 0, 0, hwnd, 0, - 0, NULL); - - if(!ghwndConsole) - return FALSE; - - return TRUE; -} - -static void OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify) -{ - switch (id) { - case ID_RESTORE: - OnShellNotify(hwnd, ID_TRAY, WM_LBUTTONDBLCLK); - break; - case ID_START_D2DBS: - fprintf(stderr,"Sending Start Signal to d2dbs\n"); - d2dbs_run = TRUE; - break; - case ID_SHUTDOWN_D2DBS: - fprintf(stderr,"Sending Shutdown Signal to d2dbs\n"); - d2dbs_run = FALSE; - d2dbs_signal_quit_wrapper(); - break; - case ID_RESTART_D2DBS: - fprintf(stderr,"Sending Restart Signal To d2dbs\n"); - d2dbs_run = TRUE; - d2dbs_signal_quit_wrapper(); - break; - case ID_EDITCONFIG_D2DBS: - ShellExecute(NULL, "open", "notepad.exe", "conf\\d2dbs.conf", NULL, SW_SHOW ); - break; - case ID_LOADCONFIG_D2DBS: - fprintf(stderr,"Sending Reload Config Signal To d2dbs\n"); - d2dbs_signal_reload_config_wrapper(); - break; - case ID_LADDER_SAVE: - fprintf(stderr,"Sending Save Ladder Signal To d2dbs\n"); - d2dbs_signal_save_ladder_wrapper(); - break; - case ID_EXIT: - OnClose(hwnd); - break; - case ID_CLEAR: - SendMessage(ghwndConsole, WM_SETTEXT, 0, 0); - break; - case ID_ABOUT: - DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(ID_ABOUT_BOX), hwnd, (DLGPROC)DlgProcAbout); - break; - } -} - -static int OnShellNotify(HWND hwnd, int uID, int uMessage) -{ - if(uID == ID_TRAY) { - if(uMessage == WM_LBUTTONDBLCLK) { - if(!IsWindowVisible(hwnd)) - ShowWindow(hwnd, SW_RESTORE); - - SetForegroundWindow(hwnd); - } - } - return 0; -} - -static void OnClose(HWND hwnd) -{ - fprintf(stderr,"Sending Exit Signal To d2dbs\n"); - gui_run = FALSE; - d2dbs_run = FALSE; - d2dbs_signal_exit_wrapper(); -} - -static void OnSize(HWND hwnd, UINT state, int cx, int cy) -{ - NOTIFYICONDATA dta; - - if( state == SIZE_MINIMIZED ) { - dta.cbSize = sizeof(NOTIFYICONDATA); - dta.hWnd = hwnd; - dta.uID = ID_TRAY; - dta.uFlags = NIF_ICON|NIF_MESSAGE|NIF_TIP; - dta.uCallbackMessage = WM_SHELLNOTIFY; - dta.hIcon = LoadIcon(GetWindowInstance(hwnd), MAKEINTRESOURCE(ID_ICON1)); - strcpy(dta.szTip, "D2DBS Version"); - strcat(dta.szTip, " "); - strcat(dta.szTip, D2DBS_VERSION_NUMBER); - - Shell_NotifyIcon(NIM_ADD, &dta); - ShowWindow(hwnd, SW_HIDE); - return; - } - - MoveWindow(ghwndConsole, 0, 0, cx, cy, TRUE); -} - -BOOL CALLBACK DlgProcAbout(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - switch (uMsg) { - case WM_CLOSE: - EndDialog(hwnd, TRUE); - return TRUE; - case WM_INITDIALOG: - return TRUE; - case WM_COMMAND: - switch ((int)wParam) { - case IDOK: - EndDialog(hwnd, TRUE); - return TRUE; - } - } - return FALSE; -} - -extern int gui_lprintf(t_eventlog_level l, const char *format, ...) -{ - va_list arglist; - va_start(arglist, format); - - return gui_lvprintf(l, format, arglist); -} - -extern int gui_lvprintf(t_eventlog_level l, const char *format, va_list arglist) -{ - char buff[4096]; - int result; - COLORREF clr; - - result = vsprintf(buff, format, arglist); - - switch(l) - { - case eventlog_level_none: - clr = RGB(0, 0, 0); - break; - case eventlog_level_trace: - clr = RGB(255, 0, 255); - break; - case eventlog_level_debug: - clr = RGB(0, 0, 255); - break; - case eventlog_level_info: - clr = RGB(0, 0, 0); - break; - case eventlog_level_warn: - clr = RGB(255, 128, 64); - break; - case eventlog_level_error: - clr = RGB(255, 0, 0); - break; - case eventlog_level_fatal: - clr = RGB(255, 0, 0); - break; - default: - clr = RGB(0, 0, 0); - } - guiAddText(buff, clr); - return result; -} - -static void guiAddText(const char *str, COLORREF clr) -{ - int start_lines, text_length, end_lines; - CHARRANGE cr; - CHARRANGE ds; - CHARFORMAT fmt; - - text_length = SendMessage(ghwndConsole, WM_GETTEXTLENGTH, 0, 0); - - if (text_length > 30000) - { - ds.cpMin = 0; - ds.cpMax = text_length - 30000; - SendMessage(ghwndConsole, EM_EXSETSEL, 0, (LPARAM)&ds); - SendMessage(ghwndConsole, EM_REPLACESEL, FALSE, 0); - } - - cr.cpMin = text_length; - cr.cpMax = text_length; - SendMessage(ghwndConsole, EM_EXSETSEL, 0, (LPARAM)&cr); - - fmt.cbSize = sizeof(CHARFORMAT); - fmt.dwMask = CFM_COLOR|CFM_FACE|CFM_SIZE|CFM_BOLD|CFM_ITALIC|CFM_STRIKEOUT|CFM_UNDERLINE; - fmt.yHeight = 160; - fmt.dwEffects = 0; - fmt.crTextColor = clr; - strcpy(fmt.szFaceName,"Courier New"); - - SendMessage(ghwndConsole, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&fmt); - SendMessage(ghwndConsole, EM_REPLACESEL, FALSE, (LPARAM)str); -} - -#define EXIT_ERROR -1 -#define EXIT_OK 0 -#define EXIT_SERVICE 1 - -static void d2dbs(void * dummy) -{ - switch (server_main(__argc, __argv)) - { - case EXIT_SERVICE: - gui_run = FALSE; /* close gui */ - case EXIT_ERROR: - d2dbs_run = FALSE; /* don't restart */ - case EXIT_OK: - ; /* do nothing */ - } - - fprintf(stderr,"Server Stopped\n"); - d2dbs_running = FALSE; -} - -#endif diff --git a/d2pack109/src/win32/service.c b/d2pack109/src/win32/service.c deleted file mode 100644 index 59eba87..0000000 --- a/d2pack109/src/win32/service.c +++ /dev/null @@ -1,236 +0,0 @@ - /* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include -#include -#include - -#if !defined(WINADVAPI) -#if !defined(_ADVAPI32_) -#define WINADVAPI DECLSPEC_IMPORT -#else -#define WINADVAPI -#endif -#endif - -extern char serviceLongName[]; -extern char serviceName[]; -extern char serviceDescription[]; - -extern int g_ServiceStatus; - -#ifdef WIN32_GUI -extern int server_main(int argc, char *argv[]); -#else -extern int main(int argc, char *argv[]); -#endif - -SERVICE_STATUS serviceStatus; -SERVICE_STATUS_HANDLE serviceStatusHandle = 0; - -typedef WINADVAPI BOOL (WINAPI *CSD_T)(SC_HANDLE, DWORD, LPCVOID); - -void Win32_ServiceInstall() -{ - SERVICE_DESCRIPTION sdBuf; - CSD_T ChangeServiceDescription; - HANDLE advapi32; - SC_HANDLE serviceControlManager = OpenSCManager(0, 0, SC_MANAGER_CREATE_SERVICE); - - if (serviceControlManager) - { - char path[_MAX_PATH + 10]; - if (GetModuleFileName( 0, path, sizeof(path)/sizeof(path[0]) ) > 0) - { - SC_HANDLE service; - strcat(path, " --service"); - service = CreateService(serviceControlManager, - serviceName, serviceLongName, - SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS, - SERVICE_AUTO_START, SERVICE_ERROR_IGNORE, path, - 0, 0, 0, 0, 0); - if (service) - { - sdBuf.lpDescription = serviceDescription; - - if (!(advapi32 = GetModuleHandle("ADVAPI32.DLL"))) - { - CloseServiceHandle(service); - CloseServiceHandle(serviceControlManager); - return; - } - - ; - if (!(ChangeServiceDescription = (CSD_T) GetProcAddress(advapi32, "ChangeServiceConfig2A"))) - { - CloseServiceHandle(service); - CloseServiceHandle(serviceControlManager); - return; - } - - ChangeServiceDescription( - service, // handle to service - SERVICE_CONFIG_DESCRIPTION, // change: description - &sdBuf); - CloseServiceHandle(service); - } - } - CloseServiceHandle(serviceControlManager); - } -} - -void Win32_ServiceUninstall() -{ - SC_HANDLE serviceControlManager = OpenSCManager(0, 0, SC_MANAGER_CONNECT); - - if (serviceControlManager) - { - SC_HANDLE service = OpenService(serviceControlManager, - serviceName, SERVICE_QUERY_STATUS | DELETE); - if (service) - { - SERVICE_STATUS serviceStatus; - if (QueryServiceStatus(service, &serviceStatus)) - { - if (serviceStatus.dwCurrentState == SERVICE_STOPPED) - DeleteService(service); - } - //DeleteService(service); - - CloseServiceHandle(service); - } - - CloseServiceHandle(serviceControlManager); - } - -} - -void WINAPI ServiceControlHandler(DWORD controlCode) -{ - switch (controlCode) - { - case SERVICE_CONTROL_INTERROGATE: - break; - - case SERVICE_CONTROL_SHUTDOWN: - case SERVICE_CONTROL_STOP: - serviceStatus.dwCurrentState = SERVICE_STOP_PENDING; - SetServiceStatus(serviceStatusHandle, &serviceStatus); - - g_ServiceStatus = 0; - return; - - case SERVICE_CONTROL_PAUSE: - g_ServiceStatus = 2; - serviceStatus.dwCurrentState = SERVICE_PAUSED; - SetServiceStatus(serviceStatusHandle, &serviceStatus); - break; - - case SERVICE_CONTROL_CONTINUE: - serviceStatus.dwCurrentState = SERVICE_RUNNING; - SetServiceStatus(serviceStatusHandle, &serviceStatus); - g_ServiceStatus = 1; - break; - - default: - if ( controlCode >= 128 && controlCode <= 255 ) - // user defined control code - break; - else - // unrecognized control code - break; - } - - SetServiceStatus(serviceStatusHandle, &serviceStatus); -} - -void WINAPI ServiceMain(DWORD argc, char *argv[]) -{ - // initialise service status - serviceStatus.dwServiceType = SERVICE_WIN32; - serviceStatus.dwCurrentState = SERVICE_START_PENDING; - serviceStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP | - SERVICE_ACCEPT_PAUSE_CONTINUE; - serviceStatus.dwWin32ExitCode = NO_ERROR; - serviceStatus.dwServiceSpecificExitCode = NO_ERROR; - serviceStatus.dwCheckPoint = 0; - serviceStatus.dwWaitHint = 0; - - serviceStatusHandle = RegisterServiceCtrlHandler(serviceName, ServiceControlHandler); - - if ( serviceStatusHandle ) - { - char path[_MAX_PATH + 1]; - int i, last_slash = 0; - - GetModuleFileName(0, path, sizeof(path)/sizeof(path[0])); - - for (i = 0; i < strlen(path); i++) { - if (path[i] == '\\') last_slash = i; - } - - path[last_slash] = 0; - - // service is starting - serviceStatus.dwCurrentState = SERVICE_START_PENDING; - SetServiceStatus(serviceStatusHandle, &serviceStatus); - - // do initialisation here - SetCurrentDirectory(path); - - // running - serviceStatus.dwControlsAccepted |= (SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN); - serviceStatus.dwCurrentState = SERVICE_RUNNING; - SetServiceStatus( serviceStatusHandle, &serviceStatus ); - - //////////////////////// - // service main cycle // - //////////////////////// - - g_ServiceStatus = 1; - argc = 1; - -#ifdef WIN32_GUI - server_main(argc, argv); -#else - main(argc, argv); -#endif - - // service was stopped - serviceStatus.dwCurrentState = SERVICE_STOP_PENDING; - SetServiceStatus(serviceStatusHandle, &serviceStatus); - - // do cleanup here - - // service is now stopped - serviceStatus.dwControlsAccepted &= ~(SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN); - serviceStatus.dwCurrentState = SERVICE_STOPPED; - SetServiceStatus(serviceStatusHandle, &serviceStatus); - } -} - -void Win32_ServiceRun() -{ - SERVICE_TABLE_ENTRY serviceTable[] = - { - { serviceName, ServiceMain }, - { 0, 0 } - }; - - if (!StartServiceCtrlDispatcher(serviceTable)) - { - } -} diff --git a/d2pack109/src/win32/service.h b/d2pack109/src/win32/service.h deleted file mode 100644 index 7150978..0000000 --- a/d2pack109/src/win32/service.h +++ /dev/null @@ -1,19 +0,0 @@ - /* - * 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. - */ - -void Win32_ServiceInstall(void); -void Win32_ServiceUninstall(void); -void Win32_ServiceRun(void); diff --git a/d2pack109/src/win32/u2d.c b/d2pack109/src/win32/u2d.c deleted file mode 100644 index c93b013..0000000 --- a/d2pack109/src/win32/u2d.c +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (C) 2004 CreepLord (creeplord@pvpgn.org) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include -#include -#include - -int u2d(char * file) -{ - FILE * orig_file; - FILE * new_file; - char temp_file[256]; - int ch; - int prev_ch = 0; - - sprintf(temp_file, "%s.tmp", file); - orig_file = fopen(file, "rb"); - new_file = fopen(temp_file, "wb"); - - while ((ch = getc(orig_file)) != EOF) - { - if ((ch == 0x0A) && (prev_ch != 0x0D)) - putc(0x0D, new_file); - - putc(ch, new_file); - prev_ch = ch; - } - - fclose(orig_file); - fclose(new_file); - remove(file); - rename(temp_file,file); - remove(temp_file); - return 0; -} - -int main (int argc, char **argv) -{ - int i; - - for (i = 1; i < argc; i++) - u2d(argv[i]); - - return 0; -} - diff --git a/d2pack109/src/win32/winmain.h b/d2pack109/src/win32/winmain.h deleted file mode 100644 index eebfe7f..0000000 --- a/d2pack109/src/win32/winmain.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2001 Erik Latoshek [forester] (laterk@inbox.lv) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef __WINMAIN_H__ -#define __WINMAIN_H__ - -#include -#include "common/eventlog.h" - -extern int gui_printf(const char *format, ...); -extern void guiOnUpdateUserList(void); - -extern int gui_lvprintf(t_eventlog_level l, const char *format, va_list arglist); -extern int gui_lprintf(t_eventlog_level l, const char *format, ...); - -#endif diff --git a/pvpgn/docs/Compile.Instructions.Win32.Dev-C++.txt b/docs/Compile.Instructions.Win32.Dev-C++.txt similarity index 98% rename from pvpgn/docs/Compile.Instructions.Win32.Dev-C++.txt rename to docs/Compile.Instructions.Win32.Dev-C++.txt index 382be50..9e80307 100644 --- a/pvpgn/docs/Compile.Instructions.Win32.Dev-C++.txt +++ b/docs/Compile.Instructions.Win32.Dev-C++.txt @@ -1,32 +1,32 @@ -PvPGN Win32 Dev-C++ Compile Instructions -This file explains how to compile PvPGN for Win32 using Dev-C++ ( 5.0 beta 9 (4.9.9.0) ) - -1) Download Dev-C++ 5.0 beta 9 (4.9.9.0) with Mingw/GCC 3.3.1 from the folling sites: -http://prdownloads.sourceforge.net/dev-cpp/devcpp4990setup.exe - -2) Install Dev-C++ in a folder without any spaces in the path - -3) From within Dev-C++ install the zlib-DevPak from the DevPacks.org community server (Tools->Check for Updates/Packages) - -4) Go into the Win32-Projects folder of the PvPGN sources -Simply double-click on any of the *.dev files to fire up Dev-C++ and use Execute->Compile to build the binary - -5) The resulting exe file will be in the bin directory and you can use it with the other files from the latest PvPGN release. - -Notes for MYSQL/PGSQL/SQLITE3/ODBC Support: - support with Dev-C++ still unsupported/untested - - -Common problems and Solutions: -============================== - -Fatal: 'all-before' does not exist - don't know how to make it: ----------------------------------------------------------------- -That happens when the wrong make.exe is invoked, usually the Borland one. It will usually leave a copyright notice in your compile log. -How to fix it? add the bin folder of your Dev-C++ (or MinGW) installation to the PATH environment variable, before any Borland path that might be there -For more details check: http://www14.brinkster.com/aditsu/dev-cpp-faq.html#allbefore - -Complains about not being able to create Makefile or 'no rule to make target all': ------------------------------------------------------------------------------------ -Check size of pvpgn\src\win32\Makefile.win +PvPGN Win32 Dev-C++ Compile Instructions +This file explains how to compile PvPGN for Win32 using Dev-C++ ( 5.0 beta 9 (4.9.9.0) ) + +1) Download Dev-C++ 5.0 beta 9 (4.9.9.0) with Mingw/GCC 3.3.1 from the folling sites: +http://prdownloads.sourceforge.net/dev-cpp/devcpp4990setup.exe + +2) Install Dev-C++ in a folder without any spaces in the path + +3) From within Dev-C++ install the zlib-DevPak from the DevPacks.org community server (Tools->Check for Updates/Packages) + +4) Go into the Win32-Projects folder of the PvPGN sources +Simply double-click on any of the *.dev files to fire up Dev-C++ and use Execute->Compile to build the binary + +5) The resulting exe file will be in the bin directory and you can use it with the other files from the latest PvPGN release. + +Notes for MYSQL/PGSQL/SQLITE3/ODBC Support: + support with Dev-C++ still unsupported/untested + + +Common problems and Solutions: +============================== + +Fatal: 'all-before' does not exist - don't know how to make it: +---------------------------------------------------------------- +That happens when the wrong make.exe is invoked, usually the Borland one. It will usually leave a copyright notice in your compile log. +How to fix it? add the bin folder of your Dev-C++ (or MinGW) installation to the PATH environment variable, before any Borland path that might be there +For more details check: http://www14.brinkster.com/aditsu/dev-cpp-faq.html#allbefore + +Complains about not being able to create Makefile or 'no rule to make target all': +----------------------------------------------------------------------------------- +Check size of pvpgn\src\win32\Makefile.win If it's 0 bytes quit Dev-C++, delete the file and try to compile again \ No newline at end of file diff --git a/pvpgn/docs/Compile.Instructions.Win32.VS.Net2005.txt b/docs/Compile.Instructions.Win32.VS.Net2005.txt similarity index 98% rename from pvpgn/docs/Compile.Instructions.Win32.VS.Net2005.txt rename to docs/Compile.Instructions.Win32.VS.Net2005.txt index d5a4c04..87934ae 100644 --- a/pvpgn/docs/Compile.Instructions.Win32.VS.Net2005.txt +++ b/docs/Compile.Instructions.Win32.VS.Net2005.txt @@ -1,56 +1,56 @@ -A step-by-step guide for building the SVN version of PvPGN using Visual Studio Professional -=========================================================================================== - -Requirements: - - CMake 2.4.7 ( http://www.cmake.org/files/v2.4/cmake-2.4.7-win32-x86.exe ) - - Visual Studio 2005 Professional - (you can also use Visual C++ Express - but this will need additional - tweaking that is beyond the scope of this guide.) - - zlib ( http://www.winimage.com/zLibDll/zlib123dll.zip AND http://www.winimage.com/zLibDll/zlib123.zip ) - - latest PvPGN sources from SVN (in this example I have them extracted under D:/svn/pvpgn/ ) - - Optional: - - MySQL ( http://dev.mysql.com/get/Downloads/MySQL-5.0/mysql-5.0.45-win32.zip/from/pick#mirrors ) - (using the installer version will make thinks alot easier for you - trust me on this) - - PostgreSQL ( http://wwwmaster.postgresql.org/download/mirrors-ftp?file=%2Fbinary%2Fv8.2.5%2Fwin32%2Fpostgresql-8.2.5-1.zip ) - (same applies here - using this installer will make things alot easier for you) - - SQLite ( http://www.sqlite.org/sqlitedll-3_4_2.zip ) - (needs some extra tweaking - but we'll leave that for later) - -Step-by-step guide: - - install Visual Studio Professional (obviously not required when allread done) - - install CMake (same applies here) - - extract PvPGN sources from zip/tarball or get them via SVN - - create a folder called "zlib" inside you PvPGN base folder ( i.e. D:/svn/pvpgn/zlib/ ) - - extract the following files from zlib123.zip into the "zlib" folder: - zconf.h, zlib.h - - extract the following file from zlib123dll.zip (from with dll32 folder) into the "zlib" folder: - zlibwapi.lib - - install MySQL if you intend to use it as a storage backend - - install PostgreSQL if you intend to use it as a storage backend - - SQLite stub - need some extra tweaking to be explained later (in version 2.0 of this guide) - - create a folder called "build" inside you PvPGN base folder ( i.e. D:/svn/pvpgn/build/ ) - - fire up CMake (I'll use the GUI version for this guide - so you should use it, too) - - Where is the source code: D:\svn\pvpgn - - Where to build the binaries: D:\svn\pvpgn\build - - Now press the "Configure" button, select "Visual Studio 2005" as the build environment and wait a few seconds - - all the components should be found without any problems - - now enable optinal components if required ( WITH_MYSQL, WITH_PGSQL, WITH_SQLITE3 ) and "Configure" again - - again all the components should be found without any problems - - Press "OK" - - double-click on D:/svn/pvpgn/build/pvpgn.sln to fire up Visual Studio 2005 - - build the "ALL_BUILD" target - - build the "INSTALL" target - - now you should find all the stuff (almost) ready under c:/Program Files/pvpgn/ - - extract the following files from zlib123dll.zip (from with dll32 folder) into the "sbin" folder: - zlibwapi.lib - - optionally get the following files from C:\Program Files\MySQL\MySQL Server 5.0\lib\opt\ and copy them into the "sbin" folder - libmysql.dll - - optionally get the following files from C:\Program Files\PostgreSQL\8.2\bin\ and copy them into the "sbin" folder - libpq.dll, libintl-2.dll, libiconv-2.dll, krb5_32.dll, comerr32.dll - - optionally extract the following files from sqlitedll-3_4_2.zip into the "sbin" folder: - sqlite3.dll - - drink a beer and congratulate yourself for what you accomplished today - - - +A step-by-step guide for building the SVN version of PvPGN using Visual Studio Professional +=========================================================================================== + +Requirements: + - CMake 2.4.7 ( http://www.cmake.org/files/v2.4/cmake-2.4.7-win32-x86.exe ) + - Visual Studio 2005 Professional + (you can also use Visual C++ Express - but this will need additional + tweaking that is beyond the scope of this guide.) + - zlib ( http://www.winimage.com/zLibDll/zlib123dll.zip AND http://www.winimage.com/zLibDll/zlib123.zip ) + - latest PvPGN sources from SVN (in this example I have them extracted under D:/svn/pvpgn/ ) + + Optional: + - MySQL ( http://dev.mysql.com/get/Downloads/MySQL-5.0/mysql-5.0.45-win32.zip/from/pick#mirrors ) + (using the installer version will make thinks alot easier for you - trust me on this) + - PostgreSQL ( http://wwwmaster.postgresql.org/download/mirrors-ftp?file=%2Fbinary%2Fv8.2.5%2Fwin32%2Fpostgresql-8.2.5-1.zip ) + (same applies here - using this installer will make things alot easier for you) + - SQLite ( http://www.sqlite.org/sqlitedll-3_4_2.zip ) + (needs some extra tweaking - but we'll leave that for later) + +Step-by-step guide: + - install Visual Studio Professional (obviously not required when allread done) + - install CMake (same applies here) + - extract PvPGN sources from zip/tarball or get them via SVN + - create a folder called "zlib" inside you PvPGN base folder ( i.e. D:/svn/pvpgn/zlib/ ) + - extract the following files from zlib123.zip into the "zlib" folder: + zconf.h, zlib.h + - extract the following file from zlib123dll.zip (from with dll32 folder) into the "zlib" folder: + zlibwapi.lib + - install MySQL if you intend to use it as a storage backend + - install PostgreSQL if you intend to use it as a storage backend + - SQLite stub - need some extra tweaking to be explained later (in version 2.0 of this guide) + - create a folder called "build" inside you PvPGN base folder ( i.e. D:/svn/pvpgn/build/ ) + - fire up CMake (I'll use the GUI version for this guide - so you should use it, too) + - Where is the source code: D:\svn\pvpgn + - Where to build the binaries: D:\svn\pvpgn\build + - Now press the "Configure" button, select "Visual Studio 2005" as the build environment and wait a few seconds + - all the components should be found without any problems + - now enable optinal components if required ( WITH_MYSQL, WITH_PGSQL, WITH_SQLITE3 ) and "Configure" again + - again all the components should be found without any problems + - Press "OK" + - double-click on D:/svn/pvpgn/build/pvpgn.sln to fire up Visual Studio 2005 + - build the "ALL_BUILD" target + - build the "INSTALL" target + - now you should find all the stuff (almost) ready under c:/Program Files/pvpgn/ + - extract the following files from zlib123dll.zip (from with dll32 folder) into the "sbin" folder: + zlibwapi.lib + - optionally get the following files from C:\Program Files\MySQL\MySQL Server 5.0\lib\opt\ and copy them into the "sbin" folder + libmysql.dll + - optionally get the following files from C:\Program Files\PostgreSQL\8.2\bin\ and copy them into the "sbin" folder + libpq.dll, libintl-2.dll, libiconv-2.dll, krb5_32.dll, comerr32.dll + - optionally extract the following files from sqlitedll-3_4_2.zip into the "sbin" folder: + sqlite3.dll + - drink a beer and congratulate yourself for what you accomplished today + + + diff --git a/pvpgn/docs/INDEX b/docs/INDEX similarity index 100% rename from pvpgn/docs/INDEX rename to docs/INDEX diff --git a/pvpgn/docs/INSTALL.unix b/docs/INSTALL.unix similarity index 100% rename from pvpgn/docs/INSTALL.unix rename to docs/INSTALL.unix diff --git a/pvpgn/docs/Makefile.am b/docs/Makefile.am similarity index 100% rename from pvpgn/docs/Makefile.am rename to docs/Makefile.am diff --git a/pvpgn/docs/PORTS b/docs/PORTS similarity index 100% rename from pvpgn/docs/PORTS rename to docs/PORTS diff --git a/pvpgn/docs/README.fdwatch b/docs/README.fdwatch similarity index 100% rename from pvpgn/docs/README.fdwatch rename to docs/README.fdwatch diff --git a/pvpgn/docs/README.storage b/docs/README.storage similarity index 100% rename from pvpgn/docs/README.storage rename to docs/README.storage diff --git a/pvpgn/docs/bnmotd.txt b/docs/bnmotd.txt similarity index 100% rename from pvpgn/docs/bnmotd.txt rename to docs/bnmotd.txt diff --git a/pvpgn/files/CMakeLists.txt b/files/CMakeLists.txt similarity index 100% rename from pvpgn/files/CMakeLists.txt rename to files/CMakeLists.txt diff --git a/pvpgn/files/IX86ver1.mpq b/files/IX86ver1.mpq similarity index 100% rename from pvpgn/files/IX86ver1.mpq rename to files/IX86ver1.mpq diff --git a/pvpgn/files/Makefile.am b/files/Makefile.am similarity index 100% rename from pvpgn/files/Makefile.am rename to files/Makefile.am diff --git a/pvpgn/files/PMACver1.mpq b/files/PMACver1.mpq similarity index 100% rename from pvpgn/files/PMACver1.mpq rename to files/PMACver1.mpq diff --git a/pvpgn/files/XMACver1.mpq b/files/XMACver1.mpq similarity index 100% rename from pvpgn/files/XMACver1.mpq rename to files/XMACver1.mpq diff --git a/pvpgn/files/ad000001.mng b/files/ad000001.mng similarity index 100% rename from pvpgn/files/ad000001.mng rename to files/ad000001.mng diff --git a/pvpgn/files/ad000001.smk b/files/ad000001.smk similarity index 100% rename from pvpgn/files/ad000001.smk rename to files/ad000001.smk diff --git a/pvpgn/files/ad000002.mng b/files/ad000002.mng similarity index 100% rename from pvpgn/files/ad000002.mng rename to files/ad000002.mng diff --git a/pvpgn/files/ad000003.mng b/files/ad000003.mng similarity index 100% rename from pvpgn/files/ad000003.mng rename to files/ad000003.mng diff --git a/pvpgn/files/ad000004.mng b/files/ad000004.mng similarity index 100% rename from pvpgn/files/ad000004.mng rename to files/ad000004.mng diff --git a/pvpgn/files/ad000075.mng b/files/ad000075.mng similarity index 100% rename from pvpgn/files/ad000075.mng rename to files/ad000075.mng diff --git a/pvpgn/files/bnserver-D2DV.ini b/files/bnserver-D2DV.ini similarity index 100% rename from pvpgn/files/bnserver-D2DV.ini rename to files/bnserver-D2DV.ini diff --git a/pvpgn/files/bnserver-D2XP.ini b/files/bnserver-D2XP.ini similarity index 100% rename from pvpgn/files/bnserver-D2XP.ini rename to files/bnserver-D2XP.ini diff --git a/pvpgn/files/bnserver-WAR3.ini b/files/bnserver-WAR3.ini similarity index 100% rename from pvpgn/files/bnserver-WAR3.ini rename to files/bnserver-WAR3.ini diff --git a/pvpgn/files/bnserver.ini b/files/bnserver.ini similarity index 100% rename from pvpgn/files/bnserver.ini rename to files/bnserver.ini diff --git a/pvpgn/files/chathelp-war3-default.txt b/files/chathelp-war3-default.txt similarity index 100% rename from pvpgn/files/chathelp-war3-default.txt rename to files/chathelp-war3-default.txt diff --git a/pvpgn/files/chathelp-war3-enUS.txt b/files/chathelp-war3-enUS.txt similarity index 100% rename from pvpgn/files/chathelp-war3-enUS.txt rename to files/chathelp-war3-enUS.txt diff --git a/pvpgn/files/chathelp-war3-frFR.txt b/files/chathelp-war3-frFR.txt similarity index 100% rename from pvpgn/files/chathelp-war3-frFR.txt rename to files/chathelp-war3-frFR.txt diff --git a/pvpgn/files/chathelp-war3-ruRU.txt b/files/chathelp-war3-ruRU.txt similarity index 100% rename from pvpgn/files/chathelp-war3-ruRU.txt rename to files/chathelp-war3-ruRU.txt diff --git a/pvpgn/files/chathelp-war3-zhCN.txt b/files/chathelp-war3-zhCN.txt similarity index 96% rename from pvpgn/files/chathelp-war3-zhCN.txt rename to files/chathelp-war3-zhCN.txt index 43c4fe4..197ddc0 100644 --- a/pvpgn/files/chathelp-war3-zhCN.txt +++ b/files/chathelp-war3-zhCN.txt @@ -1,15 +1,15 @@ -PvPGN模拟战网èŠå¤©å‘½ä»¤å¸®åŠ© - -新命令: - -使用 /f help 显示朋å‹å‘½ä»¤å¸®åŠ© -使用 /users 显示在线玩家数 -使用 /w 或者 /msg <玩家å称> å‘é€æ¶ˆæ¯ç»™çŽ©å®¶ -使用 /join <频é“> åŠ å…¥æŒ‡å®šçš„é¢‘é“ - -频é“管ç†å‘˜ï¼š - -使用 /ban <玩家å称> 把玩家从该频é“中踢出,并ç¦æ­¢çŽ©å®¶å†æ¬¡è¿›å…¥æ­¤é¢‘é“ -使用 /kick <玩家å称> 把玩家从该频é“中踢出 - -更多的帮助:输入/help +PvPGN模拟战网èŠå¤©å‘½ä»¤å¸®åŠ© + +新命令: + +使用 /f help 显示朋å‹å‘½ä»¤å¸®åŠ© +使用 /users 显示在线玩家数 +使用 /w 或者 /msg <玩家å称> å‘é€æ¶ˆæ¯ç»™çŽ©å®¶ +使用 /join <频é“> åŠ å…¥æŒ‡å®šçš„é¢‘é“ + +频é“管ç†å‘˜ï¼š + +使用 /ban <玩家å称> 把玩家从该频é“中踢出,并ç¦æ­¢çŽ©å®¶å†æ¬¡è¿›å…¥æ­¤é¢‘é“ +使用 /kick <玩家å称> 把玩家从该频é“中踢出 + +更多的帮助:输入/help diff --git a/pvpgn/files/icons-WAR3.bni b/files/icons-WAR3.bni similarity index 100% rename from pvpgn/files/icons-WAR3.bni rename to files/icons-WAR3.bni diff --git a/pvpgn/files/icons.bni b/files/icons.bni similarity index 100% rename from pvpgn/files/icons.bni rename to files/icons.bni diff --git a/pvpgn/files/icons_STAR.bni b/files/icons_STAR.bni similarity index 100% rename from pvpgn/files/icons_STAR.bni rename to files/icons_STAR.bni diff --git a/pvpgn/files/newaccount-default.txt b/files/newaccount-default.txt similarity index 100% rename from pvpgn/files/newaccount-default.txt rename to files/newaccount-default.txt diff --git a/pvpgn/files/newaccount-enUS.txt b/files/newaccount-enUS.txt similarity index 100% rename from pvpgn/files/newaccount-enUS.txt rename to files/newaccount-enUS.txt diff --git a/d2pack109/files/newbie.save b/files/newbie.save similarity index 100% rename from d2pack109/files/newbie.save rename to files/newbie.save diff --git a/pvpgn/files/termsofservice-default.txt b/files/termsofservice-default.txt similarity index 100% rename from pvpgn/files/termsofservice-default.txt rename to files/termsofservice-default.txt diff --git a/pvpgn/files/termsofservice-enUS.txt b/files/termsofservice-enUS.txt similarity index 100% rename from pvpgn/files/termsofservice-enUS.txt rename to files/termsofservice-enUS.txt diff --git a/pvpgn/files/tos-unicode_default.txt b/files/tos-unicode_default.txt similarity index 98% rename from pvpgn/files/tos-unicode_default.txt rename to files/tos-unicode_default.txt index 011a1b6..d457818 100644 --- a/pvpgn/files/tos-unicode_default.txt +++ b/files/tos-unicode_default.txt @@ -1,21 +1,21 @@ -You are currently connected to a PvPGN Server (Player -vs- Player Gaming Network) - -PvPGN TERMS OF USE: - -PvPGN is a Battle.net(R) emulation server and in no way affiliated with bnetd, warforge, or Blizzard Entertainment(R). -PvPGN is provided "as is" without warrenties of any kind. -We do not support the idea of Pirated software and urge you to purchase a legit copy of any games that you play on our servers. - -1. Information found on PvPGN. -PvPGN does not endorse or stand behind the accuracy, truthfulness or reliability of any information (including statements of opinion or advice) provided on or by means of PvPGN. Any and all statements made in forums, chat or during game play reflect only the views of their author. - -2. Disclaimer of Warrenty. -PvPGN is provided to you "as is" without warrenty of any kind. PvPGN does not warrent that their programm will be uninterrupted or error free. - -3. Limitations of Liability -PvPGN is in no way liable for loss or damage of any kind resulting from the use of PvPGN, including but not limited to, loss of goodwill, work stoppage, computer failure or malfunction, or any and all other damages or losses, commercial or otherwise. - -Battle.net(R) and Blizzard Entertainment(R) are trademarks or registered trademarks of Blizzard Entertainment in the U.S. and/or other countries. - -Besides all this... Happy gaming.. -PvPGN Project Page: http://pvpgn.berlios.de/ +You are currently connected to a PvPGN Server (Player -vs- Player Gaming Network) + +PvPGN TERMS OF USE: + +PvPGN is a Battle.net(R) emulation server and in no way affiliated with bnetd, warforge, or Blizzard Entertainment(R). +PvPGN is provided "as is" without warrenties of any kind. +We do not support the idea of Pirated software and urge you to purchase a legit copy of any games that you play on our servers. + +1. Information found on PvPGN. +PvPGN does not endorse or stand behind the accuracy, truthfulness or reliability of any information (including statements of opinion or advice) provided on or by means of PvPGN. Any and all statements made in forums, chat or during game play reflect only the views of their author. + +2. Disclaimer of Warrenty. +PvPGN is provided to you "as is" without warrenty of any kind. PvPGN does not warrent that their programm will be uninterrupted or error free. + +3. Limitations of Liability +PvPGN is in no way liable for loss or damage of any kind resulting from the use of PvPGN, including but not limited to, loss of goodwill, work stoppage, computer failure or malfunction, or any and all other damages or losses, commercial or otherwise. + +Battle.net(R) and Blizzard Entertainment(R) are trademarks or registered trademarks of Blizzard Entertainment in the U.S. and/or other countries. + +Besides all this... Happy gaming.. +PvPGN Project Page: http://pvpgn.berlios.de/ diff --git a/pvpgn/files/tos.txt b/files/tos.txt similarity index 98% rename from pvpgn/files/tos.txt rename to files/tos.txt index 011a1b6..d457818 100644 --- a/pvpgn/files/tos.txt +++ b/files/tos.txt @@ -1,21 +1,21 @@ -You are currently connected to a PvPGN Server (Player -vs- Player Gaming Network) - -PvPGN TERMS OF USE: - -PvPGN is a Battle.net(R) emulation server and in no way affiliated with bnetd, warforge, or Blizzard Entertainment(R). -PvPGN is provided "as is" without warrenties of any kind. -We do not support the idea of Pirated software and urge you to purchase a legit copy of any games that you play on our servers. - -1. Information found on PvPGN. -PvPGN does not endorse or stand behind the accuracy, truthfulness or reliability of any information (including statements of opinion or advice) provided on or by means of PvPGN. Any and all statements made in forums, chat or during game play reflect only the views of their author. - -2. Disclaimer of Warrenty. -PvPGN is provided to you "as is" without warrenty of any kind. PvPGN does not warrent that their programm will be uninterrupted or error free. - -3. Limitations of Liability -PvPGN is in no way liable for loss or damage of any kind resulting from the use of PvPGN, including but not limited to, loss of goodwill, work stoppage, computer failure or malfunction, or any and all other damages or losses, commercial or otherwise. - -Battle.net(R) and Blizzard Entertainment(R) are trademarks or registered trademarks of Blizzard Entertainment in the U.S. and/or other countries. - -Besides all this... Happy gaming.. -PvPGN Project Page: http://pvpgn.berlios.de/ +You are currently connected to a PvPGN Server (Player -vs- Player Gaming Network) + +PvPGN TERMS OF USE: + +PvPGN is a Battle.net(R) emulation server and in no way affiliated with bnetd, warforge, or Blizzard Entertainment(R). +PvPGN is provided "as is" without warrenties of any kind. +We do not support the idea of Pirated software and urge you to purchase a legit copy of any games that you play on our servers. + +1. Information found on PvPGN. +PvPGN does not endorse or stand behind the accuracy, truthfulness or reliability of any information (including statements of opinion or advice) provided on or by means of PvPGN. Any and all statements made in forums, chat or during game play reflect only the views of their author. + +2. Disclaimer of Warrenty. +PvPGN is provided to you "as is" without warrenty of any kind. PvPGN does not warrent that their programm will be uninterrupted or error free. + +3. Limitations of Liability +PvPGN is in no way liable for loss or damage of any kind resulting from the use of PvPGN, including but not limited to, loss of goodwill, work stoppage, computer failure or malfunction, or any and all other damages or losses, commercial or otherwise. + +Battle.net(R) and Blizzard Entertainment(R) are trademarks or registered trademarks of Blizzard Entertainment in the U.S. and/or other countries. + +Besides all this... Happy gaming.. +PvPGN Project Page: http://pvpgn.berlios.de/ diff --git a/pvpgn/files/tos_default.txt b/files/tos_default.txt similarity index 98% rename from pvpgn/files/tos_default.txt rename to files/tos_default.txt index 011a1b6..d457818 100644 --- a/pvpgn/files/tos_default.txt +++ b/files/tos_default.txt @@ -1,21 +1,21 @@ -You are currently connected to a PvPGN Server (Player -vs- Player Gaming Network) - -PvPGN TERMS OF USE: - -PvPGN is a Battle.net(R) emulation server and in no way affiliated with bnetd, warforge, or Blizzard Entertainment(R). -PvPGN is provided "as is" without warrenties of any kind. -We do not support the idea of Pirated software and urge you to purchase a legit copy of any games that you play on our servers. - -1. Information found on PvPGN. -PvPGN does not endorse or stand behind the accuracy, truthfulness or reliability of any information (including statements of opinion or advice) provided on or by means of PvPGN. Any and all statements made in forums, chat or during game play reflect only the views of their author. - -2. Disclaimer of Warrenty. -PvPGN is provided to you "as is" without warrenty of any kind. PvPGN does not warrent that their programm will be uninterrupted or error free. - -3. Limitations of Liability -PvPGN is in no way liable for loss or damage of any kind resulting from the use of PvPGN, including but not limited to, loss of goodwill, work stoppage, computer failure or malfunction, or any and all other damages or losses, commercial or otherwise. - -Battle.net(R) and Blizzard Entertainment(R) are trademarks or registered trademarks of Blizzard Entertainment in the U.S. and/or other countries. - -Besides all this... Happy gaming.. -PvPGN Project Page: http://pvpgn.berlios.de/ +You are currently connected to a PvPGN Server (Player -vs- Player Gaming Network) + +PvPGN TERMS OF USE: + +PvPGN is a Battle.net(R) emulation server and in no way affiliated with bnetd, warforge, or Blizzard Entertainment(R). +PvPGN is provided "as is" without warrenties of any kind. +We do not support the idea of Pirated software and urge you to purchase a legit copy of any games that you play on our servers. + +1. Information found on PvPGN. +PvPGN does not endorse or stand behind the accuracy, truthfulness or reliability of any information (including statements of opinion or advice) provided on or by means of PvPGN. Any and all statements made in forums, chat or during game play reflect only the views of their author. + +2. Disclaimer of Warrenty. +PvPGN is provided to you "as is" without warrenty of any kind. PvPGN does not warrent that their programm will be uninterrupted or error free. + +3. Limitations of Liability +PvPGN is in no way liable for loss or damage of any kind resulting from the use of PvPGN, including but not limited to, loss of goodwill, work stoppage, computer failure or malfunction, or any and all other damages or losses, commercial or otherwise. + +Battle.net(R) and Blizzard Entertainment(R) are trademarks or registered trademarks of Blizzard Entertainment in the U.S. and/or other countries. + +Besides all this... Happy gaming.. +PvPGN Project Page: http://pvpgn.berlios.de/ diff --git a/pvpgn/files/ver-ix86-1.mpq b/files/ver-ix86-1.mpq similarity index 100% rename from pvpgn/files/ver-ix86-1.mpq rename to files/ver-ix86-1.mpq diff --git a/pvpgn/man/CMakeLists.txt b/man/CMakeLists.txt similarity index 100% rename from pvpgn/man/CMakeLists.txt rename to man/CMakeLists.txt diff --git a/pvpgn/man/Makefile.am b/man/Makefile.am similarity index 100% rename from pvpgn/man/Makefile.am rename to man/Makefile.am diff --git a/pvpgn/man/bnbot.1 b/man/bnbot.1 similarity index 100% rename from pvpgn/man/bnbot.1 rename to man/bnbot.1 diff --git a/pvpgn/man/bnchat.1 b/man/bnchat.1 similarity index 100% rename from pvpgn/man/bnchat.1 rename to man/bnchat.1 diff --git a/pvpgn/man/bnetd.1 b/man/bnetd.1 similarity index 100% rename from pvpgn/man/bnetd.1 rename to man/bnetd.1 diff --git a/pvpgn/man/bnetd.conf.5 b/man/bnetd.conf.5 similarity index 100% rename from pvpgn/man/bnetd.conf.5 rename to man/bnetd.conf.5 diff --git a/pvpgn/man/bnftp.1 b/man/bnftp.1 similarity index 100% rename from pvpgn/man/bnftp.1 rename to man/bnftp.1 diff --git a/pvpgn/man/bni2tga.1 b/man/bni2tga.1 similarity index 100% rename from pvpgn/man/bni2tga.1 rename to man/bni2tga.1 diff --git a/pvpgn/man/bnibuild.1 b/man/bnibuild.1 similarity index 100% rename from pvpgn/man/bnibuild.1 rename to man/bnibuild.1 diff --git a/pvpgn/man/bniextract.1 b/man/bniextract.1 similarity index 100% rename from pvpgn/man/bniextract.1 rename to man/bniextract.1 diff --git a/pvpgn/man/bnilist.1 b/man/bnilist.1 similarity index 100% rename from pvpgn/man/bnilist.1 rename to man/bnilist.1 diff --git a/pvpgn/man/bnpass.1 b/man/bnpass.1 similarity index 100% rename from pvpgn/man/bnpass.1 rename to man/bnpass.1 diff --git a/pvpgn/man/bnpcap.1 b/man/bnpcap.1 similarity index 100% rename from pvpgn/man/bnpcap.1 rename to man/bnpcap.1 diff --git a/pvpgn/man/bnproxy.1 b/man/bnproxy.1 similarity index 100% rename from pvpgn/man/bnproxy.1 rename to man/bnproxy.1 diff --git a/pvpgn/man/bnstat.1 b/man/bnstat.1 similarity index 100% rename from pvpgn/man/bnstat.1 rename to man/bnstat.1 diff --git a/pvpgn/man/bntext.5 b/man/bntext.5 similarity index 100% rename from pvpgn/man/bntext.5 rename to man/bntext.5 diff --git a/pvpgn/man/bntrackd.1 b/man/bntrackd.1 similarity index 100% rename from pvpgn/man/bntrackd.1 rename to man/bntrackd.1 diff --git a/pvpgn/man/tgainfo.1 b/man/tgainfo.1 similarity index 100% rename from pvpgn/man/tgainfo.1 rename to man/tgainfo.1 diff --git a/pvpgn/COPYING b/pvpgn/COPYING deleted file mode 100644 index d60c31a..0000000 --- a/pvpgn/COPYING +++ /dev/null @@ -1,340 +0,0 @@ - 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/pvpgn/README b/pvpgn/README deleted file mode 100644 index 0c1a0d8..0000000 --- a/pvpgn/README +++ /dev/null @@ -1,12 +0,0 @@ - -CONGRATULATIONS!!!! - -WHY ?? BECAUSE YOU ARE ONE OF THE VERY VERY VERY FEW WHO READ THE README FILE!! - -But because the other, huge percentage do NOT, we moved the actual contents -of this file into IGNOREME file because the chances for most of the people to -read IGNOREME are at least the chances to read README (more than that, we -believe they are really much higher). - -So now, go read IGNOREME with the actual contents what you would have -expected here. diff --git a/pvpgn/files/newbie.save b/pvpgn/files/newbie.save deleted file mode 100644 index e839a52..0000000 Binary files a/pvpgn/files/newbie.save and /dev/null differ diff --git a/pvpgn/src/autoconf/install-sh b/pvpgn/src/autoconf/install-sh deleted file mode 100644 index ebc6691..0000000 --- a/pvpgn/src/autoconf/install-sh +++ /dev/null @@ -1,250 +0,0 @@ -#! /bin/sh -# -# install - install a program, script, or datafile -# This comes from X11R5 (mit/util/scripts/install.sh). -# -# Copyright 1991 by the Massachusetts Institute of Technology -# -# Permission to use, copy, modify, distribute, and sell this software and its -# documentation for any purpose is hereby granted without fee, provided that -# the above copyright notice appear in all copies and that both that -# copyright notice and this permission notice appear in supporting -# documentation, and that the name of M.I.T. not be used in advertising or -# publicity pertaining to distribution of the software without specific, -# written prior permission. M.I.T. makes no representations about the -# suitability of this software for any purpose. It is provided "as is" -# without express or implied warranty. -# -# Calling this script install-sh is preferred over install.sh, to prevent -# `make' implicit rules from creating a file called install from it -# when there is no Makefile. -# -# This script is compatible with the BSD install script, but was written -# from scratch. It can only install one file at a time, a restriction -# shared with many OS's install programs. - - -# set DOITPROG to echo to test this script - -# Don't use :- since 4.3BSD and earlier shells don't like it. -doit="${DOITPROG-}" - - -# put in absolute paths if you don't have them in your path; or use env. vars. - -mvprog="${MVPROG-mv}" -cpprog="${CPPROG-cp}" -chmodprog="${CHMODPROG-chmod}" -chownprog="${CHOWNPROG-chown}" -chgrpprog="${CHGRPPROG-chgrp}" -stripprog="${STRIPPROG-strip}" -rmprog="${RMPROG-rm}" -mkdirprog="${MKDIRPROG-mkdir}" - -transformbasename="" -transform_arg="" -instcmd="$mvprog" -chmodcmd="$chmodprog 0755" -chowncmd="" -chgrpcmd="" -stripcmd="" -rmcmd="$rmprog -f" -mvcmd="$mvprog" -src="" -dst="" -dir_arg="" - -while [ x"$1" != x ]; do - case $1 in - -c) instcmd="$cpprog" - shift - continue;; - - -d) dir_arg=true - shift - continue;; - - -m) chmodcmd="$chmodprog $2" - shift - shift - continue;; - - -o) chowncmd="$chownprog $2" - shift - shift - continue;; - - -g) chgrpcmd="$chgrpprog $2" - shift - shift - continue;; - - -s) stripcmd="$stripprog" - shift - continue;; - - -t=*) transformarg=`echo $1 | sed 's/-t=//'` - shift - continue;; - - -b=*) transformbasename=`echo $1 | sed 's/-b=//'` - shift - continue;; - - *) if [ x"$src" = x ] - then - src=$1 - else - # this colon is to work around a 386BSD /bin/sh bug - : - dst=$1 - fi - shift - continue;; - esac -done - -if [ x"$src" = x ] -then - echo "install: no input file specified" - exit 1 -else - true -fi - -if [ x"$dir_arg" != x ]; then - dst=$src - src="" - - if [ -d $dst ]; then - instcmd=: - else - instcmd=mkdir - fi -else - -# Waiting for this to be detected by the "$instcmd $src $dsttmp" command -# might cause directories to be created, which would be especially bad -# if $src (and thus $dsttmp) contains '*'. - - if [ -f $src -o -d $src ] - then - true - else - echo "install: $src does not exist" - exit 1 - fi - - if [ x"$dst" = x ] - then - echo "install: no destination specified" - exit 1 - else - true - fi - -# If destination is a directory, append the input filename; if your system -# does not like double slashes in filenames, you may need to add some logic - - if [ -d $dst ] - then - dst="$dst"/`basename $src` - else - true - fi -fi - -## this sed command emulates the dirname command -dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` - -# Make sure that the destination directory exists. -# this part is taken from Noah Friedman's mkinstalldirs script - -# Skip lots of stat calls in the usual case. -if [ ! -d "$dstdir" ]; then -defaultIFS=' -' -IFS="${IFS-${defaultIFS}}" - -oIFS="${IFS}" -# Some sh's can't handle IFS=/ for some reason. -IFS='%' -set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` -IFS="${oIFS}" - -pathcomp='' - -while [ $# -ne 0 ] ; do - pathcomp="${pathcomp}${1}" - shift - - if [ ! -d "${pathcomp}" ] ; - then - $mkdirprog "${pathcomp}" - else - true - fi - - pathcomp="${pathcomp}/" -done -fi - -if [ x"$dir_arg" != x ] -then - $doit $instcmd $dst && - - if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && - if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && - if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && - if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi -else - -# If we're going to rename the final executable, determine the name now. - - if [ x"$transformarg" = x ] - then - dstfile=`basename $dst` - else - dstfile=`basename $dst $transformbasename | - sed $transformarg`$transformbasename - fi - -# don't allow the sed command to completely eliminate the filename - - if [ x"$dstfile" = x ] - then - dstfile=`basename $dst` - else - true - fi - -# Make a temp file name in the proper directory. - - dsttmp=$dstdir/#inst.$$# - -# Move or copy the file name to the temp name - - $doit $instcmd $src $dsttmp && - - trap "rm -f ${dsttmp}" 0 && - -# and set any options; do chmod last to preserve setuid bits - -# If any of these fail, we abort the whole thing. If we want to -# ignore errors from any of these, just make sure not to ignore -# errors from the above "$doit $instcmd $src $dsttmp" command. - - if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && - if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && - if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && - if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && - -# Now rename the file to the real destination. - - $doit $rmcmd -f $dstdir/$dstfile && - $doit $mvcmd $dsttmp $dstdir/$dstfile - -fi && - - -exit 0 diff --git a/pvpgn/src/autoconf/mkdir-p b/pvpgn/src/autoconf/mkdir-p deleted file mode 100644 index dc973c3..0000000 --- a/pvpgn/src/autoconf/mkdir-p +++ /dev/null @@ -1,101 +0,0 @@ -#! /bin/sh -# $XConsortium: mkdirhier.sh,v 1.7 94/03/24 15:46:34 gildea Exp $ -# Courtesy of Paul Eggert - -# -# Modified by QingLong for portability. 24-02-97. -# - - -newline=' -' -IFS=$newline - -# -# WARNING! Some ancient shells do not understand `:=' and `:-' expansion. -# Use just `=' instead of `:=' if you have lame one. -#: ${MKDIR:=mkdir} ${TR:=tr} -# - -if test -z "${MKDIR-}" ; - then - MKDIR=mkdir -fi - -if test -z "${TR-}" ; - then - TR=tr -fi - - -case ${1--} in - -*) echo >&2 "mkdir-p: usage: mkdir-p directory ..." - exit 1 -esac - -status="" - -for directory - do - case $directory in - '') - echo >&2 "mkdir-p: empty directory name" - status="1" - continue - ;; - *"$newline"*) - echo >&2 "mkdir-p: directory name contains a newline: \`\`$directory''" - status="1" - continue - ;; - ///*) prefix="/" # See POSIX 2.3 "path". - ;; - //*) prefix="//" - ;; - /*) prefix="/" - ;; - -*) prefix="./" - ;; - *) prefix="" - esac - # - IFS=/ - set x $directory - # - case $2 in - */*) - # IFS parsing is broken - IFS=' ' - set x `echo $directory | ${TR} / ' '` - ;; - esac - # - IFS=$newline - shift - # - for filename - do - path="$prefix$filename" - prefix="$path/" - shift - # - test -d "$path" || \ - { - paths=$path - for filename - do - if test "$filename" != "." ; - then - path="$path/$filename" - paths="$paths$newline$path" - fi - done - # - ${MKDIR} $paths || status=$? - # - break - } - done -done - -exit $status diff --git a/pvpgn/src/autoconf/mkdir.m4 b/pvpgn/src/autoconf/mkdir.m4 deleted file mode 100644 index c3d8ca3..0000000 --- a/pvpgn/src/autoconf/mkdir.m4 +++ /dev/null @@ -1,35 +0,0 @@ -dnl AC_FUNC_MKDIR -dnl Check mkdir arguments. -dnl Defines MKDIR_TAKES_ONE_ARG. -dnl -dnl Based on code written by Alexandre Duret-Lutz . - -AC_DEFUN([AC_FUNC_MKDIR_ARGS], -[AC_CHECK_FUNCS([mkdir _mkdir]) -AC_CACHE_CHECK([whether mkdir takes one argument], - [ac_cv_mkdir_takes_one_arg], -[AC_TRY_COMPILE([ -#ifdef HAVE_SYS_STAT_H -# include -#endif -#ifdef HAVE_UNISTD_H -# include -#endif -#ifdef HAVE_DIR_H -# include -#endif -#ifdef HAVE_DIRECT_H -# include -#endif -#ifndef HAVE_MKDIR -# ifdef HAVE__MKDIR -# define mkdir _mkdir -# endif -#endif -],[mkdir(".");], -[ac_cv_mkdir_takes_one_arg=yes],[ac_cv_mkdir_takes_one_arg=no])]) -if test x"$ac_cv_mkdir_takes_one_arg" = xyes; then - AC_DEFINE([MKDIR_TAKES_ONE_ARG],1, - [Define if mkdir takes only one argument.]) -fi -]) diff --git a/pvpgn/src/common/introtate.h b/pvpgn/src/common/introtate.h deleted file mode 100644 index 1e01a96..0000000 --- a/pvpgn/src/common/introtate.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2000 Ross Combs (rocombs@cs.nmsu.edu) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - - -/*****/ -#ifndef JUST_NEED_TYPES -#ifndef INCLUDED_INTROTATE_PROTOS -#define INCLUDED_INTROTATE_PROTOS - -/* - * ROTL(x,n,w) rotates "w" bit wide value "x" by "n" bits to the left - * - * The expression passed in as x must have a type at least as wide as w. - * The type should probably be unsigned for this to be guaranteed to work - * properly. If n or w is signed and larger than x remember that the - * promotion rules would promote x to be of the same (signed) type. - * - * Unfortunately C doesn't have rotate operations and they can be difficult - * to implement when handling rotates by zero, negative numbers, or numbers - * greater or equal to the bit width of the number. This is because ANSI/ISO - * C makes weak guarantees about the left and right shift operators. We - * would like to not depend on word size, endianness, or how negative - * integers are represented. Unfortunately only some of those goals may be - * achieved. As for optimization, a really good compiler might be able to - * recognize what we are doing and turn it into a single machine instruction. - */ - -/* valid for 00 */ -/*#define ROTL(x,n,w) (((x)<<(n)) | ((x)>>((w)-(n))))*/ - -/* valid for 0<=n0 */ -/*#define ROTL(x,n,w) (((x)<<(n)) | ((x)>>(((-(n))&(w-1)))))*/ - -/* valid for 0<=n and w>0 , depends on 2's complement */ -#define ROTL(x,n,w) (((x)<<((n)&(w-1))) | ((x)>>(((-(n))&(w-1))))) - -/* valid for 0<=n and w>0 , uses three mods and an ugly conditional */ -/* FIXME: and also a bug because it doesn't work on PPC */ -/*#define ROTL(x,n,w) (((n)%(w)) ? (((x)<<((n)%(w))) | ((x)>>((w)-((n)%(w))))) : (x))*/ - -#define ROTL32(x,n) ROTL(x,n,32) -#define ROTL16(x,n) ROTL(x,n,16) - -#endif -#endif diff --git a/pvpgn/src/common/setup_after.h b/pvpgn/src/common/setup_after.h deleted file mode 100644 index e8f6147..0000000 --- a/pvpgn/src/common/setup_after.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (C) 2000 Ross Combs (rocombs@cs.nmsu.edu) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_SETUP_BEFORE_H -# error "This file must be included after all other header files" -#endif -#ifndef INCLUDED_SETUP_AFTER_H -#define INCLUDED_SETUP_AFTER_H - -#endif diff --git a/pvpgn/src/compat/netinet_in.h b/pvpgn/src/compat/netinet_in.h deleted file mode 100644 index 7388384..0000000 --- a/pvpgn/src/compat/netinet_in.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (C) 1999 Ross Combs (rocombs@cs.nmsu.edu) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_NETINET_IN_PROTOS -#define INCLUDED_NETINET_IN_PROTOS - -#ifndef INADDR_LOOPBACK -#define INADDR_LOOPBACK 0x7f000001 -#endif - -#ifndef INADDR_ANY -#define INADDR_ANY 0x00000000 -#endif - -#endif diff --git a/pvpgn/src/compat/read.h b/pvpgn/src/compat/read.h deleted file mode 100644 index 6be118a..0000000 --- a/pvpgn/src/compat/read.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (C) 2000 Ross Combs (rocombs@cs.nmsu.edu) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_READ_PROTOS -#define INCLUDED_READ_PROTOS - -/* Unix puts this in unistd.h */ -#ifdef WIN32 -# include -#endif - -#endif diff --git a/pvpgn/src/compat/statmacros.h b/pvpgn/src/compat/statmacros.h deleted file mode 100644 index 6bb5f67..0000000 --- a/pvpgn/src/compat/statmacros.h +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Copyright (C) 2000 Ross Combs (rocombs@cs.nmsu.edu) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_STATMACROS_PROTOS -#define INCLUDED_STATMACROS_PROTOS - -#ifdef STAT_MACROS_BROKEN -# ifdef S_ISREG -# undef S_ISREG -# endif -# ifdef S_ISDIR -# undef S_ISDIR -# endif -# ifdef S_ISCHR -# undef S_ISCHR -# endif -# ifdef S_ISBLK -# undef S_ISBLK -# endif -# ifdef S_ISFIFO -# undef S_ISFIFO -# endif -# ifdef S_ISSOCK -# undef S_ISSOCK -# endif -# ifdef S_ISLNK -# undef S_ISLNK -# endif -#endif - -#ifndef S_IFMT -# define S_IFMT 0170000 -#endif - -#ifndef S_ISREG -# ifdef S_IFREG -# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) -# endif -#endif -#ifndef S_ISDIR -# ifdef S_IFDIR -# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) -# endif -#endif -#ifndef S_ISCHR -# ifdef S_IFCHR -# define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR) -# endif -#endif -#ifndef S_ISBLK -# ifdef S_IFBLK -# define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK) -# endif -#endif -#ifndef S_ISFIFO -# ifdef S_IFIFO -# define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO) -# endif -#endif -#ifndef S_ISLNK -# ifdef S_IFLNK -# define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) -# endif -#endif -#ifndef S_ISSOCK -# ifdef S_IFSOCK -# define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK) -# endif -#endif -#ifndef S_ISCDF -# ifdef S_CDF -# define S_ISCDF(m) (S_ISDIR(m) && ((m) & S_CDF)) -# endif -#endif -#ifndef S_ISMPB -# ifdef S_IFMPB /* V7 */ -# define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB) -# define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC) -# endif -#endif -#ifndef S_ISNWK -# ifdef S_IFNWK /* HP/UX */ -# define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK) -# endif -#endif - -#ifndef S_ISUID -# define S_ISUID 01000 /* set user ID */ -#endif -#ifndef S_ISGID -# define S_ISGID 01000 /* set group ID */ -#endif -#ifndef S_ISVTX -# define S_ISVTX 01000 /* sticky bit */ -#endif - -#ifndef S_IRUSR -# ifdef S_IREAD -# define S_IRUSR S_IREAD -# else -# define S_IRUSR 00400 -# endif -#endif -#ifndef S_IWUSR -# ifdef S_IWRITE -# define S_IWUSR S_IWRITE -# else -# define S_IWUSR 00200 -# endif -#endif -#ifndef S_IXUSR -# ifdef S_IEXEC -# define S_IXUSR S_IEXEC -# else -# define S_IXUSR 00100 -# endif -#endif -#ifndef S_IRWXU -# define S_IRWXU (S_IRUSR|S_IWUSR|S_IXUSR) -#endif -#ifndef S_IRGRP -# define S_IRGRP (S_IRUSR >> 3) -#endif -#ifndef S_IWGRP -# define S_IWGRP (S_IWUSR >> 3) -#endif -#ifndef S_IXGRP -# define S_IXGRP (S_IXUSR >> 3) -#endif -#ifndef S_IRWXG -# define S_IRWXG (S_IRGRP|S_IWGRP|S_IXGRP) -#endif - -#ifndef S_IROTH -# define S_IROTH (S_IRGRP >> 3) -#endif -#ifndef S_IWOTH -# define S_IWOTH (S_IWGRP >> 3) -#endif -#ifndef S_IXOTH -# define S_IXOTH (S_IXGRP >> 3) -#endif -#ifndef S_IRWXO -# define S_IRWXO (S_IROTH|S_IWOTH|S_IXOTH) -#endif - -#endif diff --git a/pvpgn/src/win32/console_resource.h b/pvpgn/src/win32/console_resource.h deleted file mode 100644 index 765ffcb..0000000 --- a/pvpgn/src/win32/console_resource.h +++ /dev/null @@ -1,2 +0,0 @@ -#define IDI_ICON1 101 - diff --git a/pvpgn/src/win32/console_resource.rc b/pvpgn/src/win32/console_resource.rc deleted file mode 100644 index 7e362ea..0000000 --- a/pvpgn/src/win32/console_resource.rc +++ /dev/null @@ -1,10 +0,0 @@ -#include "console_resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -#ifndef __BORLANDC__ -#include "afxres.h" -#endif - -/* Icon */ -ID_ICON1 ICON DISCARDABLE "win32/logo01.ico" - diff --git a/pvpgn/src/win32/d2cs_resource.h b/pvpgn/src/win32/d2cs_resource.h deleted file mode 100644 index 7d07f53..0000000 --- a/pvpgn/src/win32/d2cs_resource.h +++ /dev/null @@ -1,17 +0,0 @@ -#define ID_TRAY 4 -#define ID_RESTORE 5 -#define ID_EXIT 6 - -#define ID_ABOUT_BOX 101 -#define ID_ICON1 102 -#define ID_MENU 103 - -#define ID_START_D2CS 40001 -#define ID_SHUTDOWN_D2CS 40002 -#define ID_RESTART_D2CS 40003 -#define ID_EDITCONFIG_D2CS 40004 -#define ID_LOADCONFIG_D2CS 40005 -#define ID_LADDER_LOAD 40006 -#define ID_RESTART_D2GS 40007 -#define ID_CLEAR 40008 -#define ID_ABOUT 40009 diff --git a/pvpgn/src/win32/d2cs_resource.rc b/pvpgn/src/win32/d2cs_resource.rc deleted file mode 100644 index d65326f..0000000 --- a/pvpgn/src/win32/d2cs_resource.rc +++ /dev/null @@ -1,44 +0,0 @@ -#include "d2cs_resource.h" -#include "d2cs/version.h" - -#define APSTUDIO_READONLY_SYMBOLS -#ifndef __BORLANDC__ -#include "afxres.h" -#endif - -/* Menu */ -ID_MENU MENU DISCARDABLE -BEGIN - MENUITEM "&Exit", ID_EXIT - MENUITEM "&Start", ID_START_D2CS - MENUITEM "Shut&down", ID_SHUTDOWN_D2CS - MENUITEM "&Restart", ID_RESTART_D2CS - MENUITEM "&Edit Configuration", ID_EDITCONFIG_D2CS - MENUITEM "Reload &Configuration", ID_LOADCONFIG_D2CS - MENUITEM "Reload &Ladder", ID_LADDER_LOAD - MENUITEM "Restart d2gs", ID_RESTART_D2GS - MENUITEM "&Clear Window", ID_CLEAR - MENUITEM "&About", ID_ABOUT -END - -/* About Dialog Box */ -ID_ABOUT_BOX DIALOGEX 120, 150, 240, 150 -STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "About This Server" -FONT 8, "MS Sans Serif" -BEGIN - GROUPBOX "",IDC_STATIC,5,5,230,140 - CTEXT "D2CS Version",IDC_STATIC,15,15,210,15 - CTEXT D2CS_VERSION_STRING,IDC_STATIC,15,25,210,15 - CTEXT "coded by the PvPGN Team",IDC_STATIC,15,40,210,15 - CTEXT "- - - - - - - - - - - - - - -",IDC_STATIC,15,55,210,15 - CTEXT "visit us @ www.pvpgn.org or",IDC_STATIC,15,70,210,15 - CTEXT "irc.pvpgn.org #pvpgn",IDC_STATIC,15,80,210,15 - CTEXT "©2002 ©2003 ©2004 PvPGN Is a Open Source Project",IDC_STATIC,15,100,210,15 - CTEXT "As specified by the GPL",IDC_STATIC,15,110,210,15 - DEFPUSHBUTTON "&OK",IDOK,95,125,50,14 -END - -/* Icon */ -ID_ICON1 ICON DISCARDABLE "win32/logo01.ico" - diff --git a/pvpgn/src/win32/d2dbs_resource.h b/pvpgn/src/win32/d2dbs_resource.h deleted file mode 100644 index 113d277..0000000 --- a/pvpgn/src/win32/d2dbs_resource.h +++ /dev/null @@ -1,16 +0,0 @@ -#define ID_TRAY 4 -#define ID_RESTORE 5 -#define ID_EXIT 6 - -#define ID_ABOUT_BOX 101 -#define ID_ICON1 102 -#define ID_MENU 103 - -#define ID_START_D2DBS 40001 -#define ID_SHUTDOWN_D2DBS 40002 -#define ID_RESTART_D2DBS 40003 -#define ID_EDITCONFIG_D2DBS 40004 -#define ID_LOADCONFIG_D2DBS 40005 -#define ID_LADDER_SAVE 40006 -#define ID_CLEAR 40007 -#define ID_ABOUT 40008 diff --git a/pvpgn/src/win32/d2dbs_resource.rc b/pvpgn/src/win32/d2dbs_resource.rc deleted file mode 100644 index 1b3b8b5..0000000 --- a/pvpgn/src/win32/d2dbs_resource.rc +++ /dev/null @@ -1,43 +0,0 @@ -#include "d2dbs_resource.h" -#include "d2dbs/version.h" - -#define APSTUDIO_READONLY_SYMBOLS -#ifndef __BORLANDC__ -#include "afxres.h" -#endif - -/* Menu */ -ID_MENU MENU DISCARDABLE -BEGIN - MENUITEM "&Exit", ID_EXIT - MENUITEM "&Start", ID_START_D2DBS - MENUITEM "Shut&down", ID_SHUTDOWN_D2DBS - MENUITEM "&Restart", ID_RESTART_D2DBS - MENUITEM "&Edit Configuration", ID_EDITCONFIG_D2DBS - MENUITEM "Reload &Configuration", ID_LOADCONFIG_D2DBS - MENUITEM "Save &Ladder", ID_LADDER_SAVE - MENUITEM "&Clear Window", ID_CLEAR - MENUITEM "&About", ID_ABOUT -END - -/* About Dialog Box */ -ID_ABOUT_BOX DIALOGEX 120, 150, 240, 150 -STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "About This Server" -FONT 8, "MS Sans Serif" -BEGIN - GROUPBOX "",IDC_STATIC,5,5,230,140 - CTEXT "D2DBS Version",IDC_STATIC,15,15,210,15 - CTEXT D2DBS_VERSION_NUMBER,IDC_STATIC,15,25,210,15 - CTEXT "coded by the PvPGN Team",IDC_STATIC,15,40,210,15 - CTEXT "- - - - - - - - - - - - - - -",IDC_STATIC,15,55,210,15 - CTEXT "visit us @ www.pvpgn.org or",IDC_STATIC,15,70,210,15 - CTEXT "irc.pvpgn.org #pvpgn",IDC_STATIC,15,80,210,15 - CTEXT "©2002 ©2003 ©2004 PvPGN Is a Open Source Project",IDC_STATIC,15,100,210,15 - CTEXT "As specified by the GPL",IDC_STATIC,15,110,210,15 - DEFPUSHBUTTON "&OK",IDOK,95,125,50,14 -END - -/* Icon */ -ID_ICON1 ICON DISCARDABLE "win32/logo01.ico" - diff --git a/pvpgn/src/win32/logo01.ico b/pvpgn/src/win32/logo01.ico deleted file mode 100644 index 9bb64a9..0000000 Binary files a/pvpgn/src/win32/logo01.ico and /dev/null differ diff --git a/pvpgn/scripts/S98bnetd b/scripts/S98bnetd similarity index 100% rename from pvpgn/scripts/S98bnetd rename to scripts/S98bnetd diff --git a/pvpgn/scripts/announce.sh b/scripts/announce.sh similarity index 100% rename from pvpgn/scripts/announce.sh rename to scripts/announce.sh diff --git a/pvpgn/scripts/bnetd.init b/scripts/bnetd.init similarity index 100% rename from pvpgn/scripts/bnetd.init rename to scripts/bnetd.init diff --git a/pvpgn/scripts/bnetd.logrotate b/scripts/bnetd.logrotate similarity index 100% rename from pvpgn/scripts/bnetd.logrotate rename to scripts/bnetd.logrotate diff --git a/pvpgn/scripts/bnetmasq.sh b/scripts/bnetmasq.sh similarity index 100% rename from pvpgn/scripts/bnetmasq.sh rename to scripts/bnetmasq.sh diff --git a/pvpgn/scripts/convert_w3.pl b/scripts/convert_w3.pl similarity index 100% rename from pvpgn/scripts/convert_w3.pl rename to scripts/convert_w3.pl diff --git a/pvpgn/scripts/cvs2cl.pl b/scripts/cvs2cl.pl similarity index 100% rename from pvpgn/scripts/cvs2cl.pl rename to scripts/cvs2cl.pl diff --git a/pvpgn/scripts/flat2cdb.pl b/scripts/flat2cdb.pl similarity index 100% rename from pvpgn/scripts/flat2cdb.pl rename to scripts/flat2cdb.pl diff --git a/pvpgn/scripts/fsgs2bnetd.pl b/scripts/fsgs2bnetd.pl similarity index 100% rename from pvpgn/scripts/fsgs2bnetd.pl rename to scripts/fsgs2bnetd.pl diff --git a/pvpgn/scripts/ladder.py b/scripts/ladder.py similarity index 100% rename from pvpgn/scripts/ladder.py rename to scripts/ladder.py diff --git a/pvpgn/scripts/lastlogin.pl b/scripts/lastlogin.pl similarity index 100% rename from pvpgn/scripts/lastlogin.pl rename to scripts/lastlogin.pl diff --git a/pvpgn/scripts/login_testusers.sh b/scripts/login_testusers.sh similarity index 100% rename from pvpgn/scripts/login_testusers.sh rename to scripts/login_testusers.sh diff --git a/pvpgn/scripts/make_testusers.sh b/scripts/make_testusers.sh similarity index 100% rename from pvpgn/scripts/make_testusers.sh rename to scripts/make_testusers.sh diff --git a/pvpgn/scripts/process.pl b/scripts/process.pl similarity index 100% rename from pvpgn/scripts/process.pl rename to scripts/process.pl diff --git a/pvpgn/scripts/pvpgn_hash.inc.php b/scripts/pvpgn_hash.inc.php similarity index 96% rename from pvpgn/scripts/pvpgn_hash.inc.php rename to scripts/pvpgn_hash.inc.php index 153a915..f088027 100644 --- a/pvpgn/scripts/pvpgn_hash.inc.php +++ b/scripts/pvpgn_hash.inc.php @@ -1,126 +1,126 @@ -> 6) + 1; - - for($i=0; $i < $nblk * 16; $i++) $blks[$i] = 0; - for($i=0; $i < strlen($str); $i++) { - $blks[$i >> 2] |= ord(substr($str, $i, 1)) << ( ($i % 4) * 8); - } - return $blks; -} -function safe_add($x, $y) { - $lsw = ($x & 0xFFFF) + ($y & 0xFFFF); - $msw = ($x >> 16) + ($y >> 16) + ($lsw >> 16); - return ($msw << 16) | ($lsw & 0xFFFF); -} - -function safe_not( $num ) { - $lsw = (~($num & 0xFFFF)) & 0xFFFF; - $msw = (~($num >> 16)) & 0xFFFF; - return ($msw << 16) | $lsw; -} - -function safe_rol( $num, $amt ) { - $leftmask = 0xffff | (0xffff << 16); - $leftmask <<= 32 - $amt; - $rightmask = 0xffff | (0xffff << 16); - $rightmask <<= $amt; - $rightmask = safe_not($rightmask); - - $remains = $num & $leftmask; - $remains >>= 32 - $amt; - $remains &= $rightmask; - - $res = ($num << $amt) | $remains; - - return $res; -} - -function ft($t, $b, $c, $d) { - if($t < 20) return ($b & $c) | ((safe_not($b)) & $d); - if($t < 40) return $d ^ $c ^ $b; - if($t < 60) return ($c & $b) | ($d & $c) | ($d & $b); - return $d ^ $c ^ $b; -} - -function kt($t) { - if ($t < 20) { - return 0x5a82 << 16 | 0x7999; - } else if ($t < 40) { - return 0x6ed9 << 16 | 0xeba1; - } else if ($t < 60) { - return 0x8f1b << 16 | 0xbcdc; - } else { - return 0xca62 << 16 | 0xc1d6; - } -} -function pvpgn_hash($str) { - $x = str2blks_pvpgn($str); - - $a = 0x6745 << 16 | 0x2301; - $b = 0xefcd << 16 | 0xab89; - $c = 0x98ba << 16 | 0xdcfe; - $d = 0x1032 << 16 | 0x5476; - $e = 0xc3d2 << 16 | 0xe1f0; - - for($i = 0; $i < sizeof($x); $i += 16) { - $olda = $a; - $oldb = $b; - $oldc = $c; - $oldd = $d; - $olde = $e; - - for($j = 0; $j < 16; $j++) { - $w[$j] = $x[$i+$j]; - } - - for($j = 0; $j < 64; $j++) { - $ww = $w[$j] ^ $w[$j+8] ^ $w[$j+2] ^ $w[$j+13]; - $w[$j+16] = 1 << ($ww%32); - } - - for($j = 0; $j < 80; $j++) { - if ($j<20) - { - $t = safe_add(safe_add(safe_rol($a, 5), ft($j, $b, $c, $d)), safe_add(safe_add($e, $w[$j]), kt($j))); - } - else - { - $t = safe_add(safe_add(safe_rol($t, 5), ft($j, $b, $c, $d)), safe_add(safe_add($e, $w[$j]), kt($j))); - } - $e = $d; - $d = $c; - $c = safe_rol($b, 30); - $b = $a; - $a = $t; - } - $a = safe_add($t, $olda); - $b = safe_add($b, $oldb); - $c = safe_add($c, $oldc); - $d = safe_add($d, $oldd); - $e = safe_add($e, $olde); - } - return sprintf("%08x%08x%08x%08x%08x",$a,$b,$c,$d,$e); -} - +> 6) + 1; + + for($i=0; $i < $nblk * 16; $i++) $blks[$i] = 0; + for($i=0; $i < strlen($str); $i++) { + $blks[$i >> 2] |= ord(substr($str, $i, 1)) << ( ($i % 4) * 8); + } + return $blks; +} +function safe_add($x, $y) { + $lsw = ($x & 0xFFFF) + ($y & 0xFFFF); + $msw = ($x >> 16) + ($y >> 16) + ($lsw >> 16); + return ($msw << 16) | ($lsw & 0xFFFF); +} + +function safe_not( $num ) { + $lsw = (~($num & 0xFFFF)) & 0xFFFF; + $msw = (~($num >> 16)) & 0xFFFF; + return ($msw << 16) | $lsw; +} + +function safe_rol( $num, $amt ) { + $leftmask = 0xffff | (0xffff << 16); + $leftmask <<= 32 - $amt; + $rightmask = 0xffff | (0xffff << 16); + $rightmask <<= $amt; + $rightmask = safe_not($rightmask); + + $remains = $num & $leftmask; + $remains >>= 32 - $amt; + $remains &= $rightmask; + + $res = ($num << $amt) | $remains; + + return $res; +} + +function ft($t, $b, $c, $d) { + if($t < 20) return ($b & $c) | ((safe_not($b)) & $d); + if($t < 40) return $d ^ $c ^ $b; + if($t < 60) return ($c & $b) | ($d & $c) | ($d & $b); + return $d ^ $c ^ $b; +} + +function kt($t) { + if ($t < 20) { + return 0x5a82 << 16 | 0x7999; + } else if ($t < 40) { + return 0x6ed9 << 16 | 0xeba1; + } else if ($t < 60) { + return 0x8f1b << 16 | 0xbcdc; + } else { + return 0xca62 << 16 | 0xc1d6; + } +} +function pvpgn_hash($str) { + $x = str2blks_pvpgn($str); + + $a = 0x6745 << 16 | 0x2301; + $b = 0xefcd << 16 | 0xab89; + $c = 0x98ba << 16 | 0xdcfe; + $d = 0x1032 << 16 | 0x5476; + $e = 0xc3d2 << 16 | 0xe1f0; + + for($i = 0; $i < sizeof($x); $i += 16) { + $olda = $a; + $oldb = $b; + $oldc = $c; + $oldd = $d; + $olde = $e; + + for($j = 0; $j < 16; $j++) { + $w[$j] = $x[$i+$j]; + } + + for($j = 0; $j < 64; $j++) { + $ww = $w[$j] ^ $w[$j+8] ^ $w[$j+2] ^ $w[$j+13]; + $w[$j+16] = 1 << ($ww%32); + } + + for($j = 0; $j < 80; $j++) { + if ($j<20) + { + $t = safe_add(safe_add(safe_rol($a, 5), ft($j, $b, $c, $d)), safe_add(safe_add($e, $w[$j]), kt($j))); + } + else + { + $t = safe_add(safe_add(safe_rol($t, 5), ft($j, $b, $c, $d)), safe_add(safe_add($e, $w[$j]), kt($j))); + } + $e = $d; + $d = $c; + $c = safe_rol($b, 30); + $b = $a; + $a = $t; + } + $a = safe_add($t, $olda); + $b = safe_add($b, $oldb); + $c = safe_add($c, $oldc); + $d = safe_add($d, $oldd); + $e = safe_add($e, $olde); + } + return sprintf("%08x%08x%08x%08x%08x",$a,$b,$c,$d,$e); +} + ?> \ No newline at end of file diff --git a/pvpgn/scripts/pvpgn_wol_hash.inc.php b/scripts/pvpgn_wol_hash.inc.php similarity index 95% rename from pvpgn/scripts/pvpgn_wol_hash.inc.php rename to scripts/pvpgn_wol_hash.inc.php index 838b578..5cd0445 100644 --- a/pvpgn/scripts/pvpgn_wol_hash.inc.php +++ b/scripts/pvpgn_wol_hash.inc.php @@ -1,58 +1,58 @@ -8) - { - return false; - } - $pwd1=$pass; - $esi=8; - $pwd2=array(null,null,null,null,null,null,null,null); - $p1=0; - $p2=0; - $edx=""; - for($i=0;$i<8;$i++) - { - if(ord($pwd1[$p1]) & 1) - { - $edx = ord($pwd1[$p1]) << 1; - $edx &= ord($pwd1[$esi]); - } - else - { - $edx = ord($pwd1[$p1]) ^ ord($pwd1[$esi]); - } - $pwd2[$p2] = $edx; - $p2++; - $esi--; - $p1++; - } - - - $WOL_HASH_CHAR = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./"; - $p1 = 0; - $p2 = 0; - for($i=0;$i<8;$i++) - { - $edx = $pwd2[$p2] & 0x3f; - $p2++; - $pwd1[$p1] = $WOL_HASH_CHAR[$edx]; - $p1++; - } - return $pwd1; -} - +8) + { + return false; + } + $pwd1=$pass; + $esi=8; + $pwd2=array(null,null,null,null,null,null,null,null); + $p1=0; + $p2=0; + $edx=""; + for($i=0;$i<8;$i++) + { + if(ord($pwd1[$p1]) & 1) + { + $edx = ord($pwd1[$p1]) << 1; + $edx &= ord($pwd1[$esi]); + } + else + { + $edx = ord($pwd1[$p1]) ^ ord($pwd1[$esi]); + } + $pwd2[$p2] = $edx; + $p2++; + $esi--; + $p1++; + } + + + $WOL_HASH_CHAR = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./"; + $p1 = 0; + $p2 = 0; + for($i=0;$i<8;$i++) + { + $edx = $pwd2[$p2] & 0x3f; + $p2++; + $pwd1[$p1] = $WOL_HASH_CHAR[$edx]; + $p1++; + } + return $pwd1; +} + ?> \ No newline at end of file diff --git a/pvpgn/scripts/rc.bnetd b/scripts/rc.bnetd similarity index 100% rename from pvpgn/scripts/rc.bnetd rename to scripts/rc.bnetd diff --git a/pvpgn/scripts/reform.awk b/scripts/reform.awk similarity index 100% rename from pvpgn/scripts/reform.awk rename to scripts/reform.awk diff --git a/pvpgn/scripts/sql/repairlevels.pl b/scripts/sql/repairlevels.pl similarity index 100% rename from pvpgn/scripts/sql/repairlevels.pl rename to scripts/sql/repairlevels.pl diff --git a/pvpgn/scripts/storage/cdb2sql.pl b/scripts/storage/cdb2sql.pl similarity index 100% rename from pvpgn/scripts/storage/cdb2sql.pl rename to scripts/storage/cdb2sql.pl diff --git a/pvpgn/scripts/storage/plain2sql.pl b/scripts/storage/plain2sql.pl similarity index 100% rename from pvpgn/scripts/storage/plain2sql.pl rename to scripts/storage/plain2sql.pl diff --git a/pvpgn/scripts/tos.bat b/scripts/tos.bat similarity index 96% rename from pvpgn/scripts/tos.bat rename to scripts/tos.bat index 8a26ef0..0a1824e 100644 --- a/pvpgn/scripts/tos.bat +++ b/scripts/tos.bat @@ -1,36 +1,36 @@ -@echo off -cd ../files - -copy tos.txt tos_RUS.txt -copy tos.txt tos_POL.txt -copy tos.txt tos_CHI.txt -copy tos.txt tos_SIN.txt -copy tos.txt tos_HAN.txt -copy tos.txt tos_KOR.txt -copy tos.txt tos_JPN.txt -copy tos.txt tos_ITA.txt -copy tos.txt tos_BRA.txt -copy tos.txt tos_POR.txt -copy tos.txt tos_FRA.txt -copy tos.txt tos_DEU.txt -copy tos.txt tos_ESP.txt -copy tos.txt tos_USA.txt -copy tos.txt tos_ENU.txt - -copy tos.txt tos-unicode_RUS.txt -copy tos.txt tos-unicode_POL.txt -copy tos.txt tos-unicode_CHI.txt -copy tos.txt tos-unicode_SIN.txt -copy tos.txt tos-unicode_HAN.txt -copy tos.txt tos-unicode_KOR.txt -copy tos.txt tos-unicode_JPN.txt -copy tos.txt tos-unicode_ITA.txt -copy tos.txt tos-unicode_BRA.txt -copy tos.txt tos-unicode_POR.txt -copy tos.txt tos-unicode_FRA.txt -copy tos.txt tos-unicode_DEU.txt -copy tos.txt tos-unicode_ESP.txt -copy tos.txt tos-unicode_USA.txt -copy tos.txt tos-unicode_ENU.txt - +@echo off +cd ../files + +copy tos.txt tos_RUS.txt +copy tos.txt tos_POL.txt +copy tos.txt tos_CHI.txt +copy tos.txt tos_SIN.txt +copy tos.txt tos_HAN.txt +copy tos.txt tos_KOR.txt +copy tos.txt tos_JPN.txt +copy tos.txt tos_ITA.txt +copy tos.txt tos_BRA.txt +copy tos.txt tos_POR.txt +copy tos.txt tos_FRA.txt +copy tos.txt tos_DEU.txt +copy tos.txt tos_ESP.txt +copy tos.txt tos_USA.txt +copy tos.txt tos_ENU.txt + +copy tos.txt tos-unicode_RUS.txt +copy tos.txt tos-unicode_POL.txt +copy tos.txt tos-unicode_CHI.txt +copy tos.txt tos-unicode_SIN.txt +copy tos.txt tos-unicode_HAN.txt +copy tos.txt tos-unicode_KOR.txt +copy tos.txt tos-unicode_JPN.txt +copy tos.txt tos-unicode_ITA.txt +copy tos.txt tos-unicode_BRA.txt +copy tos.txt tos-unicode_POR.txt +copy tos.txt tos-unicode_FRA.txt +copy tos.txt tos-unicode_DEU.txt +copy tos.txt tos-unicode_ESP.txt +copy tos.txt tos-unicode_USA.txt +copy tos.txt tos-unicode_ENU.txt + cd ../scripts \ No newline at end of file diff --git a/pvpgn/scripts/tos.sh b/scripts/tos.sh similarity index 100% rename from pvpgn/scripts/tos.sh rename to scripts/tos.sh diff --git a/pvpgn/src/CMakeLists.txt b/src/CMakeLists.txt similarity index 100% rename from pvpgn/src/CMakeLists.txt rename to src/CMakeLists.txt diff --git a/pvpgn/src/Makefile.am b/src/Makefile.am similarity index 100% rename from pvpgn/src/Makefile.am rename to src/Makefile.am diff --git a/pvpgn/src/autoconf/Makefile.am b/src/autoconf/Makefile.am similarity index 100% rename from pvpgn/src/autoconf/Makefile.am rename to src/autoconf/Makefile.am diff --git a/pvpgn/src/autoconf/ansi2knr.c b/src/autoconf/ansi2knr.c similarity index 100% rename from pvpgn/src/autoconf/ansi2knr.c rename to src/autoconf/ansi2knr.c diff --git a/pvpgn/src/autoconf/ccstdc.m4 b/src/autoconf/ccstdc.m4 similarity index 100% rename from pvpgn/src/autoconf/ccstdc.m4 rename to src/autoconf/ccstdc.m4 diff --git a/pvpgn/src/autoconf/config.guess b/src/autoconf/config.guess similarity index 100% rename from pvpgn/src/autoconf/config.guess rename to src/autoconf/config.guess diff --git a/pvpgn/src/autoconf/config.sub b/src/autoconf/config.sub similarity index 100% rename from pvpgn/src/autoconf/config.sub rename to src/autoconf/config.sub diff --git a/d2pack109/src/autoconf/install-sh b/src/autoconf/install-sh similarity index 100% rename from d2pack109/src/autoconf/install-sh rename to src/autoconf/install-sh diff --git a/d2pack109/src/autoconf/mkdir-p b/src/autoconf/mkdir-p similarity index 100% rename from d2pack109/src/autoconf/mkdir-p rename to src/autoconf/mkdir-p diff --git a/d2pack109/src/autoconf/mkdir.m4 b/src/autoconf/mkdir.m4 similarity index 100% rename from d2pack109/src/autoconf/mkdir.m4 rename to src/autoconf/mkdir.m4 diff --git a/pvpgn/src/autoconf/termios.m4 b/src/autoconf/termios.m4 similarity index 100% rename from pvpgn/src/autoconf/termios.m4 rename to src/autoconf/termios.m4 diff --git a/pvpgn/src/autoconf/winsz.m4 b/src/autoconf/winsz.m4 similarity index 100% rename from pvpgn/src/autoconf/winsz.m4 rename to src/autoconf/winsz.m4 diff --git a/pvpgn/src/bnetd/CMakeLists.txt b/src/bnetd/CMakeLists.txt similarity index 100% rename from pvpgn/src/bnetd/CMakeLists.txt rename to src/bnetd/CMakeLists.txt diff --git a/pvpgn/src/bnetd/Makefile.am b/src/bnetd/Makefile.am similarity index 100% rename from pvpgn/src/bnetd/Makefile.am rename to src/bnetd/Makefile.am diff --git a/pvpgn/src/bnetd/account.cpp b/src/bnetd/account.cpp similarity index 100% rename from pvpgn/src/bnetd/account.cpp rename to src/bnetd/account.cpp diff --git a/pvpgn/src/bnetd/account.h b/src/bnetd/account.h similarity index 100% rename from pvpgn/src/bnetd/account.h rename to src/bnetd/account.h diff --git a/pvpgn/src/bnetd/account_wrap.cpp b/src/bnetd/account_wrap.cpp similarity index 100% rename from pvpgn/src/bnetd/account_wrap.cpp rename to src/bnetd/account_wrap.cpp diff --git a/pvpgn/src/bnetd/account_wrap.h b/src/bnetd/account_wrap.h similarity index 100% rename from pvpgn/src/bnetd/account_wrap.h rename to src/bnetd/account_wrap.h diff --git a/pvpgn/src/bnetd/adbanner.cpp b/src/bnetd/adbanner.cpp similarity index 100% rename from pvpgn/src/bnetd/adbanner.cpp rename to src/bnetd/adbanner.cpp diff --git a/pvpgn/src/bnetd/adbanner.h b/src/bnetd/adbanner.h similarity index 100% rename from pvpgn/src/bnetd/adbanner.h rename to src/bnetd/adbanner.h diff --git a/pvpgn/src/bnetd/alias_command.cpp b/src/bnetd/alias_command.cpp similarity index 100% rename from pvpgn/src/bnetd/alias_command.cpp rename to src/bnetd/alias_command.cpp diff --git a/pvpgn/src/bnetd/alias_command.h b/src/bnetd/alias_command.h similarity index 100% rename from pvpgn/src/bnetd/alias_command.h rename to src/bnetd/alias_command.h diff --git a/pvpgn/src/bnetd/anongame.cpp b/src/bnetd/anongame.cpp similarity index 100% rename from pvpgn/src/bnetd/anongame.cpp rename to src/bnetd/anongame.cpp diff --git a/pvpgn/src/bnetd/anongame.h b/src/bnetd/anongame.h similarity index 100% rename from pvpgn/src/bnetd/anongame.h rename to src/bnetd/anongame.h diff --git a/pvpgn/src/bnetd/anongame_gameresult.cpp b/src/bnetd/anongame_gameresult.cpp similarity index 100% rename from pvpgn/src/bnetd/anongame_gameresult.cpp rename to src/bnetd/anongame_gameresult.cpp diff --git a/pvpgn/src/bnetd/anongame_gameresult.h b/src/bnetd/anongame_gameresult.h similarity index 100% rename from pvpgn/src/bnetd/anongame_gameresult.h rename to src/bnetd/anongame_gameresult.h diff --git a/pvpgn/src/bnetd/anongame_infos.cpp b/src/bnetd/anongame_infos.cpp similarity index 100% rename from pvpgn/src/bnetd/anongame_infos.cpp rename to src/bnetd/anongame_infos.cpp diff --git a/pvpgn/src/bnetd/anongame_infos.h b/src/bnetd/anongame_infos.h similarity index 100% rename from pvpgn/src/bnetd/anongame_infos.h rename to src/bnetd/anongame_infos.h diff --git a/pvpgn/src/bnetd/anongame_maplists.cpp b/src/bnetd/anongame_maplists.cpp similarity index 100% rename from pvpgn/src/bnetd/anongame_maplists.cpp rename to src/bnetd/anongame_maplists.cpp diff --git a/pvpgn/src/bnetd/anongame_maplists.h b/src/bnetd/anongame_maplists.h similarity index 100% rename from pvpgn/src/bnetd/anongame_maplists.h rename to src/bnetd/anongame_maplists.h diff --git a/pvpgn/src/bnetd/anongame_wol.cpp b/src/bnetd/anongame_wol.cpp similarity index 96% rename from pvpgn/src/bnetd/anongame_wol.cpp rename to src/bnetd/anongame_wol.cpp index 5d3fd1e..bb3351a 100644 --- a/pvpgn/src/bnetd/anongame_wol.cpp +++ b/src/bnetd/anongame_wol.cpp @@ -1,624 +1,624 @@ -/* - * Copyright (C) 2008 Pelish (pelish@gmail.com) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#define ANONGAME_WOL_INTERNAL_ACCESS -#include "common/setup_before.h" -#include "anongame_wol.h" - -#include -#include -#include - -#include "compat/snprintf.h" -#include "compat/strcasecmp.h" - -#include "common/irc_protocol.h" -#include "common/packet.h" -#include "common/eventlog.h" -#include "common/tag.h" -#include "common/list.h" -#include "common/anongame_protocol.h" - -#include "irc.h" -#include "handle_wol.h" -#include "connection.h" -#include "channel.h" -#include "anongame.h" -#include "common/setup_after.h" - -namespace pvpgn -{ - - namespace bnetd - { - - typedef int(*t_anong_tag)(t_anongame_wol_player * player, char * param); - - typedef struct { - const char * wol_anong_tag_string; - t_anong_tag wol_anong_tag_handler; - } t_wol_anongame_tag_table_row; - - static t_list * anongame_wol_matchlist_head = NULL; - - static int _handle_address_tag(t_anongame_wol_player * player, char * param); - static int _handle_port_tag(t_anongame_wol_player * player, char * param); - static int _handle_country_tag(t_anongame_wol_player * player, char * param); - static int _handle_colour_tag(t_anongame_wol_player * player, char * param); - - static const t_wol_anongame_tag_table_row t_wol_anongame_tag_table[] = - { - { MATCHTAG_ADDRESS, _handle_address_tag }, - { MATCHTAG_PORT, _handle_port_tag }, - { MATCHTAG_COUNTRY, _handle_country_tag }, - { MATCHTAG_COLOUR, _handle_colour_tag }, - - { NULL, NULL } - }; - - static int anongame_wol_set_playersetting(t_anongame_wol_player * player, char const * tag, char * param) - { - t_wol_anongame_tag_table_row const *p; - - for (p = t_wol_anongame_tag_table; p->wol_anong_tag_string != NULL; p++) { - if (strcasecmp(tag, p->wol_anong_tag_string) == 0) { - if (p->wol_anong_tag_handler != NULL) - return ((p->wol_anong_tag_handler)(player, param)); - } - } - return -1; - } - - /* anongame_wol player functions: */ - - static t_anongame_wol_player * anongame_wol_player_create(t_connection * conn) - { - t_anongame_wol_player * player; - - player = (t_anongame_wol_player*)xmalloc(sizeof(t_anongame_wol_player)); - - player->conn = conn; - - /* Used only in Red Alert 2 and Yuri's Revenge */ - player->address = 0; - player->port = 0; - player->country = -2; /* Default values are form packet dumps - not prefered country */ - player->colour = -2; /* Default values are form packet dumps - not prefered colour */ - - conn_wol_set_anongame_player(conn, player); - - list_append_data(anongame_wol_matchlist_head, player); - - DEBUG1("[** WOL **] annongame player created: %s", conn_get_chatname(conn)); - - return player; - } - - static int anongame_wol_player_destroy(t_anongame_wol_player * player, t_elem ** curr) - { - if (list_remove_data(anongame_wol_matchlist_head, player, curr) < 0){ - ERROR0("could not remove item from list"); - return -1; - } - - DEBUG0("[** WOL **] destroying annongame player"); - - xfree(player); - - return 0; - } - - static t_connection * anongame_wol_player_get_conn(t_anongame_wol_player const * player) - { - if (!player) { - ERROR0("got NULL player"); - return NULL; - } - - return player->conn; - } - - - static int anongame_wol_player_get_address(t_anongame_wol_player const * player) - { - if (!player) { - ERROR0("got NULL player"); - return -1; - } - - return player->address; - } - - static int _handle_address_tag(t_anongame_wol_player * player, char * param) - { - if (!player) { - ERROR0("got NULL player"); - return -1; - } - - if (param) - player->address = std::atoi(param); - - return 0; - } - - static int anongame_wol_player_get_port(t_anongame_wol_player const * player) - { - if (!player) { - ERROR0("got NULL player"); - return -1; - } - - return player->port; - } - - static int _handle_port_tag(t_anongame_wol_player * player, char * param) - { - if (!player) { - ERROR0("got NULL player"); - return -1; - } - - if (param) - player->port = std::atoi(param); - - return 0; - } - - static int anongame_wol_player_get_country(t_anongame_wol_player const * player) - { - if (!player) { - ERROR0("got NULL player"); - return -1; - } - - return player->country; - } - - static int _handle_country_tag(t_anongame_wol_player * player, char * param) - { - if (!player) { - ERROR0("got NULL player"); - return -1; - } - - if (param) - player->country = std::atoi(param); - - return 0; - } - - static int anongame_wol_player_get_colour(t_anongame_wol_player const * player) - { - if (!player) { - ERROR0("got NULL player"); - return -1; - } - - return player->colour; - } - - static int _handle_colour_tag(t_anongame_wol_player * player, char * param) - { - if (!player) { - ERROR0("got NULL player"); - return -1; - } - - if (param) - player->colour = std::atoi(param); - - return 0; - } - - /* Matchlist functions:*/ - - extern int anongame_wol_matchlist_create(void) - { - anongame_wol_matchlist_head = list_create(); - - return 0; - } - - extern int anongame_wol_matchlist_destroy(void) - { - t_anongame_wol_player * player; - t_elem * curr; - - if (anongame_wol_matchlist_head) { - LIST_TRAVERSE(anongame_wol_matchlist_head, curr) { - if (!(player = (t_anongame_wol_player*)elem_get_data(curr))) { /* should not happen */ - ERROR0("wol_matchlist contains NULL item"); - continue; - } - anongame_wol_player_destroy(player, &curr); - } - - if (list_destroy(anongame_wol_matchlist_head) < 0) - return -1; - anongame_wol_matchlist_head = NULL; - } - - return 0; - } - - extern t_list * anongame_wol_matchlist(void) - { - return anongame_wol_matchlist_head; - } - - static t_anongame_wol_player * anongame_wol_matchlist_find_player_by_conn(t_connection * conn) - { - t_anongame_wol_player * player; - t_elem * curr; - - if (!conn) { - ERROR0("got NULL conn"); - return NULL; - } - - LIST_TRAVERSE(anongame_wol_matchlist(), curr) { - t_anongame_wol_player * player = (t_anongame_wol_player *)elem_get_data(curr); - if (conn == anongame_wol_player_get_conn(player)) { - return player; - } - } - - return NULL; - } - - static int anongame_wol_matchlist_get_length(void) - { - return list_get_length(anongame_wol_matchlist_head); - } - - /* support functions */ - - static int _send_msg(t_connection * conn, char const * command, char const * text) - { - t_packet * p; - char data[MAX_IRC_MESSAGE_LEN + 1]; - unsigned len; - char const * nick; - - if (!conn) { - eventlog(eventlog_level_error, __FUNCTION__, "got NULL connection"); - return -1; - } - if (!command) { - eventlog(eventlog_level_error, __FUNCTION__, "got NULL command"); - return -1; - } - if (!text) { - eventlog(eventlog_level_error, __FUNCTION__, "got NULL text"); - return -1; - } - if (!(p = packet_create(packet_class_raw))) { - eventlog(eventlog_level_error, __FUNCTION__, "could not create packet"); - return -1; - } - - nick = conn_get_loggeduser(conn); - if (!nick) - nick = "UserName"; - - /* snprintf isn't portable -> check message length first */ - len = 1 + 12 + 1 + std::strlen(command) + 1 + std::strlen(nick) + 1 + std::strlen(text) + 2; - if (len > MAX_IRC_MESSAGE_LEN) { - eventlog(eventlog_level_error, __FUNCTION__, "message to send is too large (%u bytes)", len); - return -1; - } - else - std::sprintf(data, ":matchbot!u@h %s %s %s", command, nick, text); - - DEBUG2("[%d] sent \"%s\"", conn_get_socket(conn), data); - std::strcat(data, "\r\n"); - packet_set_size(p, 0); - packet_append_data(p, data, len); - conn_push_outqueue(conn, p); - packet_del_ref(p); - return 0; - } - - static int _get_pair(int * i, int * j, int max, bool different) - { - max++; /* We want to use just real maximum number - no metter what function do */ - - if (*i == -2) - *i = (max * rand() / (RAND_MAX + 1)); - - if (*j == -2) - *j = (max * rand() / (RAND_MAX + 1)); - - if ((different) && (*i == *j)) { - do { - *j = (max * rand() / (RAND_MAX + 1)); - } while (*i == *j); - } - return 0; - } - - - static int anongame_wol_trystart(t_anongame_wol_player const * player1) - { - t_elem * curr; - char temp[MAX_IRC_MESSAGE_LEN]; - char _temp[MAX_IRC_MESSAGE_LEN]; - int random; - - t_anongame_wol_player * player2; - t_connection * conn_pl1; - t_connection * conn_pl2; - char const * channelname; - const char * mapname; - t_clienttag ctag; - - std::memset(temp, 0, sizeof(temp)); - std::memset(_temp, 0, sizeof(_temp)); - - /** - * Expected start message is - * - * Red Alert 2: - * :Start [rand_num],0,0,[credits],0,1,[super_weapon],1,1,0,1,x,2,1,[mapsize_kilobytes],[mapname],1: - * [nick1_name],[nick1_country],[nick1_colour],[nick1_addr_hex],[nick1_nat],[nick1_prt_hex], - * [nick2_name],[nick2_country],[nick2_colour],[nick2_addr_hex],[nick2_nat],[nick2_prt_hex] - * - * Yuris Revenge Quick game: - * - * Yuris Revenge Quick Coop: - * - */ - - if (!player1) { - ERROR0("got NULL player"); - return -1; - } - - conn_pl1 = anongame_wol_player_get_conn(player1); - ctag = conn_get_clienttag(conn_pl1); - channelname = channel_get_name(conn_get_channel(conn_pl1)); - - LIST_TRAVERSE(anongame_wol_matchlist(), curr) { - player2 = (t_anongame_wol_player *)elem_get_data(curr); - conn_pl2 = anongame_wol_player_get_conn(player2); - - if ((player1 != player2) && ((conn_get_channel(conn_pl1)) == (conn_get_channel(conn_pl2)))) { - switch (ctag) { - case CLIENTTAG_REDALERT2_UINT: { - random = rand(); - - if (std::strcmp(channelname, RAL2_CHANNEL_FFA) == 0) { - int pl1_colour = anongame_wol_player_get_colour(player1); - int pl1_country = anongame_wol_player_get_country(player1); - int pl2_colour = anongame_wol_player_get_colour(player2); - int pl2_country = anongame_wol_player_get_country(player2); - - DEBUG0("Generating SOLO game for Red Alert 2"); - - _get_pair(&pl1_colour, &pl2_colour, 7, true); - _get_pair(&pl1_country, &pl2_country, 8, false); - mapname = anongame_get_map_from_prefs(ANONGAME_TYPE_1V1, ctag); - - /* We have madatory of game */ - snprintf(_temp, sizeof(_temp), ":Start %u,0,0,10000,0,1,0,1,1,0,1,x,2,1,165368,%s,1:", random, mapname); - std::strcat(temp, _temp); - - /* GameHost informations */ - snprintf(_temp, sizeof(_temp), "%s,%d,%d,%x,1,%x,", conn_get_chatname(conn_pl1), pl1_country, pl1_colour, anongame_wol_player_get_address(player1), anongame_wol_player_get_port(player1)); - std::strcat(temp, _temp); - - /* GameJoinie informations */ - snprintf(_temp, sizeof(_temp), "%s,%d,%d,%x,1,%x", conn_get_chatname(conn_pl2), pl2_country, pl2_colour, anongame_wol_player_get_address(player2), anongame_wol_player_get_port(player2)); - std::strcat(temp, _temp); - - _send_msg(conn_pl1, "PRIVMSG", temp); - _send_msg(conn_pl2, "PRIVMSG", temp); - } - else - ERROR1("undefined channel type for %s channel", channelname); - } - return 0; - case CLIENTTAG_YURISREV_UINT: { - random = rand(); - - if (std::strcmp(channelname, YURI_CHANNEL_FFA) == 0) { - int pl1_colour = anongame_wol_player_get_colour(player1); - int pl1_country = anongame_wol_player_get_country(player1); - int pl2_colour = anongame_wol_player_get_colour(player2); - int pl2_country = anongame_wol_player_get_country(player2); - - DEBUG0("Generating SOLO game for Yuri's Revenge"); - - _get_pair(&pl1_colour, &pl2_colour, 7, true); - _get_pair(&pl1_country, &pl2_country, 9, false); - mapname = anongame_get_map_from_prefs(ANONGAME_TYPE_1V1, ctag); - - /* We have madatory of game */ - snprintf(_temp, sizeof(_temp), ":Start %u,0,0,10000,0,0,1,1,1,0,3,0,x,2,1,163770,%s,1:", random, mapname); - std::strcat(temp, _temp); - - /* GameHost informations */ - snprintf(_temp, sizeof(_temp), "%s,%d,%d,-2,-2,", conn_get_chatname(conn_pl1), pl1_country, pl1_colour); - std::strcat(temp, _temp); - snprintf(_temp, sizeof(_temp), "%x,1,%x,", anongame_wol_player_get_address(player1), anongame_wol_player_get_port(player1)); - std::strcat(temp, _temp); - - /* GameJoinie informations */ - snprintf(_temp, sizeof(_temp), "%s,%d,%d,-2,-2,", conn_get_chatname(conn_pl2), pl2_country, pl2_colour); - std::strcat(temp, _temp); - snprintf(_temp, sizeof(_temp), "%x,1,%x", anongame_wol_player_get_address(player2), anongame_wol_player_get_port(player2)); - std::strcat(temp, _temp); - - _send_msg(conn_pl1, "PRIVMSG", temp); - _send_msg(conn_pl2, "PRIVMSG", temp); - } - else if (std::strcmp(channelname, YURI_CHANNEL_COOP) == 0) { - DEBUG0("Generating COOP game for Yuri's Revenge"); - - /* We have madatory of game */ - snprintf(_temp, sizeof(_temp), ":Start %u,0,0,10000,10,0,1,1,0,1,3,0,x,2,1,163770,C1A01MD.MAP,1:", random); - std::strcat(temp, _temp); - - /* GameHost informations */ - snprintf(_temp, sizeof(_temp), "%s,0,4,0,-2,", conn_get_chatname(conn_pl1)); - std::strcat(temp, _temp); - snprintf(_temp, sizeof(_temp), "%x,1,%x,", anongame_wol_player_get_address(player1), anongame_wol_player_get_port(player1)); - std::strcat(temp, _temp); - - /* GameJoinie informations */ - snprintf(_temp, sizeof(_temp), "%s,0,5,1,-2,", conn_get_chatname(anongame_wol_player_get_conn(player2))); - std::strcat(temp, _temp); - snprintf(_temp, sizeof(_temp), "%x,1,%x", anongame_wol_player_get_address(player2), anongame_wol_player_get_port(player2)); - std::strcat(temp, _temp); - - /* Some computers for coop games */ - snprintf(_temp, sizeof(_temp), ":@:0,-1,-1,-2,-2,0,-1,-1,-2,-2,1,8,1,-2,-2,1,8,2,-2,-2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,"); - std::strcat(temp, _temp); - - _send_msg(conn_pl1, "PRIVMSG", temp); - _send_msg(conn_pl2, "PRIVMSG", temp); - } - else - ERROR1("undefined channel type for %s channel", channelname); - } - return 0; - default: - DEBUG0("unsupported client for WOL Matchgame"); - return 0; - } - } - } - - return 0; - } - - static int anongame_wol_tokenize_line(t_connection * conn, char const * text) - { - t_anongame_wol_player * player; - t_tag ctag; - char const * channelname; - char * command; /* Match, CINFO, SINFO, Pings */ - char * tag; /* ADR, COL, COU... */ - char * param; /* value of paramtag */ - char * line; /* Copy of text */ - char * temp; - char * p; - - if (!conn) { - ERROR0("got NULL conn"); - return -1; - } - - if (!text) { - ERROR0("got NULL text"); - return -1; - } - - if (!(player = anongame_wol_player_create(conn))) { - ERROR0("player was not created"); - return -1; - } - - /** - * Here are expected privmsgs: - * :user!EMPR@host PRIVMSG matchbot :Match COU=-1,COL=-1,SHA=-1,SHB=-1,LOC=2,RAT=0 - * :user!RAL2@host PRIVMSG matchbot :Match COU=-2, COL=-2, LOC=1, RAT=3, RES=640, ADR=202680512, NAT=1, PRT=1295 - * :user!RAL2@host PRIVMSG matchbot :Match COU=-2, COL=-2, LOC=1, RAT=3, RES=640, ADR=202680512, NAT=1, PRT=1340 - * :user!RAL2@host PRIVMSG matchbot :Match COU=-2, COL=-2, LOC=25, RAT=1, RES=640, ADR=-501962560, NAT=1, PRT=1320 - * :user!YURI@host PRIVMSG matchbot :Match COU=-2, COL=-2, MBR=1, LOC=5, RAT=2, RES=800, ADR=202680512, NAT=1, PRT=1390 - * :user!RNGD@host PRIVMSG matchbot :CINFO VER=1329937315 CPU=2981 MEM=1023 TPOINTS=0 PLAYED=0 PINGS=00FFFFFFFFFFFFFF - * :user!RNGD@host PRIVMSG matchbot :SINFO 4F453BA3DBAE41CB00000000000000002d# 9Dedicated Renegade Server-C&C_Field.mix07FF0656FFFF1C2D|090000000000 - * :user!YURI@host PRIVMSG matchbot :Pings nickname,2; - */ - - line = (char *)xmalloc(std::strlen(text) + 2); - strcpy(line, text); - - command = line; - if (!(temp = strchr(command, ' '))) { - WARN0("got malformed line (missing command)"); - xfree(line); - return -1; - } - *temp++ = '\0'; - - if ((std::strcmp(command, "Match") == 0)) { - strcat(temp, ","); /* FIXME: This is DUMB - without that we lost the last tag/param */ - - for (p = temp; *p && (*p != '\0'); p++) { - if ((*p == ',') || (*p == ' ')) { - *p++ = '\0'; - if (temp[0] == ' ') /* Pelish: Emperor sends line without spaces but RA2/Yuri do */ - *temp++; - tag = temp; - param = strchr(tag, '='); - if (param) - *param++ = '\0'; - if (anongame_wol_set_playersetting(player, tag, param) == -1) - WARN2("[** WOL **] got unknown tag %s param %s", tag, param); - temp = p; - } - } - _send_msg(conn, "PRIVMSG", ":Working"); - anongame_wol_trystart(player); - } - else { - DEBUG1("[** WOL **] got line /%s/", text); - } - - if (line) - xfree(line); - - return 0; - } - - /* Functions for getting/sending player informations */ - - extern int anongame_wol_destroy(t_connection * conn) - { - t_elem *curr; - - /* Player destroying */ - - LIST_TRAVERSE(anongame_wol_matchlist_head, curr) { - t_anongame_wol_player * player = (t_anongame_wol_player*)elem_get_data(curr); - - if (conn == anongame_wol_player_get_conn(player)) - anongame_wol_player_destroy(player, &curr); - } - - return 0; - } - - extern int anongame_wol_privmsg(t_connection * conn, int numparams, char ** params, char * text) - { - - if (!conn) { - ERROR0("got NULL conn"); - return -1; - } - - anongame_wol_tokenize_line(conn, text); - - return 0; - } - - } - -} +/* + * Copyright (C) 2008 Pelish (pelish@gmail.com) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#define ANONGAME_WOL_INTERNAL_ACCESS +#include "common/setup_before.h" +#include "anongame_wol.h" + +#include +#include +#include + +#include "compat/snprintf.h" +#include "compat/strcasecmp.h" + +#include "common/irc_protocol.h" +#include "common/packet.h" +#include "common/eventlog.h" +#include "common/tag.h" +#include "common/list.h" +#include "common/anongame_protocol.h" + +#include "irc.h" +#include "handle_wol.h" +#include "connection.h" +#include "channel.h" +#include "anongame.h" +#include "common/setup_after.h" + +namespace pvpgn +{ + + namespace bnetd + { + + typedef int(*t_anong_tag)(t_anongame_wol_player * player, char * param); + + typedef struct { + const char * wol_anong_tag_string; + t_anong_tag wol_anong_tag_handler; + } t_wol_anongame_tag_table_row; + + static t_list * anongame_wol_matchlist_head = NULL; + + static int _handle_address_tag(t_anongame_wol_player * player, char * param); + static int _handle_port_tag(t_anongame_wol_player * player, char * param); + static int _handle_country_tag(t_anongame_wol_player * player, char * param); + static int _handle_colour_tag(t_anongame_wol_player * player, char * param); + + static const t_wol_anongame_tag_table_row t_wol_anongame_tag_table[] = + { + { MATCHTAG_ADDRESS, _handle_address_tag }, + { MATCHTAG_PORT, _handle_port_tag }, + { MATCHTAG_COUNTRY, _handle_country_tag }, + { MATCHTAG_COLOUR, _handle_colour_tag }, + + { NULL, NULL } + }; + + static int anongame_wol_set_playersetting(t_anongame_wol_player * player, char const * tag, char * param) + { + t_wol_anongame_tag_table_row const *p; + + for (p = t_wol_anongame_tag_table; p->wol_anong_tag_string != NULL; p++) { + if (strcasecmp(tag, p->wol_anong_tag_string) == 0) { + if (p->wol_anong_tag_handler != NULL) + return ((p->wol_anong_tag_handler)(player, param)); + } + } + return -1; + } + + /* anongame_wol player functions: */ + + static t_anongame_wol_player * anongame_wol_player_create(t_connection * conn) + { + t_anongame_wol_player * player; + + player = (t_anongame_wol_player*)xmalloc(sizeof(t_anongame_wol_player)); + + player->conn = conn; + + /* Used only in Red Alert 2 and Yuri's Revenge */ + player->address = 0; + player->port = 0; + player->country = -2; /* Default values are form packet dumps - not prefered country */ + player->colour = -2; /* Default values are form packet dumps - not prefered colour */ + + conn_wol_set_anongame_player(conn, player); + + list_append_data(anongame_wol_matchlist_head, player); + + DEBUG1("[** WOL **] annongame player created: %s", conn_get_chatname(conn)); + + return player; + } + + static int anongame_wol_player_destroy(t_anongame_wol_player * player, t_elem ** curr) + { + if (list_remove_data(anongame_wol_matchlist_head, player, curr) < 0){ + ERROR0("could not remove item from list"); + return -1; + } + + DEBUG0("[** WOL **] destroying annongame player"); + + xfree(player); + + return 0; + } + + static t_connection * anongame_wol_player_get_conn(t_anongame_wol_player const * player) + { + if (!player) { + ERROR0("got NULL player"); + return NULL; + } + + return player->conn; + } + + + static int anongame_wol_player_get_address(t_anongame_wol_player const * player) + { + if (!player) { + ERROR0("got NULL player"); + return -1; + } + + return player->address; + } + + static int _handle_address_tag(t_anongame_wol_player * player, char * param) + { + if (!player) { + ERROR0("got NULL player"); + return -1; + } + + if (param) + player->address = std::atoi(param); + + return 0; + } + + static int anongame_wol_player_get_port(t_anongame_wol_player const * player) + { + if (!player) { + ERROR0("got NULL player"); + return -1; + } + + return player->port; + } + + static int _handle_port_tag(t_anongame_wol_player * player, char * param) + { + if (!player) { + ERROR0("got NULL player"); + return -1; + } + + if (param) + player->port = std::atoi(param); + + return 0; + } + + static int anongame_wol_player_get_country(t_anongame_wol_player const * player) + { + if (!player) { + ERROR0("got NULL player"); + return -1; + } + + return player->country; + } + + static int _handle_country_tag(t_anongame_wol_player * player, char * param) + { + if (!player) { + ERROR0("got NULL player"); + return -1; + } + + if (param) + player->country = std::atoi(param); + + return 0; + } + + static int anongame_wol_player_get_colour(t_anongame_wol_player const * player) + { + if (!player) { + ERROR0("got NULL player"); + return -1; + } + + return player->colour; + } + + static int _handle_colour_tag(t_anongame_wol_player * player, char * param) + { + if (!player) { + ERROR0("got NULL player"); + return -1; + } + + if (param) + player->colour = std::atoi(param); + + return 0; + } + + /* Matchlist functions:*/ + + extern int anongame_wol_matchlist_create(void) + { + anongame_wol_matchlist_head = list_create(); + + return 0; + } + + extern int anongame_wol_matchlist_destroy(void) + { + t_anongame_wol_player * player; + t_elem * curr; + + if (anongame_wol_matchlist_head) { + LIST_TRAVERSE(anongame_wol_matchlist_head, curr) { + if (!(player = (t_anongame_wol_player*)elem_get_data(curr))) { /* should not happen */ + ERROR0("wol_matchlist contains NULL item"); + continue; + } + anongame_wol_player_destroy(player, &curr); + } + + if (list_destroy(anongame_wol_matchlist_head) < 0) + return -1; + anongame_wol_matchlist_head = NULL; + } + + return 0; + } + + extern t_list * anongame_wol_matchlist(void) + { + return anongame_wol_matchlist_head; + } + + static t_anongame_wol_player * anongame_wol_matchlist_find_player_by_conn(t_connection * conn) + { + t_anongame_wol_player * player; + t_elem * curr; + + if (!conn) { + ERROR0("got NULL conn"); + return NULL; + } + + LIST_TRAVERSE(anongame_wol_matchlist(), curr) { + t_anongame_wol_player * player = (t_anongame_wol_player *)elem_get_data(curr); + if (conn == anongame_wol_player_get_conn(player)) { + return player; + } + } + + return NULL; + } + + static int anongame_wol_matchlist_get_length(void) + { + return list_get_length(anongame_wol_matchlist_head); + } + + /* support functions */ + + static int _send_msg(t_connection * conn, char const * command, char const * text) + { + t_packet * p; + char data[MAX_IRC_MESSAGE_LEN + 1]; + unsigned len; + char const * nick; + + if (!conn) { + eventlog(eventlog_level_error, __FUNCTION__, "got NULL connection"); + return -1; + } + if (!command) { + eventlog(eventlog_level_error, __FUNCTION__, "got NULL command"); + return -1; + } + if (!text) { + eventlog(eventlog_level_error, __FUNCTION__, "got NULL text"); + return -1; + } + if (!(p = packet_create(packet_class_raw))) { + eventlog(eventlog_level_error, __FUNCTION__, "could not create packet"); + return -1; + } + + nick = conn_get_loggeduser(conn); + if (!nick) + nick = "UserName"; + + /* snprintf isn't portable -> check message length first */ + len = 1 + 12 + 1 + std::strlen(command) + 1 + std::strlen(nick) + 1 + std::strlen(text) + 2; + if (len > MAX_IRC_MESSAGE_LEN) { + eventlog(eventlog_level_error, __FUNCTION__, "message to send is too large (%u bytes)", len); + return -1; + } + else + std::sprintf(data, ":matchbot!u@h %s %s %s", command, nick, text); + + DEBUG2("[%d] sent \"%s\"", conn_get_socket(conn), data); + std::strcat(data, "\r\n"); + packet_set_size(p, 0); + packet_append_data(p, data, len); + conn_push_outqueue(conn, p); + packet_del_ref(p); + return 0; + } + + static int _get_pair(int * i, int * j, int max, bool different) + { + max++; /* We want to use just real maximum number - no metter what function do */ + + if (*i == -2) + *i = (max * rand() / (RAND_MAX + 1)); + + if (*j == -2) + *j = (max * rand() / (RAND_MAX + 1)); + + if ((different) && (*i == *j)) { + do { + *j = (max * rand() / (RAND_MAX + 1)); + } while (*i == *j); + } + return 0; + } + + + static int anongame_wol_trystart(t_anongame_wol_player const * player1) + { + t_elem * curr; + char temp[MAX_IRC_MESSAGE_LEN]; + char _temp[MAX_IRC_MESSAGE_LEN]; + int random; + + t_anongame_wol_player * player2; + t_connection * conn_pl1; + t_connection * conn_pl2; + char const * channelname; + const char * mapname; + t_clienttag ctag; + + std::memset(temp, 0, sizeof(temp)); + std::memset(_temp, 0, sizeof(_temp)); + + /** + * Expected start message is + * + * Red Alert 2: + * :Start [rand_num],0,0,[credits],0,1,[super_weapon],1,1,0,1,x,2,1,[mapsize_kilobytes],[mapname],1: + * [nick1_name],[nick1_country],[nick1_colour],[nick1_addr_hex],[nick1_nat],[nick1_prt_hex], + * [nick2_name],[nick2_country],[nick2_colour],[nick2_addr_hex],[nick2_nat],[nick2_prt_hex] + * + * Yuris Revenge Quick game: + * + * Yuris Revenge Quick Coop: + * + */ + + if (!player1) { + ERROR0("got NULL player"); + return -1; + } + + conn_pl1 = anongame_wol_player_get_conn(player1); + ctag = conn_get_clienttag(conn_pl1); + channelname = channel_get_name(conn_get_channel(conn_pl1)); + + LIST_TRAVERSE(anongame_wol_matchlist(), curr) { + player2 = (t_anongame_wol_player *)elem_get_data(curr); + conn_pl2 = anongame_wol_player_get_conn(player2); + + if ((player1 != player2) && ((conn_get_channel(conn_pl1)) == (conn_get_channel(conn_pl2)))) { + switch (ctag) { + case CLIENTTAG_REDALERT2_UINT: { + random = rand(); + + if (std::strcmp(channelname, RAL2_CHANNEL_FFA) == 0) { + int pl1_colour = anongame_wol_player_get_colour(player1); + int pl1_country = anongame_wol_player_get_country(player1); + int pl2_colour = anongame_wol_player_get_colour(player2); + int pl2_country = anongame_wol_player_get_country(player2); + + DEBUG0("Generating SOLO game for Red Alert 2"); + + _get_pair(&pl1_colour, &pl2_colour, 7, true); + _get_pair(&pl1_country, &pl2_country, 8, false); + mapname = anongame_get_map_from_prefs(ANONGAME_TYPE_1V1, ctag); + + /* We have madatory of game */ + snprintf(_temp, sizeof(_temp), ":Start %u,0,0,10000,0,1,0,1,1,0,1,x,2,1,165368,%s,1:", random, mapname); + std::strcat(temp, _temp); + + /* GameHost informations */ + snprintf(_temp, sizeof(_temp), "%s,%d,%d,%x,1,%x,", conn_get_chatname(conn_pl1), pl1_country, pl1_colour, anongame_wol_player_get_address(player1), anongame_wol_player_get_port(player1)); + std::strcat(temp, _temp); + + /* GameJoinie informations */ + snprintf(_temp, sizeof(_temp), "%s,%d,%d,%x,1,%x", conn_get_chatname(conn_pl2), pl2_country, pl2_colour, anongame_wol_player_get_address(player2), anongame_wol_player_get_port(player2)); + std::strcat(temp, _temp); + + _send_msg(conn_pl1, "PRIVMSG", temp); + _send_msg(conn_pl2, "PRIVMSG", temp); + } + else + ERROR1("undefined channel type for %s channel", channelname); + } + return 0; + case CLIENTTAG_YURISREV_UINT: { + random = rand(); + + if (std::strcmp(channelname, YURI_CHANNEL_FFA) == 0) { + int pl1_colour = anongame_wol_player_get_colour(player1); + int pl1_country = anongame_wol_player_get_country(player1); + int pl2_colour = anongame_wol_player_get_colour(player2); + int pl2_country = anongame_wol_player_get_country(player2); + + DEBUG0("Generating SOLO game for Yuri's Revenge"); + + _get_pair(&pl1_colour, &pl2_colour, 7, true); + _get_pair(&pl1_country, &pl2_country, 9, false); + mapname = anongame_get_map_from_prefs(ANONGAME_TYPE_1V1, ctag); + + /* We have madatory of game */ + snprintf(_temp, sizeof(_temp), ":Start %u,0,0,10000,0,0,1,1,1,0,3,0,x,2,1,163770,%s,1:", random, mapname); + std::strcat(temp, _temp); + + /* GameHost informations */ + snprintf(_temp, sizeof(_temp), "%s,%d,%d,-2,-2,", conn_get_chatname(conn_pl1), pl1_country, pl1_colour); + std::strcat(temp, _temp); + snprintf(_temp, sizeof(_temp), "%x,1,%x,", anongame_wol_player_get_address(player1), anongame_wol_player_get_port(player1)); + std::strcat(temp, _temp); + + /* GameJoinie informations */ + snprintf(_temp, sizeof(_temp), "%s,%d,%d,-2,-2,", conn_get_chatname(conn_pl2), pl2_country, pl2_colour); + std::strcat(temp, _temp); + snprintf(_temp, sizeof(_temp), "%x,1,%x", anongame_wol_player_get_address(player2), anongame_wol_player_get_port(player2)); + std::strcat(temp, _temp); + + _send_msg(conn_pl1, "PRIVMSG", temp); + _send_msg(conn_pl2, "PRIVMSG", temp); + } + else if (std::strcmp(channelname, YURI_CHANNEL_COOP) == 0) { + DEBUG0("Generating COOP game for Yuri's Revenge"); + + /* We have madatory of game */ + snprintf(_temp, sizeof(_temp), ":Start %u,0,0,10000,10,0,1,1,0,1,3,0,x,2,1,163770,C1A01MD.MAP,1:", random); + std::strcat(temp, _temp); + + /* GameHost informations */ + snprintf(_temp, sizeof(_temp), "%s,0,4,0,-2,", conn_get_chatname(conn_pl1)); + std::strcat(temp, _temp); + snprintf(_temp, sizeof(_temp), "%x,1,%x,", anongame_wol_player_get_address(player1), anongame_wol_player_get_port(player1)); + std::strcat(temp, _temp); + + /* GameJoinie informations */ + snprintf(_temp, sizeof(_temp), "%s,0,5,1,-2,", conn_get_chatname(anongame_wol_player_get_conn(player2))); + std::strcat(temp, _temp); + snprintf(_temp, sizeof(_temp), "%x,1,%x", anongame_wol_player_get_address(player2), anongame_wol_player_get_port(player2)); + std::strcat(temp, _temp); + + /* Some computers for coop games */ + snprintf(_temp, sizeof(_temp), ":@:0,-1,-1,-2,-2,0,-1,-1,-2,-2,1,8,1,-2,-2,1,8,2,-2,-2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,"); + std::strcat(temp, _temp); + + _send_msg(conn_pl1, "PRIVMSG", temp); + _send_msg(conn_pl2, "PRIVMSG", temp); + } + else + ERROR1("undefined channel type for %s channel", channelname); + } + return 0; + default: + DEBUG0("unsupported client for WOL Matchgame"); + return 0; + } + } + } + + return 0; + } + + static int anongame_wol_tokenize_line(t_connection * conn, char const * text) + { + t_anongame_wol_player * player; + t_tag ctag; + char const * channelname; + char * command; /* Match, CINFO, SINFO, Pings */ + char * tag; /* ADR, COL, COU... */ + char * param; /* value of paramtag */ + char * line; /* Copy of text */ + char * temp; + char * p; + + if (!conn) { + ERROR0("got NULL conn"); + return -1; + } + + if (!text) { + ERROR0("got NULL text"); + return -1; + } + + if (!(player = anongame_wol_player_create(conn))) { + ERROR0("player was not created"); + return -1; + } + + /** + * Here are expected privmsgs: + * :user!EMPR@host PRIVMSG matchbot :Match COU=-1,COL=-1,SHA=-1,SHB=-1,LOC=2,RAT=0 + * :user!RAL2@host PRIVMSG matchbot :Match COU=-2, COL=-2, LOC=1, RAT=3, RES=640, ADR=202680512, NAT=1, PRT=1295 + * :user!RAL2@host PRIVMSG matchbot :Match COU=-2, COL=-2, LOC=1, RAT=3, RES=640, ADR=202680512, NAT=1, PRT=1340 + * :user!RAL2@host PRIVMSG matchbot :Match COU=-2, COL=-2, LOC=25, RAT=1, RES=640, ADR=-501962560, NAT=1, PRT=1320 + * :user!YURI@host PRIVMSG matchbot :Match COU=-2, COL=-2, MBR=1, LOC=5, RAT=2, RES=800, ADR=202680512, NAT=1, PRT=1390 + * :user!RNGD@host PRIVMSG matchbot :CINFO VER=1329937315 CPU=2981 MEM=1023 TPOINTS=0 PLAYED=0 PINGS=00FFFFFFFFFFFFFF + * :user!RNGD@host PRIVMSG matchbot :SINFO 4F453BA3DBAE41CB00000000000000002d# 9Dedicated Renegade Server-C&C_Field.mix07FF0656FFFF1C2D|090000000000 + * :user!YURI@host PRIVMSG matchbot :Pings nickname,2; + */ + + line = (char *)xmalloc(std::strlen(text) + 2); + strcpy(line, text); + + command = line; + if (!(temp = strchr(command, ' '))) { + WARN0("got malformed line (missing command)"); + xfree(line); + return -1; + } + *temp++ = '\0'; + + if ((std::strcmp(command, "Match") == 0)) { + strcat(temp, ","); /* FIXME: This is DUMB - without that we lost the last tag/param */ + + for (p = temp; *p && (*p != '\0'); p++) { + if ((*p == ',') || (*p == ' ')) { + *p++ = '\0'; + if (temp[0] == ' ') /* Pelish: Emperor sends line without spaces but RA2/Yuri do */ + *temp++; + tag = temp; + param = strchr(tag, '='); + if (param) + *param++ = '\0'; + if (anongame_wol_set_playersetting(player, tag, param) == -1) + WARN2("[** WOL **] got unknown tag %s param %s", tag, param); + temp = p; + } + } + _send_msg(conn, "PRIVMSG", ":Working"); + anongame_wol_trystart(player); + } + else { + DEBUG1("[** WOL **] got line /%s/", text); + } + + if (line) + xfree(line); + + return 0; + } + + /* Functions for getting/sending player informations */ + + extern int anongame_wol_destroy(t_connection * conn) + { + t_elem *curr; + + /* Player destroying */ + + LIST_TRAVERSE(anongame_wol_matchlist_head, curr) { + t_anongame_wol_player * player = (t_anongame_wol_player*)elem_get_data(curr); + + if (conn == anongame_wol_player_get_conn(player)) + anongame_wol_player_destroy(player, &curr); + } + + return 0; + } + + extern int anongame_wol_privmsg(t_connection * conn, int numparams, char ** params, char * text) + { + + if (!conn) { + ERROR0("got NULL conn"); + return -1; + } + + anongame_wol_tokenize_line(conn, text); + + return 0; + } + + } + +} diff --git a/pvpgn/src/bnetd/anongame_wol.h b/src/bnetd/anongame_wol.h similarity index 95% rename from pvpgn/src/bnetd/anongame_wol.h rename to src/bnetd/anongame_wol.h index ee4c210..3c01a53 100644 --- a/pvpgn/src/bnetd/anongame_wol.h +++ b/src/bnetd/anongame_wol.h @@ -1,97 +1,97 @@ -/* - * Copyright (C) 2008 Pelish (pelish@gmail.com) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef INCLUDED_ANONGAME_WOL_TYPES -#define INCLUDED_ANONGAME_WOL_TYPES - -#ifdef ANONGAME_WOL_INTERNAL_ACCESS - -#ifndef JUST_NEED_TYPES -# define JUST_NEED_TYPES -# include "connection.h" -# undef JUST_NEED_TYPES -#endif - -#define MATCHTAG_ADDRESS "ADR" -#define MATCHTAG_PORT "PRT" -#define MATCHTAG_COUNTRY "COU" -#define MATCHTAG_COLOUR "COL" -#define MATCHTAG_MATCHRESOLUTION "MBR" -#define MATCHTAG_LOCATION "LOC" -#define MATCHTAG_SCREENRESOLUTION "RES" - -#define RAL2_CHANNEL_FFA "Lob 38 0" -#define YURI_CHANNEL_FFA "Lob 40 0" -#define YURI_CHANNEL_COOP "Lob 39 0" - -#endif - -namespace pvpgn -{ - - namespace bnetd - { - - typedef struct anongame_wol_player -#ifdef ANONGAME_WOL_INTERNAL_ACCESS - { - t_connection * conn; - - /* Red Alert 2 and Yuri's Revnenge */ - int address; - int port; - int country; - int colour; - } -#endif - t_anongame_wol_player; - - } - -} - -#endif - -/*******/ -#ifndef JUST_NEED_TYPES -#ifndef INCLUDED_ANONGAME_WOL_PROTOS -#define INCLUDED_ANONGAME_WOL_PROTOS - -#define JUST_NEED_TYPES -# include "connection.h" -#undef JUST_NEED_TYPES - -namespace pvpgn -{ - - namespace bnetd - { - - extern int anongame_wol_matchlist_create(void); - extern int anongame_wol_matchlist_destroy(void); - - extern int anongame_wol_destroy(t_connection * conn); - extern int anongame_wol_privmsg(t_connection * conn, int numparams, char ** params, char * text); - - } - -} - -#endif -#endif - +/* + * Copyright (C) 2008 Pelish (pelish@gmail.com) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef INCLUDED_ANONGAME_WOL_TYPES +#define INCLUDED_ANONGAME_WOL_TYPES + +#ifdef ANONGAME_WOL_INTERNAL_ACCESS + +#ifndef JUST_NEED_TYPES +# define JUST_NEED_TYPES +# include "connection.h" +# undef JUST_NEED_TYPES +#endif + +#define MATCHTAG_ADDRESS "ADR" +#define MATCHTAG_PORT "PRT" +#define MATCHTAG_COUNTRY "COU" +#define MATCHTAG_COLOUR "COL" +#define MATCHTAG_MATCHRESOLUTION "MBR" +#define MATCHTAG_LOCATION "LOC" +#define MATCHTAG_SCREENRESOLUTION "RES" + +#define RAL2_CHANNEL_FFA "Lob 38 0" +#define YURI_CHANNEL_FFA "Lob 40 0" +#define YURI_CHANNEL_COOP "Lob 39 0" + +#endif + +namespace pvpgn +{ + + namespace bnetd + { + + typedef struct anongame_wol_player +#ifdef ANONGAME_WOL_INTERNAL_ACCESS + { + t_connection * conn; + + /* Red Alert 2 and Yuri's Revnenge */ + int address; + int port; + int country; + int colour; + } +#endif + t_anongame_wol_player; + + } + +} + +#endif + +/*******/ +#ifndef JUST_NEED_TYPES +#ifndef INCLUDED_ANONGAME_WOL_PROTOS +#define INCLUDED_ANONGAME_WOL_PROTOS + +#define JUST_NEED_TYPES +# include "connection.h" +#undef JUST_NEED_TYPES + +namespace pvpgn +{ + + namespace bnetd + { + + extern int anongame_wol_matchlist_create(void); + extern int anongame_wol_matchlist_destroy(void); + + extern int anongame_wol_destroy(t_connection * conn); + extern int anongame_wol_privmsg(t_connection * conn, int numparams, char ** params, char * text); + + } + +} + +#endif +#endif + diff --git a/pvpgn/src/bnetd/attr.h b/src/bnetd/attr.h similarity index 100% rename from pvpgn/src/bnetd/attr.h rename to src/bnetd/attr.h diff --git a/pvpgn/src/bnetd/attrgroup.cpp b/src/bnetd/attrgroup.cpp similarity index 100% rename from pvpgn/src/bnetd/attrgroup.cpp rename to src/bnetd/attrgroup.cpp diff --git a/pvpgn/src/bnetd/attrgroup.h b/src/bnetd/attrgroup.h similarity index 100% rename from pvpgn/src/bnetd/attrgroup.h rename to src/bnetd/attrgroup.h diff --git a/pvpgn/src/bnetd/attrlayer.cpp b/src/bnetd/attrlayer.cpp similarity index 100% rename from pvpgn/src/bnetd/attrlayer.cpp rename to src/bnetd/attrlayer.cpp diff --git a/pvpgn/src/bnetd/attrlayer.h b/src/bnetd/attrlayer.h similarity index 100% rename from pvpgn/src/bnetd/attrlayer.h rename to src/bnetd/attrlayer.h diff --git a/pvpgn/src/bnetd/autoupdate.cpp b/src/bnetd/autoupdate.cpp similarity index 100% rename from pvpgn/src/bnetd/autoupdate.cpp rename to src/bnetd/autoupdate.cpp diff --git a/pvpgn/src/bnetd/autoupdate.h b/src/bnetd/autoupdate.h similarity index 100% rename from pvpgn/src/bnetd/autoupdate.h rename to src/bnetd/autoupdate.h diff --git a/pvpgn/src/bnetd/channel.cpp b/src/bnetd/channel.cpp similarity index 100% rename from pvpgn/src/bnetd/channel.cpp rename to src/bnetd/channel.cpp diff --git a/pvpgn/src/bnetd/channel.h b/src/bnetd/channel.h similarity index 100% rename from pvpgn/src/bnetd/channel.h rename to src/bnetd/channel.h diff --git a/pvpgn/src/bnetd/channel_conv.cpp b/src/bnetd/channel_conv.cpp similarity index 100% rename from pvpgn/src/bnetd/channel_conv.cpp rename to src/bnetd/channel_conv.cpp diff --git a/pvpgn/src/bnetd/channel_conv.h b/src/bnetd/channel_conv.h similarity index 100% rename from pvpgn/src/bnetd/channel_conv.h rename to src/bnetd/channel_conv.h diff --git a/pvpgn/src/bnetd/character.cpp b/src/bnetd/character.cpp similarity index 100% rename from pvpgn/src/bnetd/character.cpp rename to src/bnetd/character.cpp diff --git a/pvpgn/src/bnetd/character.h b/src/bnetd/character.h similarity index 100% rename from pvpgn/src/bnetd/character.h rename to src/bnetd/character.h diff --git a/pvpgn/src/bnetd/clan.cpp b/src/bnetd/clan.cpp similarity index 100% rename from pvpgn/src/bnetd/clan.cpp rename to src/bnetd/clan.cpp diff --git a/pvpgn/src/bnetd/clan.h b/src/bnetd/clan.h similarity index 100% rename from pvpgn/src/bnetd/clan.h rename to src/bnetd/clan.h diff --git a/pvpgn/src/bnetd/cmdline.cpp b/src/bnetd/cmdline.cpp similarity index 100% rename from pvpgn/src/bnetd/cmdline.cpp rename to src/bnetd/cmdline.cpp diff --git a/pvpgn/src/bnetd/cmdline.h b/src/bnetd/cmdline.h similarity index 100% rename from pvpgn/src/bnetd/cmdline.h rename to src/bnetd/cmdline.h diff --git a/pvpgn/src/bnetd/command.cpp b/src/bnetd/command.cpp similarity index 100% rename from pvpgn/src/bnetd/command.cpp rename to src/bnetd/command.cpp diff --git a/pvpgn/src/bnetd/command.h b/src/bnetd/command.h similarity index 100% rename from pvpgn/src/bnetd/command.h rename to src/bnetd/command.h diff --git a/pvpgn/src/bnetd/command_groups.cpp b/src/bnetd/command_groups.cpp similarity index 100% rename from pvpgn/src/bnetd/command_groups.cpp rename to src/bnetd/command_groups.cpp diff --git a/pvpgn/src/bnetd/command_groups.h b/src/bnetd/command_groups.h similarity index 100% rename from pvpgn/src/bnetd/command_groups.h rename to src/bnetd/command_groups.h diff --git a/pvpgn/src/bnetd/connection.cpp b/src/bnetd/connection.cpp similarity index 100% rename from pvpgn/src/bnetd/connection.cpp rename to src/bnetd/connection.cpp diff --git a/pvpgn/src/bnetd/connection.h b/src/bnetd/connection.h similarity index 100% rename from pvpgn/src/bnetd/connection.h rename to src/bnetd/connection.h diff --git a/pvpgn/src/bnetd/file.cpp b/src/bnetd/file.cpp similarity index 100% rename from pvpgn/src/bnetd/file.cpp rename to src/bnetd/file.cpp diff --git a/pvpgn/src/bnetd/file.h b/src/bnetd/file.h similarity index 100% rename from pvpgn/src/bnetd/file.h rename to src/bnetd/file.h diff --git a/pvpgn/src/bnetd/file_cdb.cpp b/src/bnetd/file_cdb.cpp similarity index 100% rename from pvpgn/src/bnetd/file_cdb.cpp rename to src/bnetd/file_cdb.cpp diff --git a/pvpgn/src/bnetd/file_cdb.h b/src/bnetd/file_cdb.h similarity index 100% rename from pvpgn/src/bnetd/file_cdb.h rename to src/bnetd/file_cdb.h diff --git a/pvpgn/src/bnetd/file_plain.cpp b/src/bnetd/file_plain.cpp similarity index 100% rename from pvpgn/src/bnetd/file_plain.cpp rename to src/bnetd/file_plain.cpp diff --git a/pvpgn/src/bnetd/file_plain.h b/src/bnetd/file_plain.h similarity index 100% rename from pvpgn/src/bnetd/file_plain.h rename to src/bnetd/file_plain.h diff --git a/pvpgn/src/bnetd/friends.cpp b/src/bnetd/friends.cpp similarity index 100% rename from pvpgn/src/bnetd/friends.cpp rename to src/bnetd/friends.cpp diff --git a/pvpgn/src/bnetd/friends.h b/src/bnetd/friends.h similarity index 100% rename from pvpgn/src/bnetd/friends.h rename to src/bnetd/friends.h diff --git a/pvpgn/src/bnetd/game.cpp b/src/bnetd/game.cpp similarity index 100% rename from pvpgn/src/bnetd/game.cpp rename to src/bnetd/game.cpp diff --git a/pvpgn/src/bnetd/game.h b/src/bnetd/game.h similarity index 100% rename from pvpgn/src/bnetd/game.h rename to src/bnetd/game.h diff --git a/pvpgn/src/bnetd/game_conv.cpp b/src/bnetd/game_conv.cpp similarity index 100% rename from pvpgn/src/bnetd/game_conv.cpp rename to src/bnetd/game_conv.cpp diff --git a/pvpgn/src/bnetd/game_conv.h b/src/bnetd/game_conv.h similarity index 100% rename from pvpgn/src/bnetd/game_conv.h rename to src/bnetd/game_conv.h diff --git a/pvpgn/src/bnetd/handle_anongame.cpp b/src/bnetd/handle_anongame.cpp similarity index 100% rename from pvpgn/src/bnetd/handle_anongame.cpp rename to src/bnetd/handle_anongame.cpp diff --git a/pvpgn/src/bnetd/handle_anongame.h b/src/bnetd/handle_anongame.h similarity index 100% rename from pvpgn/src/bnetd/handle_anongame.h rename to src/bnetd/handle_anongame.h diff --git a/pvpgn/src/bnetd/handle_apireg.cpp b/src/bnetd/handle_apireg.cpp similarity index 100% rename from pvpgn/src/bnetd/handle_apireg.cpp rename to src/bnetd/handle_apireg.cpp diff --git a/pvpgn/src/bnetd/handle_apireg.h b/src/bnetd/handle_apireg.h similarity index 100% rename from pvpgn/src/bnetd/handle_apireg.h rename to src/bnetd/handle_apireg.h diff --git a/pvpgn/src/bnetd/handle_bnet.cpp b/src/bnetd/handle_bnet.cpp similarity index 100% rename from pvpgn/src/bnetd/handle_bnet.cpp rename to src/bnetd/handle_bnet.cpp diff --git a/pvpgn/src/bnetd/handle_bnet.h b/src/bnetd/handle_bnet.h similarity index 100% rename from pvpgn/src/bnetd/handle_bnet.h rename to src/bnetd/handle_bnet.h diff --git a/pvpgn/src/bnetd/handle_bot.cpp b/src/bnetd/handle_bot.cpp similarity index 100% rename from pvpgn/src/bnetd/handle_bot.cpp rename to src/bnetd/handle_bot.cpp diff --git a/pvpgn/src/bnetd/handle_bot.h b/src/bnetd/handle_bot.h similarity index 100% rename from pvpgn/src/bnetd/handle_bot.h rename to src/bnetd/handle_bot.h diff --git a/pvpgn/src/bnetd/handle_d2cs.cpp b/src/bnetd/handle_d2cs.cpp similarity index 100% rename from pvpgn/src/bnetd/handle_d2cs.cpp rename to src/bnetd/handle_d2cs.cpp diff --git a/pvpgn/src/bnetd/handle_d2cs.h b/src/bnetd/handle_d2cs.h similarity index 100% rename from pvpgn/src/bnetd/handle_d2cs.h rename to src/bnetd/handle_d2cs.h diff --git a/pvpgn/src/bnetd/handle_file.cpp b/src/bnetd/handle_file.cpp similarity index 100% rename from pvpgn/src/bnetd/handle_file.cpp rename to src/bnetd/handle_file.cpp diff --git a/pvpgn/src/bnetd/handle_file.h b/src/bnetd/handle_file.h similarity index 100% rename from pvpgn/src/bnetd/handle_file.h rename to src/bnetd/handle_file.h diff --git a/pvpgn/src/bnetd/handle_init.cpp b/src/bnetd/handle_init.cpp similarity index 100% rename from pvpgn/src/bnetd/handle_init.cpp rename to src/bnetd/handle_init.cpp diff --git a/pvpgn/src/bnetd/handle_init.h b/src/bnetd/handle_init.h similarity index 100% rename from pvpgn/src/bnetd/handle_init.h rename to src/bnetd/handle_init.h diff --git a/pvpgn/src/bnetd/handle_irc.cpp b/src/bnetd/handle_irc.cpp similarity index 100% rename from pvpgn/src/bnetd/handle_irc.cpp rename to src/bnetd/handle_irc.cpp diff --git a/pvpgn/src/bnetd/handle_irc.h b/src/bnetd/handle_irc.h similarity index 100% rename from pvpgn/src/bnetd/handle_irc.h rename to src/bnetd/handle_irc.h diff --git a/pvpgn/src/bnetd/handle_irc_common.cpp b/src/bnetd/handle_irc_common.cpp similarity index 100% rename from pvpgn/src/bnetd/handle_irc_common.cpp rename to src/bnetd/handle_irc_common.cpp diff --git a/pvpgn/src/bnetd/handle_irc_common.h b/src/bnetd/handle_irc_common.h similarity index 100% rename from pvpgn/src/bnetd/handle_irc_common.h rename to src/bnetd/handle_irc_common.h diff --git a/pvpgn/src/bnetd/handle_telnet.cpp b/src/bnetd/handle_telnet.cpp similarity index 100% rename from pvpgn/src/bnetd/handle_telnet.cpp rename to src/bnetd/handle_telnet.cpp diff --git a/pvpgn/src/bnetd/handle_telnet.h b/src/bnetd/handle_telnet.h similarity index 100% rename from pvpgn/src/bnetd/handle_telnet.h rename to src/bnetd/handle_telnet.h diff --git a/pvpgn/src/bnetd/handle_udp.cpp b/src/bnetd/handle_udp.cpp similarity index 100% rename from pvpgn/src/bnetd/handle_udp.cpp rename to src/bnetd/handle_udp.cpp diff --git a/pvpgn/src/bnetd/handle_udp.h b/src/bnetd/handle_udp.h similarity index 100% rename from pvpgn/src/bnetd/handle_udp.h rename to src/bnetd/handle_udp.h diff --git a/pvpgn/src/bnetd/handle_wol.cpp b/src/bnetd/handle_wol.cpp similarity index 100% rename from pvpgn/src/bnetd/handle_wol.cpp rename to src/bnetd/handle_wol.cpp diff --git a/pvpgn/src/bnetd/handle_wol.h b/src/bnetd/handle_wol.h similarity index 100% rename from pvpgn/src/bnetd/handle_wol.h rename to src/bnetd/handle_wol.h diff --git a/pvpgn/src/bnetd/handle_wol_gameres.cpp b/src/bnetd/handle_wol_gameres.cpp similarity index 100% rename from pvpgn/src/bnetd/handle_wol_gameres.cpp rename to src/bnetd/handle_wol_gameres.cpp diff --git a/pvpgn/src/bnetd/handle_wol_gameres.h b/src/bnetd/handle_wol_gameres.h similarity index 100% rename from pvpgn/src/bnetd/handle_wol_gameres.h rename to src/bnetd/handle_wol_gameres.h diff --git a/pvpgn/src/bnetd/handle_wserv.cpp b/src/bnetd/handle_wserv.cpp similarity index 100% rename from pvpgn/src/bnetd/handle_wserv.cpp rename to src/bnetd/handle_wserv.cpp diff --git a/pvpgn/src/bnetd/handle_wserv.h b/src/bnetd/handle_wserv.h similarity index 100% rename from pvpgn/src/bnetd/handle_wserv.h rename to src/bnetd/handle_wserv.h diff --git a/pvpgn/src/bnetd/handlers.h b/src/bnetd/handlers.h similarity index 100% rename from pvpgn/src/bnetd/handlers.h rename to src/bnetd/handlers.h diff --git a/pvpgn/src/bnetd/helpfile.cpp b/src/bnetd/helpfile.cpp similarity index 100% rename from pvpgn/src/bnetd/helpfile.cpp rename to src/bnetd/helpfile.cpp diff --git a/pvpgn/src/bnetd/helpfile.h b/src/bnetd/helpfile.h similarity index 100% rename from pvpgn/src/bnetd/helpfile.h rename to src/bnetd/helpfile.h diff --git a/pvpgn/src/bnetd/ipban.cpp b/src/bnetd/ipban.cpp similarity index 100% rename from pvpgn/src/bnetd/ipban.cpp rename to src/bnetd/ipban.cpp diff --git a/pvpgn/src/bnetd/ipban.h b/src/bnetd/ipban.h similarity index 100% rename from pvpgn/src/bnetd/ipban.h rename to src/bnetd/ipban.h diff --git a/pvpgn/src/bnetd/irc.cpp b/src/bnetd/irc.cpp similarity index 100% rename from pvpgn/src/bnetd/irc.cpp rename to src/bnetd/irc.cpp diff --git a/pvpgn/src/bnetd/irc.h b/src/bnetd/irc.h similarity index 100% rename from pvpgn/src/bnetd/irc.h rename to src/bnetd/irc.h diff --git a/pvpgn/src/bnetd/ladder.cpp b/src/bnetd/ladder.cpp similarity index 100% rename from pvpgn/src/bnetd/ladder.cpp rename to src/bnetd/ladder.cpp diff --git a/pvpgn/src/bnetd/ladder.h b/src/bnetd/ladder.h similarity index 100% rename from pvpgn/src/bnetd/ladder.h rename to src/bnetd/ladder.h diff --git a/pvpgn/src/bnetd/ladder_calc.cpp b/src/bnetd/ladder_calc.cpp similarity index 100% rename from pvpgn/src/bnetd/ladder_calc.cpp rename to src/bnetd/ladder_calc.cpp diff --git a/pvpgn/src/bnetd/ladder_calc.h b/src/bnetd/ladder_calc.h similarity index 100% rename from pvpgn/src/bnetd/ladder_calc.h rename to src/bnetd/ladder_calc.h diff --git a/pvpgn/src/bnetd/mail.cpp b/src/bnetd/mail.cpp similarity index 100% rename from pvpgn/src/bnetd/mail.cpp rename to src/bnetd/mail.cpp diff --git a/pvpgn/src/bnetd/mail.h b/src/bnetd/mail.h similarity index 100% rename from pvpgn/src/bnetd/mail.h rename to src/bnetd/mail.h diff --git a/pvpgn/src/bnetd/main.cpp b/src/bnetd/main.cpp similarity index 100% rename from pvpgn/src/bnetd/main.cpp rename to src/bnetd/main.cpp diff --git a/pvpgn/src/bnetd/message.cpp b/src/bnetd/message.cpp similarity index 100% rename from pvpgn/src/bnetd/message.cpp rename to src/bnetd/message.cpp diff --git a/pvpgn/src/bnetd/message.h b/src/bnetd/message.h similarity index 100% rename from pvpgn/src/bnetd/message.h rename to src/bnetd/message.h diff --git a/pvpgn/src/bnetd/news.cpp b/src/bnetd/news.cpp similarity index 100% rename from pvpgn/src/bnetd/news.cpp rename to src/bnetd/news.cpp diff --git a/pvpgn/src/bnetd/news.h b/src/bnetd/news.h similarity index 100% rename from pvpgn/src/bnetd/news.h rename to src/bnetd/news.h diff --git a/pvpgn/src/bnetd/output.cpp b/src/bnetd/output.cpp similarity index 100% rename from pvpgn/src/bnetd/output.cpp rename to src/bnetd/output.cpp diff --git a/pvpgn/src/bnetd/output.h b/src/bnetd/output.h similarity index 100% rename from pvpgn/src/bnetd/output.h rename to src/bnetd/output.h diff --git a/pvpgn/src/bnetd/prefs.cpp b/src/bnetd/prefs.cpp similarity index 100% rename from pvpgn/src/bnetd/prefs.cpp rename to src/bnetd/prefs.cpp diff --git a/pvpgn/src/bnetd/prefs.h b/src/bnetd/prefs.h similarity index 100% rename from pvpgn/src/bnetd/prefs.h rename to src/bnetd/prefs.h diff --git a/pvpgn/src/bnetd/quota.h b/src/bnetd/quota.h similarity index 100% rename from pvpgn/src/bnetd/quota.h rename to src/bnetd/quota.h diff --git a/pvpgn/src/bnetd/realm.cpp b/src/bnetd/realm.cpp similarity index 100% rename from pvpgn/src/bnetd/realm.cpp rename to src/bnetd/realm.cpp diff --git a/pvpgn/src/bnetd/realm.h b/src/bnetd/realm.h similarity index 100% rename from pvpgn/src/bnetd/realm.h rename to src/bnetd/realm.h diff --git a/pvpgn/src/bnetd/runprog.cpp b/src/bnetd/runprog.cpp similarity index 100% rename from pvpgn/src/bnetd/runprog.cpp rename to src/bnetd/runprog.cpp diff --git a/pvpgn/src/bnetd/runprog.h b/src/bnetd/runprog.h similarity index 100% rename from pvpgn/src/bnetd/runprog.h rename to src/bnetd/runprog.h diff --git a/pvpgn/src/bnetd/server.cpp b/src/bnetd/server.cpp similarity index 100% rename from pvpgn/src/bnetd/server.cpp rename to src/bnetd/server.cpp diff --git a/pvpgn/src/bnetd/server.h b/src/bnetd/server.h similarity index 100% rename from pvpgn/src/bnetd/server.h rename to src/bnetd/server.h diff --git a/pvpgn/src/bnetd/sql_common.cpp b/src/bnetd/sql_common.cpp similarity index 100% rename from pvpgn/src/bnetd/sql_common.cpp rename to src/bnetd/sql_common.cpp diff --git a/pvpgn/src/bnetd/sql_common.h b/src/bnetd/sql_common.h similarity index 100% rename from pvpgn/src/bnetd/sql_common.h rename to src/bnetd/sql_common.h diff --git a/pvpgn/src/bnetd/sql_dbcreator.cpp b/src/bnetd/sql_dbcreator.cpp similarity index 100% rename from pvpgn/src/bnetd/sql_dbcreator.cpp rename to src/bnetd/sql_dbcreator.cpp diff --git a/pvpgn/src/bnetd/sql_dbcreator.h b/src/bnetd/sql_dbcreator.h similarity index 100% rename from pvpgn/src/bnetd/sql_dbcreator.h rename to src/bnetd/sql_dbcreator.h diff --git a/pvpgn/src/bnetd/sql_mysql.cpp b/src/bnetd/sql_mysql.cpp similarity index 99% rename from pvpgn/src/bnetd/sql_mysql.cpp rename to src/bnetd/sql_mysql.cpp index ab228d4..52ad282 100644 --- a/pvpgn/src/bnetd/sql_mysql.cpp +++ b/src/bnetd/sql_mysql.cpp @@ -190,7 +190,7 @@ namespace pvpgn #if MYSQL_VERSION_ID >= 50013 #if MYSQL_VERSION_ID < 50019 - my_bool my_true = true; + my_bool my_true = true; if (mysql_options(mysql, MYSQL_OPT_RECONNECT, &my_true)){ eventlog(eventlog_level_warn, __FUNCTION__, "Failed to turn on MYSQL_OPT_RECONNECT."); } diff --git a/pvpgn/src/bnetd/sql_mysql.h b/src/bnetd/sql_mysql.h similarity index 100% rename from pvpgn/src/bnetd/sql_mysql.h rename to src/bnetd/sql_mysql.h diff --git a/pvpgn/src/bnetd/sql_odbc.cpp b/src/bnetd/sql_odbc.cpp similarity index 100% rename from pvpgn/src/bnetd/sql_odbc.cpp rename to src/bnetd/sql_odbc.cpp diff --git a/pvpgn/src/bnetd/sql_odbc.h b/src/bnetd/sql_odbc.h similarity index 100% rename from pvpgn/src/bnetd/sql_odbc.h rename to src/bnetd/sql_odbc.h diff --git a/pvpgn/src/bnetd/sql_pgsql.cpp b/src/bnetd/sql_pgsql.cpp similarity index 100% rename from pvpgn/src/bnetd/sql_pgsql.cpp rename to src/bnetd/sql_pgsql.cpp diff --git a/pvpgn/src/bnetd/sql_pgsql.h b/src/bnetd/sql_pgsql.h similarity index 100% rename from pvpgn/src/bnetd/sql_pgsql.h rename to src/bnetd/sql_pgsql.h diff --git a/pvpgn/src/bnetd/sql_sqlite3.cpp b/src/bnetd/sql_sqlite3.cpp similarity index 100% rename from pvpgn/src/bnetd/sql_sqlite3.cpp rename to src/bnetd/sql_sqlite3.cpp diff --git a/pvpgn/src/bnetd/sql_sqlite3.h b/src/bnetd/sql_sqlite3.h similarity index 100% rename from pvpgn/src/bnetd/sql_sqlite3.h rename to src/bnetd/sql_sqlite3.h diff --git a/pvpgn/src/bnetd/storage.cpp b/src/bnetd/storage.cpp similarity index 100% rename from pvpgn/src/bnetd/storage.cpp rename to src/bnetd/storage.cpp diff --git a/pvpgn/src/bnetd/storage.h b/src/bnetd/storage.h similarity index 100% rename from pvpgn/src/bnetd/storage.h rename to src/bnetd/storage.h diff --git a/pvpgn/src/bnetd/storage_file.cpp b/src/bnetd/storage_file.cpp similarity index 100% rename from pvpgn/src/bnetd/storage_file.cpp rename to src/bnetd/storage_file.cpp diff --git a/pvpgn/src/bnetd/storage_file.h b/src/bnetd/storage_file.h similarity index 100% rename from pvpgn/src/bnetd/storage_file.h rename to src/bnetd/storage_file.h diff --git a/pvpgn/src/bnetd/storage_sql.cpp b/src/bnetd/storage_sql.cpp similarity index 100% rename from pvpgn/src/bnetd/storage_sql.cpp rename to src/bnetd/storage_sql.cpp diff --git a/pvpgn/src/bnetd/storage_sql.h b/src/bnetd/storage_sql.h similarity index 100% rename from pvpgn/src/bnetd/storage_sql.h rename to src/bnetd/storage_sql.h diff --git a/pvpgn/src/bnetd/storage_sql2.cpp b/src/bnetd/storage_sql2.cpp similarity index 100% rename from pvpgn/src/bnetd/storage_sql2.cpp rename to src/bnetd/storage_sql2.cpp diff --git a/pvpgn/src/bnetd/storage_sql2.h b/src/bnetd/storage_sql2.h similarity index 100% rename from pvpgn/src/bnetd/storage_sql2.h rename to src/bnetd/storage_sql2.h diff --git a/pvpgn/src/bnetd/support.cpp b/src/bnetd/support.cpp similarity index 100% rename from pvpgn/src/bnetd/support.cpp rename to src/bnetd/support.cpp diff --git a/pvpgn/src/bnetd/support.h b/src/bnetd/support.h similarity index 100% rename from pvpgn/src/bnetd/support.h rename to src/bnetd/support.h diff --git a/pvpgn/src/bnetd/team.cpp b/src/bnetd/team.cpp similarity index 100% rename from pvpgn/src/bnetd/team.cpp rename to src/bnetd/team.cpp diff --git a/pvpgn/src/bnetd/team.h b/src/bnetd/team.h similarity index 100% rename from pvpgn/src/bnetd/team.h rename to src/bnetd/team.h diff --git a/pvpgn/src/bnetd/tick.cpp b/src/bnetd/tick.cpp similarity index 100% rename from pvpgn/src/bnetd/tick.cpp rename to src/bnetd/tick.cpp diff --git a/pvpgn/src/bnetd/tick.h b/src/bnetd/tick.h similarity index 100% rename from pvpgn/src/bnetd/tick.h rename to src/bnetd/tick.h diff --git a/pvpgn/src/bnetd/timer.cpp b/src/bnetd/timer.cpp similarity index 100% rename from pvpgn/src/bnetd/timer.cpp rename to src/bnetd/timer.cpp diff --git a/pvpgn/src/bnetd/timer.h b/src/bnetd/timer.h similarity index 100% rename from pvpgn/src/bnetd/timer.h rename to src/bnetd/timer.h diff --git a/pvpgn/src/bnetd/topic.cpp b/src/bnetd/topic.cpp similarity index 100% rename from pvpgn/src/bnetd/topic.cpp rename to src/bnetd/topic.cpp diff --git a/pvpgn/src/bnetd/topic.h b/src/bnetd/topic.h similarity index 100% rename from pvpgn/src/bnetd/topic.h rename to src/bnetd/topic.h diff --git a/pvpgn/src/bnetd/tournament.cpp b/src/bnetd/tournament.cpp similarity index 100% rename from pvpgn/src/bnetd/tournament.cpp rename to src/bnetd/tournament.cpp diff --git a/pvpgn/src/bnetd/tournament.h b/src/bnetd/tournament.h similarity index 100% rename from pvpgn/src/bnetd/tournament.h rename to src/bnetd/tournament.h diff --git a/pvpgn/src/bnetd/tracker.cpp b/src/bnetd/tracker.cpp similarity index 100% rename from pvpgn/src/bnetd/tracker.cpp rename to src/bnetd/tracker.cpp diff --git a/pvpgn/src/bnetd/tracker.h b/src/bnetd/tracker.h similarity index 100% rename from pvpgn/src/bnetd/tracker.h rename to src/bnetd/tracker.h diff --git a/pvpgn/src/bnetd/udptest_send.cpp b/src/bnetd/udptest_send.cpp similarity index 100% rename from pvpgn/src/bnetd/udptest_send.cpp rename to src/bnetd/udptest_send.cpp diff --git a/pvpgn/src/bnetd/udptest_send.h b/src/bnetd/udptest_send.h similarity index 100% rename from pvpgn/src/bnetd/udptest_send.h rename to src/bnetd/udptest_send.h diff --git a/pvpgn/src/bnetd/versioncheck.cpp b/src/bnetd/versioncheck.cpp similarity index 100% rename from pvpgn/src/bnetd/versioncheck.cpp rename to src/bnetd/versioncheck.cpp diff --git a/pvpgn/src/bnetd/versioncheck.h b/src/bnetd/versioncheck.h similarity index 100% rename from pvpgn/src/bnetd/versioncheck.h rename to src/bnetd/versioncheck.h diff --git a/pvpgn/src/bnetd/watch.cpp b/src/bnetd/watch.cpp similarity index 100% rename from pvpgn/src/bnetd/watch.cpp rename to src/bnetd/watch.cpp diff --git a/pvpgn/src/bnetd/watch.h b/src/bnetd/watch.h similarity index 100% rename from pvpgn/src/bnetd/watch.h rename to src/bnetd/watch.h diff --git a/pvpgn/src/bniutils/CMakeLists.txt b/src/bniutils/CMakeLists.txt similarity index 100% rename from pvpgn/src/bniutils/CMakeLists.txt rename to src/bniutils/CMakeLists.txt diff --git a/pvpgn/src/bniutils/Makefile.am b/src/bniutils/Makefile.am similarity index 100% rename from pvpgn/src/bniutils/Makefile.am rename to src/bniutils/Makefile.am diff --git a/pvpgn/src/bniutils/bni.cpp b/src/bniutils/bni.cpp similarity index 100% rename from pvpgn/src/bniutils/bni.cpp rename to src/bniutils/bni.cpp diff --git a/pvpgn/src/bniutils/bni.h b/src/bniutils/bni.h similarity index 100% rename from pvpgn/src/bniutils/bni.h rename to src/bniutils/bni.h diff --git a/pvpgn/src/bniutils/bni2tga.cpp b/src/bniutils/bni2tga.cpp similarity index 100% rename from pvpgn/src/bniutils/bni2tga.cpp rename to src/bniutils/bni2tga.cpp diff --git a/pvpgn/src/bniutils/bnibuild.cpp b/src/bniutils/bnibuild.cpp similarity index 100% rename from pvpgn/src/bniutils/bnibuild.cpp rename to src/bniutils/bnibuild.cpp diff --git a/pvpgn/src/bniutils/bniextract.cpp b/src/bniutils/bniextract.cpp similarity index 100% rename from pvpgn/src/bniutils/bniextract.cpp rename to src/bniutils/bniextract.cpp diff --git a/pvpgn/src/bniutils/bnilist.cpp b/src/bniutils/bnilist.cpp similarity index 100% rename from pvpgn/src/bniutils/bnilist.cpp rename to src/bniutils/bnilist.cpp diff --git a/pvpgn/src/bniutils/fileio.cpp b/src/bniutils/fileio.cpp similarity index 100% rename from pvpgn/src/bniutils/fileio.cpp rename to src/bniutils/fileio.cpp diff --git a/pvpgn/src/bniutils/fileio.h b/src/bniutils/fileio.h similarity index 100% rename from pvpgn/src/bniutils/fileio.h rename to src/bniutils/fileio.h diff --git a/pvpgn/src/bniutils/tga.cpp b/src/bniutils/tga.cpp similarity index 100% rename from pvpgn/src/bniutils/tga.cpp rename to src/bniutils/tga.cpp diff --git a/pvpgn/src/bniutils/tga.h b/src/bniutils/tga.h similarity index 100% rename from pvpgn/src/bniutils/tga.h rename to src/bniutils/tga.h diff --git a/pvpgn/src/bniutils/tgainfo.cpp b/src/bniutils/tgainfo.cpp similarity index 100% rename from pvpgn/src/bniutils/tgainfo.cpp rename to src/bniutils/tgainfo.cpp diff --git a/pvpgn/src/bnpass/CMakeLists.txt b/src/bnpass/CMakeLists.txt similarity index 100% rename from pvpgn/src/bnpass/CMakeLists.txt rename to src/bnpass/CMakeLists.txt diff --git a/pvpgn/src/bnpass/Makefile.am b/src/bnpass/Makefile.am similarity index 100% rename from pvpgn/src/bnpass/Makefile.am rename to src/bnpass/Makefile.am diff --git a/pvpgn/src/bnpass/bnpass.cpp b/src/bnpass/bnpass.cpp similarity index 100% rename from pvpgn/src/bnpass/bnpass.cpp rename to src/bnpass/bnpass.cpp diff --git a/pvpgn/src/bnpass/sha1hash.cpp b/src/bnpass/sha1hash.cpp similarity index 100% rename from pvpgn/src/bnpass/sha1hash.cpp rename to src/bnpass/sha1hash.cpp diff --git a/pvpgn/src/bnpcap/CMakeLists.txt b/src/bnpcap/CMakeLists.txt similarity index 100% rename from pvpgn/src/bnpcap/CMakeLists.txt rename to src/bnpcap/CMakeLists.txt diff --git a/pvpgn/src/bnpcap/Makefile.am b/src/bnpcap/Makefile.am similarity index 100% rename from pvpgn/src/bnpcap/Makefile.am rename to src/bnpcap/Makefile.am diff --git a/pvpgn/src/bnpcap/bnpcap.cpp b/src/bnpcap/bnpcap.cpp similarity index 100% rename from pvpgn/src/bnpcap/bnpcap.cpp rename to src/bnpcap/bnpcap.cpp diff --git a/pvpgn/src/bnproxy/bnproxy.c b/src/bnproxy/bnproxy.c similarity index 100% rename from pvpgn/src/bnproxy/bnproxy.c rename to src/bnproxy/bnproxy.c diff --git a/pvpgn/src/bnproxy/virtconn.c b/src/bnproxy/virtconn.c similarity index 100% rename from pvpgn/src/bnproxy/virtconn.c rename to src/bnproxy/virtconn.c diff --git a/pvpgn/src/bnproxy/virtconn.h b/src/bnproxy/virtconn.h similarity index 100% rename from pvpgn/src/bnproxy/virtconn.h rename to src/bnproxy/virtconn.h diff --git a/pvpgn/src/bntrackd/CMakeLists.txt b/src/bntrackd/CMakeLists.txt similarity index 100% rename from pvpgn/src/bntrackd/CMakeLists.txt rename to src/bntrackd/CMakeLists.txt diff --git a/pvpgn/src/bntrackd/Makefile.am b/src/bntrackd/Makefile.am similarity index 100% rename from pvpgn/src/bntrackd/Makefile.am rename to src/bntrackd/Makefile.am diff --git a/pvpgn/src/bntrackd/bntrackd.cpp b/src/bntrackd/bntrackd.cpp similarity index 100% rename from pvpgn/src/bntrackd/bntrackd.cpp rename to src/bntrackd/bntrackd.cpp diff --git a/pvpgn/src/bntrackd/servers.xsl b/src/bntrackd/servers.xsl similarity index 100% rename from pvpgn/src/bntrackd/servers.xsl rename to src/bntrackd/servers.xsl diff --git a/pvpgn/src/client/CMakeLists.txt b/src/client/CMakeLists.txt similarity index 100% rename from pvpgn/src/client/CMakeLists.txt rename to src/client/CMakeLists.txt diff --git a/pvpgn/src/client/Makefile.am b/src/client/Makefile.am similarity index 100% rename from pvpgn/src/client/Makefile.am rename to src/client/Makefile.am diff --git a/pvpgn/src/client/ansi_term.h b/src/client/ansi_term.h similarity index 100% rename from pvpgn/src/client/ansi_term.h rename to src/client/ansi_term.h diff --git a/pvpgn/src/client/bnbot.cpp b/src/client/bnbot.cpp similarity index 100% rename from pvpgn/src/client/bnbot.cpp rename to src/client/bnbot.cpp diff --git a/pvpgn/src/client/bnchat.cpp b/src/client/bnchat.cpp similarity index 100% rename from pvpgn/src/client/bnchat.cpp rename to src/client/bnchat.cpp diff --git a/pvpgn/src/client/bnftp.cpp b/src/client/bnftp.cpp similarity index 100% rename from pvpgn/src/client/bnftp.cpp rename to src/client/bnftp.cpp diff --git a/pvpgn/src/client/bnstat.cpp b/src/client/bnstat.cpp similarity index 100% rename from pvpgn/src/client/bnstat.cpp rename to src/client/bnstat.cpp diff --git a/pvpgn/src/client/client.cpp b/src/client/client.cpp similarity index 100% rename from pvpgn/src/client/client.cpp rename to src/client/client.cpp diff --git a/pvpgn/src/client/client.h b/src/client/client.h similarity index 100% rename from pvpgn/src/client/client.h rename to src/client/client.h diff --git a/pvpgn/src/client/client_connect.cpp b/src/client/client_connect.cpp similarity index 100% rename from pvpgn/src/client/client_connect.cpp rename to src/client/client_connect.cpp diff --git a/pvpgn/src/client/client_connect.h b/src/client/client_connect.h similarity index 100% rename from pvpgn/src/client/client_connect.h rename to src/client/client_connect.h diff --git a/pvpgn/src/client/udptest.cpp b/src/client/udptest.cpp similarity index 100% rename from pvpgn/src/client/udptest.cpp rename to src/client/udptest.cpp diff --git a/pvpgn/src/client/udptest.h b/src/client/udptest.h similarity index 100% rename from pvpgn/src/client/udptest.h rename to src/client/udptest.h diff --git a/pvpgn/src/common/CMakeLists.txt b/src/common/CMakeLists.txt similarity index 100% rename from pvpgn/src/common/CMakeLists.txt rename to src/common/CMakeLists.txt diff --git a/pvpgn/src/common/Makefile.am b/src/common/Makefile.am similarity index 100% rename from pvpgn/src/common/Makefile.am rename to src/common/Makefile.am diff --git a/pvpgn/src/common/addr.cpp b/src/common/addr.cpp similarity index 100% rename from pvpgn/src/common/addr.cpp rename to src/common/addr.cpp diff --git a/pvpgn/src/common/addr.h b/src/common/addr.h similarity index 100% rename from pvpgn/src/common/addr.h rename to src/common/addr.h diff --git a/pvpgn/src/common/anongame_protocol.h b/src/common/anongame_protocol.h similarity index 100% rename from pvpgn/src/common/anongame_protocol.h rename to src/common/anongame_protocol.h diff --git a/pvpgn/src/common/asnprintf.cpp b/src/common/asnprintf.cpp similarity index 100% rename from pvpgn/src/common/asnprintf.cpp rename to src/common/asnprintf.cpp diff --git a/pvpgn/src/common/asnprintf.h b/src/common/asnprintf.h similarity index 100% rename from pvpgn/src/common/asnprintf.h rename to src/common/asnprintf.h diff --git a/pvpgn/src/common/bigint.cpp b/src/common/bigint.cpp similarity index 100% rename from pvpgn/src/common/bigint.cpp rename to src/common/bigint.cpp diff --git a/pvpgn/src/common/bigint.h b/src/common/bigint.h similarity index 100% rename from pvpgn/src/common/bigint.h rename to src/common/bigint.h diff --git a/pvpgn/src/common/bn_type.cpp b/src/common/bn_type.cpp similarity index 100% rename from pvpgn/src/common/bn_type.cpp rename to src/common/bn_type.cpp diff --git a/pvpgn/src/common/bn_type.h b/src/common/bn_type.h similarity index 100% rename from pvpgn/src/common/bn_type.h rename to src/common/bn_type.h diff --git a/pvpgn/src/common/bnet_protocol.h b/src/common/bnet_protocol.h similarity index 100% rename from pvpgn/src/common/bnet_protocol.h rename to src/common/bnet_protocol.h diff --git a/pvpgn/src/common/bnethash.cpp b/src/common/bnethash.cpp similarity index 100% rename from pvpgn/src/common/bnethash.cpp rename to src/common/bnethash.cpp diff --git a/pvpgn/src/common/bnethash.h b/src/common/bnethash.h similarity index 100% rename from pvpgn/src/common/bnethash.h rename to src/common/bnethash.h diff --git a/pvpgn/src/common/bnethashconv.cpp b/src/common/bnethashconv.cpp similarity index 100% rename from pvpgn/src/common/bnethashconv.cpp rename to src/common/bnethashconv.cpp diff --git a/pvpgn/src/common/bnethashconv.h b/src/common/bnethashconv.h similarity index 100% rename from pvpgn/src/common/bnethashconv.h rename to src/common/bnethashconv.h diff --git a/pvpgn/src/common/bnetsrp3.cpp b/src/common/bnetsrp3.cpp similarity index 100% rename from pvpgn/src/common/bnetsrp3.cpp rename to src/common/bnetsrp3.cpp diff --git a/pvpgn/src/common/bnetsrp3.h b/src/common/bnetsrp3.h similarity index 100% rename from pvpgn/src/common/bnetsrp3.h rename to src/common/bnetsrp3.h diff --git a/pvpgn/src/common/bnettime.cpp b/src/common/bnettime.cpp similarity index 100% rename from pvpgn/src/common/bnettime.cpp rename to src/common/bnettime.cpp diff --git a/pvpgn/src/common/bnettime.h b/src/common/bnettime.h similarity index 100% rename from pvpgn/src/common/bnettime.h rename to src/common/bnettime.h diff --git a/pvpgn/src/common/bot_protocol.h b/src/common/bot_protocol.h similarity index 100% rename from pvpgn/src/common/bot_protocol.h rename to src/common/bot_protocol.h diff --git a/pvpgn/src/common/cdbhash.h b/src/common/cdbhash.h similarity index 100% rename from pvpgn/src/common/cdbhash.h rename to src/common/cdbhash.h diff --git a/pvpgn/src/common/conf.cpp b/src/common/conf.cpp similarity index 100% rename from pvpgn/src/common/conf.cpp rename to src/common/conf.cpp diff --git a/pvpgn/src/common/conf.h b/src/common/conf.h similarity index 100% rename from pvpgn/src/common/conf.h rename to src/common/conf.h diff --git a/pvpgn/src/common/d2char_checksum.cpp b/src/common/d2char_checksum.cpp similarity index 100% rename from pvpgn/src/common/d2char_checksum.cpp rename to src/common/d2char_checksum.cpp diff --git a/pvpgn/src/common/d2char_checksum.h b/src/common/d2char_checksum.h similarity index 100% rename from pvpgn/src/common/d2char_checksum.h rename to src/common/d2char_checksum.h diff --git a/pvpgn/src/common/d2char_file.h b/src/common/d2char_file.h similarity index 100% rename from pvpgn/src/common/d2char_file.h rename to src/common/d2char_file.h diff --git a/pvpgn/src/common/d2cs_bnetd_protocol.h b/src/common/d2cs_bnetd_protocol.h similarity index 100% rename from pvpgn/src/common/d2cs_bnetd_protocol.h rename to src/common/d2cs_bnetd_protocol.h diff --git a/pvpgn/src/common/d2cs_d2dbs_ladder.h b/src/common/d2cs_d2dbs_ladder.h similarity index 100% rename from pvpgn/src/common/d2cs_d2dbs_ladder.h rename to src/common/d2cs_d2dbs_ladder.h diff --git a/pvpgn/src/common/d2cs_d2gs_character.h b/src/common/d2cs_d2gs_character.h similarity index 100% rename from pvpgn/src/common/d2cs_d2gs_character.h rename to src/common/d2cs_d2gs_character.h diff --git a/pvpgn/src/common/d2cs_d2gs_protocol.h b/src/common/d2cs_d2gs_protocol.h similarity index 100% rename from pvpgn/src/common/d2cs_d2gs_protocol.h rename to src/common/d2cs_d2gs_protocol.h diff --git a/pvpgn/src/common/d2cs_protocol.h b/src/common/d2cs_protocol.h similarity index 100% rename from pvpgn/src/common/d2cs_protocol.h rename to src/common/d2cs_protocol.h diff --git a/pvpgn/src/common/d2game_protocol.h b/src/common/d2game_protocol.h similarity index 100% rename from pvpgn/src/common/d2game_protocol.h rename to src/common/d2game_protocol.h diff --git a/pvpgn/src/common/elist.h b/src/common/elist.h similarity index 100% rename from pvpgn/src/common/elist.h rename to src/common/elist.h diff --git a/pvpgn/src/common/eventlog.cpp b/src/common/eventlog.cpp similarity index 100% rename from pvpgn/src/common/eventlog.cpp rename to src/common/eventlog.cpp diff --git a/pvpgn/src/common/eventlog.h b/src/common/eventlog.h similarity index 100% rename from pvpgn/src/common/eventlog.h rename to src/common/eventlog.h diff --git a/pvpgn/src/common/fdwatch.cpp b/src/common/fdwatch.cpp similarity index 100% rename from pvpgn/src/common/fdwatch.cpp rename to src/common/fdwatch.cpp diff --git a/pvpgn/src/common/fdwatch.h b/src/common/fdwatch.h similarity index 100% rename from pvpgn/src/common/fdwatch.h rename to src/common/fdwatch.h diff --git a/pvpgn/src/common/fdwatch_epoll.cpp b/src/common/fdwatch_epoll.cpp similarity index 100% rename from pvpgn/src/common/fdwatch_epoll.cpp rename to src/common/fdwatch_epoll.cpp diff --git a/pvpgn/src/common/fdwatch_epoll.h b/src/common/fdwatch_epoll.h similarity index 100% rename from pvpgn/src/common/fdwatch_epoll.h rename to src/common/fdwatch_epoll.h diff --git a/pvpgn/src/common/fdwatch_kqueue.cpp b/src/common/fdwatch_kqueue.cpp similarity index 100% rename from pvpgn/src/common/fdwatch_kqueue.cpp rename to src/common/fdwatch_kqueue.cpp diff --git a/pvpgn/src/common/fdwatch_kqueue.h b/src/common/fdwatch_kqueue.h similarity index 100% rename from pvpgn/src/common/fdwatch_kqueue.h rename to src/common/fdwatch_kqueue.h diff --git a/pvpgn/src/common/fdwatch_poll.cpp b/src/common/fdwatch_poll.cpp similarity index 100% rename from pvpgn/src/common/fdwatch_poll.cpp rename to src/common/fdwatch_poll.cpp diff --git a/pvpgn/src/common/fdwatch_poll.h b/src/common/fdwatch_poll.h similarity index 100% rename from pvpgn/src/common/fdwatch_poll.h rename to src/common/fdwatch_poll.h diff --git a/pvpgn/src/common/fdwatch_select.cpp b/src/common/fdwatch_select.cpp similarity index 100% rename from pvpgn/src/common/fdwatch_select.cpp rename to src/common/fdwatch_select.cpp diff --git a/pvpgn/src/common/fdwatch_select.h b/src/common/fdwatch_select.h similarity index 100% rename from pvpgn/src/common/fdwatch_select.h rename to src/common/fdwatch_select.h diff --git a/pvpgn/src/common/fdwbackend.cpp b/src/common/fdwbackend.cpp similarity index 100% rename from pvpgn/src/common/fdwbackend.cpp rename to src/common/fdwbackend.cpp diff --git a/pvpgn/src/common/fdwbackend.h b/src/common/fdwbackend.h similarity index 100% rename from pvpgn/src/common/fdwbackend.h rename to src/common/fdwbackend.h diff --git a/pvpgn/src/common/field_sizes.h b/src/common/field_sizes.h similarity index 100% rename from pvpgn/src/common/field_sizes.h rename to src/common/field_sizes.h diff --git a/pvpgn/src/common/file_protocol.h b/src/common/file_protocol.h similarity index 100% rename from pvpgn/src/common/file_protocol.h rename to src/common/file_protocol.h diff --git a/pvpgn/src/common/flags.h b/src/common/flags.h similarity index 100% rename from pvpgn/src/common/flags.h rename to src/common/flags.h diff --git a/pvpgn/src/common/give_up_root_privileges.cpp b/src/common/give_up_root_privileges.cpp similarity index 100% rename from pvpgn/src/common/give_up_root_privileges.cpp rename to src/common/give_up_root_privileges.cpp diff --git a/pvpgn/src/common/give_up_root_privileges.h b/src/common/give_up_root_privileges.h similarity index 100% rename from pvpgn/src/common/give_up_root_privileges.h rename to src/common/give_up_root_privileges.h diff --git a/pvpgn/src/common/gui_printf.cpp b/src/common/gui_printf.cpp similarity index 100% rename from pvpgn/src/common/gui_printf.cpp rename to src/common/gui_printf.cpp diff --git a/pvpgn/src/common/gui_printf.h b/src/common/gui_printf.h similarity index 100% rename from pvpgn/src/common/gui_printf.h rename to src/common/gui_printf.h diff --git a/pvpgn/src/common/hashtable.cpp b/src/common/hashtable.cpp similarity index 100% rename from pvpgn/src/common/hashtable.cpp rename to src/common/hashtable.cpp diff --git a/pvpgn/src/common/hashtable.h b/src/common/hashtable.h similarity index 100% rename from pvpgn/src/common/hashtable.h rename to src/common/hashtable.h diff --git a/pvpgn/src/common/hexdump.cpp b/src/common/hexdump.cpp similarity index 100% rename from pvpgn/src/common/hexdump.cpp rename to src/common/hexdump.cpp diff --git a/pvpgn/src/common/hexdump.h b/src/common/hexdump.h similarity index 100% rename from pvpgn/src/common/hexdump.h rename to src/common/hexdump.h diff --git a/pvpgn/src/common/init_protocol.h b/src/common/init_protocol.h similarity index 100% rename from pvpgn/src/common/init_protocol.h rename to src/common/init_protocol.h diff --git a/d2pack109/src/common/introtate.h b/src/common/introtate.h similarity index 100% rename from d2pack109/src/common/introtate.h rename to src/common/introtate.h diff --git a/pvpgn/src/common/irc_protocol.h b/src/common/irc_protocol.h similarity index 100% rename from pvpgn/src/common/irc_protocol.h rename to src/common/irc_protocol.h diff --git a/pvpgn/src/common/list.cpp b/src/common/list.cpp similarity index 100% rename from pvpgn/src/common/list.cpp rename to src/common/list.cpp diff --git a/pvpgn/src/common/list.h b/src/common/list.h similarity index 100% rename from pvpgn/src/common/list.h rename to src/common/list.h diff --git a/pvpgn/src/common/lstr.h b/src/common/lstr.h similarity index 100% rename from pvpgn/src/common/lstr.h rename to src/common/lstr.h diff --git a/pvpgn/src/common/network.cpp b/src/common/network.cpp similarity index 100% rename from pvpgn/src/common/network.cpp rename to src/common/network.cpp diff --git a/pvpgn/src/common/network.h b/src/common/network.h similarity index 100% rename from pvpgn/src/common/network.h rename to src/common/network.h diff --git a/pvpgn/src/common/packet.cpp b/src/common/packet.cpp similarity index 100% rename from pvpgn/src/common/packet.cpp rename to src/common/packet.cpp diff --git a/pvpgn/src/common/packet.h b/src/common/packet.h similarity index 100% rename from pvpgn/src/common/packet.h rename to src/common/packet.h diff --git a/pvpgn/src/common/peerchat.cpp b/src/common/peerchat.cpp similarity index 100% rename from pvpgn/src/common/peerchat.cpp rename to src/common/peerchat.cpp diff --git a/pvpgn/src/common/peerchat.h b/src/common/peerchat.h similarity index 100% rename from pvpgn/src/common/peerchat.h rename to src/common/peerchat.h diff --git a/pvpgn/src/common/proginfo.cpp b/src/common/proginfo.cpp similarity index 100% rename from pvpgn/src/common/proginfo.cpp rename to src/common/proginfo.cpp diff --git a/pvpgn/src/common/proginfo.h b/src/common/proginfo.h similarity index 100% rename from pvpgn/src/common/proginfo.h rename to src/common/proginfo.h diff --git a/pvpgn/src/common/queue.cpp b/src/common/queue.cpp similarity index 100% rename from pvpgn/src/common/queue.cpp rename to src/common/queue.cpp diff --git a/pvpgn/src/common/queue.h b/src/common/queue.h similarity index 100% rename from pvpgn/src/common/queue.h rename to src/common/queue.h diff --git a/pvpgn/src/common/rcm.cpp b/src/common/rcm.cpp similarity index 100% rename from pvpgn/src/common/rcm.cpp rename to src/common/rcm.cpp diff --git a/pvpgn/src/common/rcm.h b/src/common/rcm.h similarity index 100% rename from pvpgn/src/common/rcm.h rename to src/common/rcm.h diff --git a/pvpgn/src/common/rlimit.cpp b/src/common/rlimit.cpp similarity index 100% rename from pvpgn/src/common/rlimit.cpp rename to src/common/rlimit.cpp diff --git a/pvpgn/src/common/rlimit.h b/src/common/rlimit.h similarity index 100% rename from pvpgn/src/common/rlimit.h rename to src/common/rlimit.h diff --git a/pvpgn/src/common/scoped_array.h b/src/common/scoped_array.h similarity index 100% rename from pvpgn/src/common/scoped_array.h rename to src/common/scoped_array.h diff --git a/pvpgn/src/common/scoped_ptr.h b/src/common/scoped_ptr.h similarity index 100% rename from pvpgn/src/common/scoped_ptr.h rename to src/common/scoped_ptr.h diff --git a/d2pack109/src/common/setup_after.h b/src/common/setup_after.h similarity index 100% rename from d2pack109/src/common/setup_after.h rename to src/common/setup_after.h diff --git a/pvpgn/src/common/setup_before.h b/src/common/setup_before.h similarity index 100% rename from pvpgn/src/common/setup_before.h rename to src/common/setup_before.h diff --git a/pvpgn/src/common/systemerror.cpp b/src/common/systemerror.cpp similarity index 100% rename from pvpgn/src/common/systemerror.cpp rename to src/common/systemerror.cpp diff --git a/pvpgn/src/common/systemerror.h b/src/common/systemerror.h similarity index 100% rename from pvpgn/src/common/systemerror.h rename to src/common/systemerror.h diff --git a/pvpgn/src/common/tag.cpp b/src/common/tag.cpp similarity index 100% rename from pvpgn/src/common/tag.cpp rename to src/common/tag.cpp diff --git a/pvpgn/src/common/tag.h b/src/common/tag.h similarity index 100% rename from pvpgn/src/common/tag.h rename to src/common/tag.h diff --git a/pvpgn/src/common/token.cpp b/src/common/token.cpp similarity index 100% rename from pvpgn/src/common/token.cpp rename to src/common/token.cpp diff --git a/pvpgn/src/common/token.h b/src/common/token.h similarity index 100% rename from pvpgn/src/common/token.h rename to src/common/token.h diff --git a/pvpgn/src/common/tracker.h b/src/common/tracker.h similarity index 100% rename from pvpgn/src/common/tracker.h rename to src/common/tracker.h diff --git a/pvpgn/src/common/trans.cpp b/src/common/trans.cpp similarity index 100% rename from pvpgn/src/common/trans.cpp rename to src/common/trans.cpp diff --git a/pvpgn/src/common/trans.h b/src/common/trans.h similarity index 100% rename from pvpgn/src/common/trans.h rename to src/common/trans.h diff --git a/pvpgn/src/common/udp_protocol.h b/src/common/udp_protocol.h similarity index 100% rename from pvpgn/src/common/udp_protocol.h rename to src/common/udp_protocol.h diff --git a/pvpgn/src/common/util.cpp b/src/common/util.cpp similarity index 100% rename from pvpgn/src/common/util.cpp rename to src/common/util.cpp diff --git a/pvpgn/src/common/util.h b/src/common/util.h similarity index 100% rename from pvpgn/src/common/util.h rename to src/common/util.h diff --git a/pvpgn/src/common/version.h b/src/common/version.h similarity index 100% rename from pvpgn/src/common/version.h rename to src/common/version.h diff --git a/pvpgn/src/common/wol_gameres_protocol.h b/src/common/wol_gameres_protocol.h similarity index 100% rename from pvpgn/src/common/wol_gameres_protocol.h rename to src/common/wol_gameres_protocol.h diff --git a/pvpgn/src/common/wolhash.cpp b/src/common/wolhash.cpp similarity index 100% rename from pvpgn/src/common/wolhash.cpp rename to src/common/wolhash.cpp diff --git a/pvpgn/src/common/wolhash.h b/src/common/wolhash.h similarity index 100% rename from pvpgn/src/common/wolhash.h rename to src/common/wolhash.h diff --git a/pvpgn/src/common/xalloc.cpp b/src/common/xalloc.cpp similarity index 100% rename from pvpgn/src/common/xalloc.cpp rename to src/common/xalloc.cpp diff --git a/pvpgn/src/common/xalloc.h b/src/common/xalloc.h similarity index 100% rename from pvpgn/src/common/xalloc.h rename to src/common/xalloc.h diff --git a/pvpgn/src/common/xstr.cpp b/src/common/xstr.cpp similarity index 100% rename from pvpgn/src/common/xstr.cpp rename to src/common/xstr.cpp diff --git a/pvpgn/src/common/xstr.h b/src/common/xstr.h similarity index 100% rename from pvpgn/src/common/xstr.h rename to src/common/xstr.h diff --git a/pvpgn/src/common/xstring.cpp b/src/common/xstring.cpp similarity index 100% rename from pvpgn/src/common/xstring.cpp rename to src/common/xstring.cpp diff --git a/pvpgn/src/common/xstring.h b/src/common/xstring.h similarity index 100% rename from pvpgn/src/common/xstring.h rename to src/common/xstring.h diff --git a/pvpgn/src/compat/CMakeLists.txt b/src/compat/CMakeLists.txt similarity index 100% rename from pvpgn/src/compat/CMakeLists.txt rename to src/compat/CMakeLists.txt diff --git a/pvpgn/src/compat/Makefile.am b/src/compat/Makefile.am similarity index 100% rename from pvpgn/src/compat/Makefile.am rename to src/compat/Makefile.am diff --git a/pvpgn/src/compat/access.h b/src/compat/access.h similarity index 100% rename from pvpgn/src/compat/access.h rename to src/compat/access.h diff --git a/pvpgn/src/compat/gethostname.h b/src/compat/gethostname.h similarity index 100% rename from pvpgn/src/compat/gethostname.h rename to src/compat/gethostname.h diff --git a/pvpgn/src/compat/gettimeofday.cpp b/src/compat/gettimeofday.cpp similarity index 100% rename from pvpgn/src/compat/gettimeofday.cpp rename to src/compat/gettimeofday.cpp diff --git a/pvpgn/src/compat/gettimeofday.h b/src/compat/gettimeofday.h similarity index 100% rename from pvpgn/src/compat/gettimeofday.h rename to src/compat/gettimeofday.h diff --git a/pvpgn/src/compat/inet_aton.cpp b/src/compat/inet_aton.cpp similarity index 100% rename from pvpgn/src/compat/inet_aton.cpp rename to src/compat/inet_aton.cpp diff --git a/pvpgn/src/compat/inet_aton.h b/src/compat/inet_aton.h similarity index 100% rename from pvpgn/src/compat/inet_aton.h rename to src/compat/inet_aton.h diff --git a/pvpgn/src/compat/inet_ntoa.cpp b/src/compat/inet_ntoa.cpp similarity index 100% rename from pvpgn/src/compat/inet_ntoa.cpp rename to src/compat/inet_ntoa.cpp diff --git a/pvpgn/src/compat/inet_ntoa.h b/src/compat/inet_ntoa.h similarity index 100% rename from pvpgn/src/compat/inet_ntoa.h rename to src/compat/inet_ntoa.h diff --git a/pvpgn/src/compat/mkdir.h b/src/compat/mkdir.h similarity index 100% rename from pvpgn/src/compat/mkdir.h rename to src/compat/mkdir.h diff --git a/pvpgn/src/compat/mmap.cpp b/src/compat/mmap.cpp similarity index 100% rename from pvpgn/src/compat/mmap.cpp rename to src/compat/mmap.cpp diff --git a/pvpgn/src/compat/mmap.h b/src/compat/mmap.h similarity index 100% rename from pvpgn/src/compat/mmap.h rename to src/compat/mmap.h diff --git a/d2pack109/src/compat/netinet_in.h b/src/compat/netinet_in.h similarity index 100% rename from d2pack109/src/compat/netinet_in.h rename to src/compat/netinet_in.h diff --git a/pvpgn/src/compat/pdir.cpp b/src/compat/pdir.cpp similarity index 100% rename from pvpgn/src/compat/pdir.cpp rename to src/compat/pdir.cpp diff --git a/pvpgn/src/compat/pdir.h b/src/compat/pdir.h similarity index 100% rename from pvpgn/src/compat/pdir.h rename to src/compat/pdir.h diff --git a/pvpgn/src/compat/pgetopt.cpp b/src/compat/pgetopt.cpp similarity index 100% rename from pvpgn/src/compat/pgetopt.cpp rename to src/compat/pgetopt.cpp diff --git a/pvpgn/src/compat/pgetopt.h b/src/compat/pgetopt.h similarity index 100% rename from pvpgn/src/compat/pgetopt.h rename to src/compat/pgetopt.h diff --git a/pvpgn/src/compat/pgetpid.h b/src/compat/pgetpid.h similarity index 100% rename from pvpgn/src/compat/pgetpid.h rename to src/compat/pgetpid.h diff --git a/pvpgn/src/compat/psock.cpp b/src/compat/psock.cpp similarity index 100% rename from pvpgn/src/compat/psock.cpp rename to src/compat/psock.cpp diff --git a/pvpgn/src/compat/psock.h b/src/compat/psock.h similarity index 100% rename from pvpgn/src/compat/psock.h rename to src/compat/psock.h diff --git a/d2pack109/src/compat/read.h b/src/compat/read.h similarity index 100% rename from d2pack109/src/compat/read.h rename to src/compat/read.h diff --git a/pvpgn/src/compat/recv.h b/src/compat/recv.h similarity index 100% rename from pvpgn/src/compat/recv.h rename to src/compat/recv.h diff --git a/pvpgn/src/compat/rename.h b/src/compat/rename.h similarity index 100% rename from pvpgn/src/compat/rename.h rename to src/compat/rename.h diff --git a/pvpgn/src/compat/runtime_libs.h b/src/compat/runtime_libs.h similarity index 100% rename from pvpgn/src/compat/runtime_libs.h rename to src/compat/runtime_libs.h diff --git a/pvpgn/src/compat/send.h b/src/compat/send.h similarity index 100% rename from pvpgn/src/compat/send.h rename to src/compat/send.h diff --git a/pvpgn/src/compat/snprintf.cpp b/src/compat/snprintf.cpp similarity index 100% rename from pvpgn/src/compat/snprintf.cpp rename to src/compat/snprintf.cpp diff --git a/pvpgn/src/compat/snprintf.h b/src/compat/snprintf.h similarity index 100% rename from pvpgn/src/compat/snprintf.h rename to src/compat/snprintf.h diff --git a/pvpgn/src/compat/socket.h b/src/compat/socket.h similarity index 100% rename from pvpgn/src/compat/socket.h rename to src/compat/socket.h diff --git a/d2pack109/src/compat/statmacros.h b/src/compat/statmacros.h similarity index 100% rename from d2pack109/src/compat/statmacros.h rename to src/compat/statmacros.h diff --git a/pvpgn/src/compat/stdfileno.h b/src/compat/stdfileno.h similarity index 100% rename from pvpgn/src/compat/stdfileno.h rename to src/compat/stdfileno.h diff --git a/pvpgn/src/compat/strcasecmp.cpp b/src/compat/strcasecmp.cpp similarity index 100% rename from pvpgn/src/compat/strcasecmp.cpp rename to src/compat/strcasecmp.cpp diff --git a/pvpgn/src/compat/strcasecmp.h b/src/compat/strcasecmp.h similarity index 100% rename from pvpgn/src/compat/strcasecmp.h rename to src/compat/strcasecmp.h diff --git a/pvpgn/src/compat/strdup.cpp b/src/compat/strdup.cpp similarity index 100% rename from pvpgn/src/compat/strdup.cpp rename to src/compat/strdup.cpp diff --git a/pvpgn/src/compat/strdup.h b/src/compat/strdup.h similarity index 100% rename from pvpgn/src/compat/strdup.h rename to src/compat/strdup.h diff --git a/pvpgn/src/compat/strerror.cpp b/src/compat/strerror.cpp similarity index 100% rename from pvpgn/src/compat/strerror.cpp rename to src/compat/strerror.cpp diff --git a/pvpgn/src/compat/strerror.h b/src/compat/strerror.h similarity index 100% rename from pvpgn/src/compat/strerror.h rename to src/compat/strerror.h diff --git a/pvpgn/src/compat/strncasecmp.cpp b/src/compat/strncasecmp.cpp similarity index 100% rename from pvpgn/src/compat/strncasecmp.cpp rename to src/compat/strncasecmp.cpp diff --git a/pvpgn/src/compat/strncasecmp.h b/src/compat/strncasecmp.h similarity index 100% rename from pvpgn/src/compat/strncasecmp.h rename to src/compat/strncasecmp.h diff --git a/pvpgn/src/compat/strsep.cpp b/src/compat/strsep.cpp similarity index 100% rename from pvpgn/src/compat/strsep.cpp rename to src/compat/strsep.cpp diff --git a/pvpgn/src/compat/strsep.h b/src/compat/strsep.h similarity index 100% rename from pvpgn/src/compat/strsep.h rename to src/compat/strsep.h diff --git a/pvpgn/src/compat/strtoul.cpp b/src/compat/strtoul.cpp similarity index 100% rename from pvpgn/src/compat/strtoul.cpp rename to src/compat/strtoul.cpp diff --git a/pvpgn/src/compat/strtoul.h b/src/compat/strtoul.h similarity index 100% rename from pvpgn/src/compat/strtoul.h rename to src/compat/strtoul.h diff --git a/pvpgn/src/compat/termios.h b/src/compat/termios.h similarity index 100% rename from pvpgn/src/compat/termios.h rename to src/compat/termios.h diff --git a/pvpgn/src/compat/uint.h b/src/compat/uint.h similarity index 100% rename from pvpgn/src/compat/uint.h rename to src/compat/uint.h diff --git a/pvpgn/src/compat/uname.cpp b/src/compat/uname.cpp similarity index 100% rename from pvpgn/src/compat/uname.cpp rename to src/compat/uname.cpp diff --git a/pvpgn/src/compat/uname.h b/src/compat/uname.h similarity index 100% rename from pvpgn/src/compat/uname.h rename to src/compat/uname.h diff --git a/pvpgn/src/compat/vsnprintf.cpp b/src/compat/vsnprintf.cpp similarity index 100% rename from pvpgn/src/compat/vsnprintf.cpp rename to src/compat/vsnprintf.cpp diff --git a/pvpgn/src/compat/vsnprintf.h b/src/compat/vsnprintf.h similarity index 100% rename from pvpgn/src/compat/vsnprintf.h rename to src/compat/vsnprintf.h diff --git a/pvpgn/src/d2cs/CMakeLists.txt b/src/d2cs/CMakeLists.txt similarity index 100% rename from pvpgn/src/d2cs/CMakeLists.txt rename to src/d2cs/CMakeLists.txt diff --git a/pvpgn/src/d2cs/Makefile.am b/src/d2cs/Makefile.am similarity index 100% rename from pvpgn/src/d2cs/Makefile.am rename to src/d2cs/Makefile.am diff --git a/pvpgn/src/d2cs/bit.h b/src/d2cs/bit.h similarity index 100% rename from pvpgn/src/d2cs/bit.h rename to src/d2cs/bit.h diff --git a/pvpgn/src/d2cs/bnetd.cpp b/src/d2cs/bnetd.cpp similarity index 100% rename from pvpgn/src/d2cs/bnetd.cpp rename to src/d2cs/bnetd.cpp diff --git a/pvpgn/src/d2cs/bnetd.h b/src/d2cs/bnetd.h similarity index 100% rename from pvpgn/src/d2cs/bnetd.h rename to src/d2cs/bnetd.h diff --git a/pvpgn/src/d2cs/cmdline.cpp b/src/d2cs/cmdline.cpp similarity index 100% rename from pvpgn/src/d2cs/cmdline.cpp rename to src/d2cs/cmdline.cpp diff --git a/pvpgn/src/d2cs/cmdline.h b/src/d2cs/cmdline.h similarity index 100% rename from pvpgn/src/d2cs/cmdline.h rename to src/d2cs/cmdline.h diff --git a/pvpgn/src/d2cs/connection.cpp b/src/d2cs/connection.cpp similarity index 100% rename from pvpgn/src/d2cs/connection.cpp rename to src/d2cs/connection.cpp diff --git a/pvpgn/src/d2cs/connection.h b/src/d2cs/connection.h similarity index 100% rename from pvpgn/src/d2cs/connection.h rename to src/d2cs/connection.h diff --git a/pvpgn/src/d2cs/d2charfile.cpp b/src/d2cs/d2charfile.cpp similarity index 100% rename from pvpgn/src/d2cs/d2charfile.cpp rename to src/d2cs/d2charfile.cpp diff --git a/pvpgn/src/d2cs/d2charfile.h b/src/d2cs/d2charfile.h similarity index 100% rename from pvpgn/src/d2cs/d2charfile.h rename to src/d2cs/d2charfile.h diff --git a/pvpgn/src/d2cs/d2charlist.cpp b/src/d2cs/d2charlist.cpp similarity index 100% rename from pvpgn/src/d2cs/d2charlist.cpp rename to src/d2cs/d2charlist.cpp diff --git a/pvpgn/src/d2cs/d2charlist.h b/src/d2cs/d2charlist.h similarity index 100% rename from pvpgn/src/d2cs/d2charlist.h rename to src/d2cs/d2charlist.h diff --git a/pvpgn/src/d2cs/d2gs.cpp b/src/d2cs/d2gs.cpp similarity index 100% rename from pvpgn/src/d2cs/d2gs.cpp rename to src/d2cs/d2gs.cpp diff --git a/pvpgn/src/d2cs/d2gs.h b/src/d2cs/d2gs.h similarity index 100% rename from pvpgn/src/d2cs/d2gs.h rename to src/d2cs/d2gs.h diff --git a/pvpgn/src/d2cs/d2ladder.cpp b/src/d2cs/d2ladder.cpp similarity index 100% rename from pvpgn/src/d2cs/d2ladder.cpp rename to src/d2cs/d2ladder.cpp diff --git a/pvpgn/src/d2cs/d2ladder.h b/src/d2cs/d2ladder.h similarity index 100% rename from pvpgn/src/d2cs/d2ladder.h rename to src/d2cs/d2ladder.h diff --git a/pvpgn/src/d2cs/game.cpp b/src/d2cs/game.cpp similarity index 100% rename from pvpgn/src/d2cs/game.cpp rename to src/d2cs/game.cpp diff --git a/pvpgn/src/d2cs/game.h b/src/d2cs/game.h similarity index 100% rename from pvpgn/src/d2cs/game.h rename to src/d2cs/game.h diff --git a/pvpgn/src/d2cs/gamequeue.cpp b/src/d2cs/gamequeue.cpp similarity index 100% rename from pvpgn/src/d2cs/gamequeue.cpp rename to src/d2cs/gamequeue.cpp diff --git a/pvpgn/src/d2cs/gamequeue.h b/src/d2cs/gamequeue.h similarity index 100% rename from pvpgn/src/d2cs/gamequeue.h rename to src/d2cs/gamequeue.h diff --git a/pvpgn/src/d2cs/handle_bnetd.cpp b/src/d2cs/handle_bnetd.cpp similarity index 100% rename from pvpgn/src/d2cs/handle_bnetd.cpp rename to src/d2cs/handle_bnetd.cpp diff --git a/pvpgn/src/d2cs/handle_bnetd.h b/src/d2cs/handle_bnetd.h similarity index 100% rename from pvpgn/src/d2cs/handle_bnetd.h rename to src/d2cs/handle_bnetd.h diff --git a/pvpgn/src/d2cs/handle_d2cs.cpp b/src/d2cs/handle_d2cs.cpp similarity index 100% rename from pvpgn/src/d2cs/handle_d2cs.cpp rename to src/d2cs/handle_d2cs.cpp diff --git a/pvpgn/src/d2cs/handle_d2cs.h b/src/d2cs/handle_d2cs.h similarity index 100% rename from pvpgn/src/d2cs/handle_d2cs.h rename to src/d2cs/handle_d2cs.h diff --git a/pvpgn/src/d2cs/handle_d2gs.cpp b/src/d2cs/handle_d2gs.cpp similarity index 100% rename from pvpgn/src/d2cs/handle_d2gs.cpp rename to src/d2cs/handle_d2gs.cpp diff --git a/pvpgn/src/d2cs/handle_d2gs.h b/src/d2cs/handle_d2gs.h similarity index 100% rename from pvpgn/src/d2cs/handle_d2gs.h rename to src/d2cs/handle_d2gs.h diff --git a/pvpgn/src/d2cs/handle_init.cpp b/src/d2cs/handle_init.cpp similarity index 100% rename from pvpgn/src/d2cs/handle_init.cpp rename to src/d2cs/handle_init.cpp diff --git a/pvpgn/src/d2cs/handle_init.h b/src/d2cs/handle_init.h similarity index 100% rename from pvpgn/src/d2cs/handle_init.h rename to src/d2cs/handle_init.h diff --git a/pvpgn/src/d2cs/handle_signal.cpp b/src/d2cs/handle_signal.cpp similarity index 100% rename from pvpgn/src/d2cs/handle_signal.cpp rename to src/d2cs/handle_signal.cpp diff --git a/pvpgn/src/d2cs/handle_signal.h b/src/d2cs/handle_signal.h similarity index 100% rename from pvpgn/src/d2cs/handle_signal.h rename to src/d2cs/handle_signal.h diff --git a/pvpgn/src/d2cs/main.cpp b/src/d2cs/main.cpp similarity index 100% rename from pvpgn/src/d2cs/main.cpp rename to src/d2cs/main.cpp diff --git a/pvpgn/src/d2cs/net.cpp b/src/d2cs/net.cpp similarity index 100% rename from pvpgn/src/d2cs/net.cpp rename to src/d2cs/net.cpp diff --git a/pvpgn/src/d2cs/net.h b/src/d2cs/net.h similarity index 100% rename from pvpgn/src/d2cs/net.h rename to src/d2cs/net.h diff --git a/pvpgn/src/d2cs/prefs.cpp b/src/d2cs/prefs.cpp similarity index 100% rename from pvpgn/src/d2cs/prefs.cpp rename to src/d2cs/prefs.cpp diff --git a/pvpgn/src/d2cs/prefs.h b/src/d2cs/prefs.h similarity index 100% rename from pvpgn/src/d2cs/prefs.h rename to src/d2cs/prefs.h diff --git a/pvpgn/src/d2cs/s2s.cpp b/src/d2cs/s2s.cpp similarity index 100% rename from pvpgn/src/d2cs/s2s.cpp rename to src/d2cs/s2s.cpp diff --git a/pvpgn/src/d2cs/s2s.h b/src/d2cs/s2s.h similarity index 100% rename from pvpgn/src/d2cs/s2s.h rename to src/d2cs/s2s.h diff --git a/pvpgn/src/d2cs/server.cpp b/src/d2cs/server.cpp similarity index 100% rename from pvpgn/src/d2cs/server.cpp rename to src/d2cs/server.cpp diff --git a/pvpgn/src/d2cs/server.h b/src/d2cs/server.h similarity index 100% rename from pvpgn/src/d2cs/server.h rename to src/d2cs/server.h diff --git a/pvpgn/src/d2cs/serverqueue.cpp b/src/d2cs/serverqueue.cpp similarity index 100% rename from pvpgn/src/d2cs/serverqueue.cpp rename to src/d2cs/serverqueue.cpp diff --git a/pvpgn/src/d2cs/serverqueue.h b/src/d2cs/serverqueue.h similarity index 100% rename from pvpgn/src/d2cs/serverqueue.h rename to src/d2cs/serverqueue.h diff --git a/pvpgn/src/d2cs/setup.h b/src/d2cs/setup.h similarity index 100% rename from pvpgn/src/d2cs/setup.h rename to src/d2cs/setup.h diff --git a/pvpgn/src/d2cs/version.h b/src/d2cs/version.h similarity index 100% rename from pvpgn/src/d2cs/version.h rename to src/d2cs/version.h diff --git a/pvpgn/src/d2dbs/CMakeLists.txt b/src/d2dbs/CMakeLists.txt similarity index 100% rename from pvpgn/src/d2dbs/CMakeLists.txt rename to src/d2dbs/CMakeLists.txt diff --git a/pvpgn/src/d2dbs/Makefile.am b/src/d2dbs/Makefile.am similarity index 100% rename from pvpgn/src/d2dbs/Makefile.am rename to src/d2dbs/Makefile.am diff --git a/pvpgn/src/d2dbs/charlock.cpp b/src/d2dbs/charlock.cpp similarity index 100% rename from pvpgn/src/d2dbs/charlock.cpp rename to src/d2dbs/charlock.cpp diff --git a/pvpgn/src/d2dbs/charlock.h b/src/d2dbs/charlock.h similarity index 100% rename from pvpgn/src/d2dbs/charlock.h rename to src/d2dbs/charlock.h diff --git a/pvpgn/src/d2dbs/cmdline.cpp b/src/d2dbs/cmdline.cpp similarity index 100% rename from pvpgn/src/d2dbs/cmdline.cpp rename to src/d2dbs/cmdline.cpp diff --git a/pvpgn/src/d2dbs/cmdline.h b/src/d2dbs/cmdline.h similarity index 100% rename from pvpgn/src/d2dbs/cmdline.h rename to src/d2dbs/cmdline.h diff --git a/pvpgn/src/d2dbs/d2ladder.cpp b/src/d2dbs/d2ladder.cpp similarity index 100% rename from pvpgn/src/d2dbs/d2ladder.cpp rename to src/d2dbs/d2ladder.cpp diff --git a/pvpgn/src/d2dbs/d2ladder.h b/src/d2dbs/d2ladder.h similarity index 100% rename from pvpgn/src/d2dbs/d2ladder.h rename to src/d2dbs/d2ladder.h diff --git a/pvpgn/src/d2dbs/dbsdupecheck.cpp b/src/d2dbs/dbsdupecheck.cpp similarity index 100% rename from pvpgn/src/d2dbs/dbsdupecheck.cpp rename to src/d2dbs/dbsdupecheck.cpp diff --git a/pvpgn/src/d2dbs/dbsdupecheck.h b/src/d2dbs/dbsdupecheck.h similarity index 100% rename from pvpgn/src/d2dbs/dbsdupecheck.h rename to src/d2dbs/dbsdupecheck.h diff --git a/pvpgn/src/d2dbs/dbserver.cpp b/src/d2dbs/dbserver.cpp similarity index 100% rename from pvpgn/src/d2dbs/dbserver.cpp rename to src/d2dbs/dbserver.cpp diff --git a/pvpgn/src/d2dbs/dbserver.h b/src/d2dbs/dbserver.h similarity index 100% rename from pvpgn/src/d2dbs/dbserver.h rename to src/d2dbs/dbserver.h diff --git a/pvpgn/src/d2dbs/dbspacket.cpp b/src/d2dbs/dbspacket.cpp similarity index 100% rename from pvpgn/src/d2dbs/dbspacket.cpp rename to src/d2dbs/dbspacket.cpp diff --git a/pvpgn/src/d2dbs/dbspacket.h b/src/d2dbs/dbspacket.h similarity index 100% rename from pvpgn/src/d2dbs/dbspacket.h rename to src/d2dbs/dbspacket.h diff --git a/pvpgn/src/d2dbs/handle_signal.cpp b/src/d2dbs/handle_signal.cpp similarity index 100% rename from pvpgn/src/d2dbs/handle_signal.cpp rename to src/d2dbs/handle_signal.cpp diff --git a/pvpgn/src/d2dbs/handle_signal.h b/src/d2dbs/handle_signal.h similarity index 100% rename from pvpgn/src/d2dbs/handle_signal.h rename to src/d2dbs/handle_signal.h diff --git a/pvpgn/src/d2dbs/main.cpp b/src/d2dbs/main.cpp similarity index 100% rename from pvpgn/src/d2dbs/main.cpp rename to src/d2dbs/main.cpp diff --git a/pvpgn/src/d2dbs/prefs.cpp b/src/d2dbs/prefs.cpp similarity index 100% rename from pvpgn/src/d2dbs/prefs.cpp rename to src/d2dbs/prefs.cpp diff --git a/pvpgn/src/d2dbs/prefs.h b/src/d2dbs/prefs.h similarity index 100% rename from pvpgn/src/d2dbs/prefs.h rename to src/d2dbs/prefs.h diff --git a/pvpgn/src/d2dbs/setup.h b/src/d2dbs/setup.h similarity index 100% rename from pvpgn/src/d2dbs/setup.h rename to src/d2dbs/setup.h diff --git a/pvpgn/src/d2dbs/version.h b/src/d2dbs/version.h similarity index 100% rename from pvpgn/src/d2dbs/version.h rename to src/d2dbs/version.h diff --git a/pvpgn/src/test/CMakeLists.txt b/src/test/CMakeLists.txt similarity index 100% rename from pvpgn/src/test/CMakeLists.txt rename to src/test/CMakeLists.txt diff --git a/pvpgn/src/test/bigint.cpp b/src/test/bigint.cpp similarity index 100% rename from pvpgn/src/test/bigint.cpp rename to src/test/bigint.cpp diff --git a/pvpgn/src/test/bnetsrp3_test.cpp b/src/test/bnetsrp3_test.cpp similarity index 100% rename from pvpgn/src/test/bnetsrp3_test.cpp rename to src/test/bnetsrp3_test.cpp diff --git a/pvpgn/src/tinycdb/CMakeLists.txt b/src/tinycdb/CMakeLists.txt similarity index 100% rename from pvpgn/src/tinycdb/CMakeLists.txt rename to src/tinycdb/CMakeLists.txt diff --git a/pvpgn/src/tinycdb/ChangeLog b/src/tinycdb/ChangeLog similarity index 100% rename from pvpgn/src/tinycdb/ChangeLog rename to src/tinycdb/ChangeLog diff --git a/pvpgn/src/tinycdb/Makefile.am b/src/tinycdb/Makefile.am similarity index 100% rename from pvpgn/src/tinycdb/Makefile.am rename to src/tinycdb/Makefile.am diff --git a/pvpgn/src/tinycdb/cdb.cpp b/src/tinycdb/cdb.cpp similarity index 100% rename from pvpgn/src/tinycdb/cdb.cpp rename to src/tinycdb/cdb.cpp diff --git a/pvpgn/src/tinycdb/cdb.h b/src/tinycdb/cdb.h similarity index 100% rename from pvpgn/src/tinycdb/cdb.h rename to src/tinycdb/cdb.h diff --git a/pvpgn/src/tinycdb/cdb_find.cpp b/src/tinycdb/cdb_find.cpp similarity index 100% rename from pvpgn/src/tinycdb/cdb_find.cpp rename to src/tinycdb/cdb_find.cpp diff --git a/pvpgn/src/tinycdb/cdb_findnext.cpp b/src/tinycdb/cdb_findnext.cpp similarity index 100% rename from pvpgn/src/tinycdb/cdb_findnext.cpp rename to src/tinycdb/cdb_findnext.cpp diff --git a/pvpgn/src/tinycdb/cdb_hash.cpp b/src/tinycdb/cdb_hash.cpp similarity index 100% rename from pvpgn/src/tinycdb/cdb_hash.cpp rename to src/tinycdb/cdb_hash.cpp diff --git a/pvpgn/src/tinycdb/cdb_init.cpp b/src/tinycdb/cdb_init.cpp similarity index 100% rename from pvpgn/src/tinycdb/cdb_init.cpp rename to src/tinycdb/cdb_init.cpp diff --git a/pvpgn/src/tinycdb/cdb_int.h b/src/tinycdb/cdb_int.h similarity index 100% rename from pvpgn/src/tinycdb/cdb_int.h rename to src/tinycdb/cdb_int.h diff --git a/pvpgn/src/tinycdb/cdb_make.cpp b/src/tinycdb/cdb_make.cpp similarity index 100% rename from pvpgn/src/tinycdb/cdb_make.cpp rename to src/tinycdb/cdb_make.cpp diff --git a/pvpgn/src/tinycdb/cdb_make_add.cpp b/src/tinycdb/cdb_make_add.cpp similarity index 100% rename from pvpgn/src/tinycdb/cdb_make_add.cpp rename to src/tinycdb/cdb_make_add.cpp diff --git a/pvpgn/src/tinycdb/cdb_make_find.cpp b/src/tinycdb/cdb_make_find.cpp similarity index 100% rename from pvpgn/src/tinycdb/cdb_make_find.cpp rename to src/tinycdb/cdb_make_find.cpp diff --git a/pvpgn/src/tinycdb/cdb_make_put.cpp b/src/tinycdb/cdb_make_put.cpp similarity index 100% rename from pvpgn/src/tinycdb/cdb_make_put.cpp rename to src/tinycdb/cdb_make_put.cpp diff --git a/pvpgn/src/tinycdb/cdb_seek.cpp b/src/tinycdb/cdb_seek.cpp similarity index 100% rename from pvpgn/src/tinycdb/cdb_seek.cpp rename to src/tinycdb/cdb_seek.cpp diff --git a/pvpgn/src/tinycdb/cdb_seq.cpp b/src/tinycdb/cdb_seq.cpp similarity index 100% rename from pvpgn/src/tinycdb/cdb_seq.cpp rename to src/tinycdb/cdb_seq.cpp diff --git a/pvpgn/src/tinycdb/cdb_unpack.cpp b/src/tinycdb/cdb_unpack.cpp similarity index 100% rename from pvpgn/src/tinycdb/cdb_unpack.cpp rename to src/tinycdb/cdb_unpack.cpp diff --git a/pvpgn/src/win32/CMakeLists.txt b/src/win32/CMakeLists.txt similarity index 100% rename from pvpgn/src/win32/CMakeLists.txt rename to src/win32/CMakeLists.txt diff --git a/pvpgn/src/win32/Makefile.am b/src/win32/Makefile.am similarity index 100% rename from pvpgn/src/win32/Makefile.am rename to src/win32/Makefile.am diff --git a/pvpgn/src/win32/configwin.h b/src/win32/configwin.h similarity index 100% rename from pvpgn/src/win32/configwin.h rename to src/win32/configwin.h diff --git a/pvpgn/src/win32/console_output.cpp b/src/win32/console_output.cpp similarity index 100% rename from pvpgn/src/win32/console_output.cpp rename to src/win32/console_output.cpp diff --git a/pvpgn/src/win32/console_output.h b/src/win32/console_output.h similarity index 100% rename from pvpgn/src/win32/console_output.h rename to src/win32/console_output.h diff --git a/d2pack109/src/win32/console_resource.h b/src/win32/console_resource.h similarity index 100% rename from d2pack109/src/win32/console_resource.h rename to src/win32/console_resource.h diff --git a/d2pack109/src/win32/console_resource.rc b/src/win32/console_resource.rc similarity index 100% rename from d2pack109/src/win32/console_resource.rc rename to src/win32/console_resource.rc diff --git a/d2pack109/src/win32/d2cs_resource.h b/src/win32/d2cs_resource.h similarity index 100% rename from d2pack109/src/win32/d2cs_resource.h rename to src/win32/d2cs_resource.h diff --git a/d2pack109/src/win32/d2cs_resource.rc b/src/win32/d2cs_resource.rc similarity index 100% rename from d2pack109/src/win32/d2cs_resource.rc rename to src/win32/d2cs_resource.rc diff --git a/pvpgn/src/win32/d2cs_winmain.cpp b/src/win32/d2cs_winmain.cpp similarity index 100% rename from pvpgn/src/win32/d2cs_winmain.cpp rename to src/win32/d2cs_winmain.cpp diff --git a/d2pack109/src/win32/d2dbs_resource.h b/src/win32/d2dbs_resource.h similarity index 100% rename from d2pack109/src/win32/d2dbs_resource.h rename to src/win32/d2dbs_resource.h diff --git a/d2pack109/src/win32/d2dbs_resource.rc b/src/win32/d2dbs_resource.rc similarity index 100% rename from d2pack109/src/win32/d2dbs_resource.rc rename to src/win32/d2dbs_resource.rc diff --git a/pvpgn/src/win32/d2dbs_winmain.cpp b/src/win32/d2dbs_winmain.cpp similarity index 100% rename from pvpgn/src/win32/d2dbs_winmain.cpp rename to src/win32/d2dbs_winmain.cpp diff --git a/d2pack109/src/win32/logo01.ico b/src/win32/logo01.ico similarity index 100% rename from d2pack109/src/win32/logo01.ico rename to src/win32/logo01.ico diff --git a/pvpgn/src/win32/resource.h b/src/win32/resource.h similarity index 100% rename from pvpgn/src/win32/resource.h rename to src/win32/resource.h diff --git a/pvpgn/src/win32/resource.rc b/src/win32/resource.rc similarity index 100% rename from pvpgn/src/win32/resource.rc rename to src/win32/resource.rc diff --git a/pvpgn/src/win32/service.cpp b/src/win32/service.cpp similarity index 100% rename from pvpgn/src/win32/service.cpp rename to src/win32/service.cpp diff --git a/pvpgn/src/win32/service.h b/src/win32/service.h similarity index 100% rename from pvpgn/src/win32/service.h rename to src/win32/service.h diff --git a/pvpgn/src/win32/winmain.cpp b/src/win32/winmain.cpp similarity index 100% rename from pvpgn/src/win32/winmain.cpp rename to src/win32/winmain.cpp diff --git a/pvpgn/src/win32/winmain.h b/src/win32/winmain.h similarity index 100% rename from pvpgn/src/win32/winmain.h rename to src/win32/winmain.h diff --git a/pvpgn/version-history.txt b/version-history.txt similarity index 100% rename from pvpgn/version-history.txt rename to version-history.txt diff --git a/web/site/admin/downloads.php b/web/site/admin/downloads.php deleted file mode 100644 index fb0d4c0..0000000 --- a/web/site/admin/downloads.php +++ /dev/null @@ -1,127 +0,0 @@ - - - -Site admin - - -

Submit news | Edit news | Create new user | Edit links | Edit downloads | Edit user profile | Misc config | Logout

-

-\n"; - echo "filename:
\n"; - echo "size: bytes
\n"; - echo "description:
\n"; - echo ""; - echo ""; -} else { -?> - - -"; - if ($row[3] <> 1) { - echo ""; - } else { - echo ""; - } - if ($row[3] <> $max[0]) { - echo ""; - } else { - echo ""; - } - } while ($row = mysql_fetch_row($query)); -} else { - echo ""; -} -?> -
#filenamesizedescriptioneditdeletemove upmove down
".$row[3]."".$row[0]."".$row[1]."".$row[2]."editdeletemove up---move down---
No ".$_GET['type']." downloads!
-

-

-filename
-size bytes
-description
- -
- -

- - diff --git a/web/site/admin/index.php b/web/site/admin/index.php deleted file mode 100644 index e938191..0000000 --- a/web/site/admin/index.php +++ /dev/null @@ -1,212 +0,0 @@ - - - -Site admin - - - -

-Username:
-Password:
- -

-User \"".$_POST['username']."\" does not exist

\n"; - } else if ($row[2] != md5($_POST['password'])) { - echo "

Password incorrect

\n"; - } else { - $_SESSION['uid'] = $row[0]; - $_SESSION['user'] = $row[1]; - $_SESSION['email'] = $row[3]; - echo "

Login successful

\n"; - echo "

Click here to continue

\n"; - } - } else { - if ($_GET['action'] != 'logout' && $_GET['action'] != 'dochpass') { - ?> -

Submit news | Edit news | Create new user | Edit links | Edit downloads | Edit user profile | Misc config | Logout

- -

- Username:
- Password:
- Confirm password:
- Email address:
- -

- $_POST['pass2']) { - echo "

Password and repeated password do not match

\n"; - } else { - if (@mysql_query("INSERT INTO `users`(`username`,`passhash`,`email`) VALUES('".$_POST['username']."','".md5($_POST['pass1'])."','".$_POST['email']."');",$dbh)) { - echo "

User \"".$_POST['username']."\" created successfully

\n"; - } else { - echo "

Error: Could not create new user

\n"; - echo "

MySQL said: ".mysql_error()."

\n"; - } - } - } else if ($_GET['action'] == 'submit') { - echo "

\n"; - echo "Username: ".$_SESSION['user']."
\n"; - echo "Email: ".$_SESSION['email']."
\n"; - echo "Date: ".date($dateformat)."
\n"; - ?> - Subject:
- News text:
-
- -

- News added successfully

\n"; - } else { - echo "

Error: Could not insert news

\n"; - echo "

MySQL said: ".mysql_error()."

\n"; - } - } else if ($_GET['action'] == 'edit') { - echo "
"; - echo "\n"; - $query = mysql_query("SELECT timestamp,subject FROM news ORDER BY `timestamp` DESC",$dbh); - if ($row = mysql_fetch_row($query)) { - do { - echo "\n"; - } while ($row = mysql_fetch_row($query)); - } else { - echo "\n"; - } - echo "
TimestampSubjectEditDelete
".$row[0]."".$row[1]."editdelete
No news is good news!
\n"; - } else if ($_GET['action'] == 'dodelete') { - mysql_query("DELETE FROM news WHERE `timestamp` = ".$_GET['x'].";",$dbh); - echo "

Newsitem deleted

\n"; - } else if ($_GET['action'] == 'edititem') { - $row = mysql_fetch_row($temp = mysql_query("SELECT subject,text FROM news WHERE `timestamp` = ".$_GET['x'].";",$dbh)); - echo "

\n"; - echo "Date: ".date($dateformat,$_GET['x'])."
\n"; - echo "Subject:
\n"; - echo "
\n"; - echo "\n"; - echo "

\n"; - mysql_free_result($temp); - unset($temp); - unset($row); - } else if ($_GET['action'] == 'doedit') { - if (@mysql_query("UPDATE news SET `subject` = '".$_POST['subject']."', `text` = '".$_POST['text']."' WHERE `timestamp` = ".$_GET['x'].";",$dbh)) { - echo "

News updated successfully

\n"; - } else { - echo "

Error: Could not update news

\n"; - echo "

MySQL said: ".mysql_error()."

\n"; - } - } else if ($_GET['action'] == 'chpass') { - $row = mysql_fetch_row(mysql_query("SELECT username,email FROM users WHERE uid = ".$_SESSION['uid'].";",$dbh)); - ?> -

- Username:
- Password:
- Confirm password:
- Email address:
- -

- Profile updated successfully

\n"; - echo "

You must log in again before you can perform further actions.

\n"; - } else { - echo "

Error: Could not update profile

\n"; - echo "

MySQL said: ".mysql_error()."

\n"; - } - } else { - echo "

Error: Password and repeated password do not match

\n"; - } - } else if ($_GET['action'] == 'downloads') { - $row = mysql_fetch_row($temp = mysql_query("SELECT value FROM config WHERE `key` = 'latest_stable'",$dbh)); - $latest_stable = $row[0]; - mysql_free_result($temp); - $row = mysql_fetch_row($temp = mysql_query("SELECT value FROM config WHERE `key` = 'latest_development'",$dbh)); - $latest_development = $row[0]; - mysql_free_result($temp); - $row = mysql_fetch_row($temp = mysql_query("SELECT value FROM config WHERE `key` = 'latest_d2pack109'",$dbh)); - $latest_d2pack109 = $row[0]; - mysql_free_result($temp); - unset($temp); - unset($row); - echo "
\n"; - echo "Latest development release: (enter 0 to disable)
\n"; - echo "Edit files for development
\n
\n"; - echo "Latest stable release:
\n"; - echo "Edit files for stable
\n
\n"; - echo "Latest d2pack109 release:
\n"; - echo "Edit files for d2pack109
\n
\n"; - echo "\n"; - echo "
\n"; - } else if ($_GET['action'] == 'dodownloads') { - if (mysql_query("UPDATE config SET `value` = '".$_POST['development']."' WHERE `key` = 'latest_development';",$dbh) && mysql_query("UPDATE config SET `value` = '".$_POST['stable']."' WHERE `key` = 'latest_stable';",$dbh) && mysql_query("UPDATE config SET `value` = '".$_POST['d2pack109']."' WHERE `key` = 'latest_d2pack109';",$dbh)) { - echo "

Updated successfully

\n"; - } else { - echo "

Error: Could not apply changes

\n"; - echo "

MySQL said: ".mysql_error()."

\n"; - } - } else if ($_GET['action'] == 'config') { - $row = mysql_fetch_row($temp = mysql_query("SELECT COUNT(*) FROM news",$dbh)); - $total_newsitems = $row[0]; - mysql_free_result($temp); - $row = mysql_fetch_row($temp = mysql_query("SELECT value+0 FROM config WHERE `key` = 'items_front_page'",$dbh)); - $items_front_page = $row[0]; - mysql_free_result($temp); - $row = mysql_fetch_row($temp = mysql_query("SELECT value+0 FROM config WHERE `key` = 'items_archive_page'",$dbh)); - $items_archive_page = $row[0]; - mysql_free_result($temp); - $row = mysql_fetch_row($temp = mysql_query("SELECT value FROM config WHERE `key` = 'footer'",$dbh)); - $footer = $row[0]; - mysql_free_result($temp); - unset($temp); - unset($row); - echo "

\n"; - echo "News items on front page:
\n"; - echo "News items per archive page:

\n"; - echo "Page footer:
\n"; - echo "
\n"; - echo "\n"; - echo "

\n"; - } else if ($_GET['action'] == 'doconfig') { - if (mysql_query("UPDATE config SET `value` = '".$_POST['items_front_page']."' WHERE `key` = 'items_front_page';",$dbh) && mysql_query("UPDATE config SET `value` = '".$_POST['items_archive_page']."' WHERE `key` = 'items_archive_page';",$dbh) && mysql_query("UPDATE config SET `value` = '".$_POST['footer']."' WHERE `key` = 'footer';",$dbh)) { - echo "

Updated successfully

\n"; - } else { - echo "

Error: Could not apply changes

\n"; - echo "

MySQL said: ".mysql_error()."

\n"; - } - } else if ($_GET['action'] == 'logout') { - echo "

Logout successful

\n"; - } - } -} -?> - - diff --git a/web/site/admin/links.php b/web/site/admin/links.php deleted file mode 100644 index 6b9281c..0000000 --- a/web/site/admin/links.php +++ /dev/null @@ -1,128 +0,0 @@ - - - -Site admin - - -

Submit news | Edit news | Create new user | Edit links | Edit downloads | Edit user profile | Misc config | Logout

-

-\n"; - echo "URL:
\n"; - echo "target:
\n"; - echo "name:
\n"; - echo ""; - echo ""; -} else { -?> - - - -"; - if ($row[3] <> 1) { - echo ""; - } else { - echo ""; - } - if ($row[3] <> $max[0]) { - echo ""; - } else { - echo ""; - } - } while ($row = mysql_fetch_row($query)); -} else { - echo ""; -} -?> -
#URLtargetnameeditdeletemove upmove down
".$row[3]."".$row[0]."".$row[1]."".$row[2]."editdeletemove up---move down---
No links
-

-

-URL
-target
-name
- -
- -

- - diff --git a/web/site/files.php b/web/site/files.php deleted file mode 100644 index 94003f1..0000000 --- a/web/site/files.php +++ /dev/null @@ -1,44 +0,0 @@ - - - - - -\n"; - echo "\n"; - echo "\n"; - } while ($row = mysql_fetch_row($query)); -} else { - echo "\n"; -} -?> -
-Diablo II 1.09d support

"; -} elseif ($filesphp['type'] == 'development') { - echo "

Latest development release: PvPGN ".$filesphp['version']."

"; -} else { - echo "

Latest stable release: PvPGN ".$filesphp['version']."  [Changelog]

"; -} -?> -
\n"; - echo " \n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "
\n"; - echo "".$row[0]."\n"; - echo "
\n"; - echo "
\n"; - echo $row[1]."\n"; - echo "\n"; - echo formatsize($row[2])."\n"; - echo "
 We recommend using the latest development release at this time.
diff --git a/web/site/images/botbar-bg.gif b/web/site/images/botbar-bg.gif deleted file mode 100644 index c3863ef..0000000 Binary files a/web/site/images/botbar-bg.gif and /dev/null differ diff --git a/web/site/images/left01.jpg b/web/site/images/left01.jpg deleted file mode 100644 index 551028f..0000000 Binary files a/web/site/images/left01.jpg and /dev/null differ diff --git a/web/site/images/left02.jpg b/web/site/images/left02.jpg deleted file mode 100644 index d35101b..0000000 Binary files a/web/site/images/left02.jpg and /dev/null differ diff --git a/web/site/images/left03.jpg b/web/site/images/left03.jpg deleted file mode 100644 index 2c1c90a..0000000 Binary files a/web/site/images/left03.jpg and /dev/null differ diff --git a/web/site/images/left04.jpg b/web/site/images/left04.jpg deleted file mode 100644 index 7ed7a2d..0000000 Binary files a/web/site/images/left04.jpg and /dev/null differ diff --git a/web/site/images/topbar-bg.gif b/web/site/images/topbar-bg.gif deleted file mode 100644 index 631409b..0000000 Binary files a/web/site/images/topbar-bg.gif and /dev/null differ diff --git a/web/site/includes/about.htm b/web/site/includes/about.htm deleted file mode 100644 index 2c30eb6..0000000 --- a/web/site/includes/about.htm +++ /dev/null @@ -1,23 +0,0 @@ -
 
-

- What is PvPGN? -

-
-

PvPGN (Player vs Player Gaming Network) is a bnetd based gaming network server emulation project. It currently supports all Battle.net games (such as StarCraft, Diablo II, and Warcraft III), and most Westwood Online clients (Tiberian Sun, Red Alert 2, Yuri's Revenge). It gives you the power to run your own server, manage your own users, run your own tournaments, etc.

-

Some common uses of a PvPGN server:

-
    -
  • When wanting to have a small community with local users and small ladders (lots of internet cafes do that)
  • -
  • For people who want to play on a LAN but with Battle.net-like statistics
  • -
  • For people who find Battle.net too slow or laggy and want to play on a local server with no lag
  • -
-

It puts you as a "System Administrator" in control. Use a PvPGN server to host your own LAN parties or put the server online and on the internet for everyone. You can run tournaments, have your own local competition ladders. The power is in your hands.

-
-

- Where do I start? -

-
-

- If you are interested in setting up your own PvPGN server, start here.
- If you are a gamer who wants to play on a PvPGN server, start here. -

-
diff --git a/web/site/includes/help.htm b/web/site/includes/help.htm deleted file mode 100644 index 2d76a55..0000000 --- a/web/site/includes/help.htm +++ /dev/null @@ -1,22 +0,0 @@ - - - - - -
-

Getting help

-

Need help using PvPGN? Here are your options:

-

Documentation. This is where you should start. The documentation is currently under construction although constantly growing, and it is definately helpful.

-

PvPGN Wiki. Further documentation and help can be found in the wiki.

-

pvpgn-users mailing list. Get help from other users. Sign up here.

-

PvPGN Forums. If you can't figure out your problem yourself (after reading through the documentation), then you should try the forums at http://forums.pvpgn.org. Before posting for help, please search the forums to see if your question has already been answered as it is annoying for us to answer the same question over and over again.

-

PvPGN IRC. Channel #pvpgn on irc.pvpgn.org. You can chat with other PvPGN users and the developers there.

- -
-

Giving help

-

PvPGN is a volunteer effort. Here's how you can help:

-

The pvpgn-dev mailing list. Whether you're a potential developer, tester, or just want to know what's going on with PvPGN, anyone interested in PvPGN development should join the pvpgn-dev mailing list. We will occasionally ask for new code to be tested and get your feedback, as well as discussing new features, bugs, new releases, etc.

-

Developers. PvPGN has very few active developers and needs a lot more! If you can code C, then the best way to give something back to the PvPGN community is to become a developer. Start by reading the README.DEV document.

-

Testing. PvPGN is always looking for good testers (see above)

-

Documentation. The project is always short on people willing to write documentation.

-
diff --git a/web/site/includes/sqlerror.htm b/web/site/includes/sqlerror.htm deleted file mode 100644 index 4669f4a..0000000 --- a/web/site/includes/sqlerror.htm +++ /dev/null @@ -1,85 +0,0 @@ - - - - PvPGN - - - - - - - - -
- - - - - - - - - -
- - - -
-
- - - - -
-   -
-
-
- - - - - -
-
- -
-
-

- Error -

-

- There seems to be a problem with the MySQL server. Please try again later -

-
-
- - - - - - -
-   - - - - - - - - -
- Hosted -
- by -
-
- - BerliOS - -
-
- diff --git a/web/site/includes/viewnews.php b/web/site/includes/viewnews.php deleted file mode 100644 index e3152bd..0000000 --- a/web/site/includes/viewnews.php +++ /dev/null @@ -1,80 +0,0 @@ - $total_newsitems) { - $limit = $items_front_page .','. $items_archive_page; - $curpage = 1; -} else { - $limit = $_GET['start'] .','. $items_archive_page; - if (!is_int($curpage = ((($_GET['start'] - $items_front_page) / $items_archive_page) + 1))) { - $curpage = 0; - } -} - -$query = mysql_query("SELECT t1.username,t1.email,t2.timestamp,t2.subject,t2.text FROM users AS t1, news AS t2 WHERE t1.uid = t2.poster ORDER BY t2.timestamp DESC LIMIT ".$limit.";",$dbh); - -if ($row = mysql_fetch_row($query)) { - do { - echo " "; - echo " "; - echo "
"; - echo " " . $row[3]. ""; - echo "
Posted by ". $row[0] ." on ".date($dateformat,$row[2])."

"; - echo " " . str_replace("\n","
\n",str_replace("changelog","changelog",$row[4])) . "
"; - echo "
"; - echo "
 
"; - echo "
 
"; - } while ($row = mysql_fetch_row($query)); - mysql_free_result($query); -} else { - echo "
No news found
\n"; -} -if ($_GET['page'] == 'newsarchive') { -?> - - - - -
- Page: -".round($x+1).""; - } - } -?> -

- - - - - -
- News archive -

- diff --git a/web/site/index.php b/web/site/index.php deleted file mode 100644 index 041ae14..0000000 --- a/web/site/index.php +++ /dev/null @@ -1,293 +0,0 @@ -\n"; - $time = microtime_float() - $time_start; - echo " Page generation time: ".sprintf("%2.2f",$time)." seconds\n"; - echo "\n"; - echo ""; - echo ""; - die(); -} -mysql_select_db($dbname,$dbh); - -if (!isset($_GET['page'])) { - $_GET['page'] = 'index'; -} - -$query = mysql_query("SELECT title FROM titles WHERE `page` = '".$_GET['page']."';",$dbh); -if ($row = mysql_fetch_row($query)) { - $title = $row[0]; - mysql_free_result($query); - unset($query); - unset($row); -} else { - die('Hacking attempt!'); -} -?> - - - - <?php echo $title; ?> - - - - - - - - -
- - - - - - - - - -
- - - -
-
- - - - -
- - - \n"; - } - mysql_free_result($query); - unset($query); - unset($row); - unset($linkwidth); - ?> - -
-
-
-
- - - - - -
-
- \n"; - ?> -
-
- $mb ) { - $mysize = sprintf ("%01.2f",$size/$mb) . " MB"; - } elseif ( $size >= 1024 ) { - $mysize = sprintf ("%01.2f",$size/1024) . " KB"; - } else { - $mysize = $size . " bytes"; - } - return $mysize; - } - - // Check to see if there is a development release currently - if ($latest_development <> 0) { - // Pass some instructions to files.php and run it - $filesphp = array( - 'type' => 'development', - 'version' => $latest_development); - include('files.php'); - } - // We will assume that there will always be a stable release - $filesphp = array( - 'type' => 'stable', - 'version' => $latest_stable); - include('files.php'); - // And finally, d2pack109 - $filesphp = array( - 'type' => 'd2pack109', - 'version' => $latest_d2pack109); - include('files.php'); - - // Show downloads for support files. There is no reason to keep these in a database - // cos they rarely change. - ?> - - - - - - - - - - - - - - - - -
-

Support files

-
  - - - - - -
- pvpgn-support-1.2.tar.gz -
-
- Support files - - 123.09 KB -
  - - - - - - -
- pvpgn-support-1.2.zip -
-
- Support files - - 125.11 KB -

- - - - -
- More files... -
-
- \n"; - $changelog = file('includes/version-history.txt'); - $changelog[0] = 'skipme'; - $changelog[1] = 'skipme'; - foreach ($changelog as $line) { - $line = trim($line); - if ($line == 'skipme') { - continue; - } elseif (substr($line,0,1) == '[') { - $pos = strpos($line,']'); - echo "".substr($line,0,$pos+1).""; - echo substr($line,$pos+2)."
\n"; - } elseif (substr($line,0,13) == 'Changelog for' || substr($line,0,13) == 'ChangeLog for') { - echo "$line\n"; - } elseif (ereg('^========================+', $line)) { - echo "$line
\n"; - } else { - echo $line . "
\n"; - } - } - echo "

\n"; - } else if ($_GET['page'] == 'about') { - // "What is PvPGN?" page - readfile('includes/about.htm'); - } else if ($_GET['page'] == 'help') { - // "Help" page - echo "
 
\n"; - readfile('includes/help.htm'); - } else { - // To show the news page, we just include viewnews.php - echo "
 
"; - include('includes/viewnews.php'); - } - ?> -
-
- - - - - - -
-   - - - - - - - - -
- Hosted -
- by -
-
- - BerliOS - -
-
- - - - diff --git a/web/site/pvpgn.css b/web/site/pvpgn.css deleted file mode 100644 index d00f16e..0000000 --- a/web/site/pvpgn.css +++ /dev/null @@ -1,86 +0,0 @@ -body { - margin-left: 0px; - margin-top: 0px; - margin-right: 0px; - margin-bottom: 0px; - background-color: #000000; - color: #FFFFFF; -} -a { - color: #FFB019; - text-decoration: underline; -} -a.link { - display: block; - text-decoration: none; - font-family: Arial, Helvetica, sans-serif; - font-weight: bold; - font-size: 12px; - color: #FFB019; - BORDER: none; -} -a.link:hover { - background-color: #333333; -} -a.link2 { - font-weight: bold; - font-family: Arial, Helvetica, sans-serif; - font-size: 13px; - color: #FFB019; - text-decoration: none; -} -.text13 { - font-family: Arial, Helvetica, sans-serif; - font-size: 13px; - color: #FFFFFF; -} -.text12 { - font-family: Arial, Helvetica, sans-serif; - font-size: 12px; - color: #FFFFFF; -} -.text9 { - font-family: Arial, Helvetica, sans-serif; - font-size: 9px; - color: #FFFFFF; -} -.helptitle { - font-family: Arial, Helvetica, sans-serif; - font-size: 18px; - color: #FFB019; -} -.newstitle { - font-family: Arial, Helvetica, sans-serif; - font-size: 13px; - color: #FFB019; -} -.newsarchive { - text-align: center; - font-family: Arial, Helvetica, sans-serif; - font-size: 13px; - color: #FFFFFF; -} -.hostedby { - font-family: Arial, Helvetica, sans-serif; - font-size: 9px; - color: #FFFFFF; - text-align: right; -} -.footer { - font-size: 9px; - color: #666666; - font-family: Verdana, Arial, Helvetica, sans-serif; - text-align: center; - border: 0px; -} -td.topbar { - height: 68px; - vertical-align: bottom; - background-image: url(images/topbar-bg.gif); -} -td.botbar { - height: 63px; - vertical-align: top; - background-image: url(images/botbar-bg.gif); - text-align: right; -}