daily work

This commit is contained in:
Olaf Rempel 2006-02-19 18:45:56 +01:00
parent 3593290f71
commit fc57caaa6d
14 changed files with 412 additions and 88 deletions

1
.gitignore vendored
View File

@ -2,3 +2,4 @@
*.d
hlswmaster
hlswmaster.log
doc/*

269
Doxyfile Normal file
View File

@ -0,0 +1,269 @@
# Doxyfile 1.4.4
#---------------------------------------------------------------------------
# Project related configuration options
#---------------------------------------------------------------------------
PROJECT_NAME = hlswmaster-ng
PROJECT_NUMBER =
OUTPUT_DIRECTORY = doc
CREATE_SUBDIRS = NO
OUTPUT_LANGUAGE = English
USE_WINDOWS_ENCODING = NO
BRIEF_MEMBER_DESC = YES
REPEAT_BRIEF = YES
ABBREVIATE_BRIEF = "The $name class" \
"The $name widget" \
"The $name file" \
is \
provides \
specifies \
contains \
represents \
a \
an \
the
ALWAYS_DETAILED_SEC = NO
INLINE_INHERITED_MEMB = NO
FULL_PATH_NAMES = YES
STRIP_FROM_PATH = /home/razor/projects/linux-c++/hlswmaster-ng/
STRIP_FROM_INC_PATH =
SHORT_NAMES = NO
JAVADOC_AUTOBRIEF = NO
MULTILINE_CPP_IS_BRIEF = NO
DETAILS_AT_TOP = NO
INHERIT_DOCS = YES
DISTRIBUTE_GROUP_DOC = NO
SEPARATE_MEMBER_PAGES = NO
TAB_SIZE = 8
ALIASES =
OPTIMIZE_OUTPUT_FOR_C = NO
OPTIMIZE_OUTPUT_JAVA = NO
SUBGROUPING = YES
#---------------------------------------------------------------------------
# Build related configuration options
#---------------------------------------------------------------------------
EXTRACT_ALL = YES
EXTRACT_PRIVATE = YES
EXTRACT_STATIC = YES
EXTRACT_LOCAL_CLASSES = YES
EXTRACT_LOCAL_METHODS = NO
HIDE_UNDOC_MEMBERS = NO
HIDE_UNDOC_CLASSES = NO
HIDE_FRIEND_COMPOUNDS = NO
HIDE_IN_BODY_DOCS = NO
INTERNAL_DOCS = NO
CASE_SENSE_NAMES = YES
HIDE_SCOPE_NAMES = NO
SHOW_INCLUDE_FILES = YES
INLINE_INFO = YES
SORT_MEMBER_DOCS = YES
SORT_BRIEF_DOCS = NO
SORT_BY_SCOPE_NAME = NO
GENERATE_TODOLIST = YES
GENERATE_TESTLIST = YES
GENERATE_BUGLIST = YES
GENERATE_DEPRECATEDLIST= YES
ENABLED_SECTIONS =
MAX_INITIALIZER_LINES = 30
SHOW_USED_FILES = YES
SHOW_DIRECTORIES = YES
FILE_VERSION_FILTER =
#---------------------------------------------------------------------------
# configuration options related to warning and progress messages
#---------------------------------------------------------------------------
QUIET = NO
WARNINGS = YES
WARN_IF_UNDOCUMENTED = YES
WARN_IF_DOC_ERROR = YES
WARN_NO_PARAMDOC = NO
WARN_FORMAT = "$file:$line: $text"
WARN_LOGFILE =
#---------------------------------------------------------------------------
# configuration options related to the input files
#---------------------------------------------------------------------------
INPUT = /home/razor/projects/linux-c++/hlswmaster-ng
FILE_PATTERNS = *.c \
*.cc \
*.cxx \
*.cpp \
*.c++ \
*.java \
*.ii \
*.ixx \
*.ipp \
*.i++ \
*.inl \
*.h \
*.hh \
*.hxx \
*.hpp \
*.h++ \
*.idl \
*.odl \
*.cs \
*.php \
*.php3 \
*.inc \
*.m \
*.mm \
*.dox \
*.C \
*.CC \
*.C++ \
*.II \
*.I++ \
*.H \
*.HH \
*.H++ \
*.CS \
*.PHP \
*.PHP3 \
*.M \
*.MM
RECURSIVE = NO
EXCLUDE =
EXCLUDE_SYMLINKS = NO
EXCLUDE_PATTERNS =
EXAMPLE_PATH =
EXAMPLE_PATTERNS = *
EXAMPLE_RECURSIVE = NO
IMAGE_PATH =
INPUT_FILTER =
FILTER_PATTERNS =
FILTER_SOURCE_FILES = NO
#---------------------------------------------------------------------------
# configuration options related to source browsing
#---------------------------------------------------------------------------
SOURCE_BROWSER = YES
INLINE_SOURCES = YES
STRIP_CODE_COMMENTS = YES
REFERENCED_BY_RELATION = NO
REFERENCES_RELATION = NO
USE_HTAGS = NO
VERBATIM_HEADERS = YES
#---------------------------------------------------------------------------
# configuration options related to the alphabetical class index
#---------------------------------------------------------------------------
ALPHABETICAL_INDEX = NO
COLS_IN_ALPHA_INDEX = 5
IGNORE_PREFIX =
#---------------------------------------------------------------------------
# configuration options related to the HTML output
#---------------------------------------------------------------------------
GENERATE_HTML = YES
HTML_OUTPUT = html
HTML_FILE_EXTENSION = .html
HTML_HEADER =
HTML_FOOTER =
HTML_STYLESHEET =
HTML_ALIGN_MEMBERS = YES
GENERATE_HTMLHELP = NO
CHM_FILE =
HHC_LOCATION =
GENERATE_CHI = NO
BINARY_TOC = NO
TOC_EXPAND = NO
DISABLE_INDEX = NO
ENUM_VALUES_PER_LINE = 4
GENERATE_TREEVIEW = YES
TREEVIEW_WIDTH = 250
#---------------------------------------------------------------------------
# configuration options related to the LaTeX output
#---------------------------------------------------------------------------
GENERATE_LATEX = NO
LATEX_OUTPUT = latex
LATEX_CMD_NAME = latex
MAKEINDEX_CMD_NAME = makeindex
COMPACT_LATEX = NO
PAPER_TYPE = a4wide
EXTRA_PACKAGES =
LATEX_HEADER =
PDF_HYPERLINKS = NO
USE_PDFLATEX = NO
LATEX_BATCHMODE = NO
LATEX_HIDE_INDICES = NO
#---------------------------------------------------------------------------
# configuration options related to the RTF output
#---------------------------------------------------------------------------
GENERATE_RTF = NO
RTF_OUTPUT = rtf
COMPACT_RTF = NO
RTF_HYPERLINKS = NO
RTF_STYLESHEET_FILE =
RTF_EXTENSIONS_FILE =
#---------------------------------------------------------------------------
# configuration options related to the man page output
#---------------------------------------------------------------------------
GENERATE_MAN = NO
MAN_OUTPUT = man
MAN_EXTENSION = .3
MAN_LINKS = NO
#---------------------------------------------------------------------------
# configuration options related to the XML output
#---------------------------------------------------------------------------
GENERATE_XML = NO
XML_OUTPUT = xml
XML_SCHEMA =
XML_DTD =
XML_PROGRAMLISTING = YES
#---------------------------------------------------------------------------
# configuration options for the AutoGen Definitions output
#---------------------------------------------------------------------------
GENERATE_AUTOGEN_DEF = NO
#---------------------------------------------------------------------------
# configuration options related to the Perl module output
#---------------------------------------------------------------------------
GENERATE_PERLMOD = NO
PERLMOD_LATEX = NO
PERLMOD_PRETTY = YES
PERLMOD_MAKEVAR_PREFIX =
#---------------------------------------------------------------------------
# Configuration options related to the preprocessor
#---------------------------------------------------------------------------
ENABLE_PREPROCESSING = YES
MACRO_EXPANSION = NO
EXPAND_ONLY_PREDEF = NO
SEARCH_INCLUDES = YES
INCLUDE_PATH =
INCLUDE_FILE_PATTERNS =
PREDEFINED =
EXPAND_AS_DEFINED =
SKIP_FUNCTION_MACROS = YES
#---------------------------------------------------------------------------
# Configuration::additions related to external references
#---------------------------------------------------------------------------
TAGFILES =
GENERATE_TAGFILE =
ALLEXTERNALS = NO
EXTERNAL_GROUPS = YES
PERL_PATH = /usr/bin/perl
#---------------------------------------------------------------------------
# Configuration options related to the dot tool
#---------------------------------------------------------------------------
CLASS_DIAGRAMS = YES
HIDE_UNDOC_RELATIONS = YES
HAVE_DOT = YES
CLASS_GRAPH = YES
COLLABORATION_GRAPH = YES
GROUP_GRAPHS = YES
UML_LOOK = NO
TEMPLATE_RELATIONS = NO
INCLUDE_GRAPH = YES
INCLUDED_BY_GRAPH = YES
CALL_GRAPH = NO
GRAPHICAL_HIERARCHY = YES
DIRECTORY_GRAPH = YES
DOT_IMAGE_FORMAT = png
DOT_PATH =
DOTFILE_DIRS =
MAX_DOT_GRAPH_WIDTH = 1024
MAX_DOT_GRAPH_HEIGHT = 1024
MAX_DOT_GRAPH_DEPTH = 1000
DOT_TRANSPARENT = NO
DOT_MULTI_TARGETS = NO
GENERATE_LEGEND = YES
DOT_CLEANUP = YES
#---------------------------------------------------------------------------
# Configuration::additions related to the search engine
#---------------------------------------------------------------------------
SEARCHENGINE = NO

32
gamelist.cpp Normal file
View File

@ -0,0 +1,32 @@
#include "gamelist.h"
#define DEFAULT_TIMEOUT 180
GameList::GameList(Config& conf)
{
int interval = conf.getInteger("global", "game_timeout", DEFAULT_TIMEOUT);
TimerService::registerTimer(new Timer(new CleanupEvent(this), interval));
}
GameList::~GameList()
{
}
void GameList::cleanup()
{
}
void GameList::addGame()
{
}
long GameList::getLastMod()
{
return 0;
}
Iterator<GameEntry>* GameList::createIterator()
{
return new NullIterator<GameEntry>();
}

View File

@ -1,6 +1,10 @@
#ifndef _GAMELIST_H_
#define _GAMELIST_H_
#include "config.h"
#include "list.h"
#include "timerservice.h"
class GameEntry {
public:
GameEntry();
@ -11,7 +15,7 @@ protected:
GameEntry& operator=(const GameEntry& ge);
private:
struct in_addr addr;
// struct in_addr addr;
int port1;
int port2;
int gameid;
@ -20,12 +24,32 @@ private:
class GameList {
public:
virtual ~GameList() {};
GameList(Config& conf);
~GameList();
virtual void cleanup() {};
void cleanup();
void addGame();
long getLastMod();
Iterator<GameEntry>* createIterator();
protected:
GameList() {}
GameList(const GameList& gl);
GameList& operator=(const GameList& gl);
private:
class CleanupEvent : public Command {
public:
CleanupEvent(GameList* gl) : gl(gl) {}
~CleanupEvent() {}
void execute() { gl->cleanup(); }
private:
GameList* gl;
};
List<GameEntry> glist;
};
#endif // _GAMELIST_H_

View File

@ -2,13 +2,9 @@
#include "netpkt.h"
#include "gameparser.h"
#define DEFAULT_TIMEOUT 180
GameParser::GameParser(Config& conf, RecvQueue& rxQueue, ModuleList& modList)
: rxQueue(rxQueue), modList(modList)
GameParser::GameParser(RecvQueue& rxQueue, ModuleList& modList, GameList& gameList)
: rxQueue(rxQueue), modList(modList), gameList(gameList)
{
int interval = conf.getInteger("global", "game_timeout", DEFAULT_TIMEOUT);
TimerService::registerTimer(new Timer(new CleanupEvent(this), interval));
}
GameParser::~GameParser()
@ -19,7 +15,7 @@ int GameParser::execute(void* arg)
{
while (1) {
NetPkt* pkt = rxQueue.getPkt();
int ret = modList.parse(pkt, this);
int ret = modList.parse(pkt, &gameList);
switch (ret) {
case PKT_REJECT:
@ -36,8 +32,3 @@ int GameParser::execute(void* arg)
}
return 0;
}
void GameParser::cleanup()
{
// LogSystem::log(LOG_DEBUG, "GameParser::cleanup()");
}

View File

@ -1,39 +1,27 @@
#ifndef _GAMEPARSER_H_
#define _GAMEPARSER_H_
#include "gamelist.h"
#include "thread.h"
#include "config.h"
#include "recvqueue.h"
#include "modulelist.h"
#include "timerservice.h"
#include "gamelist.h"
class GameParser : public GameList, public Thread {
class GameParser : public Thread {
public:
GameParser(Config& conf, RecvQueue& rxQueue, ModuleList& modlist);
GameParser(RecvQueue& rxQueue, ModuleList& modlist, GameList& gameList);
~GameParser();
int execute(void* arg);
void cleanup();
protected:
GameParser(const GameParser& rp);
GameParser& operator=(const GameParser& rp);
private:
class CleanupEvent : public Command {
public:
CleanupEvent(GameList* sl) : sl(sl) {}
~CleanupEvent() {}
void execute() { sl->cleanup(); }
private:
GameList* sl;
};
RecvQueue& rxQueue;
ModuleList& modList;
GameList& gameList;
};
#endif // _GAMEPARSER_H_

View File

@ -1,15 +1,14 @@
#include "logging.h"
#include "timerservice.h"
#include "netpkt.h"
#include "gamescanner.h"
#define DEFAULT_INTERVAL 30
GameScanner::GameScanner(Config& conf, ModuleList& modList)
: modList(modList)
GameScanner::GameScanner(Config& conf, ModuleList& modList, RecvQueue& rxqueue)
: modList(modList), rxQueue(rxQueue)
{
msock = new MultiSock(conf);
pktCount = new Semaphore(0);
int interval = conf.getInteger("global", "scan_interval", DEFAULT_INTERVAL);
TimerService::registerTimer(new Timer(new ScanEvent(this), interval));
@ -17,10 +16,6 @@ GameScanner::GameScanner(Config& conf, ModuleList& modList)
GameScanner::~GameScanner()
{
while (!pktList.isEmpty())
delete pktList.get();
delete pktCount;
delete msock;
}
@ -29,11 +24,7 @@ int GameScanner::execute(void* arg)
while (1) {
int fd = msock->waitOnSocket();
NetPkt* pkt = NetPkt::createFromSocket(fd);
if (pkt != NULL) {
pktList.addTail(pkt);
pktCount->post();
}
rxQueue.addPkt(pkt);
}
return 0;
}
@ -42,9 +33,3 @@ void GameScanner::scan()
{
modList.scan(msock);
}
NetPkt* GameScanner::getPkt()
{
pktCount->wait();
return pktList.get();
}

View File

@ -1,27 +1,21 @@
#ifndef _GAMESCANNER_H_
#define _GAMESCANNER_H_
#include "recvqueue.h"
#include "thread.h"
#include "config.h"
#include "modulelist.h"
#include "multisock.h"
#include "semaphore.h"
#include "list.h"
#include "netpkt.h"
#include "recvqueue.h"
#include "timerservice.h"
#include "multisock.h"
class GameScanner : public RecvQueue, public Thread {
class GameScanner : public Thread {
public:
GameScanner(Config& conf, ModuleList& modList);
GameScanner(Config& conf, ModuleList& modList, RecvQueue& rxQueue);
~GameScanner();
void scan();
NetPkt* getPkt();
int execute(void* arg);
void scan();
protected:
GameScanner(const GameScanner& hs);
@ -39,11 +33,8 @@ private:
};
ModuleList& modList;
RecvQueue& rxQueue;
MultiSock* msock;
Semaphore* pktCount;
List<NetPkt> pktList;
};
#endif // _SCANNER_H_

View File

@ -5,6 +5,7 @@
#include "logging.h"
#include "config.h"
#include "recvqueue.h"
#include "gamescanner.h"
#include "gameparser.h"
#include "hlswserver.h"
@ -80,11 +81,13 @@ int main(int argc, char *argv[])
LogSystem::log(LOG_EVERYTIME, "hlswmaster-ng startup (pid:%d)", getpid());
conf.show();
RecvQueue rxQueue;
ModuleList modList(conf);
GameList gameList(conf);
GameScanner scanner(conf, modList);
GameParser parser(conf, scanner, modList);
HlswServer server(conf, parser);
GameScanner scanner(conf, modList, rxQueue);
GameParser parser(rxQueue, modList, gameList);
HlswServer server(conf);
// modList.reg(new ModHalfLife());
// modList.reg(new ModQ3Engine());

View File

@ -25,7 +25,7 @@ HlswServer::HlswPacket::~HlswPacket()
delete next;
}
bool HlswServer::HlswPacket::addGame(void* ptr)
bool HlswServer::HlswPacket::addGame(GameEntry* ge)
{
if (count < 140) {
count++;
@ -47,7 +47,7 @@ void HlswServer::HlswPacket::send(int socket, struct sockaddr_in* dst)
}
}
HlswServer::HlswServer(Config& conf, GameList& slist)
HlswServer::HlswServer(Config& conf)
{
struct sockaddr_in dst;
const char *ip;
@ -108,13 +108,15 @@ int HlswServer::execute(void* arg)
return 0;
}
/*
HlswPacket* newlist;
void HlswServer::rebuild(GameList& glist) {
Iterator<GameEntry>* it = glist.createIterator();
HlswPacket* newlist = NULL;
while (it->hasNext()) {
Data* d = it->next();
if (!newlist || !newlist->add(d))
GameEntry* d = it->next();
if (!newlist || !newlist->addGame(d)) {
newlist = new HlswPacket(newlist);
newlist->add(d);
newlist->addGame(d);
}
}
@ -124,5 +126,5 @@ int HlswServer::execute(void* arg)
mutex.unlock();
delete oldlist;
*/
delete it;
}

