From: <arn...@us...> - 2007-11-18 17:13:23
|
Revision: 91 http://adchpp.svn.sourceforge.net/adchpp/?rev=91&view=rev Author: arnetheduck Date: 2007-11-18 09:13:18 -0800 (Sun, 18 Nov 2007) Log Message: ----------- init cleanup, clienttype field Modified Paths: -------------- adchpp/trunk/adchpp/Client.cpp adchpp/trunk/adchpp/Client.h adchpp/trunk/adchpp/ClientManager.cpp adchpp/trunk/adchpp/ClientManager.h adchpp/trunk/adchpp/SettingsManager.cpp adchpp/trunk/adchpp/SettingsManager.h adchpp/trunk/adchpp/Util.h adchpp/trunk/adchpp/adchpp.cpp adchpp/trunk/adchpp/common.h adchpp/trunk/swig/SConscript adchpp/trunk/swig/adchpp.i adchpp/trunk/unix/main.cpp Modified: adchpp/trunk/adchpp/Client.cpp =================================================================== --- adchpp/trunk/adchpp/Client.cpp 2007-11-17 15:16:11 UTC (rev 90) +++ adchpp/trunk/adchpp/Client.cpp 2007-11-18 17:13:18 UTC (rev 91) @@ -89,7 +89,7 @@ return (i != psd.end()) ? i->second : 0; } -void Client::onData(const vector<uint8_t>& data) throw() { +void Client::onData(const ByteVector& data) throw() { dcdebug("In (%d): %.*s\n", data.size(), data.size(), &data[0]); size_t done = 0; @@ -164,6 +164,7 @@ cmd.addParam(string((char*)&i->first, 2)); return !changed.empty(); } + bool Client::getAllFields(AdcCommand& cmd) const throw() { for(InfMap::const_iterator i = info.begin(); i != info.end(); ++i) cmd.addParam(string((char*)&i->first, 2), i->second); @@ -184,7 +185,7 @@ for(StringIterC j = cmd.getParameters().begin(); j != cmd.getParameters().end(); ++j) { if(j->size() < 2) continue; - setField(j->substr(0, 2).c_str(), j->substr(2)); + setField(j->c_str(), j->substr(2)); } } @@ -251,4 +252,18 @@ delete this; } +void Client::setFlag(size_t flag) { + flags.setFlag(flag); + if(flag & MASK_CLIENT_TYPE) { + setField("CT", Util::toString(flags.getFlags() & MASK_CLIENT_TYPE)); + } } + +void Client::unsetFlag(size_t flag) { + flags.setFlag(flag); + if(flag & MASK_CLIENT_TYPE) { + setField("CT", Util::toString(flags.getFlags() & MASK_CLIENT_TYPE)); + } +} + +} Modified: adchpp/trunk/adchpp/Client.h =================================================================== --- adchpp/trunk/adchpp/Client.h 2007-11-17 15:16:11 UTC (rev 90) +++ adchpp/trunk/adchpp/Client.h 2007-11-18 17:13:18 UTC (rev 91) @@ -31,7 +31,7 @@ /** * The client represents one connection to a user. */ -class Client : public Flags, public FastAlloc<Client>, public boost::noncopyable { +class Client : public FastAlloc<Client>, public boost::noncopyable { public: enum State { /** Initial protocol negotiation (wait for SUP) */ @@ -48,17 +48,18 @@ enum { FLAG_BOT = 0x01, - FLAG_OP = 0x02, - FLAG_PASSWORD = 0x04, - FLAG_HIDDEN = 0x08, + FLAG_REGISTERED = 0x02, + FLAG_OP = 0x04, + FLAG_OWNER = 0x08, FLAG_HUB = 0x10, + MASK_CLIENT_TYPE = FLAG_BOT | FLAG_REGISTERED | FLAG_OP | FLAG_OWNER | FLAG_HUB, + FLAG_PASSWORD = 0x100, + FLAG_HIDDEN = 0x101, /** Extended away, no need to send msg */ - FLAG_EXT_AWAY = 0x20, + FLAG_EXT_AWAY = 0x102, /** Plugins can use these flags to disable various checks */ - /** Bypass max users count */ - FLAG_OK_COUNT = 0x80, /** Bypass ip check */ - FLAG_OK_IP = 0x100 + FLAG_OK_IP = 0x104 }; static Client* create(const ManagedSocketPtr& ms_) throw(); @@ -112,6 +113,11 @@ ADCHPP_DLL bool isFlooding(time_t addSeconds); + bool isSet(size_t aFlag) const { return flags.isSet(aFlag); } + bool isAnySet(size_t aFlag) const { return flags.isAnySet(aFlag); } + void setFlag(size_t aFlag); + void unsetFlag(size_t aFlag); + /** * Set PSD (plugin specific data). This allows a plugin to store arbitrary * per-client data, and retrieve it later on. Each plugin is only allowed @@ -153,6 +159,8 @@ InfMap info; InfMap changed; + + Flags flags; CID cid; uint32_t sid; Modified: adchpp/trunk/adchpp/ClientManager.cpp =================================================================== --- adchpp/trunk/adchpp/ClientManager.cpp 2007-11-17 15:16:11 UTC (rev 90) +++ adchpp/trunk/adchpp/ClientManager.cpp 2007-11-18 17:13:18 UTC (rev 91) @@ -118,6 +118,7 @@ .addParam("DE", SETTING(DESCRIPTION)) .addParam("VE", versionString) .addParam("CT5") + .addParam("HU1") // ADC <=0.13 .toString(); } @@ -203,14 +204,14 @@ signalBadLine_(c, aLine); } -void ClientManager::badState(Client& c) throw() { - c.send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_BAD_STATE, "Invalid state for command")); +void ClientManager::badState(Client& c, const AdcCommand& cmd) throw() { + c.send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_BAD_STATE, "Invalid state for command").addParam("FC", cmd.toString().substr(0, 4))); c.disconnect(Util::REASON_BAD_STATE); } -bool ClientManager::handleDefault(Client& c, AdcCommand&) throw() { +bool ClientManager::handleDefault(Client& c, AdcCommand& cmd) throw() { if(c.getState() != Client::STATE_NORMAL) { - badState(c); + badState(c, cmd); return false; } return true; @@ -224,7 +225,7 @@ if(c.getState() == Client::STATE_PROTOCOL) { enterIdentify(c, true); } else if(c.getState() != Client::STATE_NORMAL) { - badState(c); + badState(c, cmd); return false; } return true; @@ -232,10 +233,25 @@ bool ClientManager::verifySUP(Client& c, AdcCommand& cmd) throw() { c.updateSupports(cmd); - if(!c.supports("BASE") && !c.supports("BAS0")) { - c.send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_PROTOCOL_GENERIC, "This hub requires BASE support")); - c.disconnect(Util::REASON_NO_BASE_SUPPORT); + if(!c.supports("BASE")) { + if(COMPATIBILITY && c.supports("BAS0")) { + c.send(AdcCommand(AdcCommand::CMD_MSG).addParam("Your client only supports an experimental version of ADC, please upgrade as soon as possible as you will not be able to connect in the future")); + } else { + c.send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_PROTOCOL_GENERIC, "This hub requires BASE support")); + c.disconnect(Util::REASON_NO_BASE_SUPPORT); + } } + + if(c.supports("BASE") && !c.supports("TIGR")) { + if(COMPATIBILITY) { + // ADC <= 0.13 + c.send(AdcCommand(AdcCommand::CMD_MSG).addParam("Your client claims to support BASE but not TIGR, please upgrade as soon as possible")); + } else { + c.send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_PROTOCOL_GENERIC, "This hub requires TIGR support")); + c.disconnect(Util::REASON_NO_TIGR_SUPPORT); + } + } + return true; } @@ -249,9 +265,6 @@ if(!verifyNick(c, cmd)) return false; - if(!verifyUsers(c)) - return false; - c.updateFields(cmd); return true; } @@ -265,6 +278,9 @@ if(memcmp(tiger.finalize(), tmp, TigerHash::HASH_SIZE) == 0) return true; + if(!COMPATIBILITY) + return false; + TigerHash tiger2; // Support dc++ 0.69 for a while string cid = c.getCID().toBase32(); @@ -280,7 +296,7 @@ bool ClientManager::handle(AdcCommand::INF, Client& c, AdcCommand& cmd) throw() { if(c.getState() != Client::STATE_IDENTIFY && c.getState() != Client::STATE_NORMAL) { - badState(c); + badState(c, cmd); return false; } @@ -366,7 +382,7 @@ } if(cmd.getParam("PD", 0, strtmp)) { - c.send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_PROTOCOL_GENERIC, "PD but no ID")); + c.send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_PROTOCOL_GENERIC, "CID required when sending PID")); c.disconnect(Util::REASON_PID_WITHOUT_CID); return false; } @@ -374,7 +390,6 @@ } bool ClientManager::verifyNick(Client& c, const AdcCommand& cmd) throw() { - if(cmd.getParam("NI", 0, strtmp)) { dcdebug("%s verifying nick\n", AdcCommand::fromSID(c.getSID()).c_str()); for(string::size_type i = 0; i < strtmp.length(); ++i) { @@ -406,24 +421,6 @@ signalState_(c, oldState); } -bool ClientManager::verifyUsers(Client& c) throw() { - if(c.isSet(Client::FLAG_OK_COUNT)) - return true; - dcdebug("%s verifying user count\n", AdcCommand::fromSID(c.getSID()).c_str()); - - if(SETTING(MAX_USERS) > 0 && clients.size() >= (size_t)SETTING(MAX_USERS)) { - if(BOOLSETTING(REDIRECT_FULL)) { - c.send(AdcCommand(AdcCommand::CMD_QUI).addParam("RD", SETTING(REDIRECT_SERVER)).addParam("MS", STRING(HUB_FULL))); - } else { - c.send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_HUB_FULL, STRING(HUB_FULL))); - } - c.disconnect(Util::REASON_HUB_FULL); - return false; - } - c.setFlag(Client::FLAG_OK_COUNT); - return true; -} - void ClientManager::enterIdentify(Client& c, bool sendData) throw() { dcassert(c.getState() == Client::STATE_PROTOCOL); dcdebug("%s entering IDENTIFY\n", AdcCommand::fromSID(c.getSID()).c_str()); Modified: adchpp/trunk/adchpp/ClientManager.h =================================================================== --- adchpp/trunk/adchpp/ClientManager.h 2007-11-17 15:16:11 UTC (rev 90) +++ adchpp/trunk/adchpp/ClientManager.h 2007-11-18 17:13:18 UTC (rev 91) @@ -136,11 +136,11 @@ */ ADCHPP_DLL bool verifyIp(Client& c, AdcCommand& cmd) throw(); + /** + * Verify that CID is correct and corresponds to PID + */ ADCHPP_DLL bool verifyCID(Client& c, AdcCommand& cmd) throw(); - /** Verify the number of connected clients */ - ADCHPP_DLL bool verifyUsers(Client& c) throw(); - /** Update the state of c (this fires signalState as well) */ ADCHPP_DLL void setState(Client& c, Client::State newState) throw(); @@ -219,7 +219,7 @@ void onBadLine(Client&, const string&) throw(); void onFailed(Client&) throw(); - void badState(Client& c) throw(); + void badState(Client& c, const AdcCommand& cmd) throw(); SignalConnected::Signal signalConnected_; SignalReceive::Signal signalReceive_; Modified: adchpp/trunk/adchpp/SettingsManager.cpp =================================================================== --- adchpp/trunk/adchpp/SettingsManager.cpp 2007-11-17 15:16:11 UTC (rev 90) +++ adchpp/trunk/adchpp/SettingsManager.cpp 2007-11-18 17:13:18 UTC (rev 91) @@ -34,11 +34,11 @@ { // Strings "HubName", "ServerIp", "LogFile", "Description", - "LanguageFile", "RedirectServer", + "LanguageFile", "SENTRY", // Ints - "ServerPort", "Log", "MaxUsers", "KeepSlowUsers", - "MaxSendSize", "MaxBufferSize", "BufferSize", "MaxCommandSize", "RedirectFull", + "ServerPort", "Log", "KeepSlowUsers", + "MaxSendSize", "MaxBufferSize", "BufferSize", "MaxCommandSize", "OverflowTimeout", "DisconnectTimeout", "FloodAdd", "FloodThreshold", "LoginTimeout", "SENTRY", @@ -56,16 +56,13 @@ set(LOG_FILE, "logs/adchpp%Y%m.log"); set(DESCRIPTION, versionString); // set(LANGUAGE_FILE, "Example.adchpp.xml"); - // set(REDIRECT_SERVER, ""); set(SERVER_PORT, 2780); set(LOG, 1); - set(MAX_USERS, 0); set(KEEP_SLOW_USERS, 0); set(MAX_SEND_SIZE, 1400); set(MAX_BUFFER_SIZE, 16384); set(BUFFER_SIZE, 256); set(MAX_COMMAND_SIZE, 16384); - set(REDIRECT_FULL, 0); set(OVERFLOW_TIMEOUT, 60*1000); set(DISCONNECT_TIMEOUT, 5*1000); set(FLOOD_ADD, 1); Modified: adchpp/trunk/adchpp/SettingsManager.h =================================================================== --- adchpp/trunk/adchpp/SettingsManager.h 2007-11-17 15:16:11 UTC (rev 90) +++ adchpp/trunk/adchpp/SettingsManager.h 2007-11-18 17:13:18 UTC (rev 91) @@ -37,12 +37,12 @@ enum StrSetting { STR_FIRST, HUB_NAME = STR_FIRST, SERVER_IP, LOG_FILE, DESCRIPTION, - LANGUAGE_FILE, REDIRECT_SERVER, + LANGUAGE_FILE, STR_LAST }; enum IntSetting { INT_FIRST = STR_LAST + 1, - SERVER_PORT = INT_FIRST, LOG, MAX_USERS, KEEP_SLOW_USERS, - MAX_SEND_SIZE, MAX_BUFFER_SIZE, BUFFER_SIZE, MAX_COMMAND_SIZE, REDIRECT_FULL, + SERVER_PORT = INT_FIRST, LOG, KEEP_SLOW_USERS, + MAX_SEND_SIZE, MAX_BUFFER_SIZE, BUFFER_SIZE, MAX_COMMAND_SIZE, OVERFLOW_TIMEOUT, DISCONNECT_TIMEOUT, FLOOD_ADD, FLOOD_THRESHOLD, LOGIN_TIMEOUT, INT_LAST }; Modified: adchpp/trunk/adchpp/Util.h =================================================================== --- adchpp/trunk/adchpp/Util.h 2007-11-17 15:16:11 UTC (rev 90) +++ adchpp/trunk/adchpp/Util.h 2007-11-18 17:13:18 UTC (rev 91) @@ -109,11 +109,12 @@ class Flags { public: - typedef int MaskType; + typedef size_t MaskType; Flags() : flags(0) { } Flags(const Flags& rhs) : flags(rhs.flags) { } Flags(MaskType f) : flags(f) { } + MaskType getFlags() const { return flags; } bool isSet(MaskType aFlag) const { return (flags & aFlag) == aFlag; } bool isAnySet(MaskType aFlag) const { return (flags & aFlag) != 0; } void setFlag(MaskType aFlag) { flags |= aFlag; } @@ -166,6 +167,7 @@ REASON_NICK_INVALID, REASON_NICK_TAKEN, REASON_NO_BASE_SUPPORT, + REASON_NO_TIGR_SUPPORT, REASON_PID_MISSING, REASON_PID_CID_LENGTH, REASON_PID_CID_MISMATCH, Modified: adchpp/trunk/adchpp/adchpp.cpp =================================================================== --- adchpp/trunk/adchpp/adchpp.cpp 2007-11-17 15:16:11 UTC (rev 90) +++ adchpp/trunk/adchpp/adchpp.cpp 2007-11-18 17:13:18 UTC (rev 91) @@ -30,7 +30,14 @@ const char compileTime[] = __DATE__ " " __TIME__; -void initConfig(const string& configPath) { +static bool initialized = false; +static bool running = false; + +void initialize(const string& configPath) { + if(initialized) { + throw Exception("Already initialized"); + } + #ifdef _WIN32 WSADATA wsaData; WSAStartup(MAKEWORD(2, 2), &wsaData); @@ -47,9 +54,13 @@ PluginManager::newInstance(); SettingsManager::getInstance()->load(); + initialized = true; } void startup(void (*f)()) { + if(!initialized) { + throw Exception("adchpp not initialized"); + } /* if(!SETTING(LANGUAGE_FILE).empty()) { if(File::isAbsolutePath(SETTING(LANGUAGE_FILE))) { ResourceManager::getInstance()->loadLanguage(SETTING(LANGUAGE_FILE)); @@ -62,12 +73,21 @@ if(f) f(); ClientManager::getInstance()->startup(); + if(f) f(); SocketManager::getInstance()->startup(); if(f) f(); PluginManager::getInstance()->load(); + if(f) f(); + + running = true; } void shutdown(void (*f)()) { + if(!running) { + return; + } + + if(f) f(); PluginManager::getInstance()->shutdown(); if(f) f(); ClientManager::getInstance()->shutdown(); @@ -75,6 +95,17 @@ SocketManager::getInstance()->shutdown(); if(f) f(); + running = false; +} + +void cleanup() { + if(!initialized) { + return; + } + if(running) { + shutdown(0); + } + PluginManager::deleteInstance(); ClientManager::deleteInstance(); SocketManager::deleteInstance(); @@ -86,6 +117,8 @@ #ifdef _WIN32 WSACleanup(); #endif + + initialized = false; } //#ifdef _DEBUG Modified: adchpp/trunk/adchpp/common.h =================================================================== --- adchpp/trunk/adchpp/common.h 2007-11-17 15:16:11 UTC (rev 90) +++ adchpp/trunk/adchpp/common.h 2007-11-18 17:13:18 UTC (rev 91) @@ -100,20 +100,25 @@ typedef ByteVector::iterator ByteIter; /** - * Initialize configuration, must be called before startup + * Initialize configuration. */ -ADCHPP_DLL void initConfig(const string& path); +ADCHPP_DLL void initialize(const string& path); /** - * Second startup phase, this can take quite some time as plugins and - * dynamic data are loaded. - * @param f Unless NULL, this function is called after each step in the initialization + * Load plugins and start listening for incoming connections */ ADCHPP_DLL void startup(void (*f)()); -/** Shuts down the adchpp hub library (doh!). */ +/** + * Stop listening for incoming connections + */ ADCHPP_DLL void shutdown(void (*f)()); +/** + * Release any resources held by adchpp. Before using any library routines again, you must call initalialize. + */ +ADCHPP_DLL void cleanup(); + } #endif // COMMON_H Modified: adchpp/trunk/swig/SConscript =================================================================== --- adchpp/trunk/swig/SConscript 2007-11-17 15:16:11 UTC (rev 90) +++ adchpp/trunk/swig/SConscript 2007-11-18 17:13:18 UTC (rev 91) @@ -59,17 +59,9 @@ targets.append(rb) def buildPyModule(): - env = dev.env.Copy() - + env, target, sources = dev.prepare_build(source_path, '_pyadchpp', 'python.i') env.Append(SWIGFLAGS=['-c++','-threads','-Wall','-python', '-O', '-classic']) - cxxfile = build_path + 'python_wrap.cxx' - f = env.CXXFile(target=cxxfile, source='python.i') - pyfile = build_path + 'pyadchpp.py' - env.SideEffect(pyfile, f[0]) - targetfile = dev.get_target(source_path, 'pyadchpp.py') - env.Command(targetfile, pyfile, Copy('$TARGET', '$SOURCE')) - env.Depends(targetfile, pyfile) - + import distutils.sysconfig env.Append(CPPPATH=['#', distutils.sysconfig.get_python_inc()]) @@ -85,17 +77,23 @@ env.Append(LIBS=["python"+"".join(sys.version[0:3].split(".")), 'adchpp']) else: env.Append(LIBS=['python2.4', 'adchpp']) - - pyd = env.SharedLibrary(dev.get_target(source_path, '_pyadchpp'), [cxxfile], - SHLIBPREFIX='') + + wrapper = build_path + 'python_wrap.cc' + pyfile = build_path + 'pyadchpp.py' + pytarget = dev.get_target(source_path, 'pyadchpp.py') + env.SideEffect(pyfile, wrapper) + env.Command(pytarget, pyfile, Copy('$TARGET', '$SOURCE')) + env.Depends(pytarget, pyfile) + + pyd = env.SharedLibrary(target, sources, SHLIBPREFIX='') + env.Depends(pyd, pytarget) + targets.append(pyd) def buildLuaModule(): - env = dev.env.Copy() + env, target, sources = dev.prepare_build(source_path, 'luadchpp', 'lua.i') env.Append(SWIGFLAGS=['-c++','-Wall','-lua']) - cxxfile = build_path + 'lua_wrap.cxx' - f = env.CXXFile(build_path + 'lua_wrap.cxx', source='lua.i') env.Append(LIBS=['adchpp', 'alua']) # We assume the lua from the script plugin will be used... @@ -107,8 +105,7 @@ else: env.Append(CPPDEFINES=['LUA_USE_LINUX=1']) - luadchpp = env.SharedLibrary(dev.get_target(source_path, 'luadchpp'), [cxxfile], - SHLIBPREFIX='') + luadchpp = env.SharedLibrary(target, sources, SHLIBPREFIX='') targets.append(luadchpp) # buildRbModule() - needs threading sorted out Modified: adchpp/trunk/swig/adchpp.i =================================================================== --- adchpp/trunk/swig/adchpp.i 2007-11-17 15:16:11 UTC (rev 90) +++ adchpp/trunk/swig/adchpp.i 2007-11-18 17:13:18 UTC (rev 91) @@ -81,7 +81,8 @@ namespace adchpp { -void initConfig(const std::string& configPath); +void initialize(const std::string& configPath); +void cleanup(); template<typename F> struct Signal { @@ -138,6 +139,7 @@ REASON_NICK_INVALID, REASON_NICK_TAKEN, REASON_NO_BASE_SUPPORT, + REASON_NO_TIGR_SUPPORT, REASON_PID_MISSING, REASON_PID_CID_LENGTH, REASON_PID_CID_MISMATCH, @@ -373,16 +375,21 @@ STATE_NORMAL, STATE_DATA }; - + enum { FLAG_BOT = 0x01, - FLAG_OP = 0x02, - FLAG_PASSWORD = 0x04, - FLAG_HIDDEN = 0x08, + FLAG_REGISTERED = 0x02, + FLAG_OP = 0x04, + FLAG_OWNER = 0x08, FLAG_HUB = 0x10, - FLAG_EXT_AWAY = 0x20, - FLAG_OK_COUNT = 0x80, - FLAG_OK_IP = 0x100 + MASK_CLIENT_TYPE = FLAG_BOT | FLAG_REGISTERED | FLAG_OP | FLAG_OWNER | FLAG_HUB, + FLAG_PASSWORD = 0x100, + FLAG_HIDDEN = 0x101, + /** Extended away, no need to send msg */ + FLAG_EXT_AWAY = 0x102, + /** Plugins can use these flags to disable various checks */ + /** Bypass ip check */ + FLAG_OK_IP = 0x104 }; //static Client* create(uint32_t sid) throw(); @@ -534,7 +541,6 @@ bool verifyPassword(Client& c, const string& password, const vector<uint8_t>& salt, const string& suppliedHash); bool verifyIp(Client& c, AdcCommand& cmd) throw(); bool verifyCID(Client& c, AdcCommand& cmd) throw(); - bool verifyUsers(Client& c) throw(); void setState(Client& c, Client::State newState) throw(); @@ -609,12 +615,12 @@ enum StrSetting { STR_FIRST, HUB_NAME = STR_FIRST, SERVER_IP, LOG_FILE, DESCRIPTION, - LANGUAGE_FILE, REDIRECT_SERVER, + LANGUAGE_FILE, STR_LAST }; enum IntSetting { INT_FIRST = STR_LAST + 1, - SERVER_PORT = INT_FIRST, LOG, MAX_USERS, KEEP_SLOW_USERS, - MAX_SEND_SIZE, MAX_BUFFER_SIZE, BUFFER_SIZE, MAX_COMMAND_SIZE, REDIRECT_FULL, + SERVER_PORT = INT_FIRST, LOG, KEEP_SLOW_USERS, + MAX_SEND_SIZE, MAX_BUFFER_SIZE, BUFFER_SIZE, MAX_COMMAND_SIZE, OVERFLOW_TIMEOUT, DISCONNECT_TIMEOUT, FLOOD_ADD, FLOOD_THRESHOLD, LOGIN_TIMEOUT, INT_LAST }; Modified: adchpp/trunk/unix/main.cpp =================================================================== --- adchpp/trunk/unix/main.cpp 2007-11-17 15:16:11 UTC (rev 90) +++ adchpp/trunk/unix/main.cpp 2007-11-18 17:13:18 UTC (rev 91) @@ -26,6 +26,7 @@ #include <signal.h> +using namespace std; using namespace adchpp; static const string modName = "adchpp"; @@ -69,6 +70,7 @@ if(!asdaemon) printf("Shutting down."); shutdown(&f2); + cleanup(); if(!asdaemon) printf(".\n"); @@ -113,13 +115,13 @@ #include <sys/wait.h> static void runDaemon(const string& configPath) { - initConfig(configPath); + initialize(configPath); daemonize(); init(); try { - startup(&f2); - } catch(const Exception& e) { - LOGDT(modName, "Failed to load in stage 2"); + adchpp::startup(&f2); + } catch(const adchpp::Exception& e) { + LOGDT(modName, "Failed to start: " + e.getError()); uninit(); return; } @@ -138,7 +140,7 @@ static void runConsole(const string& configPath) { printf("Starting"); init(); - initConfig(configPath); + initialize(configPath); LOGDT(modName, versionString + " starting from console"); printf("."); try { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |