diff -Naur sucs-1.0.0.orig/daemon/daemon.cpp sucs-1.0.0/daemon/daemon.cpp --- sucs-1.0.0.orig/daemon/daemon.cpp 2008-06-16 21:40:32.000000000 +0200 +++ sucs-1.0.0/daemon/daemon.cpp 2008-06-16 21:51:52.000000000 +0200 @@ -22,7 +22,8 @@ #include #include #include - +#include +#include #include "daemon.h" using namespace sucs; @@ -93,6 +94,11 @@ exit(RunProgram()); } +void Daemon::DontDaemonise() +{ + exit(RunProgram()); +} + Daemon::Daemon() { } diff -Naur sucs-1.0.0.orig/daemon/daemon.h sucs-1.0.0/daemon/daemon.h --- sucs-1.0.0.orig/daemon/daemon.h 2008-06-16 21:40:32.000000000 +0200 +++ sucs-1.0.0/daemon/daemon.h 2008-06-16 21:51:03.000000000 +0200 @@ -28,7 +28,7 @@ void Daemonise(); // Does nothing except run the derived program. - void DontDaemonise() { exit(RunProgram()); } + void DontDaemonise(); Daemon(); virtual ~Daemon(); diff -Naur sucs-1.0.0.orig/ipc/mutex.cpp sucs-1.0.0/ipc/mutex.cpp --- sucs-1.0.0.orig/ipc/mutex.cpp 2008-06-16 21:40:31.000000000 +0200 +++ sucs-1.0.0/ipc/mutex.cpp 2008-06-16 21:47:30.000000000 +0200 @@ -18,6 +18,7 @@ #include #include +#include using namespace std; #include diff -Naur sucs-1.0.0.orig/ipc/sema.cpp sucs-1.0.0/ipc/sema.cpp --- sucs-1.0.0.orig/ipc/sema.cpp 2008-06-16 21:40:31.000000000 +0200 +++ sucs-1.0.0/ipc/sema.cpp 2008-06-16 21:44:42.000000000 +0200 @@ -15,6 +15,8 @@ #pragma implementation #include +#include +#include using namespace std; #include diff -Naur sucs-1.0.0.orig/kohonen/kohonendata.cpp sucs-1.0.0/kohonen/kohonendata.cpp --- sucs-1.0.0.orig/kohonen/kohonendata.cpp 2008-06-16 21:40:32.000000000 +0200 +++ sucs-1.0.0/kohonen/kohonendata.cpp 2008-06-16 21:57:53.000000000 +0200 @@ -17,6 +17,7 @@ #include #include #include +#include using namespace std; diff -Naur sucs-1.0.0.orig/kohonen/kohonennet.cpp sucs-1.0.0/kohonen/kohonennet.cpp --- sucs-1.0.0.orig/kohonen/kohonennet.cpp 2008-06-16 21:40:32.000000000 +0200 +++ sucs-1.0.0/kohonen/kohonennet.cpp 2008-06-16 21:57:05.000000000 +0200 @@ -17,6 +17,7 @@ #include #include #include +#include using namespace std; diff -Naur sucs-1.0.0.orig/network/link.cpp sucs-1.0.0/network/link.cpp --- sucs-1.0.0.orig/network/link.cpp 2008-06-16 21:40:32.000000000 +0200 +++ sucs-1.0.0/network/link.cpp 2008-06-16 21:48:41.000000000 +0200 @@ -15,8 +15,9 @@ #include #include -//#include +#include #include +#include using namespace std; #include diff -Naur sucs-1.0.0.orig/signals/signallistener.cpp sucs-1.0.0/signals/signallistener.cpp --- sucs-1.0.0.orig/signals/signallistener.cpp 2008-06-16 21:40:32.000000000 +0200 +++ sucs-1.0.0/signals/signallistener.cpp 2008-06-16 21:44:30.000000000 +0200 @@ -29,6 +29,8 @@ namespace sucs { +void actualHandler(int signal); + SignalListener *SignalListener::theOne = NULL; SignalListener::SignalListener() @@ -79,7 +81,7 @@ theHandlers.erase(signal); } -void sucs::actualHandler(int signal) +void actualHandler(int signal) { // cerr << "actualHandler: Received signal " << signal << "." << endl << flush; SignalListener *l = SignalListener::signalListener(); diff -Naur sucs-1.0.0.orig/signals/signallistener.cpp.orig sucs-1.0.0/signals/signallistener.cpp.orig --- sucs-1.0.0.orig/signals/signallistener.cpp.orig 1970-01-01 01:00:00.000000000 +0100 +++ sucs-1.0.0/signals/signallistener.cpp.orig 2008-06-16 21:44:30.000000000 +0200 @@ -0,0 +1,93 @@ +// +// C++ Implementation: signallistener +// +// Description: +// +// +// Author: Gav Wood , (C) 2004 +// +// Copyright: See COPYING file that comes with this distribution +// +// + +#ifdef HAVE_CONFIG_H +#include +#endif + +#define __SUCS 1 + +#include +using namespace std; + +#include + +#include "thread.h" +#include "signalhandler.h" +#include "signallistener.h" +using namespace sucs; + +namespace sucs +{ + +void actualHandler(int signal); + +SignalListener *SignalListener::theOne = NULL; + +SignalListener::SignalListener() +{ +} + +SignalListener::~SignalListener() +{ +} + +void SignalListener::set(int signal, SignalHandler *handler) +{ +/* struct sigaction *act = new struct sigaction; + act->sa_sigaction = actualHandler; + act->sa_mask = 0; + act->sa_flags = SA_SIGINFO; + sigaction(a, act, NULL); + delect act; +*/ + tdbg("SignalListener::set: Object " << handler << " is handling signal " << signal << "." << endl); + if(!theHandlers.count(signal)) + ::signal(signal, actualHandler); + theHandlers.insert(make_pair(signal, handler)); +} + +void SignalListener::reset(int signal, SignalHandler *handler) +{ + tdbg("SignalListener::reset: Object " << handler << " is not handling signal " << signal << "." << endl); + + // erase the signal handler from the handlers list + for(multimap::iterator i = theHandlers.lower_bound(signal); i != theHandlers.upper_bound(signal); i++) + if((*i).second == handler) + { theHandlers.erase(i); + break; + } + + // if no signals are being handled, resort to the default action + if(!theHandlers.count(signal)) + ::signal(signal, SIG_DFL); +} + +void SignalListener::ignore(int signal) +{ + tdbg("SignalListener::ignore: Ignoring signal " << signal << "." << endl); + ::signal(signal, SIG_IGN); + for(multimap::iterator i = theHandlers.lower_bound(signal); i != theHandlers.upper_bound(signal); i++) + (*i).second->unregister(signal); + theHandlers.erase(signal); +} + +void sucs::actualHandler(int signal) +{ +// cerr << "actualHandler: Received signal " << signal << "." << endl << flush; + SignalListener *l = SignalListener::signalListener(); + for(multimap::iterator i = l->theHandlers.lower_bound(signal); i != l->theHandlers.upper_bound(signal); i++) + (*i).second->handler(signal); + ::signal(signal, actualHandler); +} + +}; diff -Naur sucs-1.0.0.orig/sonic/stub.cpp sucs-1.0.0/sonic/stub.cpp --- sucs-1.0.0.orig/sonic/stub.cpp 2008-06-16 21:40:32.000000000 +0200 +++ sucs-1.0.0/sonic/stub.cpp 2008-06-16 21:58:56.000000000 +0200 @@ -14,6 +14,7 @@ #include #include +#include using namespace std; diff -Naur sucs-1.0.0.orig/thread/thread.cpp sucs-1.0.0/thread/thread.cpp --- sucs-1.0.0.orig/thread/thread.cpp 2008-06-16 21:40:32.000000000 +0200 +++ sucs-1.0.0/thread/thread.cpp 2008-06-16 21:48:06.000000000 +0200 @@ -17,6 +17,8 @@ #include #include #include +#include +#include using namespace std; #include @@ -28,17 +30,24 @@ Sema sucs::__output; +namespace sucs { + void *gameOn(void *arg); + void cleanup(void *arg); +} + int Thread::theIdCount = 0, Thread::theCount = 0, Thread::theNowRunningCount = 0; Sema Thread::theNowRunning; pthread_t Thread::theMainId = (pthread_t)NULL; map Thread::theThreads; -ostream &sucs::operator<<(ostream &out, const Thread &t) -{ - if(&t) - return out << t.id() << " (" << t.name() << "-" << t.threadId() << ")"; - else - return out << "0 (main-" << Thread::theMainId << ")"; +namespace sucs { + ostream &operator<<(ostream &out, const Thread &t) + { + if(&t) + return out << t.id() << " (" << t.name() << "-" << t.threadId() << ")"; + else + return out << "0 (main-" << Thread::theMainId << ")"; + } } void Thread::waitForDeath() const diff -Naur sucs-1.0.0.orig/xml/xmlreader.cpp sucs-1.0.0/xml/xmlreader.cpp --- sucs-1.0.0.orig/xml/xmlreader.cpp 2008-06-16 21:40:31.000000000 +0200 +++ sucs-1.0.0/xml/xmlreader.cpp 2008-06-16 21:55:39.000000000 +0200 @@ -15,7 +15,7 @@ #include #include #include - +#include using namespace std; #include @@ -24,6 +24,12 @@ using namespace sucs; +namespace sucs { + void cStartElement(void *userdata, const char *name, const char **atts); + void cEndElement(void *userdata, const char *name); + void cCharData(void *userdata, const XML_Char *s, int len); +} + XMLReader::XMLReader(bool newStripWhite) { StripWhite = newStripWhite; @@ -39,7 +45,9 @@ XML_ParserFree(theParser); } -istream &sucs::operator>>(istream &in, XMLReader &me) +namespace sucs { + +istream &operator>>(istream &in, XMLReader &me) { char Buffer[256]; while(!in.eof()) @@ -52,9 +60,9 @@ } } return in; -}; +} -void sucs::cStartElement(void *userdata, const char *name, const char **atts) +void cStartElement(void *userdata, const char *name, const char **atts) { map Attributes; @@ -64,12 +72,12 @@ ((XMLReader *)userdata)->StartElement(name, Attributes); } -void sucs::cEndElement(void *userdata, const char *name) +void cEndElement(void *userdata, const char *name) { ((XMLReader *)userdata)->EndElement(name); } -void sucs::cCharData(void *userdata, const XML_Char *s, int len) +void cCharData(void *userdata, const XML_Char *s, int len) { char Buffer[len + 1]; @@ -89,3 +97,5 @@ ((XMLReader *)userdata)->CharData(Buffer); } } + +}