View File

@ -10,11 +10,13 @@
class HlswServer : public Thread {
public:
HlswServer(Config& conf, GameList& slist);
HlswServer(Config& conf);
~HlswServer();
int execute(void* arg);
void rebuild(GameList& glist);
protected:
HlswServer(const HlswServer& hs);
HlswServer& operator=(const HlswServer& hs);
@ -25,7 +27,7 @@ private:
HlswPacket(HlswPacket* next);
~HlswPacket();
bool addGame(void* ptr);
bool addGame(GameEntry* ge);
void send(int socket, struct sockaddr_in* dst);
private:

25
recvqueue.cpp Normal file
View File

@ -0,0 +1,25 @@
#include "recvqueue.h"
RecvQueue::RecvQueue()
{
}
RecvQueue::~RecvQueue()
{
while (!pktList.isEmpty())
delete pktList.get();
}
void RecvQueue::addPkt(NetPkt* pkt)
{
if (pkt != NULL) {
pktList.addTail(pkt);
pktCount->post();
}
}
NetPkt* RecvQueue::getPkt()
{
pktCount->wait();
return pktList.get();
}

View File

@ -2,14 +2,24 @@
#define _RECVQUEUE_H_
#include "netpkt.h"
#include "semaphore.h"
#include "list.h"
class RecvQueue {
public:
virtual ~RecvQueue() {};
virtual NetPkt* getPkt() =0;
RecvQueue();
~RecvQueue();
void addPkt(NetPkt* pkt);
NetPkt* getPkt();
protected:
RecvQueue() {};
RecvQueue(const RecvQueue& rq);
RecvQueue& operator=(const RecvQueue& rq);
private:
Semaphore* pktCount;
List<NetPkt> pktList;
};
#endif // _RECVQUEUE_H_

View File

@ -5,10 +5,11 @@
class Semaphore {
public:
Semaphore(int i) { sem_init(&s, 0, i); }
~Semaphore() { sem_destroy(&s); }
void wait() { sem_wait(&s); }
void post() { sem_post(&s); }
Semaphore() { sem_init(&s, 0, 0); }
Semaphore(int i) { sem_init(&s, 0, i); }
~Semaphore() { sem_destroy(&s); }
void wait() { sem_wait(&s); }
void post() { sem_post(&s); }
protected:
Semaphore(const Semaphore& s);