reorganize files, only pvpgn source here now

This commit is contained in:
HarpyWar 2014-02-03 11:02:09 +04:00
parent a66afd0d43
commit 34262706ea
850 changed files with 1624 additions and 38364 deletions

View file

View file

View file

@ -18,7 +18,6 @@ New commands
* `/save` immediately save changes of accounts and clans from the cache to a storage (useful for testing) <sup>[commit](https://github.com/HarpyWar/pvpgn/commit/be8d65d16f910b2090b0db9e7eb2c043b816dae7)</sup>
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
--

View file

File diff suppressed because it is too large Load diff

View file

@ -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 <gcbirzan@wolfheart.ro> (Debian packages)
- Dorin Lazar <spooky_cbs@yahoo.com> (RPMs)
- Mihai Maties <mihai@xcyb.org> (RPMs & src.rpm snapshot script)
- Radu Radoveneanu <rakware@go.ro> (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.

View file

@ -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

View file

@ -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)

View file

@ -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

View file

@ -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 $*

View file

@ -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

View file

@ -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<LightDarkGreen '<'"
# Set to non-zero to allow creation of new realm character
allow_newchar = 1
# Do you want d2cs to check client for multilogin for security reason?
check_multilogin = 0
# Maxinum number of character per account
# Max allowed value is 21 (enforced by server)
maxchar = 8
# Character sorting. Options are: level, mtime, name, none. (none assumed if
# not specified).
#charlist_sort = "none"
# Do we need ascending or descending order for charlist?
#charlist_sort_order = "ASC"
# Maxinum number of games will be shown in join game list
# Zero = infinite
maxgamelist = 20
# Set to non-zero to allow show all games with difficulty < character difficulty
# Otherwise, only game with difficulty = character difficulty will be shown
gamelist_showall = 0
# Maxinum time in seconds that a user can idle
# Zero = infinite
idletime = 3600
# Amount of time to delay shutting down server in seconds.
shutdown_delay = 300
# Amount of time delay period is decremented by either a SIGTERM or SIGINT
# (control-c) signal in seconds.
shutdown_decr = 60
#
#################################################################################
#################################################################################
# Internal System Settings #
# You may just ignore them and use the default value #
#-------------------------------------------------------------------------------#
#
# How often will the server purge all list to clean unused data (in seconds)
listpurgeinterval = 300
# How often will the server check game queues (in seconds)
gqcheckinterval = 60
# How often will the server retry to connect to bnetd
# when connection lost (in seconds)
s2s_retryinterval = 10
# How long time the s2s connection will timeout
s2s_timeout = 10
# How often the server will check server queues for expired data
sq_checkinterval = 300
# How long time will a server queue data expire
sq_timeout = 300
# Game serer binary files checksum, use zero to skip this checking
d2gs_checksum = 0
# Game server version, use zero to skip this checking
d2gs_version = 0
# Game server password
d2gs_password = ""
# Maxinum number of second that a game will be shown on list( zero = infinite )
game_maxlifetime = 0
# A game will be automatically destroied after how long time idle
max_game_idletime = 0
# Allow Limitation created game with password, player number or level limit?
allow_gamelimit = 1
# Ladder refresh time
ladder_refresh_interval = 3600
# server to server connection max idle time in seconds
s2s_idletime = 300
# server to server connection keepalive interval
s2s_keepalive_interval = 60
# all connection timeout check interval
timeout_checkinterval = 60
# game server restart interval
d2gs_restart_delay = 300
#
#################################################################################

View file

@ -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 = var\d2cs.log
charsavedir = var\charsave
charinfodir = var\charinfo
bak_charsavedir = var\bak\charsave
bak_charinfodir = var\bak\charinfo
ladderdir = var\ladders
newbiefile = files\newbie.save
transfile = conf\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<LightDarkGreen '<'"
# Set to non-zero to allow creation of new realm character
allow_newchar = 1
# Do you want d2cs to check client for multilogin for security reason?
check_multilogin = 0
# Maxinum number of character per account
# Max allowed value is 21 (enforced by server)
maxchar = 8
# Character sorting. Options are: level, mtime, name, none. (none assumed if
# not specified).
#charlist_sort = "none"
# Do we need ascending or descending order for charlist?
#charlist_sort_order = "ASC"
# Maxinum number of games will be shown in join game list
# Zero = infinite
maxgamelist = 20
# Set to non-zero to allow show all games with difficulty < character difficulty
# Otherwise, only game with difficulty = character difficulty will be shown
gamelist_showall = 0
# Maxinum time in seconds that a user can idle
# Zero = infinite
idletime = 3600
# Amount of time to delay shutting down server in seconds.
shutdown_delay = 300
# Amount of time delay period is decremented by either a SIGTERM or SIGINT
# (control-c) signal in seconds.
shutdown_decr = 60
#
#################################################################################
#################################################################################
# Internal System Settings #
# You may just ignore them and use the default value #
#-------------------------------------------------------------------------------#
#
# How often will the server purge all list to clean unused data (in seconds)
listpurgeinterval = 300
# How often will the server check game queues (in seconds)
gqcheckinterval = 60
# How often will the server retry to connect to bnetd
# when connection lost (in seconds)
s2s_retryinterval = 10
# How long time the s2s connection will timeout
s2s_timeout = 10
# How often the server will check server queues for expired data
sq_checkinterval = 300
# How long time will a server queue data expire
sq_timeout = 300
# Game serer binary files checksum, use zero to skip this checking
d2gs_checksum = 0
# Game server version, use zero to skip this checking
d2gs_version = 0
# Game server password
d2gs_password = ""
# Maxinum number of second that a game will be shown on list( zero = infinite )
game_maxlifetime = 0
# A game will be automatically destroied after how long time idle
max_game_idletime = 0
# Allow Limitation created game with password, player number or level limit?
allow_gamelimit = 1
# Ladder refresh time
ladder_refresh_interval = 3600
# server to server connection max idle time in seconds
s2s_idletime = 300
# server to server connection keepalive interval
s2s_keepalive_interval = 60
# all connection timeout check interval
timeout_checkinterval = 60
# game server restart interval
d2gs_restart_delay = 300
#
#################################################################################

View file

@ -1,104 +0,0 @@
#################################################################################
# d2dbs.conf - Configuration file for the Diablo2 Game database 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 #
#-------------------------------------------------------------------------------#
# 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.
# dbs default listening port is 6114
servaddrs = 0.0.0.0:6114
# This is a comma delimited list of game servers
#gameservlist = your.gameserver,another.gameserver
# #
#################################################################################
#################################################################################
# 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/d2dbs.log
logfile-gs = /usr/local/var/d2dbs-gs.log
charsavedir = /usr/local/var/charsave
charinfodir = /usr/local/var/charinfo
ladderdir = /usr/local/var/ladders
bak_charsavedir = /usr/local/var/bak/charsave
bak_charinfodir = /usr/local/var/bak/charinfo
# #
#################################################################################
#################################################################################
# Misc #
#-------------------------------------------------------------------------------#
# #
# Ladder save interval
laddersave_interval = 3600
# Time that allow characters create after it insert into ladder
# These code should be rewritted to support string formmated time
ladderinit_time = 0
# create extra ladder file in XML format that can be parsed more easy
# 0 = turn extra output off (default)
# 1 = turn on the XML output
XML_ladder_output = 0
# Amount of time to delay shutting down server in seconds.
shutdown_delay = 360
# Amount of time delay period is decremented by either a SIGTERM or SIGINT
# (control-c) signal in seconds.
shutdown_decr = 60
# connection max idle time in seconds
idletime = 300
# connection keep alive interval
keepalive_interval = 60
# connection time out check interval
timeout_checkinterval = 60
# experience threshold, minimum experience needed to register on the ladder
ladderupdate_threshold = 0
# This setting activates a workaround for the well known "Lvl 100" bug.
# It should be activated for mods where the max level is greater than 99.
# Activating this should work for mods with any max level
# If level is greater than 255, it will be set to 255
# 0 = deactivated
# 1 = activated
difficulty_hack = 0
# #
#################################################################################

View file

@ -1,104 +0,0 @@
#################################################################################
# d2dbs.conf - Configuration file for the Diablo2 Game database 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 #
#-------------------------------------------------------------------------------#
# 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.
# dbs default listening port is 6114
servaddrs = 0.0.0.0:6114
# This is a comma delimited list of game servers
#gameservlist = your.gameserver,another.gameserver
# #
#################################################################################
#################################################################################
# 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 = var\d2dbs.log
logfile-gs = var\d2dbs-gs.log
charsavedir = var\charsave
charinfodir = var\charinfo
ladderdir = var\ladders
bak_charsavedir = var\bak\charsave
bak_charinfodir = var\bak\charinfo
# #
#################################################################################
#################################################################################
# Misc #
#-------------------------------------------------------------------------------#
# #
# Ladder save interval
laddersave_interval = 3600
# Time that allow characters create after it insert into ladder
# These code should be rewritted to support string formmated time
ladderinit_time = 0
# create extra ladder file in XML format that can be parsed more easy
# 0 = turn extra output off (default)
# 1 = turn on the XML output
XML_ladder_output = 0
# Amount of time to delay shutting down server in seconds.
shutdown_delay = 360
# Amount of time delay period is decremented by either a SIGTERM or SIGINT
# (control-c) signal in seconds.
shutdown_decr = 60
# connection max idle time in seconds
idletime = 300
# connection keep alive interval
keepalive_interval = 60
# connection time out check interval
timeout_checkinterval = 60
# experience threshold, minimum experience needed to register on the ladder
ladderupdate_threshold = 0
# This setting activates a workaround for the well known "Lvl 100" bug.
# It should be activated for mods where the max level is greater than 99.
# Activating this should work for mods with any max level
# If level is greater than 255, it will be set to 255
# 0 = deactivated
# 1 = activated
difficulty_hack = 0
# #
#################################################################################

View file

@ -1,25 +0,0 @@
D2Pack109 Win32 MinGW Compile Instructions
This file explains how to compile D2Pack109 for Win32 using MinGW
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
1. Download and install 'MinGW-3.1.0-1.exe' to 'C:\MinGW'
http://prdownloads.sf.net/mingw/MinGW-3.1.0-1.exe
2. Download and extract 'w32api-3.2.tar.gz' to 'C:\MinGW"
http://prdownloads.sf.net/mingw/w32api-3.2.tar.gz
3. Download 'UnxUtils.zip' and extract the following files
(install.exe and rm.exe) to 'C:\MinGW\bin'
http://unxutils.sourceforge.net/UnxUtils.zip
Location of files in UnxUtils.zip
/usr/local/wbin/install.exe
/usr/local/wbin/rm.exe
4. From a command line, change to the Win32-Projects directory
of the D2Pack109 source. Execute 'make_mingw.bat' for command
line options.
5. Compile the desired package, and install.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

View file

@ -1,48 +0,0 @@
PvPGN Install instructions for the Linux/Unix version
-------------------------------------------------------
1. First get your hands on a PvPGN source tarball or a binary package (RPM/etc).
If you got the source follow instructions bellow, if you got a binary package
jump to step 4
2. Unpack the tarball, change current directory to the source directory (ex.
pvpgn-<version>/src) and run configure. You will need to provide configure with
your custom options, ex.
./configure --prefix=<path>
It will configure the source distribution to compile and install in the <path>
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-<ver>.rpm
or
$ installpkg pvpgn-<ver>.tgz
or
$ dpkg -i pvpgn-<ver>.deb
After you install the binary package you will need to adjust PvPGN configuration
files (usually installed in /etc/pvpgn dir). Have fun!

View file

@ -1,5 +0,0 @@
To Install:
run the install.bat in the main dir
To Uninstall:
run the uninstall.bat in the main dir

View file

@ -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:

View file

@ -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
* <ghost@aladdin.com>. 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
<ceder@lysator.liu.se>)
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
<tgl@sss.pgh.pa.us>
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 <pinard@iro.umontreal.ca>;
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 <pinard@iro.umontreal.ca>;
properly erase prototype args in function parameters,
contributed by Jim Avera <jima@netcom.com>;
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 <config.h>
#endif
#include <stdio.h>
#include <ctype.h>
#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 <string.h>
# else
# include <strings.h>
# endif
#else /* not HAVE_CONFIG_H */
/* Otherwise do it the hard way */
# ifdef BSD
# include <strings.h>
# else
# ifdef VMS
extern int strlen(), strncmp();
# else
# include <string.h>
# endif
# endif
#endif /* not HAVE_CONFIG_H */
#if STDC_HEADERS
# include <stdlib.h>
#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 <malloc.h>
# 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<endfn-startfn; i++) fprintf(stderr,"%c",startfn[i]); }
fprintf(stderr,"\n");
fprintf(stderr,"p=%s\n",p);
#endif
p++; /* skip ( */
p = skipspace(p, 1);
if (*p=='*') /* maybe a function pointer */
{
startfn = p;
while (*p!='\0' && *p!=')')
p++;
if (*p=='\0')
return -1; /* wraps to the next line */
endfn = p-1;
if (contin!=-1) contin = 3;
}
else
if (!isidfirstchar(*p))
return 0; /* ok... no parameters anyway */
/* Check that the apparent function name isn't a keyword. */
/* We only need to check for keywords that could be followed */
/* by a left parenthesis (which, unfortunately, is most of them). */
if (contin != 3)
{ static char *words[] =
{ "asm", "auto", "case", "char", "const", "double",
"extern", "float", "for", "if", "int", "long",
"register", "return", "short", "signed", "sizeof",
"static", "switch", "typedef", "unsigned",
"void", "volatile", "while", 0
};
char **key = words;
char *kp;
int len = endfn - startfn;
while ( (kp = *key) != 0 )
{ if ( strlen(kp) == len && !strncmp(kp, startfn, len) )
{
fprintf(stderr,"it was a keyword\n");
return 0; /* name is a keyword */
}
key++;
}
}
/*
* If the last significant character was a ), we need to count
* parentheses, because it might be part of a formal parameter
* that is a procedure.
*/
if (contin > 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<startfn; p++)
fprintf(out,"%c",*p);
while (*(endfn++) != '(');
top: p = endfn;
breaks = (char **)malloc(sizeof(char *) * num_breaks * 2);
if ( breaks == 0 )
{ /* Couldn't allocate break table, give up */
fprintf(stderr, "Unable to allocate break table!\n");
fputs(startfn, out);
return -1;
}
btop = breaks + num_breaks * 2 - 2;
bp = breaks;
/* Parse the argument list */
do
{ int level = 0;
char *lp = NULL;
char *rp;
char *end = NULL;
if ( bp >= 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;
}

View file

@ -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 <stdarg.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
/* 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
])

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -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 <sys/types.h>
#include <unistd.h>
#include <termios.h>],
[/* 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)])
])

View file

@ -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 <sys/types.h>
# include <termios.h>
# ifdef TIOCGWINSZ
yes
# endif
], gwinsz_in_termios_h=yes)
fi
if test $gwinsz_in_termios_h = no; then
AC_EGREP_CPP([yes],
[#include <sys/types.h>
# include <sys/ioctl.h>
# 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
])

View file

@ -1,4 +0,0 @@
#!/bin/sh
autoconf
autoheader

View file

@ -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 <stddef.h>
#else
# ifndef NULL
# define NULL ((void *)0)
# endif
#endif
#ifdef STDC_HEADERS
# include <stdlib.h>
#else
# ifdef HAVE_MALLOC_H
# include <malloc.h>
# endif
#endif
#ifdef HAVE_STRING_H
# include <string.h>
#else
# ifdef HAVE_STRINGS_H
# include <strings.h>
# endif
#endif
#ifdef HAVE_MEMORY_H
# include <memory.h>
#endif
#include "compat/memset.h"
#include "compat/memcpy.h"
#include "compat/strrchr.h"
#include "compat/strdup.h"
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
#include "compat/socket.h"
#ifdef HAVE_SYS_PARAM_H
# include <sys/param.h>
#endif
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
#include "compat/netinet_in.h"
#ifdef HAVE_ARPA_INET_H
# include <arpa/inet.h>
#endif
#include "compat/inet_aton.h"
#include "compat/inet_ntoa.h"
#ifdef HAVE_NETDB_H
# include <netdb.h>
#endif
#ifdef HAVE_ASSERT_H
# include <assert.h>
#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);
}

View file

@ -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

View file

@ -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 <string.h>
#endif
#ifdef HAVE_MEMORY_H
# include <memory.h>
#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<len-1 && i<1; i++)
dst[i] = (char)(*src)[-i];
dst[i] = '\0';
return 0;
}
extern int bn_short_tag_get(bn_short 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<len-1 && i<2; i++)
dst[i] = (char)(*src)[1-i];
dst[i] = '\0';
return 0;
}
extern int bn_int_tag_get(bn_int 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<len-1 && i<4; i++)
dst[i] = (char)(*src)[3-i];
dst[i] = '\0';
return 0;
}
extern int bn_long_tag_get(bn_long 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<len-1 && i<8; i++)
dst[i] = (char)(*src)[7-i];
dst[i] = '\0';
return 0;
}
/************************************************************/
extern int bn_byte_tag_set(bn_byte * dst, char const * tag)
{
if (!dst)
{
eventlog(eventlog_level_error,__FUNCTION__,"got NULL dst");
return -1;
}
if (!tag)
{
eventlog(eventlog_level_error,__FUNCTION__,"got NULL tag");
return -1;
}
(*dst)[0] = (unsigned char)tag[0];
return 0;
}
extern int bn_short_tag_set(bn_short * dst, char const * tag)
{
if (!dst)
{
eventlog(eventlog_level_error,__FUNCTION__,"got NULL dst");
return -1;
}
if (!tag)
{
eventlog(eventlog_level_error,__FUNCTION__,"got NULL tag");
return -1;
}
(*dst)[0] = (unsigned char)tag[3];
(*dst)[1] = (unsigned char)tag[2];
return 0;
}
extern int bn_int_tag_set(bn_int * dst, char const * tag)
{
if (!dst)
{
eventlog(eventlog_level_error,__FUNCTION__,"got NULL dst");
return -1;
}
if (!tag)
{
eventlog(eventlog_level_error,__FUNCTION__,"got NULL tag");
return -1;
}
(*dst)[0] = (unsigned char)tag[3];
(*dst)[1] = (unsigned char)tag[2];
(*dst)[2] = (unsigned char)tag[1];
(*dst)[3] = (unsigned char)tag[0];
return 0;
}
extern int bn_long_tag_set(bn_long * dst, char const * tag)
{
if (!dst)
{
eventlog(eventlog_level_error,__FUNCTION__,"got NULL dst");
return -1;
}
if (!tag)
{
eventlog(eventlog_level_error,__FUNCTION__,"got NULL tag");
return -1;
}
(*dst)[0] = (unsigned char)tag[7];
(*dst)[1] = (unsigned char)tag[6];
(*dst)[2] = (unsigned char)tag[5];
(*dst)[3] = (unsigned char)tag[4];
(*dst)[4] = (unsigned char)tag[3];
(*dst)[5] = (unsigned char)tag[2];
(*dst)[6] = (unsigned char)tag[1];
(*dst)[7] = (unsigned char)tag[0];
return 0;
}
/************************************************************/
extern t_uint8 bn_byte_get(bn_byte const src)
{
t_uint8 temp;
if (!src)
{
eventlog(eventlog_level_error,__FUNCTION__,"got NULL src");
return 0;
}
temp = ((t_uint8)src[0]) ;
return temp;
}
extern t_uint16 bn_short_get(bn_short const src)
{
t_uint16 temp;
if (!src)
{
eventlog(eventlog_level_error,__FUNCTION__,"got NULL src");
return 0;
}
temp = ((t_uint16)src[0]) ;
temp |= ((t_uint16)src[1])<< 8;
return temp;
}
extern t_uint16 bn_short_nget(bn_short const src)
{
t_uint16 temp;
if (!src)
{
eventlog(eventlog_level_error,__FUNCTION__,"got NULL src");
return 0;
}
temp = ((t_uint16)src[1]) ;
temp |= ((t_uint16)src[0])<< 8;
return temp;
}
extern t_uint32 bn_int_get(bn_int const src)
{
t_uint32 temp;
if (!src)
{
eventlog(eventlog_level_error,__FUNCTION__,"got NULL src");
return 0;
}
temp = ((t_uint32)src[0]) ;
temp |= ((t_uint32)src[1])<< 8;
temp |= ((t_uint32)src[2])<<16;
temp |= ((t_uint32)src[3])<<24;
return temp;
}
extern t_uint32 bn_int_nget(bn_int const src)
{
t_uint32 temp;
if (!src)
{
eventlog(eventlog_level_error,__FUNCTION__,"got NULL src");
return 0;
}
temp = ((t_uint32)src[3]) ;
temp |= ((t_uint32)src[2])<< 8;
temp |= ((t_uint32)src[1])<<16;
temp |= ((t_uint32)src[0])<<24;
return temp;
}
#ifdef HAVE_T_LONG
extern t_uint64 bn_long_get(bn_long const src)
{
t_uint64 temp;
if (!src)
{
eventlog(eventlog_level_error,__FUNCTION__,"got NULL src");
return 0;
}
temp = ((t_uint64)src[0]) ;
temp |= ((t_uint64)src[1])<< 8;
temp |= ((t_uint64)src[2])<<16;
temp |= ((t_uint64)src[3])<<24;
temp |= ((t_uint64)src[4])<<32;
temp |= ((t_uint64)src[5])<<40;
temp |= ((t_uint64)src[6])<<48;
temp |= ((t_uint64)src[7])<<56;
return temp;
}
#endif
extern t_uint32 bn_long_get_a(bn_long const src)
{
t_uint32 temp;
if (!src)
{
eventlog(eventlog_level_error,__FUNCTION__,"got NULL src");
return 0;
}
temp = ((t_uint32)src[4]) ;
temp |= ((t_uint32)src[5])<< 8;
temp |= ((t_uint32)src[6])<<16;
temp |= ((t_uint32)src[7])<<24;
return temp;
}
extern t_uint32 bn_long_get_b(bn_long const src)
{
t_uint32 temp;
if (!src)
{
eventlog(eventlog_level_error,__FUNCTION__,"got NULL src");
return 0;
}
temp = ((t_uint32)src[0]) ;
temp |= ((t_uint32)src[1])<< 8;
temp |= ((t_uint32)src[2])<<16;
temp |= ((t_uint32)src[3])<<24;
return temp;
}
/************************************************************/
extern int bn_byte_set(bn_byte * dst, t_uint8 src)
{
if (!dst)
{
eventlog(eventlog_level_error,__FUNCTION__,"got NULL dst");
return -1;
}
(*dst)[0] = (unsigned char)((src ) );
return 0;
}
extern int bn_short_set(bn_short * dst, t_uint16 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) );
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));
}

View file

@ -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

View file

@ -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

View file

@ -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 <stddef.h>
#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 */

View file

@ -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 <stdio.h>
#ifdef HAVE_STDDEF_H
# include <stddef.h>
#else
# ifndef NULL
# define NULL ((void *)0)
# endif
#endif
#include <errno.h>
#include "compat/strerror.h"
#ifdef HAVE_STRING_H
# include <string.h>
#else
# ifdef HAVE_STRINGS_H
# include <strings.h>
# endif
#endif
#include "compat/strcasecmp.h"
#ifdef HAVE_STDARG_H
# include <stdarg.h>
#else
# ifdef HAVE_VARARGS_H
# include <varargs.h>
# endif
#endif
#ifdef TIME_WITH_SYS_TIME
# include <sys/time.h>
# include <time.h>
#else
# ifdef HAVE_SYS_TIME_H
# include <sys/time.h>
# else
# include <time.h>
# endif
#endif
#include "compat/strftime.h"
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#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);
}

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