From: <arn...@us...> - 2007-11-17 14:47:58
|
Revision: 89 http://adchpp.svn.sourceforge.net/adchpp/?rev=89&view=rev Author: arnetheduck Date: 2007-11-17 06:47:54 -0800 (Sat, 17 Nov 2007) Log Message: ----------- Implement type F Modified Paths: -------------- adchpp/trunk/adchpp/AdcCommand.h adchpp/trunk/adchpp/Client.cpp adchpp/trunk/adchpp/Client.h adchpp/trunk/adchpp/ClientManager.cpp adchpp/trunk/adchpp/ManagedSocket.cpp adchpp/trunk/adchpp/ManagedSocket.h adchpp/trunk/swig/adchpp.i Modified: adchpp/trunk/adchpp/AdcCommand.h =================================================================== --- adchpp/trunk/adchpp/AdcCommand.h 2007-11-17 13:53:54 UTC (rev 88) +++ adchpp/trunk/adchpp/AdcCommand.h 2007-11-17 14:47:54 UTC (rev 89) @@ -132,6 +132,8 @@ const string& getParam(size_t n) const { return getParameters().size() > n ? getParameters()[n] : Util::emptyString; } + + const string& getFeatures() const { return features; } /** Return a named parameter where the name is a two-letter code */ ADCHPP_DLL bool getParam(const char* name, size_t start, string& ret) const; Modified: adchpp/trunk/adchpp/Client.cpp =================================================================== --- adchpp/trunk/adchpp/Client.cpp 2007-11-17 13:53:54 UTC (rev 88) +++ adchpp/trunk/adchpp/Client.cpp 2007-11-17 14:47:54 UTC (rev 89) @@ -27,184 +27,229 @@ namespace adchpp { using namespace std::tr1::placeholders; - + Client* Client::create(const ManagedSocketPtr& ms) throw() { Client* c = new Client(); c->setSocket(ms); return c; } -Client::Client() throw() : sid(0), state(STATE_PROTOCOL), disconnecting(false), socket(0), dataBytes(0), floodTimer(0) { +Client::Client() throw() : + sid(0), state(STATE_PROTOCOL), disconnecting(false), socket(0), dataBytes(0), floodTimer(0) { } +namespace { +// Lightweight call forwarders, instead of tr1::bind +struct Handler { + Handler(void (Client::*f)(), Client* c_) : + c(c_), f0(f) { + } + Handler(void (Client::*f)(const ByteVector&), Client* c_) : + c(c_), f1(f) { + } + + void operator()() throw() { + (c->*f0)(); + } + void operator()(const ByteVector& bv) throw() { + (c->*f1)(bv); + } + + Client* c; + union { + void (Client::*f0)(); + void (Client::*f1)(const ByteVector&); + }; +}; +} + void Client::setSocket(const ManagedSocketPtr& aSocket) throw() { - dcassert(!socket); - socket = aSocket; - socket->setConnectedHandler(std::tr1::bind(&Client::onConnected, this)); - socket->setDataHandler(std::tr1::bind(&Client::onData, this, _1)); - socket->setFailedHandler(std::tr1::bind(&Client::onFailed, this)); +dcassert(!socket); +socket = aSocket; +socket->setConnectedHandler(Handler(&Client::onConnected, this)); +socket->setDataHandler(Handler(&Client::onData, this)); +socket->setFailedHandler(Handler(&Client::onFailed, this)); } void Client::onConnected() throw() { - dcdebug("Client::onConnected\n"); - ClientManager::getInstance()->onConnected(*this); +dcdebug("Client::onConnected\n"); +ClientManager::getInstance()->onConnected(*this); } void* Client::setPSD(int id, void* data) throw() { - PSDIter i = find_if(psd.begin(), psd.end(), CompareFirst<int, void*>(id)); - if(i != psd.end()) { - void* old = i->second; - i->second = data; - return old; - } else { - psd.push_back(make_pair(id, data)); - return 0; - } +PSDIter i = find_if(psd.begin(), psd.end(), CompareFirst<int, void*>(id)); +if(i != psd.end()) { + void* old = i->second; + i->second = data; + return old; +} else { + psd.push_back(make_pair(id, data)); + return 0; } +} void* Client::getPSD(int id) throw() { - PSDIter i = find_if(psd.begin(), psd.end(), CompareFirst<int, void*>(id)); - if(i != psd.end()) - return i->second; - else - return 0; +PSDIter i = find_if(psd.begin(), psd.end(), CompareFirst<int, void*>(id)); +if(i != psd.end()) +return i->second; +else +return 0; } void Client::onData(const vector<uint8_t>& data) throw() { - dcdebug("In (%d): %.*s\n", data.size(), data.size(), &data[0]); +dcdebug("In (%d): %.*s\n", data.size(), data.size(), &data[0]); - size_t done = 0; - size_t len = data.size(); - while(!disconnecting && done < len) { - if(dataBytes > 0) { - size_t n = (size_t)min(dataBytes, (int64_t)(len - done)); - dataHandler(*this, &data[done], n); - dataBytes -= n; - done += n; - } else { - size_t j = done; - while(j < len && data[j] != '\n') - ++j; - - if(j == len) { - line.append((char*)&data[done], j - done); - return; - } - line.append((char*)&data[done], j - done + 1); // include LF - - done = j + 1; +size_t done = 0; +size_t len = data.size(); +while(!disconnecting && done < len) { + if(dataBytes > 0) { + size_t n = (size_t)min(dataBytes, (int64_t)(len - done)); + dataHandler(*this, &data[done], n); + dataBytes -= n; + done += n; + } else { + size_t j = done; + while(j < len && data[j] != '\n') + ++j; - if(SETTING(MAX_COMMAND_SIZE) > 0 && line.size() > (size_t)SETTING(MAX_COMMAND_SIZE)) { - send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_PROTOCOL_GENERIC, "Command too long")); - disconnect(Util::REASON_MAX_COMMAND_SIZE); - return; - } - - if(line.size() == 1) { - line.clear(); - continue; - } - - try { - AdcCommand cmd(line); - - if(cmd.getType() == 'H') { - cmd.setFrom(getSID()); - } else if(cmd.getFrom() != getSID()) { - disconnect(Util::REASON_INVALID_SID); - return; - } - ClientManager::getInstance()->onReceive(*this, cmd); - } catch(const ParseException&) { - ClientManager::getInstance()->onBadLine(*this, line); - } - line.clear(); + if(j == len) { + line.append((char*)&data[done], j - done); + return; } - } -} + line.append((char*)&data[done], j - done + 1); // include LF -void Client::setField(const char* name, const string& value) throw() { - if(value.empty()) { - info.erase(*(uint16_t*)name); - } else { - info[*(uint16_t*)name] = value; - } - changed[*(uint16_t*)name] = value; - INF.clear(); + done = j + 1; + + if(SETTING(MAX_COMMAND_SIZE) > 0 && line.size() > (size_t)SETTING(MAX_COMMAND_SIZE)) { + send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_PROTOCOL_GENERIC, "Command too long")); + disconnect(Util::REASON_MAX_COMMAND_SIZE); + return; + } + + if(line.size() == 1) { + line.clear(); + continue; + } + + try { + AdcCommand cmd(line); + + if(cmd.getType() == 'H') { + cmd.setFrom(getSID()); + } else if(cmd.getFrom() != getSID()) { + disconnect(Util::REASON_INVALID_SID); + return; + } + ClientManager::getInstance()->onReceive(*this, cmd); + } catch(const ParseException&) { + ClientManager::getInstance()->onBadLine(*this, line); + } + line.clear(); + } + } } +void Client::setField(const char* name, const string& value) throw() { + if(value.empty()) { + info.erase(AdcCommand::toCode(name)); + } else { + info[AdcCommand::toCode(name)] = value; + } + changed[AdcCommand::toCode(name)] = value; + INF.clear(); +} + bool Client::getChangedFields(AdcCommand& cmd) const throw() { - for(InfMap::const_iterator i = changed.begin(); i != changed.end(); ++i) - cmd.addParam(string((char*)&i->first, 2)); - return !changed.empty(); + for(InfMap::const_iterator i = changed.begin(); i != changed.end(); ++i) + 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); - return !info.empty(); + for(InfMap::const_iterator i = info.begin(); i != info.end(); ++i) + cmd.addParam(string((char*)&i->first, 2), i->second); + return !info.empty(); } const string& Client::getINF() const throw() { - if(INF.empty()) { - AdcCommand cmd(AdcCommand::CMD_INF, AdcCommand::TYPE_BROADCAST, getSID()); - getAllFields(cmd); - INF = cmd.toString(); - } - return INF; + if(INF.empty()) { + AdcCommand cmd(AdcCommand::CMD_INF, AdcCommand::TYPE_BROADCAST, getSID()); + getAllFields(cmd); + INF = cmd.toString(); + } + return INF; } void Client::updateFields(const AdcCommand& cmd) throw() { - dcassert(cmd.getCommand() == AdcCommand::CMD_INF); - 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)); - } + dcassert(cmd.getCommand() == AdcCommand::CMD_INF); + 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)); + } } +bool Client::isFiltered(const string& features) const { + if(filters.empty()) { + return true; + } + + for(size_t i = 0; i < features.size(); i += 5) { + if(features[i] == '-') { + if(std::find(filters.begin(), filters.end(), features.substr(i+1, 4)) != filters.end()) { + return true; + } + } else if(features[i] == '+') { + if(std::find(filters.begin(), filters.end(), features.substr(i+1, 4)) == filters.end()) { + return true; + } + } + } + return false; +} + void Client::updateSupports(const AdcCommand& cmd) throw() { - for(StringIterC i = cmd.getParameters().begin(); i != cmd.getParameters().end(); ++i) { - const string& str = *i; - if(str.size() != 6) { - continue; - } - if(str.compare(0, 2, "AD") == 0) { - supportList.push_back(str.substr(2)); - } else if(str.compare(0, 2, "RM") == 0) { - supportList.erase(std::remove(supportList.begin(), supportList.end(), str.substr(2)), supportList.end()); - } else { - continue; - } - } + for(StringIterC i = cmd.getParameters().begin(); i != cmd.getParameters().end(); ++i) { + const string& str = *i; + if(str.size() != 6) { + continue; + } + if(str.compare(0, 2, "AD") == 0) { + supportList.push_back(str.substr(2)); + } else if(str.compare(0, 2, "RM") == 0) { + supportList.erase(std::remove(supportList.begin(), supportList.end(), str.substr(2)), supportList.end()); + } else { + continue; + } + } } bool Client::isFlooding(time_t addSeconds) { - time_t now = GET_TIME(); - if(floodTimer < now) { - floodTimer = now; - } - - floodTimer += addSeconds; - - if(floodTimer > now + SETTING(FLOOD_THRESHOLD)) { - return true; - } - - return false; + time_t now = GET_TIME(); + if(floodTimer < now) { + floodTimer = now; + } + + floodTimer += addSeconds; + + if(floodTimer > now + SETTING(FLOOD_THRESHOLD)) { + return true; + } + + return false; } void Client::disconnect(Util::Reason reason) throw() { - if(socket && !disconnecting) { - disconnecting = true; - line.clear(); - socket->disconnect(reason); - } + if(socket && !disconnecting) { + disconnecting = true; + line.clear(); + socket->disconnect(reason); + } } void Client::onFailed() throw() { - ClientManager::getInstance()->onFailed(*this); - delete this; + ClientManager::getInstance()->onFailed(*this); + delete this; } } Modified: adchpp/trunk/adchpp/Client.h =================================================================== --- adchpp/trunk/adchpp/Client.h 2007-11-17 13:53:54 UTC (rev 88) +++ adchpp/trunk/adchpp/Client.h 2007-11-17 14:47:54 UTC (rev 89) @@ -99,14 +99,16 @@ void resetChanged() { changed.clear(); } - const string& getField(const char* name) const throw() { InfMap::const_iterator i = info.find(*(uint16_t*)name); return i == info.end() ? Util::emptyString : i->second; } + const string& getField(const char* name) const throw() { InfMap::const_iterator i = info.find(AdcCommand::toCode(name)); return i == info.end() ? Util::emptyString : i->second; } ADCHPP_DLL void setField(const char* name, const string& value) throw(); ADCHPP_DLL void updateFields(const AdcCommand& cmd) throw(); ADCHPP_DLL void updateSupports(const AdcCommand& cmd) throw(); - bool isUdpActive() const { return info.find(*(uint16_t*)"U4") != info.end(); } - bool isTcpActive() const { return info.find(*(uint16_t*)"I4") != info.end(); } + bool isUdpActive() const { return info.find(AdcCommand::toCode("U4")) != info.end(); } + bool isTcpActive() const { return info.find(AdcCommand::toCode("I4")) != info.end(); } + + ADCHPP_DLL bool isFiltered(const std::string& features) const; ADCHPP_DLL bool isFlooding(time_t addSeconds); @@ -138,6 +140,9 @@ Client() throw(); virtual ~Client() throw() { } + /** H-C INF SU */ + StringList filters; + /** H-C SUP */ StringList supportList; typedef pair<int, void*> PSDPair; typedef vector<PSDPair> PSDList; Modified: adchpp/trunk/adchpp/ClientManager.cpp =================================================================== --- adchpp/trunk/adchpp/ClientManager.cpp 2007-11-17 13:53:54 UTC (rev 88) +++ adchpp/trunk/adchpp/ClientManager.cpp 2007-11-17 14:47:54 UTC (rev 89) @@ -51,9 +51,11 @@ case AdcCommand::TYPE_FEATURE: case AdcCommand::TYPE_BROADCAST: { - FastMutex::Lock l(ManagedSocket::getWriteLock()); + bool all = (cmd.getType() == AdcCommand::TYPE_BROADCAST); + FastMutex::Lock l(ManagedSocket::getWriteMutex()); for(ClientIter i = clients.begin(); i != clients.end(); ++i) { - i->second->fastSend(txt, lowPrio); + if(all || !i->second->isFiltered(cmd.getFeatures())) + i->second->fastSend(txt, lowPrio); } } SocketManager::getInstance()->addAllWriters(); @@ -78,7 +80,7 @@ void ClientManager::sendToAll(const string& cmd) throw() { { - FastMutex::Lock l(ManagedSocket::getWriteLock()); + FastMutex::Lock l(ManagedSocket::getWriteMutex()); for(ClientIter i = clients.begin(); i != clients.end(); ++i) { i->second->fastSend(cmd); } @@ -89,7 +91,7 @@ size_t ClientManager::getQueuedBytes() throw() { size_t total = 0; - FastMutex::Lock l(ManagedSocket::getWriteLock()); + FastMutex::Lock l(ManagedSocket::getWriteMutex()); for(ClientIter i = clients.begin(); i != clients.end(); ++i) { total += i->second->getQueuedBytes(); } Modified: adchpp/trunk/adchpp/ManagedSocket.cpp =================================================================== --- adchpp/trunk/adchpp/ManagedSocket.cpp 2007-11-17 13:53:54 UTC (rev 88) +++ adchpp/trunk/adchpp/ManagedSocket.cpp 2007-11-17 14:47:54 UTC (rev 89) @@ -27,7 +27,7 @@ namespace adchpp { -FastMutex ManagedSocket::outbufCS; +FastMutex ManagedSocket::writeMutex; ManagedSocket::ManagedSocket() throw() : outBuf(0), overFlow(0), disc(0) #ifdef _WIN32 @@ -54,7 +54,7 @@ void ManagedSocket::write(const char* buf, size_t len) throw() { bool add = false; { - FastMutex::Lock l(outbufCS); + FastMutex::Lock l(writeMutex); add = fastWrite(buf, len); } if(add) { @@ -93,7 +93,7 @@ ByteVector* buffer = 0; { - FastMutex::Lock l(outbufCS); + FastMutex::Lock l(writeMutex); if(outBuf == 0) { return 0; @@ -119,7 +119,7 @@ bool moreData; { - FastMutex::Lock l(outbufCS); + FastMutex::Lock l(writeMutex); if(written != buf->size()) { if(outBuf == 0) { Modified: adchpp/trunk/adchpp/ManagedSocket.h =================================================================== --- adchpp/trunk/adchpp/ManagedSocket.h 2007-11-17 13:53:54 UTC (rev 88) +++ adchpp/trunk/adchpp/ManagedSocket.h 2007-11-17 14:47:54 UTC (rev 89) @@ -44,7 +44,7 @@ ADCHPP_DLL bool fastWrite(const char* buf, size_t len, bool lowPrio = false) throw(); /** Returns the lock used for the write buffers */ - static FastMutex& getWriteLock() { return outbufCS; } + static FastMutex& getWriteMutex() { return writeMutex; } /** Returns the number of bytes in the output buffer; buffers must be locked */ size_t getQueuedBytes() { return outBuf ? outBuf->size() : 0; } @@ -110,7 +110,7 @@ DataHandler dataHandler; FailedHandler failedHandler; - ADCHPP_DLL static FastMutex outbufCS; + ADCHPP_DLL static FastMutex writeMutex; }; typedef boost::intrusive_ptr<ManagedSocket> ManagedSocketPtr; Modified: adchpp/trunk/swig/adchpp.i =================================================================== --- adchpp/trunk/swig/adchpp.i 2007-11-17 13:53:54 UTC (rev 88) +++ adchpp/trunk/swig/adchpp.i 2007-11-17 14:47:54 UTC (rev 89) @@ -85,15 +85,10 @@ template<typename F> struct Signal { - - ~Signal() { } }; template<typename Sig> struct ManagedConnection { - ManagedConnection(Sig* signal_, const typename Sig::SlotList::iterator& iter_); - ~ManagedConnection(); - void disconnect(); void release(); }; @@ -330,6 +325,8 @@ AdcCommand& addParam(const string& name, const string& value); AdcCommand& addParam(const string& str); const string& getParam(size_t n) const; + + const string& getFeatures() const; #ifndef SWIGLUA bool getParam(const char* name, size_t start, string& OUTPUT) const; @@ -423,6 +420,8 @@ bool isUdpActive(); bool isTcpActive(); + bool isFiltered(const std::string& features) const; + bool isFlooding(time_t addSeconds); //void* setPSD(int id, void* data) throw(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
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. |
From: <arn...@us...> - 2007-11-18 19:03:41
|
Revision: 92 http://adchpp.svn.sourceforge.net/adchpp/?rev=92&view=rev Author: arnetheduck Date: 2007-11-18 11:03:32 -0800 (Sun, 18 Nov 2007) Log Message: ----------- Don't import std Modified Paths: -------------- adchpp/trunk/SConstruct adchpp/trunk/adchpp/AdcCommand.cpp adchpp/trunk/adchpp/AdcCommand.h adchpp/trunk/adchpp/CID.h adchpp/trunk/adchpp/Client.cpp adchpp/trunk/adchpp/Client.h adchpp/trunk/adchpp/ClientManager.cpp adchpp/trunk/adchpp/ClientManager.h adchpp/trunk/adchpp/Encoder.cpp adchpp/trunk/adchpp/Encoder.h adchpp/trunk/adchpp/Exception.h adchpp/trunk/adchpp/File.cpp adchpp/trunk/adchpp/File.h adchpp/trunk/adchpp/LogManager.cpp adchpp/trunk/adchpp/LogManager.h adchpp/trunk/adchpp/ManagedSocket.cpp adchpp/trunk/adchpp/ManagedSocket.h adchpp/trunk/adchpp/PluginManager.cpp adchpp/trunk/adchpp/PluginManager.h adchpp/trunk/adchpp/Pool.h adchpp/trunk/adchpp/ResourceManager.cpp adchpp/trunk/adchpp/ResourceManager.h adchpp/trunk/adchpp/SettingsManager.cpp adchpp/trunk/adchpp/SettingsManager.h adchpp/trunk/adchpp/Signal.h adchpp/trunk/adchpp/SimpleXML.cpp adchpp/trunk/adchpp/SimpleXML.h adchpp/trunk/adchpp/Socket.cpp adchpp/trunk/adchpp/Socket.h adchpp/trunk/adchpp/SocketManager.cpp adchpp/trunk/adchpp/SocketManager.h adchpp/trunk/adchpp/StringDefs.cpp adchpp/trunk/adchpp/StringDefs.h adchpp/trunk/adchpp/TigerHash.cpp adchpp/trunk/adchpp/Util.cpp adchpp/trunk/adchpp/Util.h adchpp/trunk/adchpp/adchpp.cpp adchpp/trunk/adchpp/adchpp.h adchpp/trunk/adchpp/common.h adchpp/trunk/adchpp/version.cpp adchpp/trunk/adchpp/version.h adchpp/trunk/plugins/Script/src/Engine.h adchpp/trunk/plugins/Script/src/LuaEngine.cpp adchpp/trunk/plugins/Script/src/LuaEngine.h adchpp/trunk/plugins/Script/src/LuaScript.cpp adchpp/trunk/plugins/Script/src/LuaScript.h adchpp/trunk/plugins/Script/src/ScriptManager.cpp adchpp/trunk/plugins/Script/src/ScriptManager.h adchpp/trunk/swig/adchpp.i Modified: adchpp/trunk/SConstruct =================================================================== --- adchpp/trunk/SConstruct 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/SConstruct 2007-11-18 19:03:32 UTC (rev 92) @@ -152,13 +152,11 @@ conf = Configure(env) if conf.CheckCHeader('sys/epoll.h'): - conf.env.Append(CPPDEFINES='HAVE_SYS_EPOLL_H') -if conf.CheckCHeader('sys/poll.h'): - conf.env.Append(CPPDEFINES='HAVE_SYS_POLL_H') + conf.env.Append(CPPDEFINES=['HAVE_SYS_EPOLL_H']) if conf.CheckLib('dl', 'dlopen'): - conf.env.Append(CPPDEFINES='HAVE_DL') + conf.env.Append(CPPDEFINES=['HAVE_DL']) if conf.CheckLib('pthread', 'pthread_create'): - conf.env.Append(CPPDEFINES='HAVE_PTHREAD') + conf.env.Append(CPPDEFINES=['HAVE_PTHREAD']) env = conf.Finish() Modified: adchpp/trunk/adchpp/AdcCommand.cpp =================================================================== --- adchpp/trunk/adchpp/AdcCommand.cpp 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/AdcCommand.cpp 2007-11-18 19:03:32 UTC (rev 92) @@ -21,7 +21,9 @@ #include "AdcCommand.h" namespace adchpp { - + +using namespace std; + AdcCommand::AdcCommand() : cmdInt(0), str(0), from(0), type(0) { } AdcCommand::AdcCommand(Severity sev, Error err, const string& desc, char aType /* = TYPE_INFO */) : cmdInt(CMD_STA), str(&tmp), from(HUB_SID), type(aType) { Modified: adchpp/trunk/adchpp/AdcCommand.h =================================================================== --- adchpp/trunk/adchpp/AdcCommand.h 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/AdcCommand.h 2007-11-18 19:03:32 UTC (rev 92) @@ -105,38 +105,38 @@ uint32_t toCMD(uint8_t a, uint8_t b, uint8_t c) { return (((uint32_t)a) | (((uint32_t)b)<<8) | (((uint32_t)c)<<16)); } ADCHPP_DLL AdcCommand(); - ADCHPP_DLL explicit AdcCommand(Severity sev, Error err, const string& desc, char aType = TYPE_INFO); + ADCHPP_DLL explicit AdcCommand(Severity sev, Error err, const std::string& desc, char aType = TYPE_INFO); explicit AdcCommand(uint32_t cmd, char aType = TYPE_INFO, uint32_t aFrom = HUB_SID) : cmdInt(cmd), str(&tmp), from(aFrom), type(aType) { } - explicit AdcCommand(const string& aLine) throw(ParseException) : cmdInt(0), str(&aLine), type(0) { parse(aLine); } + explicit AdcCommand(const std::string& aLine) throw(ParseException) : cmdInt(0), str(&aLine), type(0) { parse(aLine); } AdcCommand(const AdcCommand& rhs) : parameters(rhs.parameters), cmdInt(rhs.cmdInt), str(&tmp), from(rhs.from), to(rhs.to), type(rhs.type) { } - ADCHPP_DLL void parse(const string& aLine) throw(ParseException); + ADCHPP_DLL void parse(const std::string& aLine) throw(ParseException); uint32_t getCommand() const { return cmdInt; } char getType() const { return type; } StringList& getParameters() { return parameters; } const StringList& getParameters() const { return parameters; } - ADCHPP_DLL const string& toString() const; + ADCHPP_DLL const std::string& toString() const; void resetString() { tmp.clear(); str = &tmp; } - AdcCommand& addParam(const string& name, const string& value) { + AdcCommand& addParam(const std::string& name, const std::string& value) { parameters.push_back(name); parameters.back() += value; return *this; } - AdcCommand& addParam(const string& param) { + AdcCommand& addParam(const std::string& param) { parameters.push_back(param); return *this; } - const string& getParam(size_t n) const { + const std::string& getParam(size_t n) const { return getParameters().size() > n ? getParameters()[n] : Util::emptyString; } - const string& getFeatures() const { return features; } + const std::string& getFeatures() const { return features; } /** Return a named parameter where the name is a two-letter code */ - ADCHPP_DLL bool getParam(const char* name, size_t start, string& ret) const; + ADCHPP_DLL bool getParam(const char* name, size_t start, std::string& ret) const; ADCHPP_DLL bool delParam(const char* name, size_t start); ADCHPP_DLL bool hasFlag(const char* name, size_t start) const; @@ -144,28 +144,28 @@ bool operator==(uint32_t aCmd) const { return cmdInt == aCmd; } - ADCHPP_DLL static void escape(const string& s, string& out); + ADCHPP_DLL static void escape(const std::string& s, std::string& out); uint32_t getTo() const { return to; } void setTo(uint32_t aTo) { to = aTo; } uint32_t getFrom() const { return from; } void setFrom(uint32_t aFrom) { from = aFrom; } - static uint32_t toSID(const string& aSID) { return *reinterpret_cast<const uint32_t*>(aSID.data()); } - static string fromSID(const uint32_t aSID) { return string(reinterpret_cast<const char*>(&aSID), sizeof(aSID)); } - static void appendSID(string& str, uint32_t aSID) { str.append(reinterpret_cast<const char*>(&aSID), sizeof(aSID)); } + static uint32_t toSID(const std::string& aSID) { return *reinterpret_cast<const uint32_t*>(aSID.data()); } + static std::string fromSID(const uint32_t aSID) { return std::string(reinterpret_cast<const char*>(&aSID), sizeof(aSID)); } + static void appendSID(std::string& str, uint32_t aSID) { str.append(reinterpret_cast<const char*>(&aSID), sizeof(aSID)); } private: AdcCommand& operator=(const AdcCommand&); StringList parameters; - string features; + std::string features; union { char cmdChar[4]; uint8_t cmd[4]; uint32_t cmdInt; }; - const string* str; - mutable string tmp; + const std::string* str; + mutable std::string tmp; uint32_t from; uint32_t to; Modified: adchpp/trunk/adchpp/CID.h =================================================================== --- adchpp/trunk/adchpp/CID.h 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/CID.h 2007-11-18 19:03:32 UTC (rev 92) @@ -38,18 +38,18 @@ }; CID() { memset(cid, 0, sizeof(cid)); } explicit CID(const uint8_t* data) { memcpy(cid, data, sizeof(cid)); } - explicit CID(const string& base32) { Encoder::fromBase32(base32.c_str(), cid, sizeof(cid)); } + explicit CID(const std::string& base32) { Encoder::fromBase32(base32.c_str(), cid, sizeof(cid)); } bool operator==(const CID& rhs) const { return memcmp(cid, rhs.cid, sizeof(cid)) == 0; } bool operator<(const CID& rhs) const { return memcmp(cid, rhs.cid, sizeof(cid)) < 0; } - string toBase32() const { return Encoder::toBase32(cid, sizeof(cid)); } - string& toBase32(string& tmp) const { return Encoder::toBase32(cid, sizeof(cid), tmp); } + std::string toBase32() const { return Encoder::toBase32(cid, sizeof(cid)); } + std::string& toBase32(std::string& tmp) const { return Encoder::toBase32(cid, sizeof(cid), tmp); } size_t toHash() const { return *reinterpret_cast<const size_t*>(cid); } const uint8_t* data() const { return cid; } - bool isZero() const { return find_if(cid, cid+SIZE, bind2nd(not_equal_to<uint8_t>(), 0)) == (cid+SIZE); } + bool isZero() const { return std::find_if(cid, cid+SIZE, std::bind2nd(std::not_equal_to<uint8_t>(), 0)) == (cid+SIZE); } static CID generate() { uint8_t data[CID::SIZE]; Modified: adchpp/trunk/adchpp/Client.cpp =================================================================== --- adchpp/trunk/adchpp/Client.cpp 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/Client.cpp 2007-11-18 19:03:32 UTC (rev 92) @@ -26,6 +26,7 @@ namespace adchpp { +using namespace std; using namespace std::tr1::placeholders; Client* Client::create(const ManagedSocketPtr& ms) throw() { Modified: adchpp/trunk/adchpp/Client.h =================================================================== --- adchpp/trunk/adchpp/Client.h 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/Client.h 2007-11-18 19:03:32 UTC (rev 92) @@ -65,17 +65,17 @@ static Client* create(const ManagedSocketPtr& ms_) throw(); const StringList& getSupportList() const throw() { return supportList; } - bool supports(const string& feat) const throw() { return find(supportList.begin(), supportList.end(), feat) != supportList.end(); } + bool supports(const std::string& feat) const throw() { return find(supportList.begin(), supportList.end(), feat) != supportList.end(); } void send(const char* command, size_t len) throw() { dcassert(socket != NULL); socket->write(command, len); } void send(const AdcCommand& cmd) throw() { send(cmd.toString()); } - void send(const string& command) throw() { send(command.c_str(), command.length()); } + void send(const std::string& command) throw() { send(command.c_str(), command.length()); } void send(const char* command) throw() { socket->write(command, strlen(command)); } - void fastSend(const string& command, bool lowPrio = false) throw() { + void fastSend(const std::string& command, bool lowPrio = false) throw() { socket->fastWrite(command.c_str(), command.length(), lowPrio); } size_t getQueuedBytes() throw() { return socket->getQueuedBytes(); } @@ -84,7 +84,7 @@ ADCHPP_DLL void disconnect(Util::Reason reason) throw(); const ManagedSocketPtr& getSocket() throw() { return socket; } const ManagedSocketPtr& getSocket() const throw() { return socket; } - const string& getIp() const throw() { dcassert(socket != NULL); return getSocket()->getIp(); } + const std::string& getIp() const throw() { dcassert(socket != NULL); return getSocket()->getIp(); } /** * Set data mode for aBytes bytes. @@ -96,12 +96,12 @@ /** Add any flags that have been updated to the AdcCommand (type etc is not set) */ ADCHPP_DLL bool getChangedFields(AdcCommand& cmd) const throw(); ADCHPP_DLL bool getAllFields(AdcCommand& cmd) const throw(); - ADCHPP_DLL const string& getINF() const throw(); + ADCHPP_DLL const std::string& getINF() const throw(); void resetChanged() { changed.clear(); } - const string& getField(const char* name) const throw() { InfMap::const_iterator i = info.find(AdcCommand::toCode(name)); return i == info.end() ? Util::emptyString : i->second; } - ADCHPP_DLL void setField(const char* name, const string& value) throw(); + const std::string& getField(const char* name) const throw() { InfMap::const_iterator i = info.find(AdcCommand::toCode(name)); return i == info.end() ? Util::emptyString : i->second; } + ADCHPP_DLL void setField(const char* name, const std::string& value) throw(); ADCHPP_DLL void updateFields(const AdcCommand& cmd) throw(); ADCHPP_DLL void updateSupports(const AdcCommand& cmd) throw(); @@ -150,11 +150,11 @@ StringList filters; /** H-C SUP */ StringList supportList; - typedef pair<int, void*> PSDPair; - typedef vector<PSDPair> PSDList; + typedef std::pair<int, void*> PSDPair; + typedef std::vector<PSDPair> PSDList; typedef PSDList::iterator PSDIter; - typedef std::tr1::unordered_map<uint16_t, string> InfMap; + typedef std::tr1::unordered_map<uint16_t, std::string> InfMap; typedef InfMap::iterator InfIter; InfMap info; @@ -168,14 +168,14 @@ bool disconnecting; PSDList psd; - string line; + std::string line; ManagedSocketPtr socket; int64_t dataBytes; time_t floodTimer; /** Latest INF cached */ - mutable string INF; + mutable std::string INF; DataFunction dataHandler; void setSocket(const ManagedSocketPtr& aSocket) throw(); Modified: adchpp/trunk/adchpp/ClientManager.cpp =================================================================== --- adchpp/trunk/adchpp/ClientManager.cpp 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/ClientManager.cpp 2007-11-18 19:03:32 UTC (rev 92) @@ -31,7 +31,9 @@ #include "SettingsManager.h" namespace adchpp { - + +using namespace std; + ClientManager* ClientManager::instance = 0; const string ClientManager::className = "ClientManager"; Modified: adchpp/trunk/adchpp/ClientManager.h =================================================================== --- adchpp/trunk/adchpp/ClientManager.h 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/ClientManager.h 2007-11-18 19:03:32 UTC (rev 92) @@ -45,14 +45,14 @@ typedef ClientMap::iterator ClientIter; /** Adds a string to SUP, propagating the change to all connected clients */ - ADCHPP_DLL void addSupports(const string& str) throw(); + ADCHPP_DLL void addSupports(const std::string& str) throw(); /** Removes a string from SUP, propagating the change to all connected clients */ - ADCHPP_DLL void removeSupports(const string& str) throw(); + ADCHPP_DLL void removeSupports(const std::string& str) throw(); ADCHPP_DLL void updateCache() throw(); /** @return SID of client or 0 if not found */ - ADCHPP_DLL uint32_t getSID(const string& nick) const throw(); + ADCHPP_DLL uint32_t getSID(const std::string& nick) const throw(); /** @return SID of client or 0 if not found */ ADCHPP_DLL uint32_t getSID(const CID& cid) const throw(); @@ -71,7 +71,7 @@ ADCHPP_DLL void send(const AdcCommand& cmd, bool lowPrio = false) throw(); /** Send command to all regardless of type */ void sendToAll(const AdcCommand& cmd) throw() { sendToAll(cmd.toString()); } - ADCHPP_DLL void sendToAll(const string& cmd) throw(); + ADCHPP_DLL void sendToAll(const std::string& cmd) throw(); /** Send command to a single client regardless of type */ ADCHPP_DLL void sendTo(const AdcCommand& cmd, const uint32_t& to) throw(); @@ -97,7 +97,7 @@ * @param sendData Send GPA. * @return The random data that was sent to the client (if sendData was true, undefined otherwise). */ - ADCHPP_DLL vector<uint8_t> enterVerify(Client& c, bool sendData) throw(); + ADCHPP_DLL ByteVector enterVerify(Client& c, bool sendData) throw(); /** * Enter NORMAL state. Call this if you stop an INF of a password-less @@ -129,7 +129,7 @@ /** * Verify password */ - ADCHPP_DLL bool verifyPassword(Client& c, const string& password, const vector<uint8_t>& salt, const string& suppliedHash); + ADCHPP_DLL bool verifyPassword(Client& c, const std::string& password, const ByteVector& salt, const std::string& suppliedHash); /** * Verify that IP is correct and replace any zero addresses. @@ -157,7 +157,7 @@ typedef SignalTraits<void (Client&)> SignalConnected; typedef SignalTraits<void (Client&, AdcCommand&, int&)> SignalReceive; - typedef SignalTraits<void (Client&, const string&)> SignalBadLine; + typedef SignalTraits<void (Client&, const std::string&)> SignalBadLine; typedef SignalTraits<void (Client&, AdcCommand&, int&)> SignalSend; typedef SignalTraits<void (Client&, int)> SignalState; typedef SignalTraits<void (Client&)> SignalDisconnected; @@ -177,10 +177,10 @@ */ StringList supports; - deque<pair<Client*, time_t> > logins; + std::deque<std::pair<Client*, time_t> > logins; ClientMap clients; - typedef std::tr1::unordered_map<string, uint32_t> NickMap; + typedef std::tr1::unordered_map<std::string, uint32_t> NickMap; NickMap nicks; typedef std::tr1::unordered_map<CID, uint32_t, CID::Hash> CIDMap; CIDMap cids; @@ -188,14 +188,14 @@ SIDSet sids; // Temporary string to use whenever a temporary string is needed (to avoid (de)allocating memory all the time...) - string strtmp; + std::string strtmp; - static const string className; + static const std::string className; // Strings used in various places along the pipeline...rebuilt in updateCache()... struct Strings { - string sup; - string inf; + std::string sup; + std::string inf; } strings; friend class Singleton<ClientManager>; @@ -216,7 +216,7 @@ void onConnected(Client&) throw(); void onReceive(Client&, AdcCommand&) throw(); - void onBadLine(Client&, const string&) throw(); + void onBadLine(Client&, const std::string&) throw(); void onFailed(Client&) throw(); void badState(Client& c, const AdcCommand& cmd) throw(); Modified: adchpp/trunk/adchpp/Encoder.cpp =================================================================== --- adchpp/trunk/adchpp/Encoder.cpp 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/Encoder.cpp 2007-11-18 19:03:32 UTC (rev 92) @@ -22,7 +22,9 @@ #include "common.h" namespace adchpp { - + +using namespace std; + const int8_t Encoder::base32Table[256] = { -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, Modified: adchpp/trunk/adchpp/Encoder.h =================================================================== --- adchpp/trunk/adchpp/Encoder.h 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/Encoder.h 2007-11-18 19:03:32 UTC (rev 92) @@ -24,9 +24,9 @@ class Encoder { public: - ADCHPP_DLL static string& toBase32(const uint8_t* src, size_t len, string& tgt); - static string toBase32(const uint8_t* src, size_t len) { - string tmp; + ADCHPP_DLL static std::string& toBase32(const uint8_t* src, size_t len, std::string& tgt); + static std::string toBase32(const uint8_t* src, size_t len) { + std::string tmp; return toBase32(src, len, tmp); } ADCHPP_DLL static void fromBase32(const char* src, uint8_t* dst, size_t len); Modified: adchpp/trunk/adchpp/Exception.h =================================================================== --- adchpp/trunk/adchpp/Exception.h 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/Exception.h 2007-11-18 19:03:32 UTC (rev 92) @@ -23,17 +23,17 @@ namespace adchpp { -class ADCHPP_VISIBLE Exception : public exception +class ADCHPP_VISIBLE Exception : public std::exception { public: Exception() { } - Exception(const string& aError) throw() : error(aError) { dcdebug("Thrown: %s\n", error.c_str()); } + Exception(const std::string& aError) throw() : error(aError) { dcdebug("Thrown: %s\n", error.c_str()); } virtual ~Exception() throw() { } - const string& getError() const throw() { return error; } + const std::string& getError() const throw() { return error; } virtual const char* what() { return error.c_str(); } protected: - string error; + std::string error; }; #ifndef NDEBUG @@ -41,7 +41,7 @@ #define STANDARD_EXCEPTION(name) class ADCHPP_VISIBLE name : public Exception { \ public:\ name() throw() : Exception(#name) { } \ - name(const string& aError) throw() : Exception(#name ": " + aError) { } \ + name(const std::string& aError) throw() : Exception(#name ": " + aError) { } \ virtual ~name() throw() { } \ } Modified: adchpp/trunk/adchpp/File.cpp =================================================================== --- adchpp/trunk/adchpp/File.cpp 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/File.cpp 2007-11-18 19:03:32 UTC (rev 92) @@ -21,7 +21,9 @@ #include "File.h" namespace adchpp { - + +using namespace std; + string File::read(uint32_t len) throw(FileException) { string tmp; tmp.resize(len); Modified: adchpp/trunk/adchpp/File.h =================================================================== --- adchpp/trunk/adchpp/File.h 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/File.h 2007-11-18 19:03:32 UTC (rev 92) @@ -46,24 +46,24 @@ TRUNCATE = 0x04 }; - ADCHPP_DLL File(const string& aFileName, int access, int mode = OPEN) throw(FileException); + ADCHPP_DLL File(const std::string& aFileName, int access, int mode = OPEN) throw(FileException); ADCHPP_DLL int64_t getSize(); - ADCHPP_DLL static int64_t getSize(const string& aFileName); + ADCHPP_DLL static int64_t getSize(const std::string& aFileName); - ADCHPP_DLL string read(uint32_t len) throw(FileException); + ADCHPP_DLL std::string read(uint32_t len) throw(FileException); /** Returns the directory part of the full path */ - ADCHPP_DLL static string getFilePath(const string& name) throw(); + ADCHPP_DLL static std::string getFilePath(const std::string& name) throw(); /** Returns the filename part of the full path */ - ADCHPP_DLL static string getFileName(const string& name) throw(); - ADCHPP_DLL static bool isAbsolutePath(const string& name) throw(); + ADCHPP_DLL static std::string getFileName(const std::string& name) throw(); + ADCHPP_DLL static bool isAbsolutePath(const std::string& name) throw(); - static string makeAbsolutePath(string const& path, string const& filename) { + static std::string makeAbsolutePath(const std::string& path, const std::string& filename) { return isAbsolutePath(filename) ? filename : path + filename; } - ADCHPP_DLL static void ensureDirectory(const string& aFile) throw(); + ADCHPP_DLL static void ensureDirectory(const std::string& aFile) throw(); #ifdef _WIN32 void close() { @@ -159,8 +159,8 @@ void setEOF() throw(FileException) { } - static void deleteFile(const string& aFileName) { ::unlink(aFileName.c_str()); }; - static void renameFile(const string& source, const string& target) { ::rename(source.c_str(), target.c_str()); }; + static void deleteFile(const std::string& aFileName) { ::unlink(aFileName.c_str()); }; + static void renameFile(const std::string& source, const std::string& target) { ::rename(source.c_str(), target.c_str()); }; #endif // WIN32 @@ -168,12 +168,12 @@ close(); } - string read() throw(FileException) { + std::string read() throw(FileException) { setPos(0); return read((uint32_t)getSize()); } - void write(const string& aString) throw(FileException) { + void write(const std::string& aString) throw(FileException) { write((void*)aString.data(), aString.size()); } Modified: adchpp/trunk/adchpp/LogManager.cpp =================================================================== --- adchpp/trunk/adchpp/LogManager.cpp 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/LogManager.cpp 2007-11-18 19:03:32 UTC (rev 92) @@ -25,6 +25,8 @@ namespace adchpp { +using namespace std; + LogManager* LogManager::instance = 0; void LogManager::logDateTime(const string& area, const string& msg) throw() Modified: adchpp/trunk/adchpp/LogManager.h =================================================================== --- adchpp/trunk/adchpp/LogManager.h 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/LogManager.h 2007-11-18 19:03:32 UTC (rev 92) @@ -35,8 +35,8 @@ * @param area Name of the module that generated the error. * @param msg Message to log. */ - void log(const string& area, const string& msg) throw() { - string tmp(area); + void log(const std::string& area, const std::string& msg) throw() { + std::string tmp(area); tmp += ": "; tmp += msg; dolog(tmp); @@ -46,7 +46,7 @@ * Same as log, but prepends the current date and time. * @see log */ - ADCHPP_DLL void logDateTime(const string& area, const string& msg) throw(); + ADCHPP_DLL void logDateTime(const std::string& area, const std::string& msg) throw(); private: friend class Singleton<LogManager>; ADCHPP_DLL static LogManager* instance; @@ -55,7 +55,7 @@ LogManager() throw() { } virtual ~LogManager() throw() { } - ADCHPP_DLL void dolog(const string& msg) throw(); + ADCHPP_DLL void dolog(const std::string& msg) throw(); }; #define LOG(area, msg) LogManager::getInstance()->log(area, msg) Modified: adchpp/trunk/adchpp/ManagedSocket.cpp =================================================================== --- adchpp/trunk/adchpp/ManagedSocket.cpp 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/ManagedSocket.cpp 2007-11-18 19:03:32 UTC (rev 92) @@ -27,6 +27,8 @@ namespace adchpp { +using namespace std; + FastMutex ManagedSocket::writeMutex; ManagedSocket::ManagedSocket() throw() : outBuf(0), overFlow(0), disc(0) Modified: adchpp/trunk/adchpp/ManagedSocket.h =================================================================== --- adchpp/trunk/adchpp/ManagedSocket.h 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/ManagedSocket.h 2007-11-18 19:03:32 UTC (rev 92) @@ -52,8 +52,8 @@ /** Asynchronous disconnect. Pending data will be written, but no more data will be read. */ ADCHPP_DLL void disconnect(Util::Reason reason) throw(); - const string& getIp() const { return ip; } - void setIp(const string& ip_) { ip = ip_; } + const std::string& getIp() const { return ip; } + void setIp(const std::string& ip_) { ip = ip_; } typedef std::tr1::function<void()> ConnectedHandler; void setConnectedHandler(const ConnectedHandler& handler) { connectedHandler = handler; } @@ -98,7 +98,7 @@ /** Disconnection scheduled for this socket */ uint32_t disc; - string ip; + std::string ip; #ifdef _WIN32 /** Data currently being sent by WSASend, 0 if not sending */ ByteVector* writeBuf; Modified: adchpp/trunk/adchpp/PluginManager.cpp =================================================================== --- adchpp/trunk/adchpp/PluginManager.cpp 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/PluginManager.cpp 2007-11-18 19:03:32 UTC (rev 92) @@ -27,8 +27,6 @@ #include "version.h" #include "File.h" -using namespace std::tr1::placeholders; - #ifdef _WIN32 #define PLUGIN_EXT _T(".dll") @@ -53,6 +51,9 @@ namespace adchpp { +using namespace std; +using namespace std::tr1::placeholders; + PluginManager* PluginManager::instance = 0; const string PluginManager::className = "PluginManager"; Modified: adchpp/trunk/adchpp/PluginManager.h =================================================================== --- adchpp/trunk/adchpp/PluginManager.h 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/PluginManager.h 2007-11-18 19:03:32 UTC (rev 92) @@ -143,7 +143,7 @@ class PluginManager : public Singleton<PluginManager> { public: - typedef std::tr1::unordered_map<string, Plugin*> Registry; + typedef std::tr1::unordered_map<std::string, Plugin*> Registry; typedef Registry::iterator RegistryIter; /** @@ -156,7 +156,7 @@ /** * Get the plugin path as set in adchpp.xml */ - const string& getPluginPath() const { + const std::string& getPluginPath() const { return pluginPath; } @@ -173,19 +173,19 @@ * Register a plugin interface under a name. * @return false if name was already registered and call fails */ - bool registerPlugin(const string& name, Plugin* ptr) { - return registry.insert(make_pair(name, ptr)).second; + bool registerPlugin(const std::string& name, Plugin* ptr) { + return registry.insert(std::make_pair(name, ptr)).second; } /** @return True if the plugin existed and was thus unregistered */ - bool unregisterPlugin(const string& name) { + bool unregisterPlugin(const std::string& name) { return registry.erase(name) > 0; } /** * @return Plugin interface, or NULL if not found */ - Plugin* getPlugin(const string& name) { + Plugin* getPlugin(const std::string& name) { RegistryIter i = registry.find(name); return i == registry.end() ? NULL : i->second; } @@ -224,22 +224,22 @@ friend class Singleton<PluginManager>; ADCHPP_DLL static PluginManager* instance; - typedef vector<PluginInfo> PluginList; + typedef std::vector<PluginInfo> PluginList; typedef PluginList::iterator PluginIter; PluginList active; Registry registry; StringList plugins; - string pluginPath; + std::string pluginPath; int pluginIds; - static const string className; + static const std::string className; PluginManager() throw(); - bool loadPlugin(const string& file); + bool loadPlugin(const std::string& file); void onLoad(const SimpleXML& xml) throw(); }; Modified: adchpp/trunk/adchpp/Pool.h =================================================================== --- adchpp/trunk/adchpp/Pool.h 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/Pool.h 2007-11-18 19:03:32 UTC (rev 92) @@ -64,7 +64,7 @@ private: size_t busy; - vector<T*> free; + std::vector<T*> free; }; Modified: adchpp/trunk/adchpp/ResourceManager.cpp =================================================================== --- adchpp/trunk/adchpp/ResourceManager.cpp 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/ResourceManager.cpp 2007-11-18 19:03:32 UTC (rev 92) @@ -26,6 +26,9 @@ namespace adchpp { +using namespace std; +using namespace std::tr1; + ResourceManager* ResourceManager::instance = 0; const string ResourceManager::className = "ResourceManager"; @@ -35,7 +38,7 @@ SimpleXML xml; xml.fromXML(f.read()); - std::tr1::unordered_map<string, int> h; + unordered_map<string, int> h; for(int i = 0; i < LAST; ++i) { h[names[i]] = i; @@ -47,7 +50,7 @@ xml.stepIn(); while(xml.findChild("String")) { - std::tr1::unordered_map<string, int>::iterator j = h.find(xml.getChildAttrib("Name")); + unordered_map<string, int>::iterator j = h.find(xml.getChildAttrib("Name")); if(j != h.end()) { strings[j->second] = xml.getChildData(); Modified: adchpp/trunk/adchpp/ResourceManager.h =================================================================== --- adchpp/trunk/adchpp/ResourceManager.h 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/ResourceManager.h 2007-11-18 19:03:32 UTC (rev 92) @@ -31,8 +31,8 @@ #include "StringDefs.h" - void loadLanguage(const string& aFile); - const string& getString(Strings x) const { return strings[x]; } + void loadLanguage(const std::string& aFile); + const std::string& getString(Strings x) const { return strings[x]; } private: @@ -43,10 +43,10 @@ ResourceManager() throw() { } virtual ~ResourceManager() throw() { } - ADCHPP_DLL static string strings[LAST]; - static string names[LAST]; + ADCHPP_DLL static std::string strings[LAST]; + static std::string names[LAST]; - static const string className; + static const std::string className; }; #define STRING(x) ResourceManager::getInstance()->getString(ResourceManager::x) Modified: adchpp/trunk/adchpp/SettingsManager.cpp =================================================================== --- adchpp/trunk/adchpp/SettingsManager.cpp 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/SettingsManager.cpp 2007-11-18 19:03:32 UTC (rev 92) @@ -27,6 +27,8 @@ namespace adchpp { +using namespace std; + SettingsManager* SettingsManager::instance = 0; const string SettingsManager::className = "SettingsManager"; Modified: adchpp/trunk/adchpp/SettingsManager.h =================================================================== --- adchpp/trunk/adchpp/SettingsManager.h 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/SettingsManager.h 2007-11-18 19:03:32 UTC (rev 92) @@ -63,9 +63,9 @@ * Get the XML name of a setting * @param n Setting identifier */ - const string& getName(int n) { dcassert(n < SETTINGS_LAST); return settingTags[n]; } + const std::string& getName(int n) { dcassert(n < SETTINGS_LAST); return settingTags[n]; } - const string& get(StrSetting key) const { + const std::string& get(StrSetting key) const { return strSettings[key - STR_FIRST]; } @@ -80,7 +80,7 @@ return (get(key) > 0); } - void set(StrSetting key, string const& value) { + void set(StrSetting key, const std::string& value) { strSettings[key - STR_FIRST] = value; } @@ -109,7 +109,7 @@ load(Util::getCfgPath() + _T("adchpp.xml")); } - void load(const string& aFileName); + void load(const std::string& aFileName); typedef SignalTraits<void (const SimpleXML&)> SignalLoad; SignalLoad::Signal& signalLoad() { return signalLoad_; } @@ -120,12 +120,12 @@ SettingsManager() throw(); virtual ~SettingsManager() throw() { } - ADCHPP_DLL static const string settingTags[SETTINGS_LAST+1]; + ADCHPP_DLL static const std::string settingTags[SETTINGS_LAST+1]; - static const string className; + static const std::string className; - string strSettings[STR_LAST - STR_FIRST]; - int intSettings[INT_LAST - INT_FIRST]; + std::string strSettings[STR_LAST - STR_FIRST]; + int intSettings[INT_LAST - INT_FIRST]; int64_t int64Settings[/*INT64_LAST - INT64_FIRST*/1]; SignalLoad::Signal signalLoad_; Modified: adchpp/trunk/adchpp/Signal.h =================================================================== --- adchpp/trunk/adchpp/Signal.h 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/Signal.h 2007-11-18 19:03:32 UTC (rev 92) @@ -26,7 +26,7 @@ template<typename F> struct Signal { typedef std::tr1::function<F> Slot; - typedef list<Slot> SlotList; + typedef std::list<Slot> SlotList; typedef typename SlotList::iterator Connection; typedef F FunctionType; Modified: adchpp/trunk/adchpp/SimpleXML.cpp =================================================================== --- adchpp/trunk/adchpp/SimpleXML.cpp 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/SimpleXML.cpp 2007-11-18 19:03:32 UTC (rev 92) @@ -22,6 +22,8 @@ namespace adchpp { +using namespace std; + SimpleXML::SimpleXML(int numAttribs) : attribs(numAttribs), found(false) { root = current = new Tag("BOGUSROOT", Util::emptyString, NULL); } Modified: adchpp/trunk/adchpp/SimpleXML.h =================================================================== --- adchpp/trunk/adchpp/SimpleXML.h 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/SimpleXML.h 2007-11-18 19:03:32 UTC (rev 92) @@ -36,34 +36,28 @@ ADCHPP_DLL SimpleXML(int numAttribs = 0); ADCHPP_DLL ~SimpleXML(); - ADCHPP_DLL void addTag(const string& aName, const string& aData = Util::emptyString) throw(SimpleXMLException); - void addTag(const string& aName, int aData) throw(SimpleXMLException) { + ADCHPP_DLL void addTag(const std::string& aName, const std::string& aData = Util::emptyString) throw(SimpleXMLException); + void addTag(const std::string& aName, int aData) throw(SimpleXMLException) { addTag(aName, Util::toString(aData)); } - void addTag(const string& aName, int64_t aData) throw(SimpleXMLException) { + void addTag(const std::string& aName, int64_t aData) throw(SimpleXMLException) { addTag(aName, Util::toString(aData)); } template<typename T> - void addAttrib(const string& aName, const T& aData) throw(SimpleXMLException) { + void addAttrib(const std::string& aName, const T& aData) throw(SimpleXMLException) { addAttrib(aName, Util::toString(aData)); } - ADCHPP_DLL void addAttrib(const string& aName, const string& aData) throw(SimpleXMLException); - void addAttrib(const string& aName, bool aData) throw(SimpleXMLException) { - addAttrib(aName, string(aData ? "1" : "0")); - } + ADCHPP_DLL void addAttrib(const std::string& aName, const std::string& aData) throw(SimpleXMLException); template <typename T> - void addChildAttrib(const string& aName, const T& aData) throw(SimpleXMLException) { + void addChildAttrib(const std::string& aName, const T& aData) throw(SimpleXMLException) { addChildAttrib(aName, Util::toString(aData)); } - ADCHPP_DLL void addChildAttrib(const string& aName, const string& aData) throw(SimpleXMLException); - void addChildAttrib(const string& aName, bool aData) throw(SimpleXMLException) { - addChildAttrib(aName, string(aData ? "1" : "0")); - } + ADCHPP_DLL void addChildAttrib(const std::string& aName, const std::string& aData) throw(SimpleXMLException); - const string& getData() const { + const std::string& getData() const { dcassert(current != NULL); return current->data; } @@ -77,53 +71,53 @@ currentChild = current->children.begin(); } - ADCHPP_DLL bool findChild(const string& aName) const throw(); + ADCHPP_DLL bool findChild(const std::string& aName) const throw(); - const string& getChildData() const throw(SimpleXMLException) { + const std::string& getChildData() const throw(SimpleXMLException) { checkChildSelected(); return (*currentChild)->data; } - const string& getChildAttrib(const string& aName, const string& aDefault = Util::emptyString) const throw(SimpleXMLException) { + const std::string& getChildAttrib(const std::string& aName, const std::string& aDefault = Util::emptyString) const throw(SimpleXMLException) { checkChildSelected(); return (*currentChild)->getAttrib(aName, aDefault); } - int getIntChildAttrib(const string& aName) throw(SimpleXMLException) { + int getIntChildAttrib(const std::string& aName) throw(SimpleXMLException) { checkChildSelected(); return Util::toInt(getChildAttrib(aName)); } - int64_t getLongLongChildAttrib(const string& aName) throw(SimpleXMLException) { + int64_t getLongLongChildAttrib(const std::string& aName) throw(SimpleXMLException) { checkChildSelected(); return Util::toInt64(getChildAttrib(aName)); } - bool getBoolChildAttrib(const string& aName) throw(SimpleXMLException) { + bool getBoolChildAttrib(const std::string& aName) throw(SimpleXMLException) { checkChildSelected(); - const string& tmp = getChildAttrib(aName); + const std::string& tmp = getChildAttrib(aName); return (tmp.size() > 0) && tmp[0] == '1'; } - ADCHPP_DLL void fromXML(const string& aXML) throw(SimpleXMLException); - string toXML() { return (!root->children.empty()) ? root->children[0]->toXML(0) : Util::emptyString; } + ADCHPP_DLL void fromXML(const std::string& aXML) throw(SimpleXMLException); + std::string toXML() { return (!root->children.empty()) ? root->children[0]->toXML(0) : Util::emptyString; } - ADCHPP_DLL static void escape(string& aString, bool aAttrib, bool aLoading = false); + ADCHPP_DLL static void escape(std::string& aString, bool aAttrib, bool aLoading = false); /** * This is a heurestic for whether escape needs to be called or not. The results are * only guaranteed for false, i e sometimes true might be returned even though escape * was not needed... */ - static bool needsEscape(const string& aString, bool aAttrib, bool aLoading = false) { - return ((aLoading) ? aString.find('&') : aString.find_first_of(aAttrib ? "<&>'\"" : "<&>")) != string::npos; + static bool needsEscape(const std::string& aString, bool aAttrib, bool aLoading = false) { + return ((aLoading) ? aString.find('&') : aString.find_first_of(aAttrib ? "<&>'\"" : "<&>")) != std::string::npos; } private: class Tag { public: typedef Tag* Ptr; - typedef vector<Ptr> List; + typedef std::vector<Ptr> List; typedef List::iterator Iter; - typedef pair<string,string> StringPair; - typedef vector<StringPair> AttribMap; + typedef std::pair<std::string, std::string> StringPair; + typedef std::vector<StringPair> AttribMap; typedef AttribMap::iterator AttribIter; /** @@ -139,29 +133,29 @@ AttribMap attribs; /** Tag name */ - string name; + std::string name; /** Tag data, may be empty. */ - string data; + std::string data; /** Parent tag, for easy traversal */ Ptr parent; - Tag(const string& aName, const string& aData, Ptr aParent, int numAttribs = 0) : name(aName), data(aData), parent(aParent) { + Tag(const std::string& aName, const std::string& aData, Ptr aParent, int numAttribs = 0) : name(aName), data(aData), parent(aParent) { if(numAttribs > 0) attribs.reserve(numAttribs); } - const string& getAttrib(const string& aName, const string& aDefault = Util::emptyString) { - AttribIter i = find_if(attribs.begin(), attribs.end(), CompareFirst<string,string>(aName)); + const std::string& getAttrib(const std::string& aName, const std::string& aDefault = Util::emptyString) { + AttribIter i = find_if(attribs.begin(), attribs.end(), CompareFirst<std::string, std::string>(aName)); return (i == attribs.end()) ? aDefault : i->second; } - ADCHPP_DLL string toXML(int indent); + ADCHPP_DLL std::string toXML(int indent); - string::size_type fromXML(const string& tmp, string::size_type start, int aa, bool isRoot = false) throw(SimpleXMLException); - string::size_type loadAttribs(const string& tmp, string::size_type start) throw(SimpleXMLException); + std::string::size_type fromXML(const std::string& tmp, std::string::size_type start, int aa, bool isRoot = false) throw(SimpleXMLException); + std::string::size_type loadAttribs(const std::string& tmp, std::string::size_type start) throw(SimpleXMLException); - void appendAttribString(string& tmp); + void appendAttribString(std::string& tmp); /** Delete all children! */ ~Tag() { for(Iter i = children.begin(); i != children.end(); ++i) { Modified: adchpp/trunk/adchpp/Socket.cpp =================================================================== --- adchpp/trunk/adchpp/Socket.cpp 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/Socket.cpp 2007-11-18 19:03:32 UTC (rev 92) @@ -21,7 +21,9 @@ #include "Socket.h" namespace adchpp { - + +using namespace std; + string SocketException::errorToString(int aError) throw() { return Util::translateError(aError); } Modified: adchpp/trunk/adchpp/Socket.h =================================================================== --- adchpp/trunk/adchpp/Socket.h 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/Socket.h 2007-11-18 19:03:32 UTC (rev 92) @@ -80,7 +80,7 @@ virtual ~SocketException() throw() { } private: int err; - static string errorToString(int aError) throw(); + static std::string errorToString(int aError) throw(); }; class Socket @@ -99,21 +99,21 @@ }; Socket() throw(SocketException) : sock(INVALID_SOCKET) { } - Socket(const string& aIp, const string& aPort) throw(SocketException) : sock(INVALID_SOCKET) { connect(aIp, aPort); } - Socket(const string& aIp, short aPort) throw(SocketException) : sock(INVALID_SOCKET) { connect(aIp, aPort); } + Socket(const std::string& aIp, const std::string& aPort) throw(SocketException) : sock(INVALID_SOCKET) { connect(aIp, aPort); } + Socket(const std::string& aIp, short aPort) throw(SocketException) : sock(INVALID_SOCKET) { connect(aIp, aPort); } virtual ~Socket() throw() { disconnect(); } virtual void create(int aType = TYPE_TCP) throw(SocketException); virtual void bind(short aPort) throw(SocketException); - virtual void connect(const string& aIp, short aPort) throw(SocketException); - void connect(const string& aIp, const string& aPort) throw(SocketException) { connect(aIp, (short)Util::toInt(aPort)); } - virtual string accept(const Socket& aSocket) throw(SocketException); + virtual void connect(const std::string& aIp, short aPort) throw(SocketException); + void connect(const std::string& aIp, const std::string& aPort) throw(SocketException) { connect(aIp, (short)Util::toInt(aPort)); } + virtual std::string accept(const Socket& aSocket) throw(SocketException); virtual void write(const char* aBuffer, size_t aLen) throw(SocketException); - void write(const string& aData) throw(SocketException) { write(aData.data(), aData.length()); } + void write(const std::string& aData) throw(SocketException) { write(aData.data(), aData.length()); } virtual int writeNB(const char* aBuffer, size_t aLen) throw(SocketException); - int writeNB(const string& aData) throw(SocketException) { return writeNB(aData.data(), aData.length()); } - virtual void writeTo(const string& aIp, short aPort, const char* aBuffer, size_t aLen) throw(SocketException); - void writeTo(const string& aIp, short aPort, const string& aData) throw(SocketException) { writeTo(aIp, aPort, aData.data(), aData.length()); } + int writeNB(const std::string& aData) throw(SocketException) { return writeNB(aData.data(), aData.length()); } + virtual void writeTo(const std::string& aIp, short aPort, const char* aBuffer, size_t aLen) throw(SocketException); + void writeTo(const std::string& aIp, short aPort, const std::string& aData) throw(SocketException) { writeTo(aIp, aPort, aData.data(), aData.length()); } virtual void disconnect() throw(); void listen(short aPort) throw(SocketException); @@ -123,7 +123,7 @@ int read(void* aBuffer, size_t aBufLen) throw(SocketException); int wait(uint32_t millis, int waitFor) throw(SocketException); - static string resolve(const string& aDns); + static std::string resolve(const std::string& aDns); int getAvailable() { u_long i = 0; @@ -143,7 +143,7 @@ } #endif - string getLocalIp() throw(); + std::string getLocalIp() throw(); int getLocalPort() throw(); socket_t getSocket() { return sock; } Modified: adchpp/trunk/adchpp/SocketManager.cpp =================================================================== --- adchpp/trunk/adchpp/SocketManager.cpp 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/SocketManager.cpp 2007-11-18 19:03:32 UTC (rev 92) @@ -37,6 +37,9 @@ #endif namespace adchpp { + +using namespace std; + static uint32_t WRITE_TIMEOUT = 100; #ifdef _WIN32 Modified: adchpp/trunk/adchpp/SocketManager.h =================================================================== --- adchpp/trunk/adchpp/SocketManager.h 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/SocketManager.h 2007-11-18 19:03:32 UTC (rev 92) @@ -49,7 +49,7 @@ virtual int run(); - typedef vector<Callback> ProcessQueue; + typedef std::vector<Callback> ProcessQueue; FastMutex processCS; @@ -58,9 +58,9 @@ Semaphore processSem; - auto_ptr<Writer> writer; + std::auto_ptr<Writer> writer; - static const string className; + static const std::string className; friend class Singleton<SocketManager>; ADCHPP_DLL static SocketManager* instance; Modified: adchpp/trunk/adchpp/StringDefs.cpp =================================================================== --- adchpp/trunk/adchpp/StringDefs.cpp 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/StringDefs.cpp 2007-11-18 19:03:32 UTC (rev 92) @@ -1,6 +1,7 @@ #include "adchpp.h" #include "ResourceManager.h" namespace adchpp { +using namespace std; string ResourceManager::strings[] = { "B", "CID taken", Modified: adchpp/trunk/adchpp/StringDefs.h =================================================================== --- adchpp/trunk/adchpp/StringDefs.h 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/StringDefs.h 2007-11-18 19:03:32 UTC (rev 92) @@ -1,6 +1,7 @@ // @Prolog: #include "adchpp.h" // @Prolog: #include "ResourceManager.h" // @Prolog: namespace adchpp { +// @Prolog: using namespace std; // @Strings: string ResourceManager::strings[] // @Names: string ResourceManager::names[] Modified: adchpp/trunk/adchpp/TigerHash.cpp =================================================================== --- adchpp/trunk/adchpp/TigerHash.cpp 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/TigerHash.cpp 2007-11-18 19:03:32 UTC (rev 92) @@ -23,6 +23,7 @@ namespace adchpp { +using namespace std; #define PASSES 3 Modified: adchpp/trunk/adchpp/Util.cpp =================================================================== --- adchpp/trunk/adchpp/Util.cpp 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/Util.cpp 2007-11-18 19:03:32 UTC (rev 92) @@ -35,6 +35,8 @@ namespace adchpp { +using namespace std; + intrusive_ptr_base::~intrusive_ptr_base() { } Modified: adchpp/trunk/adchpp/Util.h =================================================================== --- adchpp/trunk/adchpp/Util.h 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/Util.h 2007-11-18 19:03:32 UTC (rev 92) @@ -56,22 +56,22 @@ } /** Evaluates op(pair<T1, T2>.first, compareTo) */ -template<class T1, class T2, class op = equal_to<T1> > +template<class T1, class T2, class op = std::equal_to<T1> > class CompareFirst { public: CompareFirst(const T1& compareTo) : a(compareTo) { } - bool operator()(const pair<T1, T2>& p) { return op()(p.first, a); } + bool operator()(const std::pair<T1, T2>& p) { return op()(p.first, a); } private: CompareFirst& operator=(const CompareFirst&); const T1& a; }; /** Evaluates op(pair<T1, T2>.second, compareTo) */ -template<class T1, class T2, class op = equal_to<T2> > +template<class T1, class T2, class op = std::equal_to<T2> > class CompareSecond { public: CompareSecond(const T2& compareTo) : a(compareTo) { } - bool operator()(const pair<T1, T2>& p) { return op()(p.second, a); } + bool operator()(const std::pair<T1, T2>& p) { return op()(p.second, a); } private: CompareSecond& operator=(const CompareSecond&); const T2& a; @@ -179,56 +179,56 @@ ADCHPP_DLL static size_t reasons[REASON_LAST]; - ADCHPP_DLL static string emptyString; + ADCHPP_DLL static std::string emptyString; - ADCHPP_DLL static void initialize(const string& configPath); - ADCHPP_DLL static string getOsVersion(); - ADCHPP_DLL static void decodeUrl(const string& aUrl, string& aServer, short& aPort, string& aFile); - ADCHPP_DLL static string formatTime(const string& msg, time_t t = time(NULL)); + ADCHPP_DLL static void initialize(const std::string& configPath); + ADCHPP_DLL static std::string getOsVersion(); + ADCHPP_DLL static void decodeUrl(const std::string& aUrl, std::string& aServer, short& aPort, std::string& aFile); + ADCHPP_DLL static std::string formatTime(const std::string& msg, time_t t = time(NULL)); - static const string& getCfgPath() { return cfgPath; } - static void setCfgPath(const string& path) { cfgPath = path; } + static const std::string& getCfgPath() { return cfgPath; } + static void setCfgPath(const std::string& path) { cfgPath = path; } - ADCHPP_DLL static string getAppPath(); - ADCHPP_DLL static string getAppName(); + ADCHPP_DLL static std::string getAppPath(); + ADCHPP_DLL static std::string getAppName(); #ifndef _WIN32 - ADCHPP_DLL static void setApp(const string& app); - static string appPath; - static string appName; + ADCHPP_DLL static void setApp(const std::string& app); + static std::string appPath; + static std::string appName; #endif - ADCHPP_DLL static string translateError(int aError); + ADCHPP_DLL static std::string translateError(int aError); - ADCHPP_DLL static string toAcp(const wstring& wString); - static const string& toAcp(const string& wString) { return wString; } - static string& toAcp(string& wString) { return wString; } + ADCHPP_DLL static std::string toAcp(const std::wstring& wString); + static const std::string& toAcp(const std::string& wString) { return wString; } + static std::string& toAcp(std::string& wString) { return wString; } - ADCHPP_DLL static wstring toUnicode(const string& aString); - static const wstring& toUnicode(const wstring& aString) { return aString; } - static wstring& toUnicode(wstring& aString) { return aString; } + ADCHPP_DLL static std::wstring toUnicode(const std::string& aString); + static const std::wstring& toUnicode(const std::wstring& aString) { return aString; } + static std::wstring& toUnicode(std::wstring& aString) { return aString; } - static string formatBytes(const string& aString) { return formatBytes(toInt64(aString)); } + static std::string formatBytes(const std::string& aString) { return formatBytes(toInt64(aString)); } - ADCHPP_DLL static string getShortTimeString(); - ADCHPP_DLL static string getTimeString(); + ADCHPP_DLL static std::string getShortTimeString(); + ADCHPP_DLL static std::string getTimeString(); - ADCHPP_DLL static string formatBytes(int64_t aBytes); + ADCHPP_DLL static std::string formatBytes(int64_t aBytes); - ADCHPP_DLL static void tokenize(StringList& lst, const string& str, char sep, string::size_type j = 0); + ADCHPP_DLL static void tokenize(StringList& lst, const std::string& str, char sep, std::string::size_type j = 0); - static string formatSeconds(int64_t aSec) { + static std::string formatSeconds(int64_t aSec) { char buf[64]; sprintf(buf, "%01d:%02d:%02d:%02d", (int)(aSec / (24*60*60)), (int)((aSec / (60*60)) % 24), (int)((aSec / 60) % 60), (int)(aSec % 60)); return buf; } - static bool toBool(const string& aString) { return toBool(aString.c_str()); } - static int toInt(const string& aString) { return toInt(aString.c_str()); } - static double toDouble(const string& aString) { return toDouble(aString.c_str()); } - static float toFloat(const string& aString) { return toFloat(aString.c_str()); } - static int64_t toInt64(const string& aString) { return toInt64(aString.c_str()); } + static bool toBool(const std::string& aString) { return toBool(aString.c_str()); } + static int toInt(const std::string& aString) { return toInt(aString.c_str()); } + static double toDouble(const std::string& aString) { return toDouble(aString.c_str()); } + static float toFloat(const std::string& aString) { return toFloat(aString.c_str()); } + static int64_t toInt64(const std::string& aString) { return toInt64(aString.c_str()); } static bool toBool(const char* aString) { return toInt(aString) > 0; } static int toInt(const char* aString) { return ::atoi(aString); } @@ -242,37 +242,41 @@ #endif } - static string toString(short val) { + static std::string toString(bool val) { + return val ? "1" : "0"; + } + + static std::string toString(short val) { char buf[8]; sprintf(buf, "%d", (int)val); return buf; } - static string toString(unsigned short val) { + static std::string toString(unsigned short val) { char buf[8]; sprintf(buf, "%u", (unsigned int)val); return buf; } - static string toString(int val) { + static std::string toString(int val) { char buf[16]; sprintf(buf, "%d", val); return buf; } - static string toString(unsigned int val) { + static std::string toString(unsigned int val) { char buf[16]; sprintf(buf, "%u", val); return buf; } - static string toString(long val) { + static std::string toString(long val) { char buf[32]; sprintf(buf, "%ld", val); return buf; } - static string toString(unsigned long val) { + static std::string toString(unsigned long val) { char buf[32]; sprintf(buf, "%lu", val); return buf; } - static string toString(long long val) { + static std::string toString(long long val) { char buf[32]; #ifdef _MSC_VER sprintf(buf, "%I64d", val); @@ -281,7 +285,7 @@ #endif return buf; } - static string toString(unsigned long long val) { + static std::string toString(unsigned long long val) { char buf[32]; #ifdef _MSC_VER sprintf(buf, "%I64u", val); @@ -291,18 +295,18 @@ return buf; } - static string toString(double val, int maxDec = 2) { + static std::string toString(double val, int maxDec = 2) { char buf[32]; sprintf(buf, "%.*f", maxDec, val); return buf; } - static const string& toString(const string& aString) { + static const std::string& toString(const std::string& aString) { return aString; } /** Avoid this! Use the one of a connected socket instead... */ - ADCHPP_DLL static string getLocalIp(); + ADCHPP_DLL static std::string getLocalIp(); struct Clear { void operator()(ByteVector& x); @@ -316,7 +320,7 @@ static double randd() { return ((double)rand()) / ((double)0xffffffff); } private: - ADCHPP_DLL static string cfgPath; + ADCHPP_DLL static std::string cfgPath; }; } Modified: adchpp/trunk/adchpp/adchpp.cpp =================================================================== --- adchpp/trunk/adchpp/adchpp.cpp 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/adchpp.cpp 2007-11-18 19:03:32 UTC (rev 92) @@ -27,7 +27,9 @@ #include "SettingsManager.h" namespace adchpp { - + +using namespace std; + const char compileTime[] = __DATE__ " " __TIME__; static bool initialized = false; Modified: adchpp/trunk/adchpp/adchpp.h =================================================================== --- adchpp/trunk/adchpp/adchpp.h 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/adchpp.h 2007-11-18 19:03:32 UTC (rev 92) @@ -111,8 +111,9 @@ #endif -#include <cerrno> -#include <cstdarg> +#include <errno.h> +#include <stdarg.h> +#include <stddef.h> #include <string> #include <vector> @@ -140,12 +141,6 @@ #include <boost/intrusive_ptr.hpp> #include <boost/noncopyable.hpp> -namespace adchpp { - -using namespace std; - -} - #ifdef _UNICODE # ifndef _T # define _T(s) L##s Modified: adchpp/trunk/adchpp/common.h =================================================================== --- adchpp/trunk/adchpp/common.h 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/common.h 2007-11-18 19:03:32 UTC (rev 92) @@ -102,7 +102,7 @@ /** * Initialize configuration. */ -ADCHPP_DLL void initialize(const string& path); +ADCHPP_DLL void initialize(const std::string& path); /** * Load plugins and start listening for incoming connections Modified: adchpp/trunk/adchpp/version.cpp =================================================================== --- adchpp/trunk/adchpp/version.cpp 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/version.cpp 2007-11-18 19:03:32 UTC (rev 92) @@ -21,9 +21,11 @@ #define FULLVERSIONSTRING APPNAME " v" VERSIONSTRING "-" BUILDSTRING namespace adchpp { + +using namespace std; + +string appName = APPNAME; +string versionString = FULLVERSIONSTRING; +float versionFloat = VERSIONFLOAT; - string appName = APPNAME; - string versionString = FULLVERSIONSTRING; - float versionFloat = VERSIONFLOAT; - } Modified: adchpp/trunk/adchpp/version.h =================================================================== --- adchpp/trunk/adchpp/version.h 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/version.h 2007-11-18 19:03:32 UTC (rev 92) @@ -20,8 +20,8 @@ #define ADCHPP_VERSION_H namespace adchpp { - ADCHPP_DLL extern string appName; - ADCHPP_DLL extern string versionString; + ADCHPP_DLL extern std::string appName; + ADCHPP_DLL extern std::string versionString; ADCHPP_DLL extern float versionFloat; } Modified: adchpp/trunk/plugins/Script/src/Engine.h =================================================================== --- adchpp/trunk/plugins/Script/src/Engine.h 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/plugins/Script/src/Engine.h 2007-11-18 19:03:32 UTC (rev 92) @@ -27,10 +27,10 @@ public: virtual ~Engine() { } - virtual Script* loadScript(const string& path, const string& filename, const ParameterMap& parameters) = 0; + virtual Script* loadScript(const std::string& path, const std::string& filename, const ParameterMap& parameters) = 0; virtual void unloadScript(Script* script) = 0; - virtual void getStats(string& str) const = 0; + virtual void getStats(std::string& str) const = 0; private: }; Modified: adchpp/trunk/plugins/Script/src/LuaEngine.cpp =================================================================== --- adchpp/trunk/plugins/Script/src/LuaEngine.cpp 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/plugins/Script/src/LuaEngine.cpp 2007-11-18 19:03:32 UTC (rev 92) @@ -22,8 +22,13 @@ #include "LuaScript.h" #include <adchpp/Util.h> + +extern "C" { #include <lua.h> +} +using namespace std; + LuaEngine::LuaEngine() { } Modified: adchpp/trunk/plugins/Script/src/LuaEngine.h =================================================================== --- adchpp/trunk/plugins/Script/src/LuaEngine.h 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/plugins/Script/src/LuaEngine.h 2007-11-18 19:03:32 UTC (rev 92) @@ -28,11 +28,11 @@ LuaEngine(); virtual ~LuaEngine(); - virtual Script* loadScript(const string& path, const string& filename, const ParameterMap& parameters); + virtual Script* loadScript(const std::string& path, const std::string& filename, const ParameterMap& parameters); virtual void unloadScri... [truncated message content] |
From: <arn...@us...> - 2007-12-09 19:40:25
|
Revision: 101 http://adchpp.svn.sourceforge.net/adchpp/?rev=101&view=rev Author: arnetheduck Date: 2007-12-09 11:40:15 -0800 (Sun, 09 Dec 2007) Log Message: ----------- Simplify logmanager, more lua fixes Modified Paths: -------------- adchpp/trunk/adchpp/LogManager.cpp adchpp/trunk/adchpp/LogManager.h adchpp/trunk/adchpp/PluginManager.cpp adchpp/trunk/adchpp/SettingsManager.cpp adchpp/trunk/adchpp/SocketManager.cpp adchpp/trunk/plugins/Bloom/src/BloomManager.cpp adchpp/trunk/plugins/Script/examples/access.lua adchpp/trunk/plugins/Script/src/LuaScript.cpp adchpp/trunk/plugins/Script/src/ScriptManager.cpp adchpp/trunk/swig/adchpp.i adchpp/trunk/swig/lua.i adchpp/trunk/swig/python.i adchpp/trunk/unix/main.cpp adchpp/trunk/unix/po/adchppd.pot adchpp/trunk/windows/adchppdw.cpp Modified: adchpp/trunk/adchpp/LogManager.cpp =================================================================== --- adchpp/trunk/adchpp/LogManager.cpp 2007-12-09 18:53:20 UTC (rev 100) +++ adchpp/trunk/adchpp/LogManager.cpp 2007-12-09 19:40:15 UTC (rev 101) @@ -29,8 +29,7 @@ LogManager* LogManager::instance = 0; -void LogManager::logDateTime(const string& area, const string& msg) throw() -{ +void LogManager::log(const string& area, const string& msg) throw() { char buf[64]; time_t now = time(NULL); size_t s = strftime(buf, 64, "%Y-%m-%d %H:%M:%S: ", localtime(&now)); @@ -41,7 +40,6 @@ dolog(tmp); } - void LogManager::dolog(const string& msg) throw() { dcdebug("Logging: %s\n", msg.c_str()); if(SETTING(LOG)) { Modified: adchpp/trunk/adchpp/LogManager.h =================================================================== --- adchpp/trunk/adchpp/LogManager.h 2007-12-09 18:53:20 UTC (rev 100) +++ adchpp/trunk/adchpp/LogManager.h 2007-12-09 19:40:15 UTC (rev 101) @@ -35,23 +35,13 @@ * @param area Name of the module that generated the error. * @param msg Message to log. */ - void log(const std::string& area, const std::string& msg) throw() { - std::string tmp(area); - tmp += ": "; - tmp += msg; - dolog(tmp); - } + ADCHPP_DLL void log(const std::string& area, const std::string& msg) throw(); - /** - * Same as log, but prepends the current date and time. - * @see log - */ - ADCHPP_DLL void logDateTime(const std::string& area, const std::string& msg) throw(); private: friend class Singleton<LogManager>; ADCHPP_DLL static LogManager* instance; FastMutex mtx; - + LogManager() throw() { } virtual ~LogManager() throw() { } @@ -59,7 +49,6 @@ }; #define LOG(area, msg) LogManager::getInstance()->log(area, msg) -#define LOGDT(area, msg) LogManager::getInstance()->logDateTime(area, msg) } Modified: adchpp/trunk/adchpp/PluginManager.cpp =================================================================== --- adchpp/trunk/adchpp/PluginManager.cpp 2007-12-09 18:53:20 UTC (rev 100) +++ adchpp/trunk/adchpp/PluginManager.cpp 2007-12-09 19:40:15 UTC (rev 101) @@ -86,7 +86,7 @@ #endif if(h == NULL) { - LOGDT(className, "Failed to load " + Util::toAcp(file) + ": " + PM_GET_ERROR_STRING()); + LOG(className, "Failed to load " + Util::toAcp(file) + ": " + PM_GET_ERROR_STRING()); return false; } @@ -103,7 +103,7 @@ h = PM_LOAD_LIBRARY(file.c_str()); } if(h == NULL) { - LOGDT(className, "Failed to load " + Util::toAcp(file) + ": " + PM_GET_ERROR_STRING()); + LOG(className, "Failed to load " + Util::toAcp(file) + ": " + PM_GET_ERROR_STRING()); return false; } #endif @@ -113,21 +113,21 @@ if(l != NULL && u != NULL) { int i = l(); if(i != 0) { - LOGDT(className, "Failed to load plugin " + Util::toAcp(file) + " (Error " + Util::toString(i) + ")"); + LOG(className, "Failed to load plugin " + Util::toAcp(file) + " (Error " + Util::toString(i) + ")"); } else { // Wonderful, we have a plugin... active.push_back(PluginInfo(h, v, l, u)); - LOGDT(className, Util::toAcp(file) + " loaded"); + LOG(className, Util::toAcp(file) + " loaded"); return true; } } else { - LOGDT(className, Util::toAcp(file) + " is not a valid ADCH++ plugin"); + LOG(className, Util::toAcp(file) + " is not a valid ADCH++ plugin"); } } else { - LOGDT(className, Util::toAcp(file) + " is for another version of ADCH++ (" + Util::toString(ver) + "), please get the correct one from the author"); + LOG(className, Util::toAcp(file) + " is for another version of ADCH++ (" + Util::toString(ver) + "), please get the correct one from the author"); } } else { - LOGDT(className, Util::toAcp(file) + " is not a valid ADCH++ plugin"); + LOG(className, Util::toAcp(file) + " is not a valid ADCH++ plugin"); } PM_UNLOAD_LIBRARY(h); Modified: adchpp/trunk/adchpp/SettingsManager.cpp =================================================================== --- adchpp/trunk/adchpp/SettingsManager.cpp 2007-12-09 18:53:20 UTC (rev 100) +++ adchpp/trunk/adchpp/SettingsManager.cpp 2007-12-09 19:40:15 UTC (rev 101) @@ -105,7 +105,7 @@ if(xml.findChild(attr)) set(StrSetting(i), xml.getChildData()); else - LOGDT(className, attr + " missing from settings, using default"); + LOG(className, attr + " missing from settings, using default"); xml.resetCurrentChild(); } for(i=INT_FIRST; i<INT_LAST; i++) { @@ -115,7 +115,7 @@ if(xml.findChild(attr)) set(IntSetting(i), Util::toInt(xml.getChildData())); else - LOGDT(className, attr + " missing from settings, using default"); + LOG(className, attr + " missing from settings, using default"); xml.resetCurrentChild(); } Modified: adchpp/trunk/adchpp/SocketManager.cpp =================================================================== --- adchpp/trunk/adchpp/SocketManager.cpp 2007-12-09 18:53:20 UTC (rev 100) +++ adchpp/trunk/adchpp/SocketManager.cpp 2007-12-09 19:40:15 UTC (rev 101) @@ -172,7 +172,7 @@ *overlapped = MSOverlapped(MSOverlapped::SHUTDOWN); if(!poller.post(overlapped)) { - LOGDT(SocketManager::className, "Fatal error while posting shutdown to completion port: " + Util::translateError(::GetLastError())); + LOG(SocketManager::className, "Fatal error while posting shutdown to completion port: " + Util::translateError(::GetLastError())); } join(); } @@ -189,7 +189,7 @@ private: bool init() { if(!poller.init()) { - LOGDT(SocketManager::className, "Unable to start poller: " + Util::translateError(socket_errno)); + LOG(SocketManager::className, "Unable to start poller: " + Util::translateError(socket_errno)); return false; } @@ -197,23 +197,23 @@ srv.listen(SETTING(SERVER_PORT)); srv.setBlocking(false); } catch(const SocketException& e) { - LOGDT(SocketManager::className, "Unable to create server socket: " + e.getError()); + LOG(SocketManager::className, "Unable to create server socket: " + e.getError()); return false; } if(!poller.associate(srv.getSocket())) { - LOGDT(SocketManager::className, "Unable to associate server socket with poller: " + Util::translateError(socket_errno)); + LOG(SocketManager::className, "Unable to associate server socket with poller: " + Util::translateError(socket_errno)); return false; } #ifndef _WIN32 if(socketpair(AF_UNIX, SOCK_STREAM, 0, event) == -1) { - LOGDT(SocketManager::className, "Unable to create event socketpair: " + Util::translateError(errno)); + LOG(SocketManager::className, "Unable to create event socketpair: " + Util::translateError(errno)); return false; } if(!poller.associate(event[1])) { - LOGDT(SocketManager::className, "Unable to associate event: " + Util::translateError(errno)); + LOG(SocketManager::className, "Unable to associate event: " + Util::translateError(errno)); return false; } #endif @@ -221,7 +221,7 @@ } virtual int run() { - LOGDT(SocketManager::className, "Writer starting"); + LOG(SocketManager::className, "Writer starting"); if(!init()) { return 0; } @@ -242,7 +242,7 @@ } } - LOGDT(SocketManager::className, "Writer shutting down"); + LOG(SocketManager::className, "Writer shutting down"); return 0; } @@ -257,7 +257,7 @@ int error = ::GetLastError(); if(overlapped == 0) { if(error != WAIT_TIMEOUT) { - LOGDT(SocketManager::className, "Fatal error while getting status from completion port: " + Util::translateError(error)); + LOG(SocketManager::className, "Fatal error while getting status from completion port: " + Util::translateError(error)); return; } } else if(overlapped->type == MSOverlapped::ACCEPT_DONE) { @@ -310,12 +310,12 @@ try { ms->create(); } catch (const SocketException& e) { - LOGDT(SocketManager::className, "Unable to create socket: " + e.getError()); + LOG(SocketManager::className, "Unable to create socket: " + e.getError()); return; } if(!poller.associate(ms->getSocket())) { - LOGDT(SocketManager::className, "Unable to associate poller: " + Util::translateError(::GetLastError())); + LOG(SocketManager::className, "Unable to associate poller: " + Util::translateError(::GetLastError())); return; } @@ -331,7 +331,7 @@ int error = ::WSAGetLastError(); if(error != ERROR_IO_PENDING) { if(!stop) { - LOGDT(SocketManager::className, "Failed accepting connection: " + Util::translateError(GetLastError())); + LOG(SocketManager::className, "Failed accepting connection: " + Util::translateError(GetLastError())); } pool.put(overlapped); @@ -491,7 +491,7 @@ void handleEvents() { vector<epoll_event> events; if(!poller.get(events)) { - LOGDT(SocketManager::className, "Poller failed: " + Util::translateError(errno)); + LOG(SocketManager::className, "Poller failed: " + Util::translateError(errno)); } for(vector<epoll_event>::iterator i = events.begin(); i != events.end(); ++i) { epoll_event& ev = *i; @@ -518,7 +518,7 @@ ms->setIp(ms->sock.accept(srv)); if(!poller.associate(ms)) { - LOGDT(SocketManager::className, "Unable to associate EPoll: " + Util::translateError(errno)); + LOG(SocketManager::className, "Unable to associate EPoll: " + Util::translateError(errno)); return; } @@ -530,7 +530,7 @@ read(ms); } catch (const SocketException& e) { - LOGDT(SocketManager::className, "Unable to create socket: " + e.getError()); + LOG(SocketManager::className, "Unable to create socket: " + e.getError()); return; } } @@ -610,7 +610,7 @@ if(err == EAGAIN || err == EINTR) { return; } - LOGDT(SocketManager::className, "Error reading from event[1]: " + Util::translateError(err)); + LOG(SocketManager::className, "Error reading from event[1]: " + Util::translateError(err)); return; } @@ -692,7 +692,7 @@ const string SocketManager::className = "SocketManager"; int SocketManager::run() { - LOGDT(SocketManager::className, "Starting"); + LOG(SocketManager::className, "Starting"); writer->start(); writer->setThreadPriority(Thread::HIGH); @@ -706,14 +706,14 @@ } for(ProcessQueue::iterator i = workQueue.begin(); i != workQueue.end(); ++i) { if(!(*i)) { - LOGDT(SocketManager::className, "Shutting down"); + LOG(SocketManager::className, "Shutting down"); return 0; } (*i)(); } workQueue.clear(); } - LOGDT(SocketManager::className, "ERROR; should never end up here..."); + LOG(SocketManager::className, "ERROR; should never end up here..."); return 0; } Modified: adchpp/trunk/plugins/Bloom/src/BloomManager.cpp =================================================================== --- adchpp/trunk/plugins/Bloom/src/BloomManager.cpp 2007-12-09 18:53:20 UTC (rev 100) +++ adchpp/trunk/plugins/Bloom/src/BloomManager.cpp 2007-12-09 19:40:15 UTC (rev 101) @@ -28,14 +28,14 @@ const string BloomManager::className = "BloomManager"; BloomManager::BloomManager() { - LOGDT(className, "Starting"); + LOG(className, "Starting"); ClientManager* cm = ClientManager::getInstance(); receiveConn = manage(&cm->signalReceive(), std::tr1::bind(&BloomManager::onReceive, this, _1, _2, _3)); disconnectConn = manage(&cm->signalDisconnected(), std::tr1::bind(&BloomManager::onDisconnected, this, _1)); } BloomManager::~BloomManager() { - LOGDT(className, "Shutting down"); + LOG(className, "Shutting down"); } static const std::string FEATURE = "BLOM"; Modified: adchpp/trunk/plugins/Script/examples/access.lua =================================================================== --- adchpp/trunk/plugins/Script/examples/access.lua 2007-12-09 18:53:20 UTC (rev 100) +++ adchpp/trunk/plugins/Script/examples/access.lua 2007-12-09 19:40:15 UTC (rev 101) @@ -241,7 +241,6 @@ for field, regex in pairs(inf_fields) do val = cmd:getParam(field, 0) if #val > 0 and hasVal and not val:match(regex) then - print("Bad INF " .. field) reply(c, "Field " .. field .. " has an invalid value, removed") cmd:delParam(field, 0) end @@ -252,6 +251,11 @@ return command_processed end + if #cmd:getParam("CT", 0) > 0 then + dump(c, adchpp.AdcCommand_ERROR_PROTOCOL_GENERIC, "I decide what type you are") + return command_processed + end + if #cmd:getParam("OP", 0) > 0 then dump(c, adchpp.AdcCommand_ERROR_PROTOCOL_GENERIC, "I decide who's an OP") return command_processed @@ -323,7 +327,6 @@ local user = get_user(c:getCID():toBase32(), c:getField("NI")) if not user then - print("User sending PAS not found (?)") dump(c, adchpp.AdcCommand_ERROR_PROTOCOL_GENERIC, "Can't find you now") return command_processed end @@ -388,7 +391,6 @@ local function onMSG(c, cmd) msg = cmd:getParam(0) - print("got message") local command, parameters = msg:match("^%+(%a+) ?(.*)") if not command then @@ -514,7 +516,7 @@ victim = cm:getClient(adchpp.AdcCommand_toSID(sid)) if not victim then - print "Victim not found" + reply(c, "Victim not found") return command_processed end @@ -538,7 +540,6 @@ local allowed_type = command_contexts[cmd:getCommand()] if allowed_type then if not cmd:getType():match(allowed_type) then - print("Invalid context for " .. cmd:getCommandString()) reply(c, "Invalid context for " .. cmd:getCommandString()) return command_processed end @@ -549,14 +550,12 @@ if allowed_level then user = get_user(c:getCID(), c:getField("NI")) if not user or user.level < allowed_level then - print("unallowed") reply(c, "You don't have access to " .. cmd:getCommandString()) return command_processed end end end - print("command is " .. cmd:getCommand() .. " msg is " .. adchpp.AdcCommand_CMD_MSG) if cmd:getCommand() == adchpp.AdcCommand_CMD_INF then return onINF(c, cmd) elseif cmd:getCommand() == adchpp.AdcCommand_CMD_PAS then Modified: adchpp/trunk/plugins/Script/src/LuaScript.cpp =================================================================== --- adchpp/trunk/plugins/Script/src/LuaScript.cpp 2007-12-09 18:53:20 UTC (rev 100) +++ adchpp/trunk/plugins/Script/src/LuaScript.cpp 2007-12-09 19:40:15 UTC (rev 101) @@ -87,9 +87,9 @@ int error = luaL_loadfile(l, filename.c_str()) || lua_pcall(l, 0, 0, 0); if(error) { - LOGDT(className, string("Error loading file: ") + lua_tostring(l, -1)); + LOG(className, string("Error loading file: ") + lua_tostring(l, -1)); } else { - LOGDT(className, "Loaded " + filename); + LOG(className, "Loaded " + filename); } chdir(old_dir); } Modified: adchpp/trunk/plugins/Script/src/ScriptManager.cpp =================================================================== --- adchpp/trunk/plugins/Script/src/ScriptManager.cpp 2007-12-09 18:53:20 UTC (rev 100) +++ adchpp/trunk/plugins/Script/src/ScriptManager.cpp 2007-12-09 19:40:15 UTC (rev 101) @@ -39,7 +39,7 @@ const string ScriptManager::className = "ScriptManager"; ScriptManager::ScriptManager() { - LOGDT(className, "Starting"); + LOG(className, "Starting"); ClientManager::SignalReceive::Signal& sig = ClientManager::getInstance()->signalReceive(); receiveConn = manage(&sig, std::tr1::bind(&ScriptManager::onReceive, this, _1, _2, _3)); @@ -47,7 +47,7 @@ } ScriptManager::~ScriptManager() { - LOGDT(className, "Shutting down"); + LOG(className, "Shutting down"); clearEngines(); } @@ -74,7 +74,7 @@ } xml.stepOut(); } catch(const Exception& e) { - LOGDT(className, "Failed to load settings: " + e.getError()); + LOG(className, "Failed to load settings: " + e.getError()); return; } } Modified: adchpp/trunk/swig/adchpp.i =================================================================== --- adchpp/trunk/swig/adchpp.i 2007-12-09 18:53:20 UTC (rev 100) +++ adchpp/trunk/swig/adchpp.i 2007-12-09 19:40:15 UTC (rev 101) @@ -455,7 +455,6 @@ { public: void log(const std::string& area, const std::string& msg) throw(); - void logDateTime(const std::string& area, const std::string& msg) throw(); }; %template(SignalC) Signal<void (Client&)>; Modified: adchpp/trunk/swig/lua.i =================================================================== --- adchpp/trunk/swig/lua.i 2007-12-09 18:53:20 UTC (rev 100) +++ adchpp/trunk/swig/lua.i 2007-12-09 19:40:15 UTC (rev 101) @@ -179,4 +179,3 @@ return std::string(); } } - Modified: adchpp/trunk/swig/python.i =================================================================== --- adchpp/trunk/swig/python.i 2007-12-09 18:53:20 UTC (rev 100) +++ adchpp/trunk/swig/python.i 2007-12-09 19:40:15 UTC (rev 101) @@ -1,6 +1,5 @@ %module pyadchpp - %{ // Python pollution #undef socklen_t @@ -111,3 +110,4 @@ PyObject* obj; }; %} + Modified: adchpp/trunk/unix/main.cpp =================================================================== --- adchpp/trunk/unix/main.cpp 2007-12-09 18:53:20 UTC (rev 100) +++ adchpp/trunk/unix/main.cpp 2007-12-09 19:40:15 UTC (rev 101) @@ -66,7 +66,7 @@ } static void uninit() { - LOGDT(modName, versionString + " shut down"); + LOG(modName, versionString + " shut down"); if(!asdaemon) printf(_("Shutting down.")); shutdown(&f2); @@ -86,19 +86,19 @@ static void daemonize() { switch(fork()) { case -1: - LOGDT(modName, string("First fork failed: ") + strerror(errno)); + LOG(modName, string("First fork failed: ") + strerror(errno)); exit(5); case 0: break; default: _exit(0); } if(setsid() < 0) { - LOGDT(modName, string("setsid failed: ") + strerror(errno)); + LOG(modName, string("setsid failed: ") + strerror(errno)); exit(6); } switch(fork()) { case -1: - LOGDT(modName, string("Second fork failed: ") + strerror(errno)); + LOG(modName, string("Second fork failed: ") + strerror(errno)); exit(7); case 0: break; default: exit(0); @@ -121,11 +121,11 @@ try { adchpp::startup(&f2); } catch(const adchpp::Exception& e) { - LOGDT(modName, "Failed to start: " + e.getError()); + LOG(modName, "Failed to start: " + e.getError()); uninit(); return; } - LOGDT(modName, versionString + " started as a daemon"); + LOG(modName, versionString + " started as a daemon"); // Now what? int x = 0; sigset_t st; @@ -141,7 +141,7 @@ printf(_("Starting")); init(); initialize(configPath); - LOGDT(modName, versionString + " starting from console"); + LOG(modName, versionString + " starting from console"); printf("."); try { startup(&f2); Modified: adchpp/trunk/unix/po/adchppd.pot =================================================================== --- adchpp/trunk/unix/po/adchppd.pot 2007-12-09 18:53:20 UTC (rev 100) +++ adchpp/trunk/unix/po/adchppd.pot 2007-12-09 19:40:15 UTC (rev 101) @@ -7,7 +7,7 @@ msgstr "" "Project-Id-Version: \"adchpp\"--copyright-holder=\"Jacek Sieka\"\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2007-12-09 18:46+0100\n" +"POT-Creation-Date: 2007-12-09 20:22+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL...@li...>\n" Modified: adchpp/trunk/windows/adchppdw.cpp =================================================================== --- adchpp/trunk/windows/adchppdw.cpp 2007-12-09 18:53:20 UTC (rev 100) +++ adchpp/trunk/windows/adchppdw.cpp 2007-12-09 19:40:15 UTC (rev 101) @@ -28,7 +28,7 @@ static const string modName = "adchpp"; -#define LOGERROR(func) LOGDT(modName, func " failed: " + Util::translateError(GetLastError())) +#define LOGERROR(func) LOG(modName, func " failed: " + Util::translateError(GetLastError())) #define PRINTERROR(func) fprintf(stderr, func " failed: 0x%x, %s", GetLastError(), Util::translateError(GetLastError()).c_str()) #ifdef _MSC_VER @@ -172,9 +172,9 @@ initialize(configPath); if(asService) - LOGDT(modName, versionString + " started as a service"); + LOG(modName, versionString + " started as a service"); else - LOGDT(modName, versionString + " started from console"); + LOG(modName, versionString + " started from console"); } static void f2() { @@ -182,7 +182,7 @@ } static void uninit() { - LOGDT(modName, versionString + " shut down"); + LOG(modName, versionString + " shut down"); printf("Shutting down."); shutdown(&f2); #if defined(_MSC_VER) && !defined(NDEBUG) @@ -202,7 +202,7 @@ case SERVICE_CONTROL_SHUTDOWN: // Fallthrough case SERVICE_CONTROL_STOP: ss.dwCurrentState = SERVICE_STOP_PENDING; exitSem.signal(); break; case SERVICE_CONTROL_INTERROGATE: break; - default: LOGDT(modName, "Unknown service handler code " + Util::toString(code)); + default: LOG(modName, "Unknown service handler code " + Util::toString(code)); } if(!SetServiceStatus(ssh, &ss)) { @@ -243,7 +243,7 @@ try { startup(&f); } catch(const Exception& e) { - LOGDT(modName, "ADCH++ startup failed because: " + e.getError()); + LOG(modName, "ADCH++ startup failed because: " + e.getError()); uninit(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2007-12-14 15:17:02
|
Revision: 105 http://adchpp.svn.sourceforge.net/adchpp/?rev=105&view=rev Author: arnetheduck Date: 2007-12-14 07:16:58 -0800 (Fri, 14 Dec 2007) Log Message: ----------- python versions other than 2.5 on linux, lua script fix Modified Paths: -------------- adchpp/trunk/plugins/Script/examples/access.lua adchpp/trunk/readme.txt adchpp/trunk/swig/SConscript Modified: adchpp/trunk/plugins/Script/examples/access.lua =================================================================== --- adchpp/trunk/plugins/Script/examples/access.lua 2007-12-10 20:11:15 UTC (rev 104) +++ adchpp/trunk/plugins/Script/examples/access.lua 2007-12-14 15:16:58 UTC (rev 105) @@ -49,9 +49,10 @@ local context_bcast = "[BF]" local context_direct = "[DE]" local context_send = "[BFD]" +local context_hubdirect = "[HDE]" local command_contexts = { - [adchpp.AdcCommand_CMD_STA] = context_hub, + [adchpp.AdcCommand_CMD_STA] = context_hubdirect, [adchpp.AdcCommand_CMD_SUP] = context_hub, [adchpp.AdcCommand_CMD_SID] = context_hub, [adchpp.AdcCommand_CMD_INF] = context_bcast, Modified: adchpp/trunk/readme.txt =================================================================== --- adchpp/trunk/readme.txt 2007-12-10 20:11:15 UTC (rev 104) +++ adchpp/trunk/readme.txt 2007-12-14 15:16:58 UTC (rev 105) @@ -3,7 +3,8 @@ -- Introduction -- -ADCH++ is a hub for the ADC network. +ADCH++ is a hub for the ADC network. It implements the ADC protocol, which can +be found here: http://dcplusplus.sf.net/ADC.html. -- Requirements -- @@ -16,7 +17,6 @@ An administrator/root account (to install as service / run on port < 1024 on unix). A brain (to understand the readme and setup) gcc 4.2+ (linux or mingw) -boost (http://www.boost.org) scons (http://www.scons.org) swig 1.3.33 @@ -25,10 +25,11 @@ On the client side, I've only tested with DC++. -- Building -- -Install boost, swig and scons. Ensure that your compiler is available in the +Install swig and scons. Ensure that your compiler is available in the PATH. To build with gcc (*nix, mingw), run "scons" in the adchpp root folder. To build with msvc (windows), run "scons tools=default" in the adchpp root folder. To build a release build, add "mode=release" to the build line. +For additional build options, type "scons -h". -- Command line options -- Modified: adchpp/trunk/swig/SConscript =================================================================== --- adchpp/trunk/swig/SConscript 2007-12-10 20:11:15 UTC (rev 104) +++ adchpp/trunk/swig/SConscript 2007-12-14 15:16:58 UTC (rev 105) @@ -87,7 +87,7 @@ env.Append(CPPPATH=[incpath]) else: env.Append(CPPPATH=[distutils.sysconfig.get_python_inc()]) - env.Append(LIBS=['python2.4']) + env.Append(LIBS=['python' + sys.version[0:3]]) env.Append(LIBS=['adchpp']) wrapper = build_path + 'python_wrap.cc' This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2007-12-22 22:18:14
|
Revision: 109 http://adchpp.svn.sourceforge.net/adchpp/?rev=109&view=rev Author: arnetheduck Date: 2007-12-22 14:18:06 -0800 (Sat, 22 Dec 2007) Log Message: ----------- Update docs, fix some minor issues Modified Paths: -------------- adchpp/trunk/License.txt adchpp/trunk/SConstruct adchpp/trunk/adchpp/PluginManager.h adchpp/trunk/adchpp/SettingsManager.h adchpp/trunk/adchpp/version.cpp adchpp/trunk/changelog.txt adchpp/trunk/etc/Script.xml adchpp/trunk/etc/adchpp.xml adchpp/trunk/plugins/Script/examples/access.lua adchpp/trunk/plugins/Script/src/ScriptManager.cpp adchpp/trunk/readme.txt adchpp/trunk/unix/main.cpp adchpp/trunk/unix/po/adchppd.pot Modified: adchpp/trunk/License.txt =================================================================== --- adchpp/trunk/License.txt 2007-12-20 09:53:30 UTC (rev 108) +++ adchpp/trunk/License.txt 2007-12-22 22:18:06 UTC (rev 109) @@ -1,5 +1,5 @@ adchpp -Copyright (C) 2006 Jacek Sieka, arnetheduck on gmail point com +Copyright (C) 2006-2007 Jacek Sieka, arnetheduck on gmail point com Here follows the full text of the GPL-2: Modified: adchpp/trunk/SConstruct =================================================================== --- adchpp/trunk/SConstruct 2007-12-20 09:53:30 UTC (rev 108) +++ adchpp/trunk/SConstruct 2007-12-22 22:18:06 UTC (rev 109) @@ -117,7 +117,6 @@ if env['savetemps'] and 'gcc' in env['TOOLS']: env.Append(CCFLAGS = ['-save-temps', '-fverbose-asm']) - if env['CC'] == 'cl': flags = msvc_flags xxflags = msvc_xxflags Modified: adchpp/trunk/adchpp/PluginManager.h =================================================================== --- adchpp/trunk/adchpp/PluginManager.h 2007-12-20 09:53:30 UTC (rev 108) +++ adchpp/trunk/adchpp/PluginManager.h 2007-12-22 22:18:06 UTC (rev 109) @@ -205,7 +205,7 @@ } /** @internal */ void shutdown(); - + private: virtual ~PluginManager() throw(); Modified: adchpp/trunk/adchpp/SettingsManager.h =================================================================== --- adchpp/trunk/adchpp/SettingsManager.h 2007-12-20 09:53:30 UTC (rev 108) +++ adchpp/trunk/adchpp/SettingsManager.h 2007-12-22 22:18:06 UTC (rev 109) @@ -89,7 +89,7 @@ void set(IntSetting key, bool value) { set(key, (int)value); } void load() { - load(Util::getCfgPath() + _T("adchpp.xml")); + load(Util::getCfgPath() + "adchpp.xml"); } void load(const std::string& aFileName); Modified: adchpp/trunk/adchpp/version.cpp =================================================================== --- adchpp/trunk/adchpp/version.cpp 2007-12-20 09:53:30 UTC (rev 108) +++ adchpp/trunk/adchpp/version.cpp 2007-12-22 22:18:06 UTC (rev 109) @@ -18,7 +18,7 @@ #define BUILDSTRING "Release" #endif -#define FULLVERSIONSTRING APPNAME " v" VERSIONSTRING "-" BUILDSTRING +#define FULLVERSIONSTRING APPNAME " v" VERSIONSTRING " " BUILDSTRING namespace adchpp { Modified: adchpp/trunk/changelog.txt =================================================================== --- adchpp/trunk/changelog.txt 2007-12-20 09:53:30 UTC (rev 108) +++ adchpp/trunk/changelog.txt 2007-12-22 22:18:06 UTC (rev 109) @@ -1,3 +1,2 @@ --- 2.0 -- -* Initial release - +-- 2.1 -- + * Initial ADC 1.0 release \ No newline at end of file Modified: adchpp/trunk/etc/Script.xml =================================================================== --- adchpp/trunk/etc/Script.xml 2007-12-20 09:53:30 UTC (rev 108) +++ adchpp/trunk/etc/Script.xml 2007-12-22 22:18:06 UTC (rev 109) @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="utf-8" standalone="yes"?> <ScriptPlugin> - <Engine scriptPath="Scripts/"> + <Engine language="lua" scriptPath="Scripts/"> <Script>access.lua</Script> </Engine> </ScriptPlugin> Modified: adchpp/trunk/etc/adchpp.xml =================================================================== --- adchpp/trunk/etc/adchpp.xml 2007-12-20 09:53:30 UTC (rev 108) +++ adchpp/trunk/etc/adchpp.xml 2007-12-22 22:18:06 UTC (rev 109) @@ -6,7 +6,7 @@ <!-- This is the name of the hub as it should be reported to the clients during login and to the hub registration services. --> <HubName type="string">ADCH++</HubName> - <Description>ADCH++ Test hub</Description> + <Description type="string">ADCH++ Test hub</Description> <!-- Logging --> <!-- Enable/disable logging --> Modified: adchpp/trunk/plugins/Script/examples/access.lua =================================================================== --- adchpp/trunk/plugins/Script/examples/access.lua 2007-12-20 09:53:30 UTC (rev 108) +++ adchpp/trunk/plugins/Script/examples/access.lua 2007-12-22 22:18:06 UTC (rev 109) @@ -6,10 +6,16 @@ adchpp = luadchpp -- Configuration + +-- Where to read/write user database local users_file = adchpp.Util_getCfgPath() .. "users.txt" +-- Maximum number of non-registered users, -1 = no limit, 0 = no unregistered users allowed +local max_users = -1 + +-- Users with level lower than the specified will not be allowed to run command at all local command_min_levels = { --- [adchpp.CMD_DSC] = 2 +-- [adchpp.AdcCommand.CMD_MSG] = 2 } -- Regexes for the various fields. @@ -159,10 +165,13 @@ end local function dump(c, code, msg) + print("dumping") + print(code) + print(msg) answer = adchpp.AdcCommand(adchpp.AdcCommand_CMD_STA, adchpp.AdcCommand_TYPE_INFO, adchpp.AdcCommand_HUB_SID) answer:addParam("" .. tostring(adchpp.AdcCommand_SEV_FATAL) .. code):addParam(msg) c:send(answer) - c:disconnect() + c:disconnect(0) end local function reply(c, msg) @@ -171,6 +180,23 @@ c:send(answer) end +local function check_max_users() + + if max_users == -1 then + return + end + + if max_users == 0 then + return adchpp.AdcCommand_ERROR_REGGED_ONLY, "Only registered users are allowed in here" + end + + local count = cm:getClients():size() + if count >= max_users then + return adchpp.AdcCommand_ERROR_HUB_FULL, "Hub full, please try again later" + end + return +end + local function get_user(cid, nick) local user if cid then @@ -291,6 +317,11 @@ local user = get_user(cid, nick) if not user then + local code, err = check_max_users() + if code then + dump(c, code, err) + return command_processed + end return 0 end Modified: adchpp/trunk/plugins/Script/src/ScriptManager.cpp =================================================================== --- adchpp/trunk/plugins/Script/src/ScriptManager.cpp 2007-12-20 09:53:30 UTC (rev 108) +++ adchpp/trunk/plugins/Script/src/ScriptManager.cpp 2007-12-22 22:18:06 UTC (rev 109) @@ -62,9 +62,15 @@ xml.fromXML(File(Util::getCfgPath() + "Script.xml", File::READ).read()); xml.stepIn(); while(xml.findChild("Engine")) { - std::string scriptPath = xml.getChildAttrib("scriptPath"); + const std::string& scriptPath = xml.getChildAttrib("scriptPath"); + const std::string& language = xml.getChildAttrib("language"); - engines.push_back(new LuaEngine); + if(language.empty() || language == "lua") { + engines.push_back(new LuaEngine); + } else { + LOG(className, "Unrecognised language " + language); + continue; + } xml.stepIn(); while(xml.findChild("Script")) { @@ -84,7 +90,6 @@ load(); } - void ScriptManager::onReceive(Client& c, AdcCommand& cmd, int& override) { if(cmd.getCommand() != AdcCommand::CMD_MSG) { Modified: adchpp/trunk/readme.txt =================================================================== --- adchpp/trunk/readme.txt 2007-12-20 09:53:30 UTC (rev 108) +++ adchpp/trunk/readme.txt 2007-12-22 22:18:06 UTC (rev 109) @@ -1,59 +1,98 @@ --- License -- -See license.txt - --- Introduction -- - -ADCH++ is a hub for the ADC network. It implements the ADC protocol, which can -be found here: http://dcplusplus.sf.net/ADC.html. - --- Requirements -- - -Win2k/XP/2k3 (may run on NT4 with a fresh service pack as well...don't know). -or -Linux 2.6.x - -A network card with a correctly configured TCP/IP stack. -A computer that can run the above mentioned OS. -An administrator/root account (to install as service / run on port < 1024 on unix). -A brain (to understand the readme and setup) -gcc 4.2+ (linux or mingw) -scons (http://www.scons.org) -swig 1.3.33 - -** Important!! The hub will _NOT_ run on Win9x/ME. ** - -On the client side, I've only tested with DC++. - --- Building -- -Install swig and scons. Ensure that your compiler is available in the -PATH. To build with gcc (*nix, mingw), run "scons" in the adchpp root folder. -To build with msvc (windows), run "scons tools=default" in the adchpp root -folder. To build a release build, add "mode=release" to the build line. -For additional build options, type "scons -h". - --- Command line options -- - --c <configdir> Run with an alternate config directoy. Must be an absolute path. --i <name> Install the hub service to enable running as a service. * Windows only * --u <name> Remove the service you created earlier. * Windows only * --v Print version information (make sure to include this in any bug reports) --d Run as a daemon. Kill with a standard sigterm. * Linux only * --p <pid-file> Write process pid to <pid-file> * Linux only * - --- Where to find more info -- - -Try http://adchpp.sf.net/ or http://dcpp.net/forum/. - --- Send in patches -- -I'll gladly accept patches, but in order to avoid future licensing issues, I ask you to -give me copyright over any submitted code. Make sure that the code doesn't break support -for any of the platforms supported and that it looks more or less like the rest of the -code (indent, names etc). -Please use unified patches agains latest svn trunk (i e svn diff or diff -u). - --- Donate money -- - -If you feel like helping out but don't know how, this is obviously a good way =)...paste this link in your -browser (goes to paypal): - -https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=arnetheduck%40gmail%2ecom&item_name=DCPlusPlus&no_shipping=1&return=http%3a%2f%2fdcplusplus%2esf%2enet%2f&cancel_return=http%3a%2f%2fdcplusplus%2esf%2enet%2f&cn=Greeting&tax=0¤cy_code=EUR&bn=PP%2dDonationsBF&charset=UTF%2d8 += ADCH++ - A hub software for ADC + +== Introduction + +ADCH++ is a hub for the ADC network. It implements the +http://dcplusplus.sf.net/ADC.html[ADC protocol]. The core application is very +simple, but extensible using plugins. Among the standard plugins there is a +scripting plugin that allows hub owners to further customize the hub using the +http://www.lua.org[Lua] scripting language. The core is also exposed as a +Python module, thus it is possible to use it within a Python application. + +== License +ADCH++ is licensed under the GPL. For details, see license.txt supplied with +the application. A side effect of the license is that any plugins you write +must be released under a license compatible with the GPL. + +== Download +The latest version of ADCH++ can be downloaded from +http://sourceforge.net/projects/adchpp/[SourceForge]. The source code resides +in http://sourceforge.net/svn/?group_id=172105[SVN]. + +== Requirements +To run ADCH++ you will need the following: + +* A computer with a network card +* Linux with a 2.6-based kernel or Windows 2000/XP +* A brain (to understand the readme and do the setup) +* Optional: An administrator account (to install as service / run on port < 1024 on + unix) + +NOTE: The hub will not run on Windows 9x/ME + +To compile the sources you will also need: + +* GCC 4.2+ (Linux or http://www.mingw.org[MinGW]) +* http://www.scons.org[SCons 0.97] +* http://www.swig.org[SWIG 1.3.33] +* http://www.python.org[Python] 2.5 (Windows) or 2.4+ (Linux) + +== Building +To build ADCH++ from source you have to: + +* Install SWIG and ensure it's in your PATH +* Install Python and ensure it's in your PATH +* Install SCons and ensure it's in your PATH +* Windows: Install MinGW and ensure it's in your PATH +* Linux: Install GCC 4.2+ and appropriate header files +* In the source folder, type "scons -h" to see additional compile options +* Type "scons" to create a debug build. "scons mode=release" will create a + release build. + +== Configuration +ADCH++ is configured using an XML file, as are the standard plugins. The +example configuration contains enough comments to get you started. In Linux, +the default location for configuration files is "/etc/adchpp/". In Windows, it's +a directory named "config" under the installation directory. + +== Running +ADCH++ will normally run as a console / terminal application but can also be +convinced to run in the background (daemon/service). It accepts various +command line options such as: + +[separator="|"] +``_ +-c <configdir> | Run with an alternate config directoy. Must be an absolute path. +-i <name> | Install the hub service to enable running as a service. * Windows only * +-u <name> | Remove the service you created earlier. * Windows only * +-v | Print version information (make sure to include this in any bug reports) +-d | Run as a daemon. Kill with a standard sigterm. * Linux only * +-p <pid-file> | Write process pid to <pid-file> * Linux only * +___ + +== Where to find more info +Try its http://adchpp.sf.net/[home page] or the +http://dcplusplus.sf.net/[DC++ home page]. + +== Patches and contributions +I'll gladly accept patches, but in order to avoid future licensing issues, I ask you to +give me copyright over any submitted code. Make sure that the code doesn't break support +for any of the platforms supported and that it looks more or less like the +rest of the code (indent, names etc). + +Patches should be sent to the dcplusplus-devel mailing list. Subscription +information can be found +https://lists.sourceforge.net/lists/listinfo/dcplusplus-devel[here]. + +Please use unified patches agains latest svn trunk (i e svn diff) and supply a +description of what the patch does. + +== Donations + +If you feel like helping out but don't know how, this is obviously a good way +=) + +https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=arnetheduck%40gmail%2ecom&item_name=DCPlusPlus&no_shipping=1&return=http%3a%2f%2fdcplusplus%2esf%2enet%2f&cancel_return=http%3a%2f%2fdcplusplus%2esf%2enet%2f&cn=Greeting&tax=0¤cy_code=EUR&bn=PP%2dDonationsBF&charset=UTF%2d8[Donate!] + +// vim: set syntax=asciidoc: + Modified: adchpp/trunk/unix/main.cpp =================================================================== --- adchpp/trunk/unix/main.cpp 2007-12-20 09:53:30 UTC (rev 108) +++ adchpp/trunk/unix/main.cpp 2007-12-22 22:18:06 UTC (rev 109) @@ -168,7 +168,6 @@ int main(int argc, char* argv[]) { - // IMHO, argv[0] is the program name... char buf[PATH_MAX + 1]; char* path = buf; if (readlink("/proc/self/exe", buf, sizeof (buf)) == -1) { Modified: adchpp/trunk/unix/po/adchppd.pot =================================================================== --- adchpp/trunk/unix/po/adchppd.pot 2007-12-20 09:53:30 UTC (rev 108) +++ adchpp/trunk/unix/po/adchppd.pot 2007-12-22 22:18:06 UTC (rev 109) @@ -7,7 +7,7 @@ msgstr "" "Project-Id-Version: \"adchpp\"--copyright-holder=\"Jacek Sieka\"\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2007-12-09 20:22+0100\n" +"POT-Creation-Date: 2007-12-22 23:02+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL...@li...>\n" @@ -45,27 +45,27 @@ msgid "Usage: adchpp [[-c <configdir>] [-d]] | [-v] | [-h]\n" msgstr "" -#: unix/main.cpp:189 +#: unix/main.cpp:188 #, c-format msgid "-c <directory>\n" msgstr "" -#: unix/main.cpp:195 +#: unix/main.cpp:194 #, c-format msgid "Config dir must be an absolute path\n" msgstr "" -#: unix/main.cpp:204 +#: unix/main.cpp:203 #, c-format msgid "-p <pid-file>\n" msgstr "" -#: unix/main.cpp:213 +#: unix/main.cpp:212 #, c-format msgid "Unknown parameter: %s\n" msgstr "" -#: unix/main.cpp:222 +#: unix/main.cpp:221 #, c-format msgid "Can't open %s for writing\n" msgstr "" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2007-12-22 23:08:33
|
Revision: 110 http://adchpp.svn.sourceforge.net/adchpp/?rev=110&view=rev Author: arnetheduck Date: 2007-12-22 15:08:03 -0800 (Sat, 22 Dec 2007) Log Message: ----------- Add boost, more docs fixes Modified Paths: -------------- adchpp/trunk/Doxyfile Added Paths: ----------- adchpp/trunk/boost/ adchpp/trunk/boost/LICENSE_1_0.txt adchpp/trunk/boost/Readme.txt adchpp/trunk/boost/boost/ adchpp/trunk/boost/boost/algorithm/ adchpp/trunk/boost/boost/algorithm/minmax.hpp adchpp/trunk/boost/boost/algorithm/minmax_element.hpp adchpp/trunk/boost/boost/algorithm/string/ adchpp/trunk/boost/boost/algorithm/string/case_conv.hpp adchpp/trunk/boost/boost/algorithm/string/classification.hpp adchpp/trunk/boost/boost/algorithm/string/compare.hpp adchpp/trunk/boost/boost/algorithm/string/concept.hpp adchpp/trunk/boost/boost/algorithm/string/config.hpp adchpp/trunk/boost/boost/algorithm/string/constants.hpp adchpp/trunk/boost/boost/algorithm/string/detail/ adchpp/trunk/boost/boost/algorithm/string/detail/case_conv.hpp adchpp/trunk/boost/boost/algorithm/string/detail/classification.hpp adchpp/trunk/boost/boost/algorithm/string/detail/find_format.hpp adchpp/trunk/boost/boost/algorithm/string/detail/find_format_all.hpp adchpp/trunk/boost/boost/algorithm/string/detail/find_format_store.hpp adchpp/trunk/boost/boost/algorithm/string/detail/find_iterator.hpp adchpp/trunk/boost/boost/algorithm/string/detail/finder.hpp adchpp/trunk/boost/boost/algorithm/string/detail/finder_regex.hpp adchpp/trunk/boost/boost/algorithm/string/detail/formatter.hpp adchpp/trunk/boost/boost/algorithm/string/detail/formatter_regex.hpp adchpp/trunk/boost/boost/algorithm/string/detail/predicate.hpp adchpp/trunk/boost/boost/algorithm/string/detail/replace_storage.hpp adchpp/trunk/boost/boost/algorithm/string/detail/sequence.hpp adchpp/trunk/boost/boost/algorithm/string/detail/trim.hpp adchpp/trunk/boost/boost/algorithm/string/detail/util.hpp adchpp/trunk/boost/boost/algorithm/string/erase.hpp adchpp/trunk/boost/boost/algorithm/string/find.hpp adchpp/trunk/boost/boost/algorithm/string/find_format.hpp adchpp/trunk/boost/boost/algorithm/string/find_iterator.hpp adchpp/trunk/boost/boost/algorithm/string/finder.hpp adchpp/trunk/boost/boost/algorithm/string/formatter.hpp adchpp/trunk/boost/boost/algorithm/string/iter_find.hpp adchpp/trunk/boost/boost/algorithm/string/join.hpp adchpp/trunk/boost/boost/algorithm/string/predicate.hpp adchpp/trunk/boost/boost/algorithm/string/predicate_facade.hpp adchpp/trunk/boost/boost/algorithm/string/regex.hpp adchpp/trunk/boost/boost/algorithm/string/regex_find_format.hpp adchpp/trunk/boost/boost/algorithm/string/replace.hpp adchpp/trunk/boost/boost/algorithm/string/sequence_traits.hpp adchpp/trunk/boost/boost/algorithm/string/split.hpp adchpp/trunk/boost/boost/algorithm/string/std/ adchpp/trunk/boost/boost/algorithm/string/std/list_traits.hpp adchpp/trunk/boost/boost/algorithm/string/std/rope_traits.hpp adchpp/trunk/boost/boost/algorithm/string/std/slist_traits.hpp adchpp/trunk/boost/boost/algorithm/string/std/string_traits.hpp adchpp/trunk/boost/boost/algorithm/string/std_containers_traits.hpp adchpp/trunk/boost/boost/algorithm/string/trim.hpp adchpp/trunk/boost/boost/algorithm/string/yes_no_type.hpp adchpp/trunk/boost/boost/algorithm/string.hpp adchpp/trunk/boost/boost/algorithm/string_regex.hpp adchpp/trunk/boost/boost/aligned_storage.hpp adchpp/trunk/boost/boost/any.hpp adchpp/trunk/boost/boost/archive/ adchpp/trunk/boost/boost/archive/add_facet.hpp adchpp/trunk/boost/boost/archive/archive_exception.hpp adchpp/trunk/boost/boost/archive/basic_archive.hpp adchpp/trunk/boost/boost/archive/basic_binary_iarchive.hpp adchpp/trunk/boost/boost/archive/basic_binary_iprimitive.hpp adchpp/trunk/boost/boost/archive/basic_binary_oarchive.hpp adchpp/trunk/boost/boost/archive/basic_binary_oprimitive.hpp adchpp/trunk/boost/boost/archive/basic_streambuf_locale_saver.hpp adchpp/trunk/boost/boost/archive/basic_text_iarchive.hpp adchpp/trunk/boost/boost/archive/basic_text_iprimitive.hpp adchpp/trunk/boost/boost/archive/basic_text_oarchive.hpp adchpp/trunk/boost/boost/archive/basic_text_oprimitive.hpp adchpp/trunk/boost/boost/archive/basic_xml_archive.hpp adchpp/trunk/boost/boost/archive/basic_xml_iarchive.hpp adchpp/trunk/boost/boost/archive/basic_xml_oarchive.hpp adchpp/trunk/boost/boost/archive/binary_iarchive.hpp adchpp/trunk/boost/boost/archive/binary_iarchive_impl.hpp adchpp/trunk/boost/boost/archive/binary_oarchive.hpp adchpp/trunk/boost/boost/archive/binary_oarchive_impl.hpp adchpp/trunk/boost/boost/archive/binary_wiarchive.hpp adchpp/trunk/boost/boost/archive/binary_woarchive.hpp adchpp/trunk/boost/boost/archive/codecvt_null.hpp adchpp/trunk/boost/boost/archive/detail/ adchpp/trunk/boost/boost/archive/detail/abi_prefix.hpp adchpp/trunk/boost/boost/archive/detail/abi_suffix.hpp adchpp/trunk/boost/boost/archive/detail/archive_pointer_iserializer.hpp adchpp/trunk/boost/boost/archive/detail/archive_pointer_oserializer.hpp adchpp/trunk/boost/boost/archive/detail/auto_link_archive.hpp adchpp/trunk/boost/boost/archive/detail/auto_link_warchive.hpp adchpp/trunk/boost/boost/archive/detail/basic_archive_impl.hpp adchpp/trunk/boost/boost/archive/detail/basic_config.hpp adchpp/trunk/boost/boost/archive/detail/basic_iarchive.hpp adchpp/trunk/boost/boost/archive/detail/basic_iserializer.hpp adchpp/trunk/boost/boost/archive/detail/basic_oarchive.hpp adchpp/trunk/boost/boost/archive/detail/basic_oserializer.hpp adchpp/trunk/boost/boost/archive/detail/basic_pointer_iserializer.hpp adchpp/trunk/boost/boost/archive/detail/basic_pointer_oserializer.hpp adchpp/trunk/boost/boost/archive/detail/basic_serializer.hpp adchpp/trunk/boost/boost/archive/detail/basic_serializer_map.hpp adchpp/trunk/boost/boost/archive/detail/common_iarchive.hpp adchpp/trunk/boost/boost/archive/detail/common_oarchive.hpp adchpp/trunk/boost/boost/archive/detail/decl.hpp adchpp/trunk/boost/boost/archive/detail/interface_iarchive.hpp adchpp/trunk/boost/boost/archive/detail/interface_oarchive.hpp adchpp/trunk/boost/boost/archive/detail/iserializer.hpp adchpp/trunk/boost/boost/archive/detail/known_archive_types.hpp adchpp/trunk/boost/boost/archive/detail/known_archive_types_fwd.hpp adchpp/trunk/boost/boost/archive/detail/oserializer.hpp adchpp/trunk/boost/boost/archive/detail/polymorphic_iarchive_impl.hpp adchpp/trunk/boost/boost/archive/detail/polymorphic_oarchive_impl.hpp adchpp/trunk/boost/boost/archive/detail/utf8_codecvt_facet.hpp adchpp/trunk/boost/boost/archive/dinkumware.hpp adchpp/trunk/boost/boost/archive/impl/ adchpp/trunk/boost/boost/archive/impl/archive_pointer_iserializer.ipp adchpp/trunk/boost/boost/archive/impl/archive_pointer_oserializer.ipp adchpp/trunk/boost/boost/archive/impl/basic_binary_iarchive.ipp adchpp/trunk/boost/boost/archive/impl/basic_binary_iprimitive.ipp adchpp/trunk/boost/boost/archive/impl/basic_binary_oarchive.ipp adchpp/trunk/boost/boost/archive/impl/basic_binary_oprimitive.ipp adchpp/trunk/boost/boost/archive/impl/basic_text_iarchive.ipp adchpp/trunk/boost/boost/archive/impl/basic_text_iprimitive.ipp adchpp/trunk/boost/boost/archive/impl/basic_text_oarchive.ipp adchpp/trunk/boost/boost/archive/impl/basic_text_oprimitive.ipp adchpp/trunk/boost/boost/archive/impl/basic_xml_grammar.hpp adchpp/trunk/boost/boost/archive/impl/basic_xml_iarchive.ipp adchpp/trunk/boost/boost/archive/impl/basic_xml_oarchive.ipp adchpp/trunk/boost/boost/archive/impl/text_iarchive_impl.ipp adchpp/trunk/boost/boost/archive/impl/text_oarchive_impl.ipp adchpp/trunk/boost/boost/archive/impl/text_wiarchive_impl.ipp adchpp/trunk/boost/boost/archive/impl/text_woarchive_impl.ipp adchpp/trunk/boost/boost/archive/impl/xml_iarchive_impl.ipp adchpp/trunk/boost/boost/archive/impl/xml_oarchive_impl.ipp adchpp/trunk/boost/boost/archive/impl/xml_wiarchive_impl.ipp adchpp/trunk/boost/boost/archive/impl/xml_woarchive_impl.ipp adchpp/trunk/boost/boost/archive/iterators/ adchpp/trunk/boost/boost/archive/iterators/base64_exception.hpp adchpp/trunk/boost/boost/archive/iterators/base64_from_binary.hpp adchpp/trunk/boost/boost/archive/iterators/binary_from_base64.hpp adchpp/trunk/boost/boost/archive/iterators/dataflow.hpp adchpp/trunk/boost/boost/archive/iterators/dataflow_exception.hpp adchpp/trunk/boost/boost/archive/iterators/escape.hpp adchpp/trunk/boost/boost/archive/iterators/head_iterator.hpp adchpp/trunk/boost/boost/archive/iterators/insert_linebreaks.hpp adchpp/trunk/boost/boost/archive/iterators/istream_iterator.hpp adchpp/trunk/boost/boost/archive/iterators/mb_from_wchar.hpp adchpp/trunk/boost/boost/archive/iterators/ostream_iterator.hpp adchpp/trunk/boost/boost/archive/iterators/remove_whitespace.hpp adchpp/trunk/boost/boost/archive/iterators/transform_width.hpp adchpp/trunk/boost/boost/archive/iterators/unescape.hpp adchpp/trunk/boost/boost/archive/iterators/wchar_from_mb.hpp adchpp/trunk/boost/boost/archive/iterators/xml_escape.hpp adchpp/trunk/boost/boost/archive/iterators/xml_unescape.hpp adchpp/trunk/boost/boost/archive/iterators/xml_unescape_exception.hpp adchpp/trunk/boost/boost/archive/polymorphic_binary_iarchive.hpp adchpp/trunk/boost/boost/archive/polymorphic_binary_oarchive.hpp adchpp/trunk/boost/boost/archive/polymorphic_iarchive.hpp adchpp/trunk/boost/boost/archive/polymorphic_oarchive.hpp adchpp/trunk/boost/boost/archive/polymorphic_text_iarchive.hpp adchpp/trunk/boost/boost/archive/polymorphic_text_oarchive.hpp adchpp/trunk/boost/boost/archive/polymorphic_text_wiarchive.hpp adchpp/trunk/boost/boost/archive/polymorphic_text_woarchive.hpp adchpp/trunk/boost/boost/archive/polymorphic_xml_iarchive.hpp adchpp/trunk/boost/boost/archive/polymorphic_xml_oarchive.hpp adchpp/trunk/boost/boost/archive/polymorphic_xml_wiarchive.hpp adchpp/trunk/boost/boost/archive/polymorphic_xml_woarchive.hpp adchpp/trunk/boost/boost/archive/text_iarchive.hpp adchpp/trunk/boost/boost/archive/text_oarchive.hpp adchpp/trunk/boost/boost/archive/text_wiarchive.hpp adchpp/trunk/boost/boost/archive/text_woarchive.hpp adchpp/trunk/boost/boost/archive/tmpdir.hpp adchpp/trunk/boost/boost/archive/wcslen.hpp adchpp/trunk/boost/boost/archive/xml_iarchive.hpp adchpp/trunk/boost/boost/archive/xml_oarchive.hpp adchpp/trunk/boost/boost/archive/xml_wiarchive.hpp adchpp/trunk/boost/boost/archive/xml_woarchive.hpp adchpp/trunk/boost/boost/array.hpp adchpp/trunk/boost/boost/assert.hpp adchpp/trunk/boost/boost/assign/ adchpp/trunk/boost/boost/assign/assignment_exception.hpp adchpp/trunk/boost/boost/assign/list_inserter.hpp adchpp/trunk/boost/boost/assign/list_of.hpp adchpp/trunk/boost/boost/assign/ptr_list_inserter.hpp adchpp/trunk/boost/boost/assign/ptr_list_of.hpp adchpp/trunk/boost/boost/assign/ptr_map_inserter.hpp adchpp/trunk/boost/boost/assign/std/ adchpp/trunk/boost/boost/assign/std/deque.hpp adchpp/trunk/boost/boost/assign/std/list.hpp adchpp/trunk/boost/boost/assign/std/map.hpp adchpp/trunk/boost/boost/assign/std/queue.hpp adchpp/trunk/boost/boost/assign/std/set.hpp adchpp/trunk/boost/boost/assign/std/slist.hpp adchpp/trunk/boost/boost/assign/std/stack.hpp adchpp/trunk/boost/boost/assign/std/vector.hpp adchpp/trunk/boost/boost/assign/std.hpp adchpp/trunk/boost/boost/assign.hpp adchpp/trunk/boost/boost/bind/ adchpp/trunk/boost/boost/bind/apply.hpp adchpp/trunk/boost/boost/bind/arg.hpp adchpp/trunk/boost/boost/bind/bind_cc.hpp adchpp/trunk/boost/boost/bind/bind_mf_cc.hpp adchpp/trunk/boost/boost/bind/bind_template.hpp adchpp/trunk/boost/boost/bind/make_adaptable.hpp adchpp/trunk/boost/boost/bind/mem_fn_cc.hpp adchpp/trunk/boost/boost/bind/mem_fn_template.hpp adchpp/trunk/boost/boost/bind/mem_fn_vw.hpp adchpp/trunk/boost/boost/bind/placeholders.hpp adchpp/trunk/boost/boost/bind/protect.hpp adchpp/trunk/boost/boost/bind/storage.hpp adchpp/trunk/boost/boost/bind.hpp adchpp/trunk/boost/boost/blank.hpp adchpp/trunk/boost/boost/blank_fwd.hpp adchpp/trunk/boost/boost/call_traits.hpp adchpp/trunk/boost/boost/cast.hpp adchpp/trunk/boost/boost/checked_delete.hpp adchpp/trunk/boost/boost/compatibility/ adchpp/trunk/boost/boost/compatibility/cpp_c_headers/ adchpp/trunk/boost/boost/compatibility/cpp_c_headers/cassert adchpp/trunk/boost/boost/compatibility/cpp_c_headers/cctype adchpp/trunk/boost/boost/compatibility/cpp_c_headers/cerrno adchpp/trunk/boost/boost/compatibility/cpp_c_headers/cfloat adchpp/trunk/boost/boost/compatibility/cpp_c_headers/climits adchpp/trunk/boost/boost/compatibility/cpp_c_headers/clocale adchpp/trunk/boost/boost/compatibility/cpp_c_headers/cmath adchpp/trunk/boost/boost/compatibility/cpp_c_headers/csetjmp adchpp/trunk/boost/boost/compatibility/cpp_c_headers/csignal adchpp/trunk/boost/boost/compatibility/cpp_c_headers/cstdarg adchpp/trunk/boost/boost/compatibility/cpp_c_headers/cstddef adchpp/trunk/boost/boost/compatibility/cpp_c_headers/cstdio adchpp/trunk/boost/boost/compatibility/cpp_c_headers/cstdlib adchpp/trunk/boost/boost/compatibility/cpp_c_headers/cstring adchpp/trunk/boost/boost/compatibility/cpp_c_headers/ctime adchpp/trunk/boost/boost/compatibility/cpp_c_headers/cwchar adchpp/trunk/boost/boost/compatibility/cpp_c_headers/cwctype adchpp/trunk/boost/boost/compressed_pair.hpp adchpp/trunk/boost/boost/concept_archetype.hpp adchpp/trunk/boost/boost/concept_check.hpp adchpp/trunk/boost/boost/config/ adchpp/trunk/boost/boost/config/abi/ adchpp/trunk/boost/boost/config/abi/borland_prefix.hpp adchpp/trunk/boost/boost/config/abi/borland_suffix.hpp adchpp/trunk/boost/boost/config/abi/msvc_prefix.hpp adchpp/trunk/boost/boost/config/abi/msvc_suffix.hpp adchpp/trunk/boost/boost/config/abi_prefix.hpp adchpp/trunk/boost/boost/config/abi_suffix.hpp adchpp/trunk/boost/boost/config/auto_link.hpp adchpp/trunk/boost/boost/config/compiler/ adchpp/trunk/boost/boost/config/compiler/borland.hpp adchpp/trunk/boost/boost/config/compiler/comeau.hpp adchpp/trunk/boost/boost/config/compiler/common_edg.hpp adchpp/trunk/boost/boost/config/compiler/compaq_cxx.hpp adchpp/trunk/boost/boost/config/compiler/digitalmars.hpp adchpp/trunk/boost/boost/config/compiler/gcc.hpp adchpp/trunk/boost/boost/config/compiler/gcc_xml.hpp adchpp/trunk/boost/boost/config/compiler/greenhills.hpp adchpp/trunk/boost/boost/config/compiler/hp_acc.hpp adchpp/trunk/boost/boost/config/compiler/intel.hpp adchpp/trunk/boost/boost/config/compiler/kai.hpp adchpp/trunk/boost/boost/config/compiler/metrowerks.hpp adchpp/trunk/boost/boost/config/compiler/mpw.hpp adchpp/trunk/boost/boost/config/compiler/sgi_mipspro.hpp adchpp/trunk/boost/boost/config/compiler/sunpro_cc.hpp adchpp/trunk/boost/boost/config/compiler/vacpp.hpp adchpp/trunk/boost/boost/config/compiler/visualc.hpp adchpp/trunk/boost/boost/config/no_tr1/ adchpp/trunk/boost/boost/config/no_tr1/complex.hpp adchpp/trunk/boost/boost/config/no_tr1/functional.hpp adchpp/trunk/boost/boost/config/no_tr1/memory.hpp adchpp/trunk/boost/boost/config/no_tr1/utility.hpp adchpp/trunk/boost/boost/config/platform/ adchpp/trunk/boost/boost/config/platform/aix.hpp adchpp/trunk/boost/boost/config/platform/amigaos.hpp adchpp/trunk/boost/boost/config/platform/beos.hpp adchpp/trunk/boost/boost/config/platform/bsd.hpp adchpp/trunk/boost/boost/config/platform/cygwin.hpp adchpp/trunk/boost/boost/config/platform/hpux.hpp adchpp/trunk/boost/boost/config/platform/irix.hpp adchpp/trunk/boost/boost/config/platform/linux.hpp adchpp/trunk/boost/boost/config/platform/macos.hpp adchpp/trunk/boost/boost/config/platform/qnxnto.hpp adchpp/trunk/boost/boost/config/platform/solaris.hpp adchpp/trunk/boost/boost/config/platform/win32.hpp adchpp/trunk/boost/boost/config/posix_features.hpp adchpp/trunk/boost/boost/config/requires_threads.hpp adchpp/trunk/boost/boost/config/select_compiler_config.hpp adchpp/trunk/boost/boost/config/select_platform_config.hpp adchpp/trunk/boost/boost/config/select_stdlib_config.hpp adchpp/trunk/boost/boost/config/stdlib/ adchpp/trunk/boost/boost/config/stdlib/dinkumware.hpp adchpp/trunk/boost/boost/config/stdlib/libcomo.hpp adchpp/trunk/boost/boost/config/stdlib/libstdcpp3.hpp adchpp/trunk/boost/boost/config/stdlib/modena.hpp adchpp/trunk/boost/boost/config/stdlib/msl.hpp adchpp/trunk/boost/boost/config/stdlib/roguewave.hpp adchpp/trunk/boost/boost/config/stdlib/sgi.hpp adchpp/trunk/boost/boost/config/stdlib/stlport.hpp adchpp/trunk/boost/boost/config/stdlib/vacpp.hpp adchpp/trunk/boost/boost/config/suffix.hpp adchpp/trunk/boost/boost/config/user.hpp adchpp/trunk/boost/boost/config.hpp adchpp/trunk/boost/boost/crc.hpp adchpp/trunk/boost/boost/cregex.hpp adchpp/trunk/boost/boost/cstdint.hpp adchpp/trunk/boost/boost/cstdlib.hpp adchpp/trunk/boost/boost/current_function.hpp adchpp/trunk/boost/boost/date_time/ adchpp/trunk/boost/boost/date_time/adjust_functors.hpp adchpp/trunk/boost/boost/date_time/c_local_time_adjustor.hpp adchpp/trunk/boost/boost/date_time/c_time.hpp adchpp/trunk/boost/boost/date_time/compiler_config.hpp adchpp/trunk/boost/boost/date_time/constrained_value.hpp adchpp/trunk/boost/boost/date_time/date.hpp adchpp/trunk/boost/boost/date_time/date_clock_device.hpp adchpp/trunk/boost/boost/date_time/date_defs.hpp adchpp/trunk/boost/boost/date_time/date_duration.hpp adchpp/trunk/boost/boost/date_time/date_duration_types.hpp adchpp/trunk/boost/boost/date_time/date_facet.hpp adchpp/trunk/boost/boost/date_time/date_format_simple.hpp adchpp/trunk/boost/boost/date_time/date_formatting.hpp adchpp/trunk/boost/boost/date_time/date_formatting_limited.hpp adchpp/trunk/boost/boost/date_time/date_formatting_locales.hpp adchpp/trunk/boost/boost/date_time/date_generator_formatter.hpp adchpp/trunk/boost/boost/date_time/date_generator_parser.hpp adchpp/trunk/boost/boost/date_time/date_generators.hpp adchpp/trunk/boost/boost/date_time/date_iterator.hpp adchpp/trunk/boost/boost/date_time/date_names_put.hpp adchpp/trunk/boost/boost/date_time/date_parsing.hpp adchpp/trunk/boost/boost/date_time/dst_rules.hpp adchpp/trunk/boost/boost/date_time/dst_transition_generators.hpp adchpp/trunk/boost/boost/date_time/filetime_functions.hpp adchpp/trunk/boost/boost/date_time/format_date_parser.hpp adchpp/trunk/boost/boost/date_time/gregorian/ adchpp/trunk/boost/boost/date_time/gregorian/conversion.hpp adchpp/trunk/boost/boost/date_time/gregorian/formatters.hpp adchpp/trunk/boost/boost/date_time/gregorian/formatters_limited.hpp adchpp/trunk/boost/boost/date_time/gregorian/greg_calendar.hpp adchpp/trunk/boost/boost/date_time/gregorian/greg_date.hpp adchpp/trunk/boost/boost/date_time/gregorian/greg_day.hpp adchpp/trunk/boost/boost/date_time/gregorian/greg_day_of_year.hpp adchpp/trunk/boost/boost/date_time/gregorian/greg_duration.hpp adchpp/trunk/boost/boost/date_time/gregorian/greg_duration_types.hpp adchpp/trunk/boost/boost/date_time/gregorian/greg_facet.hpp adchpp/trunk/boost/boost/date_time/gregorian/greg_month.hpp adchpp/trunk/boost/boost/date_time/gregorian/greg_serialize.hpp adchpp/trunk/boost/boost/date_time/gregorian/greg_weekday.hpp adchpp/trunk/boost/boost/date_time/gregorian/greg_year.hpp adchpp/trunk/boost/boost/date_time/gregorian/greg_ymd.hpp adchpp/trunk/boost/boost/date_time/gregorian/gregorian.hpp adchpp/trunk/boost/boost/date_time/gregorian/gregorian_io.hpp adchpp/trunk/boost/boost/date_time/gregorian/gregorian_types.hpp adchpp/trunk/boost/boost/date_time/gregorian/parsers.hpp adchpp/trunk/boost/boost/date_time/gregorian_calendar.hpp adchpp/trunk/boost/boost/date_time/gregorian_calendar.ipp adchpp/trunk/boost/boost/date_time/int_adapter.hpp adchpp/trunk/boost/boost/date_time/iso_format.hpp adchpp/trunk/boost/boost/date_time/local_time/ adchpp/trunk/boost/boost/date_time/local_time/conversion.hpp adchpp/trunk/boost/boost/date_time/local_time/custom_time_zone.hpp adchpp/trunk/boost/boost/date_time/local_time/date_duration_operators.hpp adchpp/trunk/boost/boost/date_time/local_time/dst_transition_day_rules.hpp adchpp/trunk/boost/boost/date_time/local_time/local_date_time.hpp adchpp/trunk/boost/boost/date_time/local_time/local_time.hpp adchpp/trunk/boost/boost/date_time/local_time/local_time_io.hpp adchpp/trunk/boost/boost/date_time/local_time/local_time_types.hpp adchpp/trunk/boost/boost/date_time/local_time/posix_time_zone.hpp adchpp/trunk/boost/boost/date_time/local_time/tz_database.hpp adchpp/trunk/boost/boost/date_time/local_time_adjustor.hpp adchpp/trunk/boost/boost/date_time/local_timezone_defs.hpp adchpp/trunk/boost/boost/date_time/locale_config.hpp adchpp/trunk/boost/boost/date_time/microsec_time_clock.hpp adchpp/trunk/boost/boost/date_time/parse_format_base.hpp adchpp/trunk/boost/boost/date_time/period.hpp adchpp/trunk/boost/boost/date_time/period_formatter.hpp adchpp/trunk/boost/boost/date_time/period_parser.hpp adchpp/trunk/boost/boost/date_time/posix_time/ adchpp/trunk/boost/boost/date_time/posix_time/conversion.hpp adchpp/trunk/boost/boost/date_time/posix_time/date_duration_operators.hpp adchpp/trunk/boost/boost/date_time/posix_time/posix_time.hpp adchpp/trunk/boost/boost/date_time/posix_time/posix_time_config.hpp adchpp/trunk/boost/boost/date_time/posix_time/posix_time_duration.hpp adchpp/trunk/boost/boost/date_time/posix_time/posix_time_io.hpp adchpp/trunk/boost/boost/date_time/posix_time/posix_time_legacy_io.hpp adchpp/trunk/boost/boost/date_time/posix_time/posix_time_system.hpp adchpp/trunk/boost/boost/date_time/posix_time/posix_time_types.hpp adchpp/trunk/boost/boost/date_time/posix_time/ptime.hpp adchpp/trunk/boost/boost/date_time/posix_time/time_formatters.hpp adchpp/trunk/boost/boost/date_time/posix_time/time_formatters_limited.hpp adchpp/trunk/boost/boost/date_time/posix_time/time_parsers.hpp adchpp/trunk/boost/boost/date_time/posix_time/time_period.hpp adchpp/trunk/boost/boost/date_time/posix_time/time_serialize.hpp adchpp/trunk/boost/boost/date_time/special_defs.hpp adchpp/trunk/boost/boost/date_time/special_values_formatter.hpp adchpp/trunk/boost/boost/date_time/special_values_parser.hpp adchpp/trunk/boost/boost/date_time/string_convert.hpp adchpp/trunk/boost/boost/date_time/string_parse_tree.hpp adchpp/trunk/boost/boost/date_time/strings_from_facet.hpp adchpp/trunk/boost/boost/date_time/testfrmwk.hpp adchpp/trunk/boost/boost/date_time/time.hpp adchpp/trunk/boost/boost/date_time/time_clock.hpp adchpp/trunk/boost/boost/date_time/time_defs.hpp adchpp/trunk/boost/boost/date_time/time_duration.hpp adchpp/trunk/boost/boost/date_time/time_facet.hpp adchpp/trunk/boost/boost/date_time/time_formatting_streams.hpp adchpp/trunk/boost/boost/date_time/time_iterator.hpp adchpp/trunk/boost/boost/date_time/time_parsing.hpp adchpp/trunk/boost/boost/date_time/time_resolution_traits.hpp adchpp/trunk/boost/boost/date_time/time_system_counted.hpp adchpp/trunk/boost/boost/date_time/time_system_split.hpp adchpp/trunk/boost/boost/date_time/time_zone_base.hpp adchpp/trunk/boost/boost/date_time/time_zone_names.hpp adchpp/trunk/boost/boost/date_time/tz_db_base.hpp adchpp/trunk/boost/boost/date_time/wrapping_int.hpp adchpp/trunk/boost/boost/date_time/year_month_day.hpp adchpp/trunk/boost/boost/date_time.hpp adchpp/trunk/boost/boost/detail/ adchpp/trunk/boost/boost/detail/algorithm.hpp adchpp/trunk/boost/boost/detail/allocator_utilities.hpp adchpp/trunk/boost/boost/detail/atomic_count.hpp adchpp/trunk/boost/boost/detail/atomic_count_gcc.hpp adchpp/trunk/boost/boost/detail/atomic_count_pthreads.hpp adchpp/trunk/boost/boost/detail/atomic_count_win32.hpp adchpp/trunk/boost/boost/detail/bad_weak_ptr.hpp adchpp/trunk/boost/boost/detail/binary_search.hpp adchpp/trunk/boost/boost/detail/call_traits.hpp adchpp/trunk/boost/boost/detail/catch_exceptions.hpp adchpp/trunk/boost/boost/detail/compressed_pair.hpp adchpp/trunk/boost/boost/detail/dynamic_bitset.hpp adchpp/trunk/boost/boost/detail/endian.hpp adchpp/trunk/boost/boost/detail/indirect_traits.hpp adchpp/trunk/boost/boost/detail/interlocked.hpp adchpp/trunk/boost/boost/detail/is_function_ref_tester.hpp adchpp/trunk/boost/boost/detail/is_incrementable.hpp adchpp/trunk/boost/boost/detail/is_xxx.hpp adchpp/trunk/boost/boost/detail/iterator.hpp adchpp/trunk/boost/boost/detail/lightweight_mutex.hpp adchpp/trunk/boost/boost/detail/lightweight_test.hpp adchpp/trunk/boost/boost/detail/limits.hpp adchpp/trunk/boost/boost/detail/lwm_nop.hpp adchpp/trunk/boost/boost/detail/lwm_pthreads.hpp adchpp/trunk/boost/boost/detail/lwm_win32_cs.hpp adchpp/trunk/boost/boost/detail/named_template_params.hpp adchpp/trunk/boost/boost/detail/no_exceptions_support.hpp adchpp/trunk/boost/boost/detail/none_t.hpp adchpp/trunk/boost/boost/detail/numeric_traits.hpp adchpp/trunk/boost/boost/detail/ob_call_traits.hpp adchpp/trunk/boost/boost/detail/ob_compressed_pair.hpp adchpp/trunk/boost/boost/detail/quick_allocator.hpp adchpp/trunk/boost/boost/detail/reference_content.hpp adchpp/trunk/boost/boost/detail/select_type.hpp adchpp/trunk/boost/boost/detail/shared_array_nmt.hpp adchpp/trunk/boost/boost/detail/shared_count.hpp adchpp/trunk/boost/boost/detail/shared_ptr_nmt.hpp adchpp/trunk/boost/boost/detail/sp_counted_base.hpp adchpp/trunk/boost/boost/detail/sp_counted_base_cw_ppc.hpp adchpp/trunk/boost/boost/detail/sp_counted_base_cw_x86.hpp adchpp/trunk/boost/boost/detail/sp_counted_base_gcc_ia64.hpp adchpp/trunk/boost/boost/detail/sp_counted_base_gcc_ppc.hpp adchpp/trunk/boost/boost/detail/sp_counted_base_gcc_x86.hpp adchpp/trunk/boost/boost/detail/sp_counted_base_nt.hpp adchpp/trunk/boost/boost/detail/sp_counted_base_pt.hpp adchpp/trunk/boost/boost/detail/sp_counted_base_w32.hpp adchpp/trunk/boost/boost/detail/sp_counted_impl.hpp adchpp/trunk/boost/boost/detail/templated_streams.hpp adchpp/trunk/boost/boost/detail/utf8_codecvt_facet.hpp adchpp/trunk/boost/boost/detail/workaround.hpp adchpp/trunk/boost/boost/dynamic_bitset/ adchpp/trunk/boost/boost/dynamic_bitset/config.hpp adchpp/trunk/boost/boost/dynamic_bitset/dynamic_bitset.hpp adchpp/trunk/boost/boost/dynamic_bitset.hpp adchpp/trunk/boost/boost/dynamic_bitset_fwd.hpp adchpp/trunk/boost/boost/dynamic_property_map.hpp adchpp/trunk/boost/boost/enable_shared_from_this.hpp adchpp/trunk/boost/boost/filesystem/ adchpp/trunk/boost/boost/filesystem/cerrno.hpp adchpp/trunk/boost/boost/filesystem/config.hpp adchpp/trunk/boost/boost/filesystem/convenience.hpp adchpp/trunk/boost/boost/filesystem/exception.hpp adchpp/trunk/boost/boost/filesystem/fstream.hpp adchpp/trunk/boost/boost/filesystem/operations.hpp adchpp/trunk/boost/boost/filesystem/path.hpp adchpp/trunk/boost/boost/filesystem.hpp adchpp/trunk/boost/boost/foreach.hpp adchpp/trunk/boost/boost/format/ adchpp/trunk/boost/boost/format/alt_sstream.hpp adchpp/trunk/boost/boost/format/alt_sstream_impl.hpp adchpp/trunk/boost/boost/format/detail/ adchpp/trunk/boost/boost/format/detail/compat_workarounds.hpp adchpp/trunk/boost/boost/format/detail/config_macros.hpp adchpp/trunk/boost/boost/format/detail/msvc_disambiguater.hpp adchpp/trunk/boost/boost/format/detail/unset_macros.hpp adchpp/trunk/boost/boost/format/detail/workarounds_gcc-2_95.hpp adchpp/trunk/boost/boost/format/detail/workarounds_stlport.hpp adchpp/trunk/boost/boost/format/exceptions.hpp adchpp/trunk/boost/boost/format/feed_args.hpp adchpp/trunk/boost/boost/format/format_class.hpp adchpp/trunk/boost/boost/format/format_fwd.hpp adchpp/trunk/boost/boost/format/format_implementation.hpp adchpp/trunk/boost/boost/format/free_funcs.hpp adchpp/trunk/boost/boost/format/group.hpp adchpp/trunk/boost/boost/format/internals.hpp adchpp/trunk/boost/boost/format/internals_fwd.hpp adchpp/trunk/boost/boost/format/parsing.hpp adchpp/trunk/boost/boost/format.hpp adchpp/trunk/boost/boost/function/ adchpp/trunk/boost/boost/function/detail/ adchpp/trunk/boost/boost/function/detail/function_iterate.hpp adchpp/trunk/boost/boost/function/detail/gen_maybe_include.pl adchpp/trunk/boost/boost/function/detail/maybe_include.hpp adchpp/trunk/boost/boost/function/detail/prologue.hpp adchpp/trunk/boost/boost/function/function0.hpp adchpp/trunk/boost/boost/function/function1.hpp adchpp/trunk/boost/boost/function/function10.hpp adchpp/trunk/boost/boost/function/function2.hpp adchpp/trunk/boost/boost/function/function3.hpp adchpp/trunk/boost/boost/function/function4.hpp adchpp/trunk/boost/boost/function/function5.hpp adchpp/trunk/boost/boost/function/function6.hpp adchpp/trunk/boost/boost/function/function7.hpp adchpp/trunk/boost/boost/function/function8.hpp adchpp/trunk/boost/boost/function/function9.hpp adchpp/trunk/boost/boost/function/function_base.hpp adchpp/trunk/boost/boost/function/function_template.hpp adchpp/trunk/boost/boost/function/gen_function_N.pl adchpp/trunk/boost/boost/function.hpp adchpp/trunk/boost/boost/function_equal.hpp adchpp/trunk/boost/boost/function_output_iterator.hpp adchpp/trunk/boost/boost/functional/ adchpp/trunk/boost/boost/functional/detail/ adchpp/trunk/boost/boost/functional/detail/container_fwd.hpp adchpp/trunk/boost/boost/functional/detail/float_functions.hpp adchpp/trunk/boost/boost/functional/detail/hash_float.hpp adchpp/trunk/boost/boost/functional/hash/ adchpp/trunk/boost/boost/functional/hash/deque.hpp adchpp/trunk/boost/boost/functional/hash/hash.hpp adchpp/trunk/boost/boost/functional/hash/list.hpp adchpp/trunk/boost/boost/functional/hash/map.hpp adchpp/trunk/boost/boost/functional/hash/pair.hpp adchpp/trunk/boost/boost/functional/hash/set.hpp adchpp/trunk/boost/boost/functional/hash/vector.hpp adchpp/trunk/boost/boost/functional/hash.hpp adchpp/trunk/boost/boost/functional/hash_fwd.hpp adchpp/trunk/boost/boost/functional.hpp adchpp/trunk/boost/boost/generator_iterator.hpp adchpp/trunk/boost/boost/get_pointer.hpp adchpp/trunk/boost/boost/graph/ adchpp/trunk/boost/boost/graph/adj_list_serialize.hpp adchpp/trunk/boost/boost/graph/adjacency_iterator.hpp adchpp/trunk/boost/boost/graph/adjacency_list.hpp adchpp/trunk/boost/boost/graph/adjacency_list_io.hpp adchpp/trunk/boost/boost/graph/adjacency_matrix.hpp adchpp/trunk/boost/boost/graph/astar_search.hpp adchpp/trunk/boost/boost/graph/bandwidth.hpp adchpp/trunk/boost/boost/graph/bc_clustering.hpp adchpp/trunk/boost/boost/graph/bellman_ford_shortest_paths.hpp adchpp/trunk/boost/boost/graph/betweenness_centrality.hpp adchpp/trunk/boost/boost/graph/biconnected_components.hpp adchpp/trunk/boost/boost/graph/breadth_first_search.hpp adchpp/trunk/boost/boost/graph/circle_layout.hpp adchpp/trunk/boost/boost/graph/compressed_sparse_row_graph.hpp adchpp/trunk/boost/boost/graph/connected_components.hpp adchpp/trunk/boost/boost/graph/copy.hpp adchpp/trunk/boost/boost/graph/create_condensation_graph.hpp adchpp/trunk/boost/boost/graph/cuthill_mckee_ordering.hpp adchpp/trunk/boost/boost/graph/dag_shortest_paths.hpp adchpp/trunk/boost/boost/graph/depth_first_search.hpp adchpp/trunk/boost/boost/graph/detail/ adchpp/trunk/boost/boost/graph/detail/adj_list_edge_iterator.hpp adchpp/trunk/boost/boost/graph/detail/adjacency_list.hpp adchpp/trunk/boost/boost/graph/detail/array_binary_tree.hpp adchpp/trunk/boost/boost/graph/detail/bitset.hpp adchpp/trunk/boost/boost/graph/detail/bitset_adaptor.hpp adchpp/trunk/boost/boost/graph/detail/connected_components.hpp adchpp/trunk/boost/boost/graph/detail/edge.hpp adchpp/trunk/boost/boost/graph/detail/incidence_iterator.hpp adchpp/trunk/boost/boost/graph/detail/incremental_components.hpp adchpp/trunk/boost/boost/graph/detail/indexed_properties.hpp adchpp/trunk/boost/boost/graph/detail/is_same.hpp adchpp/trunk/boost/boost/graph/detail/list_base.hpp adchpp/trunk/boost/boost/graph/detail/permutation.hpp adchpp/trunk/boost/boost/graph/detail/read_graphviz_spirit.hpp adchpp/trunk/boost/boost/graph/detail/self_avoiding_walk.hpp adchpp/trunk/boost/boost/graph/detail/set_adaptor.hpp adchpp/trunk/boost/boost/graph/detail/shadow_iterator.hpp adchpp/trunk/boost/boost/graph/detail/sparse_ordering.hpp adchpp/trunk/boost/boost/graph/dijkstra_shortest_paths.hpp adchpp/trunk/boost/boost/graph/dominator_tree.hpp adchpp/trunk/boost/boost/graph/edge_connectivity.hpp adchpp/trunk/boost/boost/graph/edge_list.hpp adchpp/trunk/boost/boost/graph/edmunds_karp_max_flow.hpp adchpp/trunk/boost/boost/graph/erdos_renyi_generator.hpp adchpp/trunk/boost/boost/graph/exception.hpp adchpp/trunk/boost/boost/graph/filtered_graph.hpp adchpp/trunk/boost/boost/graph/floyd_warshall_shortest.hpp adchpp/trunk/boost/boost/graph/fruchterman_reingold.hpp adchpp/trunk/boost/boost/graph/graph_archetypes.hpp adchpp/trunk/boost/boost/graph/graph_as_tree.hpp adchpp/trunk/boost/boost/graph/graph_concepts.hpp adchpp/trunk/boost/boost/graph/graph_selectors.hpp adchpp/trunk/boost/boost/graph/graph_test.hpp adchpp/trunk/boost/boost/graph/graph_traits.hpp adchpp/trunk/boost/boost/graph/graph_utility.hpp adchpp/trunk/boost/boost/graph/graphviz.hpp adchpp/trunk/boost/boost/graph/gursoy_atun_layout.hpp adchpp/trunk/boost/boost/graph/incremental_components.hpp adchpp/trunk/boost/boost/graph/isomorphism.hpp adchpp/trunk/boost/boost/graph/iteration_macros.hpp adchpp/trunk/boost/boost/graph/iteration_macros_undef.hpp adchpp/trunk/boost/boost/graph/johnson_all_pairs_shortest.hpp adchpp/trunk/boost/boost/graph/kamada_kawai_spring_layout.hpp adchpp/trunk/boost/boost/graph/king_ordering.hpp adchpp/trunk/boost/boost/graph/kruskal_min_spanning_tree.hpp adchpp/trunk/boost/boost/graph/leda_graph.hpp adchpp/trunk/boost/boost/graph/matrix_as_graph.hpp adchpp/trunk/boost/boost/graph/max_cardinality_matching.hpp adchpp/trunk/boost/boost/graph/minimum_degree_ordering.hpp adchpp/trunk/boost/boost/graph/named_function_params.hpp adchpp/trunk/boost/boost/graph/neighbor_bfs.hpp adchpp/trunk/boost/boost/graph/page_rank.hpp adchpp/trunk/boost/boost/graph/plod_generator.hpp adchpp/trunk/boost/boost/graph/prim_minimum_spanning_tree.hpp adchpp/trunk/boost/boost/graph/profile.hpp adchpp/trunk/boost/boost/graph/properties.hpp adchpp/trunk/boost/boost/graph/property_iter_range.hpp adchpp/trunk/boost/boost/graph/push_relabel_max_flow.hpp adchpp/trunk/boost/boost/graph/random.hpp adchpp/trunk/boost/boost/graph/random_layout.hpp adchpp/trunk/boost/boost/graph/read_dimacs.hpp adchpp/trunk/boost/boost/graph/relax.hpp adchpp/trunk/boost/boost/graph/reverse_graph.hpp adchpp/trunk/boost/boost/graph/sequential_vertex_coloring.hpp adchpp/trunk/boost/boost/graph/simple_point.hpp adchpp/trunk/boost/boost/graph/sloan_ordering.hpp adchpp/trunk/boost/boost/graph/small_world_generator.hpp adchpp/trunk/boost/boost/graph/smallest_last_ordering.hpp adchpp/trunk/boost/boost/graph/stanford_graph.hpp adchpp/trunk/boost/boost/graph/strong_components.hpp adchpp/trunk/boost/boost/graph/subgraph.hpp adchpp/trunk/boost/boost/graph/topological_sort.hpp adchpp/trunk/boost/boost/graph/transitive_closure.hpp adchpp/trunk/boost/boost/graph/transpose_graph.hpp adchpp/trunk/boost/boost/graph/tree_traits.hpp adchpp/trunk/boost/boost/graph/two_bit_color_map.hpp adchpp/trunk/boost/boost/graph/undirected_dfs.hpp adchpp/trunk/boost/boost/graph/vector_as_graph.hpp adchpp/trunk/boost/boost/graph/visitors.hpp adchpp/trunk/boost/boost/graph/wavefront.hpp adchpp/trunk/boost/boost/implicit_cast.hpp adchpp/trunk/boost/boost/indirect_reference.hpp adchpp/trunk/boost/boost/integer/ adchpp/trunk/boost/boost/integer/integer_mask.hpp adchpp/trunk/boost/boost/integer/static_log2.hpp adchpp/trunk/boost/boost/integer/static_min_max.hpp adchpp/trunk/boost/boost/integer.hpp adchpp/trunk/boost/boost/integer_fwd.hpp adchpp/trunk/boost/boost/integer_traits.hpp adchpp/trunk/boost/boost/intrusive_ptr.hpp adchpp/trunk/boost/boost/io/ adchpp/trunk/boost/boost/io/ios_state.hpp adchpp/trunk/boost/boost/io_fwd.hpp adchpp/trunk/boost/boost/iostreams/ adchpp/trunk/boost/boost/iostreams/categories.hpp adchpp/trunk/boost/boost/iostreams/chain.hpp adchpp/trunk/boost/boost/iostreams/char_traits.hpp adchpp/trunk/boost/boost/iostreams/checked_operations.hpp adchpp/trunk/boost/boost/iostreams/close.hpp adchpp/trunk/boost/boost/iostreams/code_converter.hpp adchpp/trunk/boost/boost/iostreams/combine.hpp adchpp/trunk/boost/boost/iostreams/compose.hpp adchpp/trunk/boost/boost/iostreams/concepts.hpp adchpp/trunk/boost/boost/iostreams/constants.hpp adchpp/trunk/boost/boost/iostreams/copy.hpp adchpp/trunk/boost/boost/iostreams/detail/ adchpp/trunk/boost/boost/iostreams/detail/access_control.hpp adchpp/trunk/boost/boost/iostreams/detail/adapter/ adchpp/trunk/boost/boost/iostreams/detail/adapter/basic_adapter.hpp adchpp/trunk/boost/boost/iostreams/detail/adapter/concept_adapter.hpp adchpp/trunk/boost/boost/iostreams/detail/adapter/direct_adapter.hpp adchpp/trunk/boost/boost/iostreams/detail/adapter/mode_adapter.hpp adchpp/trunk/boost/boost/iostreams/detail/adapter/non_blocking_adapter.hpp adchpp/trunk/boost/boost/iostreams/detail/adapter/output_iterator_adapter.hpp adchpp/trunk/boost/boost/iostreams/detail/adapter/range_adapter.hpp adchpp/trunk/boost/boost/iostreams/detail/add_facet.hpp adchpp/trunk/boost/boost/iostreams/detail/bool_trait_def.hpp adchpp/trunk/boost/boost/iostreams/detail/broken_overload_resolution/ adchpp/trunk/boost/boost/iostreams/detail/broken_overload_resolution/forward.hpp adchpp/trunk/boost/boost/iostreams/detail/broken_overload_resolution/stream.hpp adchpp/trunk/boost/boost/iostreams/detail/broken_overload_resolution/stream_buffer.hpp adchpp/trunk/boost/boost/iostreams/detail/buffer.hpp adchpp/trunk/boost/boost/iostreams/detail/call_traits.hpp adchpp/trunk/boost/boost/iostreams/detail/char_traits.hpp adchpp/trunk/boost/boost/iostreams/detail/closer.hpp adchpp/trunk/boost/boost/iostreams/detail/codecvt_helper.hpp adchpp/trunk/boost/boost/iostreams/detail/codecvt_holder.hpp adchpp/trunk/boost/boost/iostreams/detail/config/ adchpp/trunk/boost/boost/iostreams/detail/config/auto_link.hpp adchpp/trunk/boost/boost/iostreams/detail/config/bzip2.hpp adchpp/trunk/boost/boost/iostreams/detail/config/codecvt.hpp adchpp/trunk/boost/boost/iostreams/detail/config/disable_warnings.hpp adchpp/trunk/boost/boost/iostreams/detail/config/dyn_link.hpp adchpp/trunk/boost/boost/iostreams/detail/config/enable_warnings.hpp adchpp/trunk/boost/boost/iostreams/detail/config/gcc.hpp adchpp/trunk/boost/boost/iostreams/detail/config/limits.hpp adchpp/trunk/boost/boost/iostreams/detail/config/overload_resolution.hpp adchpp/trunk/boost/boost/iostreams/detail/config/wide_streams.hpp adchpp/trunk/boost/boost/iostreams/detail/config/windows_posix.hpp adchpp/trunk/boost/boost/iostreams/detail/config/zlib.hpp adchpp/trunk/boost/boost/iostreams/detail/counted_array.hpp adchpp/trunk/boost/boost/iostreams/detail/default_arg.hpp adchpp/trunk/boost/boost/iostreams/detail/dispatch.hpp adchpp/trunk/boost/boost/iostreams/detail/double_object.hpp adchpp/trunk/boost/boost/iostreams/detail/enable_if_stream.hpp adchpp/trunk/boost/boost/iostreams/detail/error.hpp adchpp/trunk/boost/boost/iostreams/detail/forward.hpp adchpp/trunk/boost/boost/iostreams/detail/fstream.hpp adchpp/trunk/boost/boost/iostreams/detail/ios.hpp adchpp/trunk/boost/boost/iostreams/detail/iostream.hpp adchpp/trunk/boost/boost/iostreams/detail/is_dereferenceable.hpp adchpp/trunk/boost/boost/iostreams/detail/is_iterator_range.hpp adchpp/trunk/boost/boost/iostreams/detail/newline.hpp adchpp/trunk/boost/boost/iostreams/detail/optional.hpp adchpp/trunk/boost/boost/iostreams/detail/param_type.hpp adchpp/trunk/boost/boost/iostreams/detail/push.hpp adchpp/trunk/boost/boost/iostreams/detail/push_params.hpp adchpp/trunk/boost/boost/iostreams/detail/resolve.hpp adchpp/trunk/boost/boost/iostreams/detail/select.hpp adchpp/trunk/boost/boost/iostreams/detail/select_by_size.hpp adchpp/trunk/boost/boost/iostreams/detail/streambuf/ adchpp/trunk/boost/boost/iostreams/detail/streambuf/chainbuf.hpp adchpp/trunk/boost/boost/iostreams/detail/streambuf/direct_streambuf.hpp adchpp/trunk/boost/boost/iostreams/detail/streambuf/indirect_streambuf.hpp adchpp/trunk/boost/boost/iostreams/detail/streambuf/linked_streambuf.hpp adchpp/trunk/boost/boost/iostreams/detail/streambuf.hpp adchpp/trunk/boost/boost/iostreams/detail/system_failure.hpp adchpp/trunk/boost/boost/iostreams/detail/template_params.hpp adchpp/trunk/boost/boost/iostreams/detail/translate_int_type.hpp adchpp/trunk/boost/boost/iostreams/detail/vc6/ adchpp/trunk/boost/boost/iostreams/detail/vc6/close.hpp adchpp/trunk/boost/boost/iostreams/detail/vc6/read.hpp adchpp/trunk/boost/boost/iostreams/detail/vc6/write.hpp adchpp/trunk/boost/boost/iostreams/detail/wrap_unwrap.hpp adchpp/trunk/boost/boost/iostreams/device/ adchpp/trunk/boost/boost/iostreams/device/array.hpp adchpp/trunk/boost/boost/iostreams/device/back_inserter.hpp adchpp/trunk/boost/boost/iostreams/device/file.hpp adchpp/trunk/boost/boost/iostreams/device/file_descriptor.hpp adchpp/trunk/boost/boost/iostreams/device/mapped_file.hpp adchpp/trunk/boost/boost/iostreams/device/null.hpp adchpp/trunk/boost/boost/iostreams/filter/ adchpp/trunk/boost/boost/iostreams/filter/aggregate.hpp adchpp/trunk/boost/boost/iostreams/filter/bzip2.hpp adchpp/trunk/boost/boost/iostreams/filter/counter.hpp adchpp/trunk/boost/boost/iostreams/filter/gzip.hpp adchpp/trunk/boost/boost/iostreams/filter/line.hpp adchpp/trunk/boost/boost/iostreams/filter/newline.hpp adchpp/trunk/boost/boost/iostreams/filter/regex.hpp adchpp/trunk/boost/boost/iostreams/filter/stdio.hpp adchpp/trunk/boost/boost/iostreams/filter/symmetric.hpp adchpp/trunk/boost/boost/iostreams/filter/test.hpp adchpp/trunk/boost/boost/iostreams/filter/zlib.hpp adchpp/trunk/boost/boost/iostreams/filtering_stream.hpp adchpp/trunk/boost/boost/iostreams/filtering_streambuf.hpp adchpp/trunk/boost/boost/iostreams/flush.hpp adchpp/trunk/boost/boost/iostreams/get.hpp adchpp/trunk/boost/boost/iostreams/imbue.hpp adchpp/trunk/boost/boost/iostreams/input_sequence.hpp adchpp/trunk/boost/boost/iostreams/invert.hpp adchpp/trunk/boost/boost/iostreams/operations.hpp adchpp/trunk/boost/boost/iostreams/operations_fwd.hpp adchpp/trunk/boost/boost/iostreams/optimal_buffer_size.hpp adchpp/trunk/boost/boost/iostreams/output_sequence.hpp adchpp/trunk/boost/boost/iostreams/pipeline.hpp adchpp/trunk/boost/boost/iostreams/positioning.hpp adchpp/trunk/boost/boost/iostreams/put.hpp adchpp/trunk/boost/boost/iostreams/putback.hpp adchpp/trunk/boost/boost/iostreams/read.hpp adchpp/trunk/boost/boost/iostreams/restrict.hpp adchpp/trunk/boost/boost/iostreams/seek.hpp adchpp/trunk/boost/boost/iostreams/skip.hpp adchpp/trunk/boost/boost/iostreams/stream.hpp adchpp/trunk/boost/boost/iostreams/stream_buffer.hpp adchpp/trunk/boost/boost/iostreams/tee.hpp adchpp/trunk/boost/boost/iostreams/traits.hpp adchpp/trunk/boost/boost/iostreams/traits_fwd.hpp adchpp/trunk/boost/boost/iostreams/write.hpp adchpp/trunk/boost/boost/iterator/ adchpp/trunk/boost/boost/iterator/counting_iterator.hpp adchpp/trunk/boost/boost/iterator/detail/ adchpp/trunk/boost/boost/iterator/detail/any_conversion_eater.hpp adchpp/trunk/boost/boost/iterator/detail/config_def.hpp adchpp/trunk/boost/boost/iterator/detail/config_undef.hpp adchpp/trunk/boost/boost/iterator/detail/enable_if.hpp adchpp/trunk/boost/boost/iterator/detail/facade_iterator_category.hpp adchpp/trunk/boost/boost/iterator/detail/minimum_category.hpp adchpp/trunk/boost/boost/iterator/filter_iterator.hpp adchpp/trunk/boost/boost/iterator/indirect_iterator.hpp adchpp/trunk/boost/boost/iterator/interoperable.hpp adchpp/trunk/boost/boost/iterator/is_lvalue_iterator.hpp adchpp/trunk/boost/boost/iterator/is_readable_iterator.hpp adchpp/trunk/boost/boost/iterator/iterator_adaptor.hpp adchpp/trunk/boost/boost/iterator/iterator_archetypes.hpp adchpp/trunk/boost/boost/iterator/iterator_categories.hpp adchpp/trunk/boost/boost/iterator/iterator_concepts.hpp adchpp/trunk/boost/boost/iterator/iterator_facade.hpp adchpp/trunk/boost/boost/iterator/iterator_traits.hpp adchpp/trunk/boost/boost/iterator/new_iterator_tests.hpp adchpp/trunk/boost/boost/iterator/permutation_iterator.hpp adchpp/trunk/boost/boost/iterator/reverse_iterator.hpp adchpp/trunk/boost/boost/iterator/transform_iterator.hpp adchpp/trunk/boost/boost/iterator/zip_iterator.hpp adchpp/trunk/boost/boost/iterator.hpp adchpp/trunk/boost/boost/iterator_adaptors.hpp adchpp/trunk/boost/boost/lambda/ adchpp/trunk/boost/boost/lambda/algorithm.hpp adchpp/trunk/boost/boost/lambda/bind.hpp adchpp/trunk/boost/boost/lambda/casts.hpp adchpp/trunk/boost/boost/lambda/closures.hpp adchpp/trunk/boost/boost/lambda/construct.hpp adchpp/trunk/boost/boost/lambda/control_structures.hpp adchpp/trunk/boost/boost/lambda/core.hpp adchpp/trunk/boost/boost/lambda/detail/ adchpp/trunk/boost/boost/lambda/detail/actions.hpp adchpp/trunk/boost/boost/lambda/detail/arity_code.hpp adchpp/trunk/boost/boost/lambda/detail/bind_functions.hpp adchpp/trunk/boost/boost/lambda/detail/control_constructs_common.hpp adchpp/trunk/boost/boost/lambda/detail/control_structures_impl.hpp adchpp/trunk/boost/boost/lambda/detail/function_adaptors.hpp adchpp/trunk/boost/boost/lambda/detail/is_instance_of.hpp adchpp/trunk/boost/boost/lambda/detail/lambda_config.hpp adchpp/trunk/boost/boost/lambda/detail/lambda_functor_base.hpp adchpp/trunk/boost/boost/lambda/detail/lambda_functors.hpp adchpp/trunk/boost/boost/lambda/detail/lambda_fwd.hpp adchpp/trunk/boost/boost/lambda/detail/lambda_traits.hpp adchpp/trunk/boost/boost/lambda/detail/member_ptr.hpp adchpp/trunk/boost/boost/lambda/detail/operator_actions.hpp adchpp/trunk/boost/boost/lambda/detail/operator_lambda_func_base.hpp adchpp/trunk/boost/boost/lambda/detail/operator_return_type_traits.hpp adchpp/trunk/boost/boost/lambda/detail/operators.hpp adchpp/trunk/boost/boost/lambda/detail/ret.hpp adchpp/trunk/boost/boost/lambda/detail/return_type_traits.hpp adchpp/trunk/boost/boost/lambda/detail/select_functions.hpp adchpp/trunk/boost/boost/lambda/exceptions.hpp adchpp/trunk/boost/boost/lambda/if.hpp adchpp/trunk/boost/boost/lambda/lambda.hpp adchpp/trunk/boost/boost/lambda/loops.hpp adchpp/trunk/boost/boost/lambda/numeric.hpp adchpp/trunk/boost/boost/lambda/switch.hpp adchpp/trunk/boost/boost/last_value.hpp adchpp/trunk/boost/boost/lexical_cast.hpp adchpp/trunk/boost/boost/limits.hpp adchpp/trunk/boost/boost/logic/ adchpp/trunk/boost/boost/logic/tribool.hpp adchpp/trunk/boost/boost/logic/tribool_fwd.hpp adchpp/trunk/boost/boost/logic/tribool_io.hpp adchpp/trunk/boost/boost/math/ adchpp/trunk/boost/boost/math/common_factor.hpp adchpp/trunk/boost/boost/math/common_factor_ct.hpp adchpp/trunk/boost/boost/math/common_factor_rt.hpp adchpp/trunk/boost/boost/math/complex/ adchpp/trunk/boost/boost/math/complex/acos.hpp adchpp/trunk/boost/boost/math/complex/acosh.hpp adchpp/trunk/boost/boost/math/complex/asin.hpp adchpp/trunk/boost/boost/math/complex/asinh.hpp adchpp/trunk/boost/boost/math/complex/atan.hpp adchpp/trunk/boost/boost/math/complex/atanh.hpp adchpp/trunk/boost/boost/math/complex/details.hpp adchpp/trunk/boost/boost/math/complex/fabs.hpp adchpp/trunk/boost/boost/math/complex.hpp adchpp/trunk/boost/boost/math/octonion.hpp adchpp/trunk/boost/boost/math/quaternion.hpp adchpp/trunk/boost/boost/math/special_functions/ adchpp/trunk/boost/boost/math/special_functions/acosh.hpp adchpp/trunk/boost/boost/math/special_functions/asinh.hpp adchpp/trunk/boost/boost/math/special_functions/atanh.hpp adchpp/trunk/boost/boost/math/special_functions/detail/ adchpp/trunk/boost/boost/math/special_functions/detail/series.hpp adchpp/trunk/boost/boost/math/special_functions/expm1.hpp adchpp/trunk/boost/boost/math/special_functions/hypot.hpp adchpp/trunk/boost/boost/math/special_functions/log1p.hpp adchpp/trunk/boost/boost/math/special_functions/sinc.hpp adchpp/trunk/boost/boost/math/special_functions/sinhc.hpp adchpp/trunk/boost/boost/math_fwd.hpp adchpp/trunk/boost/boost/mem_fn.hpp adchpp/trunk/boost/boost/mpl/ adchpp/trunk/boost/boost/mpl/O1_size.hpp adchpp/trunk/boost/boost/mpl/O1_size_fwd.hpp adchpp/trunk/boost/boost/mpl/accumulate.hpp adchpp/trunk/boost/boost/mpl/advance.hpp adchpp/trunk/boost/boost/mpl/advance_fwd.hpp adchpp/trunk/boost/boost/mpl/alias.hpp adchpp/trunk/boost/boost/mpl/always.hpp adchpp/trunk/boost/boost/mpl/and.hpp adchpp/trunk/boost/boost/mpl/apply.hpp adchpp/trunk/boost/boost/mpl/apply_fwd.hpp adchpp/trunk/boost/boost/mpl/apply_wrap.hpp adchpp/trunk/boost/boost/mpl/arg.hpp adchpp/trunk/boost/boost/mpl/arg_fwd.hpp adchpp/trunk/boost/boost/mpl/arithmetic.hpp adchpp/trunk/boost/boost/mpl/as_sequence.hpp adchpp/trunk/boost/boost/mpl/assert.hpp adchpp/trunk/boost/boost/mpl/at.hpp adchpp/trunk/boost/boost/mpl/at_fwd.hpp adchpp/trunk/boost/boost/mpl/aux_/ adchpp/trunk/boost/boost/mpl/aux_/O1_size_impl.hpp adchpp/trunk/boost/boost/mpl/aux_/adl_barrier.hpp adchpp/trunk/boost/boost/mpl/aux_/advance_backward.hpp adchpp/trunk/boost/boost/mpl/aux_/advance_forward.hpp adchpp/trunk/boost/boost/mpl/aux_/apply_1st.hpp adchpp/trunk/boost/boost/mpl/aux_/arg_typedef.hpp adchpp/trunk/boost/boost/mpl/aux_/arithmetic_op.hpp adchpp/trunk/boost/boost/mpl/aux_/arity.hpp adchpp/trunk/boost/boost/mpl/aux_/arity_spec.hpp adchpp/trunk/boost/boost/mpl/aux_/at_impl.hpp adchpp/trunk/boost/boost/mpl/aux_/back_impl.hpp adchpp/trunk/boost/boost/mpl/aux_/basic_bind.hpp adchpp/trunk/boost/boost/mpl/aux_/begin_end_impl.hpp adchpp/trunk/boost/boost/mpl/aux_/clear_impl.hpp adchpp/trunk/boost/boost/mpl/aux_/common_name_wknd.hpp adchpp/trunk/boost/boost/mpl/aux_/comparison_op.hpp adchpp/trunk/boost/boost/mpl/aux_/config/ adchpp/trunk/boost/boost/mpl/aux_/config/adl.hpp adchpp/trunk/boost/boost/mpl/aux_/config/arrays.hpp adchpp/trunk/boost/boost/mpl/aux_/config/bind.hpp adchpp/trunk/boost/boost/mpl/aux_/config/compiler.hpp adchpp/trunk/boost/boost/mpl/aux_/config/ctps.hpp adchpp/trunk/boost/boost/mpl/aux_/config/dependent_nttp.hpp adchpp/trunk/boost/boost/mpl/aux_/config/dmc_ambiguous_ctps.hpp adchpp/trunk/boost/boost/mpl/aux_/config/dtp.hpp adchpp/trunk/boost/boost/mpl/aux_/config/eti.hpp adchpp/trunk/boost/boost/mpl/aux_/config/forwarding.hpp adchpp/trunk/boost/boost/mpl/aux_/config/gcc.hpp adchpp/trunk/boost/boost/mpl/aux_/config/has_apply.hpp adchpp/trunk/boost/boost/mpl/aux_/config/has_xxx.hpp adchpp/trunk/boost/boost/mpl/aux_/config/integral.hpp adchpp/trunk/boost/boost/mpl/aux_/config/intel.hpp adchpp/trunk/boost/boost/mpl/aux_/config/lambda.hpp adchpp/trunk/boost/boost/mpl/aux_/config/msvc.hpp adchpp/trunk/boost/boost/mpl/aux_/config/msvc_typename.hpp adchpp/trunk/boost/boost/mpl/aux_/config/nttp.hpp adchpp/trunk/boost/boost/mpl/aux_/config/operators.hpp adchpp/trunk/boost/boost/mpl/aux_/config/overload_resolution.hpp adchpp/trunk/boost/boost/mpl/aux_/config/preprocessor.hpp adchpp/trunk/boost/boost/mpl/aux_/config/static_constant.hpp adchpp/trunk/boost/boost/mpl/aux_/config/ttp.hpp adchpp/trunk/boost/boost/mpl/aux_/config/typeof.hpp adchpp/trunk/boost/boost/mpl/aux_/config/use_preprocessed.hpp adchpp/trunk/boost/boost/mpl/aux_/config/workaround.hpp adchpp/trunk/boost/boost/mpl/aux_/contains_impl.hpp adchpp/trunk/boost/boost/mpl/aux_/count_args.hpp adchpp/trunk/boost/boost/mpl/aux_/count_impl.hpp adchpp/trunk/boost/boost/mpl/aux_/empty_impl.hpp adchpp/trunk/boost/boost/mpl/aux_/erase_impl.hpp adchpp/trunk/boost/boost/mpl/aux_/erase_key_impl.hpp adchpp/trunk/boost/boost/mpl/aux_/filter_iter.hpp adchpp/trunk/boost/boost/mpl/aux_/find_if_pred.hpp adchpp/trunk/boost/boost/mpl/aux_/fold_impl.hpp adchpp/trunk/boost/boost/mpl/aux_/fold_impl_body.hpp adchpp/trunk/boost/boost/mpl/aux_/fold_op.hpp adchpp/trunk/boost/boost/mpl/aux_/fold_pred.hpp adchpp/trunk/boost/boost/mpl/aux_/front_impl.hpp adchpp/trunk/boost/boost/mpl/aux_/full_lambda.hpp adchpp/trunk/boost/boost/mpl/aux_/has_apply.hpp adchpp/trunk/boost/boost/mpl/aux_/has_begin.hpp adchpp/trunk/boost/boost/mpl/aux_/has_key_impl.hpp adchpp/trunk/boost/boost/mpl/aux_/has_rebind.hpp adchpp/trunk/boost/boost/mpl/aux_/has_size.hpp adchpp/trunk/boost/boost/mpl/aux_/has_tag.hpp adchpp/trunk/boost/boost/mpl/aux_/has_type.hpp adchpp/trunk/boost/boost/mpl/aux_/include_preprocessed.hpp adchpp/trunk/boost/boost/mpl/aux_/insert_impl.hpp adchpp/trunk/boost/boost/mpl/aux_/insert_range_impl.hpp adchpp/trunk/boost/boost/mpl/aux_/inserter_algorithm.hpp adchpp/trunk/boost/boost/mpl/aux_/integral_wrapper.hpp adchpp/trunk/boost/boost/mpl/aux_/is_msvc_eti_arg.hpp adchpp/trunk/boost/boost/mpl/aux_/iter_apply.hpp adchpp/trunk/boost/boost/mpl/aux_/iter_fold_if_impl.hpp adchpp/trunk/boost/boost/mpl/aux_/iter_fold_impl.hpp adchpp/trunk/boost/boost/mpl/aux_/iter_push_front.hpp adchpp/trunk/boost/boost/mpl/aux_/joint_iter.hpp adchpp/trunk/boost/boost/mpl/aux_/lambda_arity_param.hpp adchpp/trunk/boost/boost/mpl/aux_/lambda_no_ctps.hpp adchpp/trunk/boost/boost/mpl/aux_/lambda_spec.hpp adchpp/trunk/boost/boost/mpl/aux_/lambda_support.hpp adchpp/trunk/boost/boost/mpl/aux_/largest_int.hpp adchpp/trunk/boost/boost/mpl/aux_/logical_op.hpp adchpp/trunk/boost/boost/mpl/aux_/msvc_dtw.hpp adchpp/trunk/boost/boost/mpl/aux_/msvc_eti_base.hpp adchpp/trunk/boost/boost/mpl/aux_/msvc_is_class.hpp adchpp/trunk/boost/boost/mpl/aux_/msvc_never_true.hpp adchpp/trunk/boost/boost/mpl/aux_/msvc_type.hpp adchpp/trunk/boost/boost/mpl/aux_/na.hpp adchpp/trunk/boost/boost/mpl/aux_/na_assert.hpp adchpp/trunk/boost/boost/mpl/aux_/na_fwd.hpp adchpp/trunk/boost/boost/mpl/aux_/na_spec.hpp adchpp/trunk/boost/boost/mpl/aux_/nested_type_wknd.hpp adchpp/trunk/boost/boost/mpl/aux_/nttp_decl.hpp adchpp/trunk/boost/boost/mpl/aux_/numeric_cast_utils.hpp adchpp/trunk/boost/boost/mpl/aux_/numeric_op.hpp adchpp/trunk/boost/boost/mpl/aux_/order_impl.hpp adchpp/trunk/boost/boost/mpl/aux_/overload_names.hpp adchpp/trunk/boost/boost/mpl/aux_/partition_op.hpp adchpp/trunk/boost/boost/mpl/aux_/pop_back_impl.hpp adchpp/trunk/boost/boost/mpl/aux_/pop_front_impl.hpp adchpp/trunk/boost/boost/mpl/aux_/preprocessed/ adchpp/trunk/boost/boost/mpl/aux_/preprocessed/bcc/ adchpp/trunk/boost/boost/mpl/aux_/preprocessed/bcc/advance_backward.hpp adchpp/trunk/boost/boost/mpl/aux_/preprocessed/bcc/advance_forward.hpp adchpp/trunk/boost/boost/mpl/aux_/preprocessed/bcc/and.hpp adchpp/trunk/boost/boost/mpl/aux_/preprocessed/bcc/apply.hpp adchpp/trunk/boost/boost/mpl/aux_/preprocessed/bcc/apply_fwd.hpp adchpp/trunk/boost/boost/mpl/aux_/preprocessed/bcc/apply_wrap.hpp adchpp/trunk/boost/boost/mpl/aux_/preprocessed/bcc/arg.hpp adchpp/trunk/boost/boost/mpl/aux_/preprocessed/bcc/basic_bind.hpp adchpp/trunk/boost/boost/mpl/aux_/preprocessed/bcc/bind.hpp adchpp/trunk/boost/boost/mpl/aux_/preprocessed/bcc/bind_fwd.hpp adchpp/trunk/boost/boost/mpl/aux_/preprocessed/bcc/bitand.hpp adchpp/trunk/boost/boost/mpl/aux_/preprocessed/bcc/bitor.hpp adchpp/trunk/boost/boost/mpl/aux_/preprocessed/bcc/bitxor.hpp adchpp/trunk/boost/boost/mpl/aux_/preprocessed/bcc/deque.hpp adchpp/trunk/boost/boost/mpl/aux_/preprocessed/bcc/divides.hpp adchpp/trunk/boost/boost/mpl/aux_/preprocessed/bcc/equal_to.hpp adchpp/trunk/boost/boost/mpl/aux_/preprocessed/bcc/fold_impl.hpp adchpp/trunk/boost/boost/mpl/aux_/preprocessed/bcc/full_lambda.hpp adchpp/trunk/boost/boost/mpl/aux_/preprocessed/bcc/greater.hpp adchpp/trunk/boost/boost/mpl/aux_/preprocessed/bcc/greater_equal.hpp adchpp/trunk/boost/boost/mpl/aux_/preprocessed/bcc/inherit.hpp adchpp/trunk/boost/boost/mpl/aux_/preprocessed/bcc/iter_fold_if_impl.hpp adchpp/trunk/boost/boost/mpl/aux_/preprocessed/bcc/iter_fold_impl.hpp adchpp/trunk/boost/boost/mpl/aux_/preprocessed/bcc/lambda_no_ctps.hpp adchpp/trunk/boost/boost/mpl/aux_/preprocessed/bcc/less.hpp adchpp/trunk/boost/boost/mpl/aux_/preprocessed/bcc/less_equal.hpp adchpp/trunk/boost/boost/mpl/aux_/preprocessed/bcc/list.hpp adchpp/trunk/boost/boost/mpl/aux_/preprocessed/bcc/list_c.hpp adchpp/trunk/boost/boost/mpl/aux_/preprocessed/bcc/map.hpp adchpp/trunk/boost/boost/mpl/aux_/preprocessed/bcc/minus.hpp adchpp/trunk/boost/boost/mpl/aux_/preprocessed/bcc/modulus.hpp adchpp/trunk/boost/boost/mpl/aux_/preprocessed/bcc/not_equal_to.hpp adchpp/trunk/boost/boost/mpl/aux_/preprocessed/bcc/or.hpp adchpp/trunk/boost/boost/mpl/aux_/preprocessed/bcc/placeholders.hpp adchpp/trunk/boost/boost/mpl/aux_/preprocessed/bcc/plus.hpp adchpp/trunk/boost/boost/mpl/aux_/preprocessed/bcc/quote.hpp adchpp/trunk/boost/boost/mpl/aux_/preprocessed/bcc/reverse_fold_impl.hpp adchpp/trunk/boost/boost/mpl/aux_/preprocessed/bcc/reverse_iter_fold_impl.hpp adchpp/trunk/boost/boost/mpl/aux_/preprocessed/bcc/set.hpp adchpp/trunk/boost/boost/mpl/aux_/preprocessed/bcc/set_c.hpp adchpp/trunk/boost/boost/mpl/aux_/preprocessed/bcc/shift_left.hpp adchpp/trunk/boost/boost/mpl/aux_/preprocessed/bcc/shift_right.hpp adchpp/trunk/boost/boost/mpl/aux_/preprocessed/bcc/template_arity.hpp adchpp/trunk/boost/boost/mpl/aux_/preprocessed/bcc/times.hpp adchpp/trunk/boost/boost/mpl/aux_/preprocessed/bcc/unpack_args.hpp adchpp/trunk/boost/boost/mpl/aux_/preprocessed/bcc/vector.hpp adchpp/trunk/boost/boost/mpl/aux_/preprocessed/bcc/vector_c.hpp adchp... [truncated message content] |
From: <arn...@us...> - 2007-12-23 20:30:51
|
Revision: 111 http://adchpp.svn.sourceforge.net/adchpp/?rev=111&view=rev Author: arnetheduck Date: 2007-12-23 12:30:27 -0800 (Sun, 23 Dec 2007) Log Message: ----------- Bloom filter fixes Modified Paths: -------------- adchpp/trunk/adchpp/ClientManager.cpp adchpp/trunk/adchpp/ClientManager.h adchpp/trunk/plugins/Bloom/src/BloomManager.cpp adchpp/trunk/plugins/Bloom/src/BloomManager.h adchpp/trunk/plugins/Bloom/src/HashBloom.cpp adchpp/trunk/plugins/Bloom/src/HashBloom.h adchpp/trunk/unix/po/adchppd.pot Modified: adchpp/trunk/adchpp/ClientManager.cpp =================================================================== --- adchpp/trunk/adchpp/ClientManager.cpp 2007-12-22 23:08:03 UTC (rev 110) +++ adchpp/trunk/adchpp/ClientManager.cpp 2007-12-23 20:30:27 UTC (rev 111) @@ -50,19 +50,23 @@ void ClientManager::send(const AdcCommand& cmd, bool lowPrio /* = false */) throw() { const string& txt = cmd.toString(); - + + bool all = false; switch (cmd.getType()) { - case AdcCommand::TYPE_FEATURE: - case AdcCommand::TYPE_BROADCAST: { - bool all = (cmd.getType() == AdcCommand::TYPE_BROADCAST); + case AdcCommand::TYPE_BROADCAST: all = true; // Fallthrough + case AdcCommand::TYPE_FEATURE: { FastMutex::Lock l(ManagedSocket::getWriteMutex()); for (ClientIter i = clients.begin(); i != clients.end(); ++i) { - if (all || !i->second->isFiltered(cmd.getFeatures())) - i->second->fastSend(txt, lowPrio); + if (all || !i->second->isFiltered(cmd.getFeatures())) { + int override = 0; + signalSend_(*i->second, cmd, override); + if(!(override & DONT_SEND)) { + i->second->fastSend(txt, lowPrio); + } + } } - } SocketManager::getInstance()->addAllWriters(); - break; + } break; case AdcCommand::TYPE_DIRECT: // Fallthrough case AdcCommand::TYPE_ECHO: { ClientIter i = clients.find(cmd.getTo()); @@ -75,9 +79,8 @@ } } } + } break; } - break; - } } void ClientManager::sendToAll(const string& cmd) throw() { Modified: adchpp/trunk/adchpp/ClientManager.h =================================================================== --- adchpp/trunk/adchpp/ClientManager.h 2007-12-22 23:08:03 UTC (rev 110) +++ adchpp/trunk/adchpp/ClientManager.h 2007-12-23 20:30:27 UTC (rev 111) @@ -152,7 +152,7 @@ typedef SignalTraits<void (Client&)> SignalConnected; typedef SignalTraits<void (Client&, AdcCommand&, int&)> SignalReceive; typedef SignalTraits<void (Client&, const std::string&)> SignalBadLine; - typedef SignalTraits<void (Client&, AdcCommand&, int&)> SignalSend; + typedef SignalTraits<void (Client&, const AdcCommand&, int&)> SignalSend; typedef SignalTraits<void (Client&, int)> SignalState; typedef SignalTraits<void (Client&)> SignalDisconnected; Modified: adchpp/trunk/plugins/Bloom/src/BloomManager.cpp =================================================================== --- adchpp/trunk/plugins/Bloom/src/BloomManager.cpp 2007-12-22 23:08:03 UTC (rev 110) +++ adchpp/trunk/plugins/Bloom/src/BloomManager.cpp 2007-12-23 20:30:27 UTC (rev 111) @@ -25,16 +25,18 @@ #include <adchpp/Util.h> using namespace std; +using namespace std::tr1; using namespace std::tr1::placeholders; using namespace adchpp; BloomManager* BloomManager::instance = 0; const string BloomManager::className = "BloomManager"; -BloomManager::BloomManager() { +BloomManager::BloomManager() : searches(0), tthSearches(0), stopped(0) { LOG(className, "Starting"); ClientManager* cm = ClientManager::getInstance(); receiveConn = manage(&cm->signalReceive(), std::tr1::bind(&BloomManager::onReceive, this, _1, _2, _3)); + sendConn = manage(&cm->signalSend(), std::tr1::bind(&BloomManager::onSend, this, _1, _2, _3)); disconnectConn = manage(&cm->signalDisconnected(), std::tr1::bind(&BloomManager::onDisconnected, this, _1)); } @@ -56,11 +58,10 @@ size_t k = HashBloom::get_k(n); size_t m = HashBloom::get_m(n, k); + blooms.erase(c.getSID()); + + pending[c.getSID()] = make_tuple(ByteVector(), m, k); - HashBloom& bloom = blooms[c.getCID()]; - - bloom.reset(k); - AdcCommand get(AdcCommand::CMD_GET); get.addParam("blom"); get.addParam("/"); @@ -77,29 +78,83 @@ return; } + PendingMap::const_iterator i = pending.find(c.getSID()); + if(i == pending.end()) { + c.send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_BAD_STATE, "Unexpected bloom filter update")); + c.disconnect(Util::REASON_BAD_STATE); + override |= ClientManager::DONT_DISPATCH | ClientManager::DONT_SEND; + return; + } + int64_t bytes = Util::toInt(cmd.getParam(3)); - c.setDataMode(std::tr1::bind(&BloomManager::onData, this, _1, _2, _3), bytes); - override |= ClientManager::DONT_DISPATCH | ClientManager::DONT_SEND; - } else if(cmd.getCommand() == AdcCommand::CMD_SCH && cmd.getParam("TR", 0, tmp)) { - BloomMap::const_iterator i = blooms.find(c.getCID()); - if(i != blooms.end() && !i->second.match(TTHValue(tmp))) { - // Stop it - dcdebug("Stopping search\n"); + if(bytes != static_cast<int64_t>(get<1>(i->second) / 8)) { + c.send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_PROTOCOL_GENERIC, "Invalid number of bytes")); + c.disconnect(Util::REASON_PLUGIN); override |= ClientManager::DONT_DISPATCH | ClientManager::DONT_SEND; + pending.erase(c.getSID()); + return; } + + c.setDataMode(bind(&BloomManager::onData, this, _1, _2, _3), bytes); + override |= ClientManager::DONT_DISPATCH | ClientManager::DONT_SEND; + } else if(cmd.getCommand() == AdcCommand::CMD_MSG && cmd.getParameters().size() >= 1) { + if(cmd.getParam(0).compare(0, 6, "+stats") == 0) { + string stats = "\nBloom filter statistics:"; + stats += "\nTotal outgoing searches: " + Util::toString(searches); + stats += "\nOutgoing TTH searches: " + Util::toString(tthSearches) + " (" + Util::toString(tthSearches * 100. / searches) + "% of total)"; + stats += "\nStopped outgoing searches: " + Util::toString(stopped) + " (" + Util::toString(stopped * 100. / searches) + "% of total, " + Util::toString(stopped * 100. / tthSearches) + "% of TTH searches"; + int64_t bytes = getBytes(); + size_t clients = ClientManager::getInstance()->getClients().size(); + stats += "\nClient support: " + Util::toString(blooms.size()) + "/" + Util::toString(clients) + " (" + Util::toString(blooms.size() * 100. / clients) + "%)"; + stats += "\nApproximate memory usage: " + Util::formatBytes(bytes) + ", " + Util::formatBytes(static_cast<double>(bytes) / clients) + "/client"; + c.send(AdcCommand(AdcCommand::CMD_MSG).addParam(stats)); + override |= ClientManager::DONT_SEND; + } } } -void BloomManager::onData(Client& c, const uint8_t* data, size_t len) { - HashBloom& bloom = blooms[c.getCID()]; - for(size_t i = 0; i < len; ++i) { - for(size_t j = 0; j < 8; ++j) { - bloom.push_back(data[i] & (1 << j)); +void BloomManager::onSend(Client& c, const AdcCommand& cmd, int& override) { + if(cmd.getCommand() == AdcCommand::CMD_SCH) { + searches++; + string tmp; + if(cmd.getParam("TR", 0, tmp)) { + tthSearches++; + BloomMap::const_iterator i = blooms.find(c.getSID()); + if(i != blooms.end() && !i->second.match(TTHValue(tmp))) { + // Stop it + stopped++; + dcdebug("Stopping search\n"); + override |= ClientManager::DONT_SEND; + } } + } +} +int64_t BloomManager::getBytes() const { + int64_t bytes = 0; + for(BloomMap::const_iterator i = blooms.begin(); i != blooms.end(); ++i) { + bytes += i->second.size() / 8; } + return bytes; } +void BloomManager::onData(Client& c, const uint8_t* data, size_t len) { + PendingMap::iterator i = pending.find(c.getSID()); + if(i == pending.end()) { + // Shouldn't happen + return; + } + ByteVector& v = get<0>(i->second); + v.insert(v.end(), data, data + len); + + if(v.size() == get<1>(i->second) / 8) { + HashBloom& bloom = blooms[c.getSID()]; + bloom.reset(v, get<2>(i->second)); + pending.erase(i); + } +} + void BloomManager::onDisconnected(Client& c) { - blooms.erase(c.getCID()); + blooms.erase(c.getSID()); + pending.erase(c.getSID()); } Modified: adchpp/trunk/plugins/Bloom/src/BloomManager.h =================================================================== --- adchpp/trunk/plugins/Bloom/src/BloomManager.h 2007-12-22 23:08:03 UTC (rev 110) +++ adchpp/trunk/plugins/Bloom/src/BloomManager.h 2007-12-23 20:30:27 UTC (rev 111) @@ -19,10 +19,7 @@ #ifndef BLOOM_MANAGER_H #define BLOOM_MANAGER_H -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - +#include <tuple> #include <adchpp/Exception.h> #include <adchpp/Singleton.h> #include <adchpp/ClientManager.h> @@ -55,21 +52,33 @@ virtual int getVersion() { return 0; } - void onReceive(Client& c, AdcCommand& cmd, int&); - void onData(Client& c, const uint8_t* data, size_t len); - void onDisconnected(Client& c); - static const std::string className; private: friend class Singleton<BloomManager>; static BloomManager* instance; - typedef std::tr1::unordered_map<CID, HashBloom> BloomMap; + typedef std::tr1::unordered_map<uint32_t, HashBloom> BloomMap; BloomMap blooms; + // bytes, m, k + typedef std::tr1::tuple<ByteVector, size_t, size_t> PendingItem; + typedef std::tr1::unordered_map<uint32_t, PendingItem> PendingMap; + PendingMap pending; + + int64_t searches; + int64_t tthSearches; + int64_t stopped; + ClientManager::SignalReceive::ManagedConnection receiveConn; ClientManager::SignalDisconnected::ManagedConnection disconnectConn; + ClientManager::SignalSend::ManagedConnection sendConn; + int64_t getBytes() const; + void onReceive(Client& c, AdcCommand& cmd, int&); + void onSend(Client& c, const AdcCommand& cmd, int&); + void onData(Client& c, const uint8_t* data, size_t len); + void onDisconnected(Client& c); + }; #endif //ACCESSMANAGER_H Modified: adchpp/trunk/plugins/Bloom/src/HashBloom.cpp =================================================================== --- adchpp/trunk/plugins/Bloom/src/HashBloom.cpp 2007-12-22 23:08:03 UTC (rev 110) +++ adchpp/trunk/plugins/Bloom/src/HashBloom.cpp 2007-12-23 20:30:27 UTC (rev 111) @@ -41,9 +41,15 @@ bloom.push_back(v); } -void HashBloom::reset(size_t k_) { - bloom.resize(0); +void HashBloom::reset(ByteVector& v, size_t k_) { k = k_; + + bloom.resize(v.size() * 8); + for(size_t i = 0; i < v.size(); ++i) { + for(size_t j = 0; j < 8; ++j) { + bloom[i*8 + j] = ((v[i] >> j) != 0); + } + } } size_t HashBloom::pos(const TTHValue& tth, size_t n) const { Modified: adchpp/trunk/plugins/Bloom/src/HashBloom.h =================================================================== --- adchpp/trunk/plugins/Bloom/src/HashBloom.h 2007-12-22 23:08:03 UTC (rev 110) +++ adchpp/trunk/plugins/Bloom/src/HashBloom.h 2007-12-23 20:30:27 UTC (rev 111) @@ -22,8 +22,10 @@ void add(const TTHValue& tth); bool match(const TTHValue& tth) const; - void reset(size_t k); + void reset(ByteVector& v, size_t k); void push_back(bool v); + + size_t size() const { return bloom.size(); } private: size_t pos(const TTHValue& tth, size_t n) const; Modified: adchpp/trunk/unix/po/adchppd.pot =================================================================== --- adchpp/trunk/unix/po/adchppd.pot 2007-12-22 23:08:03 UTC (rev 110) +++ adchpp/trunk/unix/po/adchppd.pot 2007-12-23 20:30:27 UTC (rev 111) @@ -7,7 +7,7 @@ msgstr "" "Project-Id-Version: \"adchpp\"--copyright-holder=\"Jacek Sieka\"\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2007-12-22 23:02+0100\n" +"POT-Creation-Date: 2007-12-23 00:10+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL...@li...>\n" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2007-12-30 21:41:50
|
Revision: 117 http://adchpp.svn.sourceforge.net/adchpp/?rev=117&view=rev Author: arnetheduck Date: 2007-12-30 13:41:46 -0800 (Sun, 30 Dec 2007) Log Message: ----------- Use ref-counted buffer to save some memory Modified Paths: -------------- adchpp/trunk/adchpp/AdcCommand.cpp adchpp/trunk/adchpp/AdcCommand.h adchpp/trunk/adchpp/Client.cpp adchpp/trunk/adchpp/Client.h adchpp/trunk/adchpp/ClientManager.cpp adchpp/trunk/adchpp/ClientManager.h adchpp/trunk/adchpp/ManagedSocket.cpp adchpp/trunk/adchpp/ManagedSocket.h adchpp/trunk/adchpp/Socket.cpp adchpp/trunk/adchpp/Socket.h adchpp/trunk/adchpp/SocketManager.cpp adchpp/trunk/adchpp/SocketManager.h adchpp/trunk/swig/adchpp.i adchpp/trunk/test/PyClient.py Added Paths: ----------- adchpp/trunk/adchpp/Buffer.h Modified: adchpp/trunk/adchpp/AdcCommand.cpp =================================================================== --- adchpp/trunk/adchpp/AdcCommand.cpp 2007-12-28 15:35:31 UTC (rev 116) +++ adchpp/trunk/adchpp/AdcCommand.cpp 2007-12-30 21:41:46 UTC (rev 117) @@ -24,9 +24,9 @@ using namespace std; -AdcCommand::AdcCommand() : cmdInt(0), str(0), from(0), type(0) { } +AdcCommand::AdcCommand() : cmdInt(0), from(0), type(0) { } -AdcCommand::AdcCommand(Severity sev, Error err, const string& desc, char aType /* = TYPE_INFO */) : cmdInt(CMD_STA), str(&tmp), from(HUB_SID), type(aType) { +AdcCommand::AdcCommand(Severity sev, Error err, const string& desc, char aType /* = TYPE_INFO */) : cmdInt(CMD_STA), from(HUB_SID), type(aType) { addParam(Util::toString(sev * 100 + err)); addParam(desc); } @@ -44,28 +44,30 @@ } } -void AdcCommand::parse(const string& aLine) throw(ParseException) { - if(aLine.length() < 5) { +void AdcCommand::parse(const char* buf, size_t len) throw(ParseException) { + if(len < 5) { throw ParseException("Command too short"); } - type = aLine[0]; + type = buf[0]; if(type != TYPE_BROADCAST && type != TYPE_CLIENT && type != TYPE_DIRECT && type != TYPE_ECHO && type != TYPE_FEATURE && type != TYPE_INFO && type != TYPE_HUB && type != TYPE_UDP) { throw ParseException("Invalid type"); } - cmd[0] = aLine[1]; - cmd[1] = aLine[2]; - cmd[2] = aLine[3]; + cmd[0] = buf[1]; + cmd[1] = buf[2]; + cmd[2] = buf[3]; - if(aLine[4] != ' ') { + if(buf[4] != ' ') { throw ParseException("Missing space after command"); } - string::size_type len = aLine.length() - 1; // aLine contains trailing LF + // Skip trailing LF + len--; - const char* buf = aLine.c_str(); + parameters.reserve(8); + string cur; cur.reserve(64); @@ -158,10 +160,19 @@ } } -const string& AdcCommand::toString() const { - if(!str->empty()) - return *str; +const BufferPtr& AdcCommand::getBuffer() const { + if(!buffer) { + buffer = BufferPtr(new Buffer(toString())); + } + return buffer; +} +string AdcCommand::toString() const { + if(buffer) { + return string((char*)buffer->data(), buffer->size()); + } + string tmp; + tmp.reserve(128); tmp += type; @@ -206,7 +217,7 @@ for(string::size_type i = start; i < getParameters().size(); ++i) { if(toCode(name) == toCode(getParameters()[i].c_str())) { getParameters().erase(getParameters().begin() + i); - resetString(); + resetBuffer(); return true; } } Modified: adchpp/trunk/adchpp/AdcCommand.h =================================================================== --- adchpp/trunk/adchpp/AdcCommand.h 2007-12-28 15:35:31 UTC (rev 116) +++ adchpp/trunk/adchpp/AdcCommand.h 2007-12-30 21:41:46 UTC (rev 117) @@ -22,6 +22,7 @@ #include "common.h" #include "Exception.h" #include "Util.h" +#include "Buffer.h" namespace adchpp { @@ -108,33 +109,37 @@ ADCHPP_DLL AdcCommand(); ADCHPP_DLL explicit AdcCommand(Severity sev, Error err, const std::string& desc, char aType = TYPE_INFO); - explicit AdcCommand(uint32_t cmd, char aType = TYPE_INFO, uint32_t aFrom = HUB_SID) : cmdInt(cmd), str(&tmp), from(aFrom), type(aType) { } - explicit AdcCommand(const std::string& aLine) throw(ParseException) : cmdInt(0), str(&aLine), type(0) { parse(aLine); } - AdcCommand(const AdcCommand& rhs) : parameters(rhs.parameters), cmdInt(rhs.cmdInt), str(&tmp), from(rhs.from), to(rhs.to), type(rhs.type) { } + explicit AdcCommand(uint32_t cmd, char aType = TYPE_INFO, uint32_t aFrom = HUB_SID) : cmdInt(cmd), from(aFrom), type(aType) { } + explicit AdcCommand(const std::string& aLine) throw(ParseException) : cmdInt(0), type(0) { parse(aLine); } + explicit AdcCommand(const BufferPtr& buffer_) throw(ParseException) : buffer(buffer_), cmdInt(0), type(0) { parse((const char*)buffer->data(), buffer->size()); } + AdcCommand(const AdcCommand& rhs) : parameters(rhs.parameters), cmdInt(rhs.cmdInt), from(rhs.from), to(rhs.to), type(rhs.type) { } - ADCHPP_DLL void parse(const std::string& aLine) throw(ParseException); + void parse(const std::string& str) throw(ParseException) { parse(str.data(), str.size()); } + ADCHPP_DLL void parse(const char* buf, size_t len) throw(ParseException); uint32_t getCommand() const { return cmdInt; } char getType() const { return type; } - + std::string getFourCC() const { std::string tmp(4, 0); tmp[0] = type; tmp[1] = cmd[0]; tmp[2] = cmd[1]; tmp[3] = cmd[2]; return tmp; } StringList& getParameters() { return parameters; } const StringList& getParameters() const { return parameters; } + ADCHPP_DLL std::string toString() const; - ADCHPP_DLL const std::string& toString() const; - void resetString() { tmp.clear(); str = &tmp; } - AdcCommand& addParam(const std::string& name, const std::string& value) { parameters.push_back(name); parameters.back() += value; return *this; } + AdcCommand& addParam(const std::string& param) { parameters.push_back(param); return *this; } + const std::string& getParam(size_t n) const { return getParameters().size() > n ? getParameters()[n] : Util::emptyString; } + void resetBuffer() { buffer = BufferPtr(); } + const std::string& getFeatures() const { return features; } /** Return a named parameter where the name is a two-letter code */ @@ -148,6 +153,8 @@ ADCHPP_DLL static void escape(const std::string& s, std::string& out); + ADCHPP_DLL const BufferPtr& getBuffer() const; + uint32_t getTo() const { return to; } void setTo(uint32_t aTo) { to = aTo; } uint32_t getFrom() const { return from; } @@ -161,14 +168,15 @@ StringList parameters; std::string features; + + mutable BufferPtr buffer; + union { char cmdChar[4]; uint8_t cmd[4]; uint32_t cmdInt; }; - const std::string* str; - mutable std::string tmp; - + uint32_t from; uint32_t to; char type; Added: adchpp/trunk/adchpp/Buffer.h =================================================================== --- adchpp/trunk/adchpp/Buffer.h (rev 0) +++ adchpp/trunk/adchpp/Buffer.h 2007-12-30 21:41:46 UTC (rev 117) @@ -0,0 +1,43 @@ +#ifndef BUFFER_H_ +#define BUFFER_H_ + +#include "FastAlloc.h" + +namespace adchpp { + +/** + * Reference-counted buffer + */ +class Buffer : public intrusive_ptr_base, public FastAlloc<Buffer> { +public: + Buffer(const std::string& str) : buf((uint8_t*)str.data(), (uint8_t*)str.data() + str.size()) { } + Buffer(const void* ptr, const size_t size) : buf((uint8_t*) ptr, ((uint8_t*)ptr)+size) { } + Buffer(const size_t size) : buf(size) { } + + operator const ByteVector&() const { return buf; } + operator ByteVector&() { return buf; } + + void resize(size_t new_size) { buf.resize(new_size); } + size_t size() const { return buf.size(); } + const uint8_t* data() const { return &buf[0]; } + uint8_t* data() { return &buf[0]; } + + /** Erase the first n bytes */ + void erase_first(size_t n) { + buf.erase(buf.begin(), buf.begin() + n); + } + + template<typename InputIterator> + void append(InputIterator start, InputIterator end) { + buf.insert(buf.end(), start, end); + } +private: + ByteVector buf; +}; + +typedef boost::intrusive_ptr<Buffer> BufferPtr; +typedef std::vector<BufferPtr> BufferList; + +} + +#endif /*BUFFER_H_*/ Modified: adchpp/trunk/adchpp/Client.cpp =================================================================== --- adchpp/trunk/adchpp/Client.cpp 2007-12-28 15:35:31 UTC (rev 116) +++ adchpp/trunk/adchpp/Client.cpp 2007-12-30 21:41:46 UTC (rev 117) @@ -43,19 +43,19 @@ // Lightweight call forwarders, instead of tr1::bind struct Handler { Handler(void (Client::*f)(), Client* c_) : c(c_), f0(f) { } - Handler(void (Client::*f)(const ByteVector&), Client* c_) : c(c_), f1(f) { } + Handler(void (Client::*f)(const BufferPtr&), Client* c_) : c(c_), f1(f) { } void operator()() throw() { (c->*f0)(); } - void operator()(const ByteVector& bv) throw() { + void operator()(const BufferPtr& bv) throw() { (c->*f1)(bv); } Client* c; union { void (Client::*f0)(); - void (Client::*f1)(const ByteVector&); + void (Client::*f1)(const BufferPtr&); }; }; } @@ -90,43 +90,59 @@ return (i != psd.end()) ? i->second : 0; } -void Client::onData(const ByteVector& data) throw() { - dcdebug("In (%d): %.*s\n", data.size(), data.size(), &data[0]); - +void Client::onData(const BufferPtr& buf) throw() { + uint8_t* data = buf->data(); size_t done = 0; - size_t len = data.size(); + size_t len = buf->size(); while(!disconnecting && done < len) { if(dataBytes > 0) { size_t n = (size_t)min(dataBytes, (int64_t)(len - done)); - dataHandler(*this, &data[done], n); + dataHandler(*this, data + done, n); dataBytes -= n; done += n; } else { size_t j = done; while(j < len && data[j] != '\n') ++j; - + if(j == len) { - line.append((char*)&data[done], j - done); + if(!buffer) { + if(done == 0) { + buffer = buf; + } else { + buffer = BufferPtr(new Buffer(data + done, len - done)); + } + } else { + buffer->append(data + done, data + len); + } return; + } else if(!buffer) { + if(done == 0 && j == len-1) { + buffer = buf; + } else { + buffer = BufferPtr(new Buffer(data + done, j - done + 1)); + } + } else { + buffer->append(data + done, data + j + 1); } - line.append((char*)&data[done], j - done + 1); // include LF done = j + 1; + + size_t max_cmd_size = static_cast<size_t>(SETTING(MAX_COMMAND_SIZE)); - if(SETTING(MAX_COMMAND_SIZE) > 0 && line.size() > (size_t)SETTING(MAX_COMMAND_SIZE)) { + if(max_cmd_size > 0 && buffer->size() > max_cmd_size) { send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_PROTOCOL_GENERIC, "Command too long")); disconnect(Util::REASON_MAX_COMMAND_SIZE); return; } - if(line.size() == 1) { - line.clear(); + if(buffer->size() == 1) { + buffer = BufferPtr(); continue; } try { - AdcCommand cmd(line); + AdcCommand cmd(buffer); if(cmd.getType() == 'H') { cmd.setFrom(getSID()); @@ -136,9 +152,9 @@ } ClientManager::getInstance()->onReceive(*this, cmd); } catch(const ParseException&) { - ClientManager::getInstance()->onBadLine(*this, line); + ClientManager::getInstance()->onBadLine(*this, string((char*)buffer->data(), buffer->size())); } - line.clear(); + buffer = BufferPtr(); } } } @@ -157,7 +173,7 @@ info[code] = value; } changed[code] = value; - INF.clear(); + INF = BufferPtr(); } bool Client::getChangedFields(AdcCommand& cmd) const throw() { @@ -172,11 +188,11 @@ return !info.empty(); } -const string& Client::getINF() const throw() { - if(INF.empty()) { +const BufferPtr& Client::getINF() const throw() { + if(!INF) { AdcCommand cmd(AdcCommand::CMD_INF, AdcCommand::TYPE_BROADCAST, getSID()); getAllFields(cmd); - INF = cmd.toString(); + INF = cmd.getBuffer(); } return INF; } @@ -243,7 +259,6 @@ void Client::disconnect(Util::Reason reason) throw() { if(socket && !disconnecting) { disconnecting = true; - line.clear(); socket->disconnect(reason); } } Modified: adchpp/trunk/adchpp/Client.h =================================================================== --- adchpp/trunk/adchpp/Client.h 2007-12-28 15:35:31 UTC (rev 116) +++ adchpp/trunk/adchpp/Client.h 2007-12-30 21:41:46 UTC (rev 117) @@ -68,16 +68,14 @@ const StringList& getSupportList() const throw() { return supportList; } bool supports(const std::string& feat) const throw() { return find(supportList.begin(), supportList.end(), feat) != supportList.end(); } - void send(const char* command, size_t len) throw() { - dcassert(socket != NULL); - socket->write(command, len); - } - void send(const AdcCommand& cmd) throw() { send(cmd.toString()); } + void send(const char* command, size_t len) throw() { send(BufferPtr(new Buffer(command, len))); } + + void send(const AdcCommand& cmd) throw() { send(cmd.getBuffer()); } void send(const std::string& command) throw() { send(command.c_str(), command.length()); } - void send(const char* command) throw() { socket->write(command, strlen(command)); } - - void fastSend(const std::string& command, bool lowPrio = false) throw() { - socket->fastWrite(command.c_str(), command.length(), lowPrio); + void send(const BufferPtr& command) throw() { socket->write(command); } + + void fastSend(const BufferPtr& command, bool lowPrio = false) throw() { + socket->fastWrite(command, lowPrio); } size_t getQueuedBytes() throw() { return socket->getQueuedBytes(); } @@ -97,7 +95,7 @@ /** Add any flags that have been updated to the AdcCommand (type etc is not set) */ ADCHPP_DLL bool getChangedFields(AdcCommand& cmd) const throw(); ADCHPP_DLL bool getAllFields(AdcCommand& cmd) const throw(); - ADCHPP_DLL const std::string& getINF() const throw(); + ADCHPP_DLL const BufferPtr& getINF() const throw(); void resetChanged() { changed.clear(); } @@ -169,20 +167,21 @@ bool disconnecting; PSDList psd; - std::string line; + BufferPtr buffer; ManagedSocketPtr socket; int64_t dataBytes; time_t floodTimer; /** Latest INF cached */ - mutable std::string INF; + mutable BufferPtr INF; DataFunction dataHandler; void setSocket(const ManagedSocketPtr& aSocket) throw(); void onConnected() throw(); - void onData(const ByteVector&) throw(); + void onData(const BufferPtr&) throw(); void onFailed() throw(); + }; } Modified: adchpp/trunk/adchpp/ClientManager.cpp =================================================================== --- adchpp/trunk/adchpp/ClientManager.cpp 2007-12-28 15:35:31 UTC (rev 116) +++ adchpp/trunk/adchpp/ClientManager.cpp 2007-12-30 21:41:46 UTC (rev 117) @@ -49,7 +49,7 @@ } void ClientManager::send(const AdcCommand& cmd, bool lowPrio /* = false */) throw() { - const string& txt = cmd.toString(); + const BufferPtr& buf = cmd.getBuffer(); bool all = false; switch (cmd.getType()) { @@ -61,21 +61,20 @@ int override = 0; signalSend_(*i->second, cmd, override); if(!(override & DONT_SEND)) { - i->second->fastSend(txt, lowPrio); + i->second->fastSend(buf, lowPrio); } } } - SocketManager::getInstance()->addAllWriters(); } break; case AdcCommand::TYPE_DIRECT: // Fallthrough case AdcCommand::TYPE_ECHO: { ClientIter i = clients.find(cmd.getTo()); if (i != clients.end()) { - i->second->send(txt); + i->second->send(buf); if (COMPATIBILITY || cmd.getType() == AdcCommand::TYPE_ECHO) { i = clients.find(cmd.getFrom()); if (i != clients.end()) { - i->second->send(txt); + i->second->send(buf); } } } @@ -83,14 +82,11 @@ } } -void ClientManager::sendToAll(const string& cmd) throw() { - { - FastMutex::Lock l(ManagedSocket::getWriteMutex()); - for (ClientIter i = clients.begin(); i != clients.end(); ++i) { - i->second->fastSend(cmd); - } +void ClientManager::sendToAll(const BufferPtr& buf) throw() { + FastMutex::Lock l(ManagedSocket::getWriteMutex()); + for (ClientIter i = clients.begin(); i != clients.end(); ++i) { + i->second->fastSend(buf); } - SocketManager::getInstance()->addAllWriters(); } size_t ClientManager::getQueuedBytes() throw() { @@ -106,7 +102,7 @@ void ClientManager::sendTo(const AdcCommand& cmd, const uint32_t& to) throw() { ClientIter i = clients.find(to); if (i != clients.end()) { - i->second->send(cmd.toString()); + i->second->send(cmd.getBuffer()); } } @@ -115,7 +111,7 @@ AdcCommand s(AdcCommand::CMD_SUP); for (StringIter i = supports.begin(); i != supports.end(); ++i) s.addParam("AD" + *i); - strings.sup = s.toString(); + strings.sup = s.getBuffer(); strings.inf = AdcCommand(AdcCommand::CMD_INF) .addParam("NI", SETTING(HUB_NAME)) @@ -124,7 +120,7 @@ .addParam("VE", versionString) .addParam("CT5") .addParam("HU1") // ADC <=0.13 - .toString(); + .getBuffer(); } bool ClientManager::checkFlooding(Client& c, const AdcCommand& cmd) throw() { @@ -202,7 +198,7 @@ } 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.send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_BAD_STATE, "Invalid state for command").addParam("FC", cmd.getFourCC())); c.disconnect(Util::REASON_BAD_STATE); } @@ -323,7 +319,7 @@ } else if (j->compare(2, j->size()-2, "0.0.0.0") == 0) { c.setField("I4", c.getIp()); *j = "I4" + c.getIp(); - cmd.resetString(); + cmd.resetBuffer(); } else if (j->size()-2 != c.getIp().size() || j->compare(2, j->size()-2, c.getIp()) != 0) { c.send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_BAD_IP, "Your ip is " + c.getIp()).addParam("IP", c.getIp())); c.disconnect(Util::REASON_INVALID_IP); @@ -453,13 +449,11 @@ dcassert(c.getState() == Client::STATE_IDENTIFY || c.getState() == Client::STATE_VERIFY); dcdebug("%s entering NORMAL\n", AdcCommand::fromSID(c.getSID()).c_str()); - if (sendData) { - string str; - for (ClientIter i = clients.begin(); i != clients.end(); ++i) { - str += i->second->getINF(); + if(sendData) { + for(ClientIter i = clients.begin(); i != clients.end(); ++i) { + c.send(i->second->getINF()); } - c.send(str); - if (sendOwnInf) { + if(sendOwnInf) { sendToAll(c.getINF()); c.send(c.getINF()); } Modified: adchpp/trunk/adchpp/ClientManager.h =================================================================== --- adchpp/trunk/adchpp/ClientManager.h 2007-12-28 15:35:31 UTC (rev 116) +++ adchpp/trunk/adchpp/ClientManager.h 2007-12-30 21:41:46 UTC (rev 117) @@ -69,9 +69,10 @@ /** Send a command to the clients according to its type */ ADCHPP_DLL void send(const AdcCommand& cmd, bool lowPrio = false) throw(); + void sendToAll(const AdcCommand& cmd) throw() { sendToAll(cmd.getBuffer()); } /** Send command to all regardless of type */ - void sendToAll(const AdcCommand& cmd) throw() { sendToAll(cmd.toString()); } - ADCHPP_DLL void sendToAll(const std::string& cmd) throw(); + void sendToAll(const std::string& cmd) throw() { sendToAll(BufferPtr(new Buffer(cmd))); } + ADCHPP_DLL void sendToAll(const BufferPtr& buffer) throw(); /** Send command to a single client regardless of type */ ADCHPP_DLL void sendTo(const AdcCommand& cmd, const uint32_t& to) throw(); @@ -188,8 +189,8 @@ // Strings used in various places along the pipeline...rebuilt in updateCache()... struct Strings { - std::string sup; - std::string inf; + BufferPtr sup; + BufferPtr inf; } strings; friend class Singleton<ClientManager>; Modified: adchpp/trunk/adchpp/ManagedSocket.cpp =================================================================== --- adchpp/trunk/adchpp/ManagedSocket.cpp 2007-12-28 15:35:31 UTC (rev 116) +++ adchpp/trunk/adchpp/ManagedSocket.cpp 2007-12-30 21:41:46 UTC (rev 117) @@ -31,7 +31,7 @@ FastMutex ManagedSocket::writeMutex; -ManagedSocket::ManagedSocket() throw() : outBuf(0), overFlow(0), disc(0) +ManagedSocket::ManagedSocket() throw() : overFlow(0), disc(0) #ifdef _WIN32 , writeBuf(0) #else @@ -42,6 +42,7 @@ ManagedSocket::~ManagedSocket() throw() { dcdebug("ManagedSocket deleted\n"); +#if 0 if(outBuf) { dcdebug("Left (%d): %.*s\n", outBuf->size(), outBuf->size(), &(*outBuf)[0]); Util::freeBuf = outBuf; @@ -53,105 +54,118 @@ Util::freeBuf = writeBuf; } #endif +#endif } -void ManagedSocket::write(const char* buf, size_t len) throw() { - bool add = false; - { - FastMutex::Lock l(writeMutex); - add = fastWrite(buf, len); +void ManagedSocket::write(const BufferPtr& buf) throw() { + FastMutex::Lock l(writeMutex); + fastWrite(buf); +} + +static size_t sum(const BufferList& l) { + size_t bytes = 0; + for(BufferList::const_iterator i = l.begin(); i != l.end(); ++i) { + bytes += (*i)->size(); } - if(add) { - SocketManager::getInstance()->addWriter(this); - } + return bytes; } -bool ManagedSocket::fastWrite(const char* buf, size_t len, bool lowPrio /* = false */) throw() { - if((len == 0) || (disc > 0)) - return false; +size_t ManagedSocket::getQueuedBytes() const { + return sum(outBuf); +} + +void ManagedSocket::fastWrite(const BufferPtr& buf, bool lowPrio /* = false */) throw() { + if((buf->size() == 0) || (disc > 0)) + return; - bool add = false; - if(outBuf == 0) { - add = true; - outBuf = Util::freeBuf; - } + size_t queued = getQueuedBytes(); - if(outBuf->size() + len > (uint32_t)SETTING(MAX_BUFFER_SIZE)) { + if(queued + buf->size() > (size_t)SETTING(MAX_BUFFER_SIZE)) { if(lowPrio && SETTING(KEEP_SLOW_USERS)) { - return false; + return; } else if(overFlow > 0 && overFlow + SETTING(OVERFLOW_TIMEOUT) < GET_TICK()) { disconnect(Util::REASON_WRITE_OVERFLOW); - return false; + return; } else { overFlow = GET_TICK(); } } - Stats::queueBytes += len; + Stats::queueBytes += buf->size(); Stats::queueCalls++; - outBuf->insert(outBuf->end(), buf, buf + len); - return add; + outBuf.push_back(buf); } -ByteVector* ManagedSocket::prepareWrite() { +void ManagedSocket::prepareWrite(BufferList& buffers) { if(isBlocked()) { - return 0; + return; } - - ByteVector* buffer = 0; - { - FastMutex::Lock l(writeMutex); - - if(outBuf == 0) { - return 0; - } - - if(SETTING(MAX_SEND_SIZE) > 0 && (outBuf->size() > (size_t)SETTING(MAX_SEND_SIZE))) { - // Damn, we take a copy and leave the rest... - buffer = Util::freeBuf; - buffer->insert(buffer->end(), outBuf->begin(), outBuf->begin() + SETTING(MAX_SEND_SIZE)); - outBuf->erase(outBuf->begin(), outBuf->begin() + SETTING(MAX_SEND_SIZE)); - } else { - buffer = outBuf; - outBuf = 0; + FastMutex::Lock l(writeMutex); + size_t queued = getQueuedBytes(); + if(queued == 0) { + return; + } + + size_t max_send = static_cast<size_t>(SETTING(MAX_SEND_SIZE)); + + if((max_send > 0) && (queued > max_send)) { + // Copy as many buffers as possible + // TODO The last copied buffer should be split... + size_t done = 0; + BufferList::iterator i; + for(i = outBuf.begin(); i != outBuf.end(); ++i) { + buffers.push_back(*i); + done += (*i)->size(); + if(done > max_send) { + break; + } } + outBuf.erase(outBuf.begin(), i); + } else { + buffers.swap(outBuf); } - return buffer; } -bool ManagedSocket::completeWrite(ByteVector* buf, size_t written) throw() { +bool ManagedSocket::completeWrite(BufferList& buffers, size_t written) throw() { Stats::sendBytes += written; Stats::sendCalls++; - bool moreData; - { - FastMutex::Lock l(writeMutex); + size_t done = 0; + BufferList::iterator i = buffers.begin(); + for(; i != buffers.end(); ++i) { + if(done + (*i)->size() > written) { + break; + } + done += (*i)->size(); + } + + FastMutex::Lock l(writeMutex); + + if(done != written) { + // i points to the first not fully written buffer.. + size_t diff = written - done; + if(diff != 0) { + (*i)->erase_first(diff); + } - if(written != buf->size()) { - if(outBuf == 0) { - buf->erase(buf->begin(), buf->begin() + written); - outBuf = buf; - buf = 0; - } else { - outBuf->insert(outBuf->begin(), buf->begin() + written, buf->end()); - } - } - moreData = (outBuf != 0) || disc > 0; - if( !outBuf || (outBuf->size() < (size_t)SETTING(MAX_BUFFER_SIZE)) ) - overFlow = 0; - + outBuf.insert(outBuf.begin(), i, buffers.end()); } + + buffers.clear(); - if(buf) { - Util::freeBuf = buf; + size_t left = getQueuedBytes(); + if(overFlow > 0) { + if(left < static_cast<size_t>(SETTING(MAX_BUFFER_SIZE))) { + overFlow = 0; + } } - return moreData; + return left > 0 || disc > 0; } -bool ManagedSocket::completeRead(ByteVector* buf) throw() { +bool ManagedSocket::completeRead(const BufferPtr& buf) throw() { Stats::recvBytes += buf->size(); Stats::recvCalls++; SocketManager::getInstance()->addJob(std::tr1::bind(&ManagedSocket::processData, this, buf)); @@ -163,6 +177,7 @@ } void ManagedSocket::failSocket(int) throw() { + sock.disconnect(); SocketManager::getInstance()->addJob(failedHandler); } @@ -173,12 +188,10 @@ disc = GET_TICK() + SETTING(DISCONNECT_TIMEOUT); Util::reasons[reason]++; - SocketManager::getInstance()->addDisconnect(this); } -void ManagedSocket::processData(ByteVector* buf) throw() { - dataHandler(*buf); - Util::freeBuf = buf; +void ManagedSocket::processData(const BufferPtr& buf) throw() { + dataHandler(buf); } } Modified: adchpp/trunk/adchpp/ManagedSocket.h =================================================================== --- adchpp/trunk/adchpp/ManagedSocket.h 2007-12-28 15:35:31 UTC (rev 116) +++ adchpp/trunk/adchpp/ManagedSocket.h 2007-12-30 21:41:46 UTC (rev 117) @@ -26,9 +26,10 @@ #include "Mutex.h" #include "Signal.h" #include "Util.h" +#include "Buffer.h" namespace adchpp { - + /** * An asynchronous socket managed by SocketManager. */ @@ -37,16 +38,16 @@ void create() throw(SocketException) { sock.create(); } /** Asynchronous write */ - ADCHPP_DLL void write(const char* buf, size_t len) throw(); + ADCHPP_DLL void write(const BufferPtr& buf) throw(); /** Asynchronous write, assumes that buffers are locked */ - ADCHPP_DLL bool fastWrite(const char* buf, size_t len, bool lowPrio = false) throw(); + ADCHPP_DLL void fastWrite(const BufferPtr& buf, bool lowPrio = false) throw(); /** Returns the lock used for the write buffers */ static FastMutex& getWriteMutex() { return writeMutex; } /** Returns the number of bytes in the output buffer; buffers must be locked */ - size_t getQueuedBytes() { return outBuf ? outBuf->size() : 0; } + size_t getQueuedBytes() const; /** Asynchronous disconnect. Pending data will be written, but no more data will be read. */ ADCHPP_DLL void disconnect(Util::Reason reason) throw(); @@ -56,7 +57,7 @@ typedef std::tr1::function<void()> ConnectedHandler; void setConnectedHandler(const ConnectedHandler& handler) { connectedHandler = handler; } - typedef std::tr1::function<void(const ByteVector&)> DataHandler; + typedef std::tr1::function<void(const BufferPtr&)> DataHandler; void setDataHandler(const DataHandler& handler) { dataHandler = handler; } typedef std::tr1::function<void()> FailedHandler; void setFailedHandler(const FailedHandler& handler) { failedHandler = handler; } @@ -69,17 +70,17 @@ ~ManagedSocket() throw(); // Functions for Writer (called from Writer thread) - ByteVector* prepareWrite(); + void prepareWrite(BufferList& buffers); void completeAccept() throw(); - bool completeWrite(ByteVector* buf, size_t written) throw(); - bool completeRead(ByteVector* buf) throw(); + bool completeWrite(BufferList& buffers, size_t written) throw(); + bool completeRead(const BufferPtr& buf) throw(); void failSocket(int error) throw(); void shutdown() { sock.shutdown(); } void close() { sock.disconnect(); } // Functions processing events - void processData(ByteVector* buf) throw(); + void processData(const BufferPtr& buf) throw(); // No copies ManagedSocket(const ManagedSocket&); @@ -88,8 +89,9 @@ friend class Writer; Socket sock; + /** Output buffer, for storing data that's waiting to be transmitted */ - ByteVector* outBuf; + BufferList outBuf; /** Overflow timer, the buffer is allowed to overflow for 1 minute, then disconnect */ uint32_t overFlow; /** Disconnection scheduled for this socket */ @@ -98,11 +100,11 @@ std::string ip; #ifdef _WIN32 /** Data currently being sent by WSASend, 0 if not sending */ - ByteVector* writeBuf; - /** WSABUF for data being sent */ - WSABUF wsabuf; + BufferList writeBuf; + /** Buffer containing WSABUF's for data being sent */ + BufferPtr wsabuf; - bool isBlocked() { return writeBuf != 0; } + bool isBlocked() { return !writeBuf.empty(); } #else bool blocked; bool isBlocked() { return blocked; } Modified: adchpp/trunk/adchpp/Socket.cpp =================================================================== --- adchpp/trunk/adchpp/Socket.cpp 2007-12-28 15:35:31 UTC (rev 116) +++ adchpp/trunk/adchpp/Socket.cpp 2007-12-30 21:41:46 UTC (rev 117) @@ -163,15 +163,6 @@ return len; } -void Socket::write(const char* aBuffer, size_t aLen) throw(SocketException) { - size_t pos = writeNB(aBuffer, aLen); - while(pos < aLen) { - // Try once every second at least, you never know... - wait(1000, WAIT_WRITE); - pos += writeNB(aBuffer + pos, aLen - pos); - } -} - #ifndef MSG_NOSIGNAL #define MSG_NOSIGNAL 0 #endif @@ -187,13 +178,13 @@ * @return 0 if socket would block, otherwise the number of bytes written * @throw SocketExcpetion Send failed. */ -int Socket::writeNB(const char* aBuffer, size_t aLen) throw(SocketException) { +int Socket::write(const void* aBuffer, size_t aLen) throw(SocketException) { dcdebug("Writing %db: %.100s\n", aLen, aBuffer); dcassert(aLen > 0); - int i = ::send(sock, aBuffer, (int)aLen, MSG_NOSIGNAL | MSG_DONTWAIT); + int i = ::send(sock,(char*)aBuffer, (int)aLen, MSG_NOSIGNAL | MSG_DONTWAIT); if(i == SOCKET_ERROR) { - if(socket_errno == EWOULDBLOCK) { + if(socket_errno == EWOULDBLOCK || socket_errno == EINTR || socket_errno == EAGAIN) { return 0; } checksockerr(i); @@ -211,7 +202,7 @@ * @param aLen Data length * @throw SocketExcpetion Send failed. */ -void Socket::writeTo(const string& aIp, short aPort, const char* aBuffer, size_t aLen) throw(SocketException) { +void Socket::writeTo(const string& aIp, short aPort, const void* aBuffer, size_t aLen) throw(SocketException) { if(sock == INVALID_SOCKET) { create(TYPE_UDP); } @@ -238,7 +229,7 @@ serv_addr.sin_addr.s_addr = *((uint32_t*)host->h_addr); } - int i = ::sendto(sock, aBuffer, (int)aLen, 0, (struct sockaddr*)&serv_addr, sizeof(serv_addr)); + int i = ::sendto(sock, (char*)aBuffer, (int)aLen, 0, (struct sockaddr*)&serv_addr, sizeof(serv_addr)); checksockerr(i); } Modified: adchpp/trunk/adchpp/Socket.h =================================================================== --- adchpp/trunk/adchpp/Socket.h 2007-12-28 15:35:31 UTC (rev 116) +++ adchpp/trunk/adchpp/Socket.h 2007-12-30 21:41:46 UTC (rev 117) @@ -107,12 +107,11 @@ virtual void bind(short aPort) throw(SocketException); virtual void connect(const std::string& aIp, short aPort) throw(SocketException); void connect(const std::string& aIp, const std::string& aPort) throw(SocketException) { connect(aIp, (short)Util::toInt(aPort)); } + int read(void* aBuffer, size_t aBufLen) throw(SocketException); virtual std::string accept(const Socket& aSocket) throw(SocketException); - virtual void write(const char* aBuffer, size_t aLen) throw(SocketException); + virtual int write(const void* aBuffer, size_t aLen) throw(SocketException); void write(const std::string& aData) throw(SocketException) { write(aData.data(), aData.length()); } - virtual int writeNB(const char* aBuffer, size_t aLen) throw(SocketException); - int writeNB(const std::string& aData) throw(SocketException) { return writeNB(aData.data(), aData.length()); } - virtual void writeTo(const std::string& aIp, short aPort, const char* aBuffer, size_t aLen) throw(SocketException); + virtual void writeTo(const std::string& aIp, short aPort, const void* aBuffer, size_t aLen) throw(SocketException); void writeTo(const std::string& aIp, short aPort, const std::string& aData) throw(SocketException) { writeTo(aIp, aPort, aData.data(), aData.length()); } virtual void disconnect() throw(); @@ -120,7 +119,6 @@ void shutdown() { ::shutdown(sock, SD_BOTH); } - int read(void* aBuffer, size_t aBufLen) throw(SocketException); int wait(uint32_t millis, int waitFor) throw(SocketException); static std::string resolve(const std::string& aDns); Modified: adchpp/trunk/adchpp/SocketManager.cpp =================================================================== --- adchpp/trunk/adchpp/SocketManager.cpp 2007-12-28 15:35:31 UTC (rev 116) +++ adchpp/trunk/adchpp/SocketManager.cpp 2007-12-30 21:41:46 UTC (rev 117) @@ -321,13 +321,13 @@ DWORD x = 0; - ms->writeBuf = Util::freeBuf; - ms->writeBuf->resize(ACCEPT_BUF_SIZE); + ms->writeBuf.push_back(BufferPtr(new Buffer(ACCEPT_BUF_SIZE))); + ms->writeBuf.back()->resize(ACCEPT_BUF_SIZE); MSOverlapped* overlapped = pool.get(); *overlapped = MSOverlapped(MSOverlapped::ACCEPT_DONE, ms); - if(!::AcceptEx(srv.getSocket(), ms->getSocket(), &(*ms->writeBuf)[0], 0, ACCEPT_BUF_SIZE/2, ACCEPT_BUF_SIZE/2, &x, overlapped)) { + if(!::AcceptEx(srv.getSocket(), ms->getSocket(), ms->writeBuf.back()->data(), 0, ACCEPT_BUF_SIZE/2, ACCEPT_BUF_SIZE/2, &x, overlapped)) { int error = ::WSAGetLastError(); if(error != ERROR_IO_PENDING) { if(!stop) { @@ -348,12 +348,11 @@ struct sockaddr_in *local, *remote; int sz1 = sizeof(local), sz2 = sizeof(remote); - ::GetAcceptExSockaddrs(&(*ms->writeBuf)[0], 0, ACCEPT_BUF_SIZE/2, ACCEPT_BUF_SIZE/2, reinterpret_cast<sockaddr**>(&local), &sz1, reinterpret_cast<sockaddr**>(&remote), &sz2); + ::GetAcceptExSockaddrs(ms->writeBuf.back()->data(), 0, ACCEPT_BUF_SIZE/2, ACCEPT_BUF_SIZE/2, reinterpret_cast<sockaddr**>(&local), &sz1, reinterpret_cast<sockaddr**>(&remote), &sz2); ms->setIp(inet_ntoa(remote->sin_addr)); - Util::freeBuf = ms->writeBuf; - ms->writeBuf = 0; + ms->writeBuf.clear(); active.insert(ms); accepting.erase(ms); @@ -393,18 +392,14 @@ } void handleReadDone(const ManagedSocketPtr& ms) throw() { - ByteVector* readBuf = Util::freeBuf; + BufferPtr readBuf(new Buffer(SETTING(BUFFER_SIZE))); - if(readBuf->size() < (size_t)SETTING(BUFFER_SIZE)) - readBuf->resize(SETTING(BUFFER_SIZE)); + WSABUF wsa = { (u_long)readBuf->size(), (char*)readBuf->data() }; - WSABUF wsa = { (u_long)readBuf->size(), (char*)&(*readBuf)[0] }; - DWORD bytes = 0; DWORD flags = 0; if(::WSARecv(ms->getSocket(), &wsa, 1, &bytes, &flags, 0, 0) == SOCKET_ERROR) { - Util::freeBuf = readBuf; int error = ::WSAGetLastError(); if(error != WSAEWOULDBLOCK) { // Socket failed... @@ -417,7 +412,6 @@ } if(bytes == 0) { - Util::freeBuf = readBuf; disconnect(ms, 0); return; } @@ -429,13 +423,13 @@ } void write(const ManagedSocketPtr& ms) throw() { - if(stop || !(*ms)) { + if(stop || !(*ms) || !ms->writeBuf.empty()) { return; } - ms->writeBuf = ms->prepareWrite(); + ms->prepareWrite(ms->writeBuf); - if(!ms->writeBuf) { + if(ms->writeBuf.empty()) { uint32_t now = GET_TICK(); if(ms->disc || (ms->isBlocked() && ms->disc < now)) { @@ -444,14 +438,17 @@ return; } - ms->wsabuf.len = ms->writeBuf->size(); - ms->wsabuf.buf = reinterpret_cast<char*>(&(*ms->writeBuf)[0]); - + ms->wsabuf->resize(sizeof(WSABUF) * ms->writeBuf.size()); + for(size_t i = 0; i < ms->writeBuf.size(); ++i) { + WSABUF wsa = { (u_long)ms->writeBuf[i]->size(), (char*)ms->writeBuf[i]->data() }; + memcpy(ms->wsabuf->data() + i * sizeof(WSABUF), &wsa, sizeof(WSABUF)); + } + MSOverlapped* overlapped = pool.get(); *overlapped = MSOverlapped(MSOverlapped::WRITE_DONE, ms); DWORD x = 0; - if(::WSASend(ms->getSocket(), &ms->wsabuf, 1, &x, 0, reinterpret_cast<LPWSAOVERLAPPED>(overlapped), 0) != 0) { + if(::WSASend(ms->getSocket(), (WSABUF*)ms->wsabuf->data(), ms->writeBuf.size(), &x, 0, reinterpret_cast<LPWSAOVERLAPPED>(overlapped), 0) != 0) { int error = ::WSAGetLastError(); if(error != WSA_IO_PENDING) { pool.put(overlapped); @@ -461,19 +458,10 @@ } void handleWriteDone(const ManagedSocketPtr& ms, DWORD bytes) throw() { - ByteVector* buf = ms->writeBuf; - ms->writeBuf = 0; - - if(!buf) { - dcdebug("No buffer in handleWriteDone??\n"); - return; - } - ms->completeWrite(buf, bytes); + ms->completeWrite(ms->writeBuf, bytes); } void failWrite(const ManagedSocketPtr& ms, int error) throw() { - Util::freeBuf = ms->writeBuf; - ms->writeBuf = 0; disconnect(ms, error); } @@ -516,6 +504,7 @@ ManagedSocketPtr ms(new ManagedSocket()); try { ms->setIp(ms->sock.accept(srv)); + ms->sock.setBlocking(false); if(!poller.associate(ms)) { LOG(SocketManager::className, "Unable to associate EPoll: " + Util::translateError(errno)); @@ -540,14 +529,10 @@ return false; for(;;) { - ByteVector* readBuf = Util::freeBuf; - if(readBuf->size() < (size_t)SETTING(BUFFER_SIZE)) - readBuf->resize(SETTING(BUFFER_SIZE)); - - ssize_t bytes = ::recv(ms->getSocket(), &(*readBuf)[0], readBuf->size(), MSG_DONTWAIT); + BufferPtr buf(new Buffer(SETTING(BUFFER_SIZE))); + + ssize_t bytes = ::recv(ms->getSocket(), buf->data(), buf->size(), MSG_DONTWAIT); if(bytes == -1) { - Util::freeBuf = readBuf; - int error = errno; if(error != EAGAIN && error != EINTR) { ms->close(); @@ -556,14 +541,13 @@ } break; } else if(bytes == 0) { - Util::freeBuf = readBuf; ms->close(); disconnect(ms, 0); return false; } - readBuf->resize(bytes); - ms->completeRead(readBuf); + buf->resize(bytes); + ms->completeRead(buf); } return true; } @@ -572,30 +556,33 @@ if(stop || !(*ms)) { return; } - + BufferList buffers; while(true) { - ByteVector* writeBuf = ms->prepareWrite(); - - if(!writeBuf) { + ms->prepareWrite(buffers); + if(buffers.empty()) { uint32_t now = GET_TICK(); if(ms->disc || (ms->isBlocked() && ms->disc < now)) { disconnect(ms, 0); } return; } - - ssize_t bytes = ::send(ms->getSocket(), &(*writeBuf)[0], writeBuf->size(), MSG_NOSIGNAL | MSG_DONTWAIT); + std::vector<iovec> iov(buffers.size()); + for(size_t i = 0; i < buffers.size(); ++i) { + iov[i].iov_base = buffers[i]->data(); + iov[i].iov_len = buffers[i]->size(); + } + ssize_t bytes = ::writev(ms->getSocket(), &iov[0], iov.size()); if(bytes == -1) { int error = errno; if(error == EAGAIN) { - ms->completeWrite(writeBuf, 0); + ms->completeWrite(buffers, 0); return; } - Util::freeBuf = writeBuf; + //Util::freeBuf = writeBuf; disconnect(ms, error); return; } - if(!ms->completeWrite(writeBuf, bytes)) { + if(!ms->completeWrite(buffers, bytes)) { break; } } @@ -717,15 +704,6 @@ return 0; } -void SocketManager::addWriter(const ManagedSocketPtr& ms) throw() { -} - -void SocketManager::addAllWriters() throw() { -} - -void SocketManager::addDisconnect(const ManagedSocketPtr& ms) throw() { -} - void SocketManager::addJob(const Callback& callback) throw() { FastMutex::Lock l(processMutex); Modified: adchpp/trunk/adchpp/SocketManager.h =================================================================== --- adchpp/trunk/adchpp/SocketManager.h 2007-12-28 15:35:31 UTC (rev 116) +++ adchpp/trunk/adchpp/SocketManager.h 2007-12-30 21:41:46 UTC (rev 117) @@ -37,10 +37,6 @@ void startup() throw(ThreadException) { start(); } void shutdown(); - void addWriter(const ManagedSocketPtr& ms) throw(); - void addDisconnect(const ManagedSocketPtr& ms) throw(); - void addAllWriters() throw(); - typedef std::tr1::function<void (const ManagedSocketPtr&)> IncomingHandler; void setIncomingHandler(const IncomingHandler& handler) { incomingHandler = handler; } Modified: adchpp/trunk/swig/adchpp.i =================================================================== --- adchpp/trunk/swig/adchpp.i 2007-12-28 15:35:31 UTC (rev 116) +++ adchpp/trunk/swig/adchpp.i 2007-12-30 21:41:46 UTC (rev 117) @@ -327,8 +327,8 @@ StringList& getParameters(); //const StringList& getParameters() const; - const std::string& toString() const; - void resetString(); + std::string toString() const; + void resetBuffer(); AdcCommand& addParam(const std::string& name, const std::string& value); AdcCommand& addParam(const std::string& str); Modified: adchpp/trunk/test/PyClient.py =================================================================== --- adchpp/trunk/test/PyClient.py 2007-12-28 15:35:31 UTC (rev 116) +++ adchpp/trunk/test/PyClient.py 2007-12-30 21:41:46 UTC (rev 117) @@ -1,159 +1,157 @@ -#!/usr/bin/python -import sys - -sys.path.append('../build/debug-default/bin') - -CLIENTS = 100 - -import socket, threading, time - -from pyadchpp import ParseException, Util_initialize, CID, CID_generate, Encoder_toBase32, Encoder_fromBase32, AdcCommand, AdcCommand_toSID, TigerHash, CID - -Util_initialize("") - -class Client(object): - def __init__(self, n): - self.sock = socket.socket() - self.pid = CID_generate() - tiger = TigerHash() - tiger.update(self.pid.data()) - self.cid = CID(Encoder_toBase32(tiger.finalize())) - self.nick = "user_" + str(n) + "_" + self.cid.toBase32() - self.running = True - self.line = "" - - def connect(self, ipport): - self.sock.connect(ipport) - - def command(self, cmd): - s = cmd.toString() - print self.nick, "sending", s - self.sock.send(cmd.toString()) - - def get_command(self): - index = self.line.find('\n') - while index == -1: - line = self.sock.recv(4096) - if len(line) == 0: - return None - - self.line += line - index = self.line.find('\n') - if index==0: - self.line = self.line[index+1:] - index = -1 - - self.lastline = self.line[:index + 1] - self.line = self.line[index+1:] - return AdcCommand(self.lastline) - - def expect(self, command): - cmd = self.get_command() - if not cmd or cmd.getCommand() != command: - if not cmd: - error = "expect: connection closed" - else: - error = "expect: " + cmd.getCommandString() - raise Exception, error - return cmd - - def login(self, ipport): - self.connect(ipport) - cmd = AdcCommand(AdcCommand.CMD_SUP, AdcCommand.TYPE_HUB, 0) - cmd.addParam("ADBASE").addParam("ADTIGR") - self.command(cmd) - self.expect(AdcCommand.CMD_SUP) - sid = self.expect(AdcCommand.CMD_SID) - self.sid = AdcCommand_toSID(sid.getParam(0)) - - cmd = AdcCommand(AdcCommand.CMD_INF, AdcCommand.TYPE_BROADCAST, self.sid) - cmd.addParam("ID" + self.cid.toBase32()) - cmd.addParam("PD" + self.pid.toBase32()) - cmd.addParam("NI" + self.nick) - self.command(cmd) - -# def test_close(self): -# self.sock.close() - - def test_error(self): - cmd = AdcCommand(AdcCommand.CMD_MSG, AdcCommand.TYPE_BROADCAST, self.sid) - cmd.addParam("+error") - self.command(cmd) - - def test_test(self): - cmd = AdcCommand(AdcCommand.CMD_MSG, AdcCommand.TYPE_BROADCAST, self.sid) - cmd.addParam("+test") - self.command(cmd) - - def test_msg(self): - cmd = AdcCommand(AdcCommand.CMD_MSG, AdcCommand.TYPE_BROADCAST, self.sid) - cmd.addParam("hello from " + self.nick) - self.command(cmd) - - def test_nick(self): - self.nick = "user_" + str(CID_generate()) - cmd = AdcCommand(AdcCommand.CMD_MSG, AdcCommand.TYPE_BROADCAST, self.sid) - cmd.addParam("renaming myself to " + self.nick) - self.command(cmd) - cmd = AdcCommand(AdcCommand.CMD_INF, AdcCommand.TYPE_BROADCAST, self.sid) - cmd.addParam("NI", self.nick) - self.command(cmd) - - def __call__(self): - try: - while self.get_command(): - pass - self.sock.close() - except Exception, e: - print "Client " + self.nick + " died:", e - except ParseException, e: - print "Client " + self.nick + " died, line was:", self.lastline - self.running = False -try: - import sys - if len(sys.argv) > 2: - ip = sys.argv[1] - port = int(sys.argv[2]) - else: - ip = "127.0.0.1" - port = 2780 - - clients = [] - for i in range(CLIENTS): - if i > 0 and i % 10 == 0: - #time.sleep(3) - pass - print "Logging in", i - client = Client(i) - clients.append(client) - client.login((ip,port)) - t = threading.Thread(target = client, name = client.nick) - t.setDaemon(True) - t.start() - - time.sleep(5) - import random - tests = [] - for k,v in Client.__dict__.iteritems(): - if len(k) < 4 or k[0:4] != "test": - continue - tests.append(v) - print tests - while len(clients) > 0: - time.sleep(1) - for c in clients: - if not c.running: - clients.remove(c) - - if len(clients) == 0: - break - - if random.random() > (5./len(clients)): - continue - try: - random.choice(tests)(c) - except Exception, e: - pass - print "No more clients" -except Exception, e: - print e +#!/usr/bin/python +import sys + +sys.path.append('../build/debug-default/bin') + +CLIENTS = 100 + +import socket, threading, time, random, sys + +from pyadchpp import ParseException, Util_initialize, CID, CID_generate, Encoder_toBase32, Encoder_fromBase32, AdcCommand, AdcCommand_toSID, TigerHash, CID + +Util_initialize("") + +class Client(object): + def __init__(self, n): + self.sock = socket.socket() + self.pid = CID_generate() + tiger = TigerHash() + tiger.update(self.pid.data()) + self.cid = CID(Encoder_toBase32(tiger.finalize())) + self.nick = "user_" + str(n) + "_" + self.cid.toBase32() + self.running = True + self.line = "" + + def connect(self, ipport): + self.sock.connect(ipport) + + def command(self, cmd): + s = cmd.toString() + print self.nick, "sending", len(s), s + self.sock.send(s) + + def get_command(self): + index = self.line.find('\n') + while index == -1: + line = self.sock.recv(4096) + if len(line) == 0: + return None + + self.line += line + index = self.line.find('\n') + if index==0: + self.line = self.line[index+1:] + index = -1 + + self.lastline = self.line[:index + 1] + self.line = self.line[index+1:] + return AdcCommand(self.lastline) + + def expect(self, command): + cmd = self.get_command() + if not cmd or cmd.getCommand() != command: + if not cmd: + error = "expect: connection closed" + else: + error = "expect: " + cmd.getCommandString() + raise Exception, error + return cmd + + def login(self, ipport): + self.connect(ipport) + cmd = AdcCommand(AdcCommand.CMD_SUP, AdcCommand.TYPE_HUB, 0) + cmd.addParam("ADBASE").addParam("ADTIGR") + self.command(cmd) + self.expect(AdcCommand.CMD_SUP) + sid = self.expect(AdcCommand.CMD_SID) + self.sid = AdcCommand_toSID(sid.getParam(0)) + + cmd = AdcCommand(AdcCommand.CMD_INF, AdcCommand.TYPE_BROADCAST, self.sid) + cmd.addParam("ID" + self.cid.toBase32()) + cmd.addParam("PD" + self.pid.toBase32()) + cmd.addParam("NI" + self.nick) + self.command(cmd) + +# def test_close(self): +# self.sock.close() + + def test_error(self): + cmd = AdcCommand(AdcCommand.CMD_MSG, AdcCommand.TYPE_BROADCAST, self.sid) + cmd.addParam("+error") + self.command(cmd) + + def test_test(self): + cmd = AdcCommand(AdcCommand.CMD_MSG, AdcCommand.TYPE_BROADCAST, self.sid) + cmd.addParam("+test") + self.command(cmd) + + def test_msg(self): + cmd = AdcCommand(AdcCommand.CMD_MSG, AdcCommand.TYPE_BROADCAST, self.sid) + cmd.addParam("hello from " + self.nick) + self.command(cmd) + + def test_nick(self): + self.nick = "user_" + str(CID_generate()) + cmd = AdcCommand(AdcCommand.CMD_MSG, AdcCommand.TYPE_BROADCAST, self.sid) + cmd.addParam("renaming myself to " + self.nick) + self.command(cmd) + cmd = AdcCommand(AdcCommand.CMD_INF, AdcCommand.TYPE_BROADCAST, self.sid) + cmd.addParam("NI", self.nick) + self.command(cmd) + + def __call__(self): + try: + while self.get_command(): + pass + self.sock.close() + except Exception, e: + print "Client " + self.nick + " died:", e + except ParseException, e: + print "Client " + self.nick + " died, line was:", self.lastline + self.running = False +try: + if len(sys.argv) > 2: + ip = sys.argv[1] + port = int(sys.argv[2]) + else: + ip = "127.0.0.1" + port = 2780 + + clients = [] + for i in range(CLIENTS): + if i > 0 and i % 10 == 0: + #time.sleep(3) + pass + print "Logging in", i + client = Client(i) + clients.append(client) + client.login((ip,port)) + t = threading.Thread(target = client, name = client.nick) + t.setDaemon(True) + t.start() + + time.sleep(5) + tests = [] + for k,v in Client.__dict__.iteritems(): + if len(k) < 4 or k[0:4] != "test": + continue + tests.append(v) + print tests + while len(clients) > 0: + #time.sleep(1) + for c in clients: + if not c.running: + clients.remove(c) + + if len(clients) == 0: + break + + if random.random() > (5./len(clients)): + continue + try: + random.choice(tests)(c) + except Exception, e: + pass + print "No more clients" +except Exception, e: + print e This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2007-12-31 20:15:40
|
Revision: 118 http://adchpp.svn.sourceforge.net/adchpp/?rev=118&view=rev Author: arnetheduck Date: 2007-12-31 12:15:30 -0800 (Mon, 31 Dec 2007) Log Message: ----------- Use memory pool again Modified Paths: -------------- adchpp/trunk/adchpp/Buffer.h adchpp/trunk/adchpp/ManagedSocket.cpp adchpp/trunk/adchpp/PluginManager.cpp adchpp/trunk/adchpp/PluginManager.h adchpp/trunk/adchpp/SocketManager.cpp adchpp/trunk/adchpp/Util.cpp adchpp/trunk/adchpp/Util.h adchpp/trunk/swig/adchpp.i adchpp/trunk/swig/lua.i adchpp/trunk/swig/python.i Added Paths: ----------- adchpp/trunk/adchpp/Buffer.cpp Added: adchpp/trunk/adchpp/Buffer.cpp =================================================================== --- adchpp/trunk/adchpp/Buffer.cpp (rev 0) +++ adchpp/trunk/adchpp/Buffer.cpp 2007-12-31 20:15:30 UTC (rev 118) @@ -0,0 +1,18 @@ +#include "adchpp.h" + +#include "Buffer.h" +#include "SettingsManager.h" + +namespace adchpp { + +Pool<ByteVector, Buffer::Clear> Buffer::free; + +void Buffer::Clear::operator()(ByteVector& v) { + if(v.capacity() > static_cast<size_t>(SETTING(BUFFER_SIZE))) { + ByteVector().swap(v); + } else { + v.clear(); + } +} + +} Modified: adchpp/trunk/adchpp/Buffer.h =================================================================== --- adchpp/trunk/adchpp/Buffer.h 2007-12-30 21:41:46 UTC (rev 117) +++ adchpp/trunk/adchpp/Buffer.h 2007-12-31 20:15:30 UTC (rev 118) @@ -1,6 +1,8 @@ #ifndef BUFFER_H_ #define BUFFER_H_ +#include "Pool.h" +#include "Util.h" #include "FastAlloc.h" namespace adchpp { @@ -10,29 +12,36 @@ */ class Buffer : public intrusive_ptr_base, public FastAlloc<Buffer> { public: - Buffer(const std::string& str) : buf((uint8_t*)str.data(), (uint8_t*)str.data() + str.size()) { } - Buffer(const void* ptr, const size_t size) : buf((uint8_t*) ptr, ((uint8_t*)ptr)+size) { } - Buffer(const size_t size) : buf(size) { } + Buffer(const std::string& str) : bufp(free) { append((uint8_t*)str.data(), (uint8_t*)str.data() + str.size()); } + Buffer(const void* ptr, const size_t size) : bufp(free) { append((uint8_t*) ptr, ((uint8_t*)ptr)+size); } + Buffer(const size_t size) : bufp(free) { resize(size); } + ~Buffer() { free = bufp; } - operator const ByteVector&() const { return buf; } - operator ByteVector&() { return buf; } + operator const ByteVector&() const { return buf(); } + operator ByteVector&() { return buf(); } - void resize(size_t new_size) { buf.resize(new_size); } - size_t size() const { return buf.size(); } - const uint8_t* data() const { return &buf[0]; } - uint8_t* data() { return &buf[0]; } + void resize(size_t new_size) { buf().resize(new_size); } + size_t size() const { return buf().size(); } + const uint8_t* data() const { return &buf()[0]; } + uint8_t* data() { return &buf()[0]; } /** Erase the first n bytes */ - void erase_first(size_t n) { - buf.erase(buf.begin(), buf.begin() + n); - } + void erase_first(size_t n) { buf().erase(buf().begin(), buf().begin() + n); } template<typename InputIterator> - void append(InputIterator start, InputIterator end) { - buf.insert(buf.end(), start, end); - } + void append(InputIterator start, InputIterator end) { buf().insert(buf().end(), start, end); } private: - ByteVector buf; + + const ByteVector& buf() const { return *bufp; } + ByteVector& buf() { return *bufp; } + + ByteVector* bufp; + + struct Clear { + ADCHPP_DLL void operator()(ByteVector& x); + }; + + ADCHPP_DLL static Pool<ByteVector, Clear> free; }; typedef boost::intrusive_ptr<Buffer> BufferPtr; Modified: adchpp/trunk/adchpp/ManagedSocket.cpp =================================================================== --- adchpp/trunk/adchpp/ManagedSocket.cpp 2007-12-30 21:41:46 UTC (rev 117) +++ adchpp/trunk/adchpp/ManagedSocket.cpp 2007-12-31 20:15:30 UTC (rev 118) @@ -42,19 +42,6 @@ ManagedSocket::~ManagedSocket() throw() { dcdebug("ManagedSocket deleted\n"); -#if 0 - if(outBuf) { - dcdebug("Left (%d): %.*s\n", outBuf->size(), outBuf->size(), &(*outBuf)[0]); - Util::freeBuf = outBuf; - } - -#ifdef _WIN32 - if(writeBuf) { - dcdebug("Left2 (%d): %.*s\n", writeBuf->size(), writeBuf->size(), &(*writeBuf)[0]); - Util::freeBuf = writeBuf; - } -#endif -#endif } void ManagedSocket::write(const BufferPtr& buf) throw() { Modified: adchpp/trunk/adchpp/PluginManager.cpp =================================================================== --- adchpp/trunk/adchpp/PluginManager.cpp 2007-12-30 21:41:46 UTC (rev 117) +++ adchpp/trunk/adchpp/PluginManager.cpp 2007-12-31 20:15:30 UTC (rev 118) @@ -52,6 +52,7 @@ namespace adchpp { using namespace std; +using namespace std::tr1; using namespace std::tr1::placeholders; PluginManager* PluginManager::instance = 0; @@ -65,6 +66,10 @@ } +void PluginManager::attention(const function<void()>& f) { + SocketManager::getInstance()->addJob(f); +} + bool PluginManager::loadPlugin(const string& file) { if(file.length() < 3) { return false; Modified: adchpp/trunk/adchpp/PluginManager.h =================================================================== --- adchpp/trunk/adchpp/PluginManager.h 2007-12-30 21:41:46 UTC (rev 117) +++ adchpp/trunk/adchpp/PluginManager.h 2007-12-31 20:15:30 UTC (rev 118) @@ -22,7 +22,7 @@ * * ADCH++ contains a rather powerful plugin API that can be used to create advanced * plugins that change or add to ADCH++'s behaviour. Most plugins will need - * PluginManager.h, ClientManager. and Client.h included to work, even though the + * PluginManager.h, ClientManager.h and Client.h included to work, even though the * other header files are available as well (they're more likely to change in future * versions though). You can use any method that is declared as DLL or is inline, the * others are meant to be internal to ADCH++, very likely to change/disappear and will @@ -36,13 +36,7 @@ * of the ADCH++ plugin API. This version usually follows the main ADCH++ version, * unless a small update is made that I judge shouldn't affect plugins in any way. * Most of the time, recompiling the plugin should be enough, unless any major changes - * have been made, and your plugin doesn't rely on the nasty internals. As to compilers, - * the windows version is compiled using Visual C++ 7.1 (.NET), with various optimizations - * enabled. In theory, VC6 should work as well, as I haven't seen any information about - * changes in the name mangling scheme, but if you get strange linker errors, don't - * blame me. For best results, make sure you have the same settings. The Linux version - * is compiled with G++ 3.4.x, and I don't have a clue if older versions will work - * (probably not...). + * have been made, and your plugin doesn't rely on the nasty internals. * * @section Threads Threads * @@ -50,19 +44,16 @@ * communication while the other does all other work (handle protocol data and * so on). All plugins are run in the worker thread, which is the only thread * visible to the API. You are only allowed to interact with ADCH++ from this - * thread, as none of the API is thread safe (this is a performance issue, this way - * no locks are taken), unless otherwise noted. This has a few important - * consequences. First off, you can assume that your plugin will only be called - * by this thread, which means that you don't have to worry about multithreading - * issues unless you start threads by yourself. Second, any work you do in a plugin - * halts <b>all</b> of ADCH++'s processing (apart from receiving/sending buffered - * data), in other words, don't do any lengthy processing in the on methods, as - * the whole of ADCH++ will suffer. Third, if you indeed start another thread, make + * thread, as none of the API is thread safe, unless otherwise noted. This has a + * few important consequences. First off, you can assume that your plugin will + * only be called by this thread, which means that you don't have to worry about + * multithreading issues unless you start threads by yourself. Second, any work you + * do in a plugin halts <b>all</b> of ADCH++'s processing (apart from receiving/sending + * buffered data), in other words, don't do any lengthy processing in the on methods, + * as the whole of ADCH++ will suffer. Third, if you indeed start another thread, make * sure you don't use any API functions from it apart from those explicitly marked * as thread safe. To indicate from a plugin that you have work to do in the main - * worker thread, call PluginManager::attention(). This will generate an - * Attention event in the near future, where your thread can do its work (be - * careful though, the Attention event might be raised by other plugins). + * worker thread, call PluginManager::attention(). */ #ifndef ADCHPP_PLUGINMANAGER_H @@ -147,6 +138,13 @@ typedef Registry::iterator RegistryIter; /** + * This is a thread-safe method to call when you need to perform some work + * in the main ADCH++ worker thread. Your job will be executed once, when + * time permits. + */ + ADCHPP_DLL void attention(const std::tr1::function<void()>& f); + + /** * Get a list of currently loaded plugins */ const StringList& getPluginList() const { @@ -174,7 +172,7 @@ * @return false if name was already registered and call fails */ bool registerPlugin(const std::string& name, Plugin* ptr) { - return registry.insert(std::make_pair(name, ptr)).second; + return registry.insert(std::make_pair(name, ptr)).second; } /** @return True if the plugin existed and was thus unregistered */ @@ -193,7 +191,7 @@ /** * The full map of registered plugins. */ - const Registry& getPlugins() { + const Registry& getPlugins() const { return registry; } Modified: adchpp/trunk/adchpp/SocketManager.cpp =================================================================== --- adchpp/trunk/adchpp/SocketManager.cpp 2007-12-30 21:41:46 UTC (rev 117) +++ adchpp/trunk/adchpp/SocketManager.cpp 2007-12-31 20:15:30 UTC (rev 118) @@ -578,7 +578,6 @@ ms->completeWrite(buffers, 0); return; } - //Util::freeBuf = writeBuf; disconnect(ms, error); return; } @@ -650,7 +649,7 @@ bool stop; - typedef unordered_set<ManagedSocketPtr, PointerHash<ManagedSocket> > SocketSet; + typedef unordered_set<ManagedSocketPtr> SocketSet; /** Sockets that have a pending read */ SocketSet active; /** Sockets that are being written to but should be disconnected if timeout it reached */ Modified: adchpp/trunk/adchpp/Util.cpp =================================================================== --- adchpp/trunk/adchpp/Util.cpp 2007-12-30 21:41:46 UTC (rev 117) +++ adchpp/trunk/adchpp/Util.cpp 2007-12-31 20:15:30 UTC (rev 118) @@ -63,7 +63,6 @@ string Util::cfgPath; size_t Util::reasons[REASON_LAST]; -Pool<ByteVector, Util::Clear> Util::freeBuf; static void sgenrand(unsigned long seed); @@ -74,14 +73,6 @@ setCfgPath(configPath); } -void Util::Clear::operator()(ByteVector& v) { - if(v.capacity() > static_cast<size_t>(SETTING(BUFFER_SIZE))) { - ByteVector().swap(v); - } else { - v.clear(); - } -} - /** * Decodes a URL the best it can... * Default ports: Modified: adchpp/trunk/adchpp/Util.h =================================================================== --- adchpp/trunk/adchpp/Util.h 2007-12-30 21:41:46 UTC (rev 117) +++ adchpp/trunk/adchpp/Util.h 2007-12-31 20:15:30 UTC (rev 118) @@ -22,6 +22,15 @@ #include "Pool.h" #include "Mutex.h" +namespace std { namespace tr1 { + +template<typename T> +struct hash<boost::intrusive_ptr<T> > { + size_t operator()(const boost::intrusive_ptr<T>& t) const { return hash<T*>()(t.get()); } +}; + +} } + namespace adchpp { struct intrusive_ptr_base { @@ -81,24 +90,6 @@ void operator()(T* ptr) { delete ptr; } }; -/** A generic hash for pointers */ -template<class T> -struct PointerHash { -#if _MSC_VER >= 1300 - static const size_t bucket_size = 4; - static const size_t min_buckets = 8; -#endif - size_t operator()(const T* a) const { return ((size_t)a)/sizeof(T); } - bool operator()(const T* a, const T* b) { return a < b; } - - size_t operator()(const boost::intrusive_ptr<T>& a) const { return ((size_t)a.get())/sizeof(T); } - bool operator()(const boost::intrusive_ptr<T>& a, const boost::intrusive_ptr<T>& b) { return a.get() < b.get(); } -}; -template<> -struct PointerHash<void> { - size_t operator()(const void* a) const { return ((size_t)a)>>2; } -}; - /** * Compares two values * @return -1 if v1 < v2, 0 if v1 == v2 and 1 if v1 > v2 @@ -307,12 +298,6 @@ /** Avoid this! Use the one of a connected socket instead... */ ADCHPP_DLL static std::string getLocalIp(); - struct Clear { - void operator()(ByteVector& x); - }; - /** Pool of free buffers */ - ADCHPP_DLL static Pool<ByteVector, Clear> freeBuf; - ADCHPP_DLL static uint32_t rand(); static uint32_t rand(uint32_t high) { return rand() % high; } static uint32_t rand(uint32_t low, uint32_t high) { return rand(high-low) + low; } Modified: adchpp/trunk/swig/adchpp.i =================================================================== --- adchpp/trunk/swig/adchpp.i 2007-12-30 21:41:46 UTC (rev 117) +++ adchpp/trunk/swig/adchpp.i 2007-12-31 20:15:30 UTC (rev 118) @@ -718,6 +718,8 @@ class PluginManager { public: + void attention(const std::tr1::function<void()>& f); + //typedef HASH_MAP<std::string, Plugin*> Registry; //typedef Registry::iterator RegistryIter; Modified: adchpp/trunk/swig/lua.i =================================================================== --- adchpp/trunk/swig/lua.i 2007-12-30 21:41:46 UTC (rev 117) +++ adchpp/trunk/swig/lua.i 2007-12-31 20:15:30 UTC (rev 118) @@ -42,6 +42,11 @@ LuaFunction(const LuaFunction& rhs) : L(rhs.L), registryItem(rhs.registryItem) { } LuaFunction& operator=(const LuaFunction& rhs) { L = rhs.L; registryItem = rhs.registryItem; return *this; } + void operator()() { + pushFunction(); + docall(0, 0); + } + void operator()(adchpp::Client& c) { pushFunction(); @@ -144,6 +149,10 @@ lua_pushnumber(L, (lua_Number)$1); SWIG_arg++; } +%typemap(in) std::tr1::function<void () > { + $1 = LuaFunction(L); +} + %typemap(in) std::tr1::function<void (adchpp::Client &) > { $1 = LuaFunction(L); } Modified: adchpp/trunk/swig/python.i =================================================================== --- adchpp/trunk/swig/python.i 2007-12-30 21:41:46 UTC (rev 117) +++ adchpp/trunk/swig/python.i 2007-12-31 20:15:30 UTC (rev 118) @@ -5,6 +5,9 @@ #undef socklen_t %} +%typemap(in) std::tr1::function<void ()> { + $1 = PyHandle($input, false); +} %typemap(in) std::tr1::function<void (adchpp::Client&)> { $1 = PyHandle($input, false); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2008-01-01 15:28:57
|
Revision: 119 http://adchpp.svn.sourceforge.net/adchpp/?rev=119&view=rev Author: arnetheduck Date: 2008-01-01 07:28:48 -0800 (Tue, 01 Jan 2008) Log Message: ----------- Remove socketmanager from swig interface Modified Paths: -------------- adchpp/trunk/Doxyfile adchpp/trunk/swig/adchpp.i Modified: adchpp/trunk/Doxyfile =================================================================== --- adchpp/trunk/Doxyfile 2007-12-31 20:15:30 UTC (rev 118) +++ adchpp/trunk/Doxyfile 2008-01-01 15:28:48 UTC (rev 119) @@ -91,7 +91,7 @@ # Doxygen will generate a detailed section even if there is only a brief # description. -ALWAYS_DETAILED_SEC = NO +ALWAYS_DETAILED_SEC = YES # If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all # inherited members of a class in the documentation of that class as if those @@ -476,7 +476,7 @@ # $version, which will be replaced by the version of the file (if it could # be obtained via FILE_VERSION_FILTER) -WARN_FORMAT = "$file:$line: $text " +WARN_FORMAT = "$file:$line: $text " # The WARN_LOGFILE tag can be used to specify a file to which warning # and error messages should be written. If left blank the output is written @@ -750,7 +750,7 @@ # the HTML help compiler (hhc.exe). If non-empty doxygen will try to run # the HTML help compiler on the generated index.hhp. -HHC_LOCATION = "C:\Program Files\HTML Help Workshop\hhc.exe " +HHC_LOCATION = "C:\Program Files\HTML Help Workshop\hhc.exe " # If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag # controls if a separate .chi index file is generated (YES) or that @@ -1071,8 +1071,8 @@ # instead of the = operator. PREDEFINED = _REENTRANT \ - "GETSETREF(a,b,c)=private: a b; public: const a& get##c() const {}; void set##c(const a&) {}; " \ - "GETSET(a,b,c)=private: a b; public: a get##c() const {}; void set##c(a) {}; " + "GETSETREF(a,b,c)=private: a b; public: const a& get##c() const {}; void set##c(const a&) {}; " \ + "GETSET(a,b,c)=private: a b; public: a get##c() const {}; void set##c(a) {}; " # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then # this tag can be used to specify a list of macro names that should be expanded. Modified: adchpp/trunk/swig/adchpp.i =================================================================== --- adchpp/trunk/swig/adchpp.i 2007-12-31 20:15:30 UTC (rev 118) +++ adchpp/trunk/swig/adchpp.i 2008-01-01 15:28:48 UTC (rev 119) @@ -12,7 +12,6 @@ #include <adchpp/Exception.h> #include <adchpp/PluginManager.h> #include <adchpp/TigerHash.h> -#include <adchpp/SocketManager.h> using namespace adchpp; @@ -64,7 +63,6 @@ %nodefaultdtor SettingsManager; %nodefaultdtor Util; %nodefaultdtor PluginManager; -%nodefaultdtor SocketManager; namespace adchpp { class Client; @@ -513,10 +511,6 @@ } } -class SocketManager { - public: -}; - class ClientManager { public: @@ -744,6 +738,5 @@ LogManager* getLM() { return LogManager::getInstance(); } SettingsManager* getSM() { return SettingsManager::getInstance(); } PluginManager* getPM() { return PluginManager::getInstance(); } - SocketManager* getSocketManager() { return SocketManager::getInstance(); } } %} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2008-01-15 13:53:59
|
Revision: 127 http://adchpp.svn.sourceforge.net/adchpp/?rev=127&view=rev Author: arnetheduck Date: 2008-01-15 05:53:57 -0800 (Tue, 15 Jan 2008) Log Message: ----------- Rework bloom filter implementation Modified Paths: -------------- adchpp/trunk/adchpp/ClientManager.cpp adchpp/trunk/adchpp/SocketManager.cpp adchpp/trunk/adchpp/TigerHash.h adchpp/trunk/changelog.txt adchpp/trunk/plugins/Bloom/src/BloomManager.cpp adchpp/trunk/plugins/Bloom/src/HashBloom.cpp adchpp/trunk/plugins/Bloom/src/HashBloom.h adchpp/trunk/plugins/Bloom/src/HashValue.h adchpp/trunk/swig/adchpp.i Modified: adchpp/trunk/adchpp/ClientManager.cpp =================================================================== --- adchpp/trunk/adchpp/ClientManager.cpp 2008-01-06 19:18:26 UTC (rev 126) +++ adchpp/trunk/adchpp/ClientManager.cpp 2008-01-15 13:53:57 UTC (rev 127) @@ -269,9 +269,9 @@ TigerHash tiger; tiger.update(&password[0], password.size()); tiger.update(&salt[0], salt.size()); - uint8_t tmp[TigerHash::HASH_SIZE]; - Encoder::fromBase32(suppliedHash.c_str(), tmp, TigerHash::HASH_SIZE); - if (memcmp(tiger.finalize(), tmp, TigerHash::HASH_SIZE) == 0) { + uint8_t tmp[TigerHash::BYTES]; + Encoder::fromBase32(suppliedHash.c_str(), tmp, TigerHash::BYTES); + if (memcmp(tiger.finalize(), tmp, TigerHash::BYTES) == 0) { return true; } @@ -284,7 +284,7 @@ tiger2.update(c.getCID().data(), CID::SIZE); tiger2.update(&password[0], password.size()); tiger2.update(&salt[0], salt.size()); - if (memcmp(tiger2.finalize(), tmp, TigerHash::HASH_SIZE) == 0) { + if (memcmp(tiger2.finalize(), tmp, TigerHash::BYTES) == 0) { c.send(AdcCommand(AdcCommand::CMD_MSG).addParam("Your client uses an old PAS encoding, please upgrade")); return true; } Modified: adchpp/trunk/adchpp/SocketManager.cpp =================================================================== --- adchpp/trunk/adchpp/SocketManager.cpp 2008-01-06 19:18:26 UTC (rev 126) +++ adchpp/trunk/adchpp/SocketManager.cpp 2008-01-15 13:53:57 UTC (rev 127) @@ -534,12 +534,16 @@ ssize_t bytes = ::recv(ms->getSocket(), buf->data(), buf->size(), MSG_DONTWAIT); if(bytes == -1) { int error = errno; - if(error != EAGAIN && error != EINTR) { - ms->close(); - disconnect(ms, error); - return false; + if(error == EINTR) { + continue; } - break; + if(error == EAGAIN) { + break; + } + + ms->close(); + disconnect(ms, error); + return false; } else if(bytes == 0) { ms->close(); disconnect(ms, 0); @@ -557,33 +561,31 @@ return; } BufferList buffers; - while(true) { - ms->prepareWrite(buffers); - if(buffers.empty()) { - uint32_t now = GET_TICK(); - if(ms->disc || (ms->isBlocked() && ms->disc < now)) { - disconnect(ms, 0); - } - return; + ms->prepareWrite(buffers); + if(buffers.empty()) { + uint32_t now = GET_TICK(); + if(ms->disc || (ms->isBlocked() && ms->disc < now)) { + disconnect(ms, 0); } - std::vector<iovec> iov(buffers.size()); - for(size_t i = 0; i < buffers.size(); ++i) { - iov[i].iov_base = buffers[i]->data(); - iov[i].iov_len = buffers[i]->size(); - } - ssize_t bytes = ::writev(ms->getSocket(), &iov[0], iov.size()); - if(bytes == -1) { - int error = errno; - if(error == EAGAIN) { - ms->completeWrite(buffers, 0); - return; - } + return; + } + std::vector<iovec> iov(buffers.size()); + for(size_t i = 0; i < buffers.size(); ++i) { + iov[i].iov_base = buffers[i]->data(); + iov[i].iov_len = buffers[i]->size(); + } + ssize_t bytes = ::writev(ms->getSocket(), &iov[0], iov.size()); + if(bytes == -1) { + int error = errno; + if(error == EAGAIN) { + ms->setBlocked(true); + } else if(error != EINTR) { disconnect(ms, error); return; } - if(!ms->completeWrite(buffers, bytes)) { - break; - } + ms->completeWrite(buffers, 0); + } else { + ms->completeWrite(buffers, bytes); } } Modified: adchpp/trunk/adchpp/TigerHash.h =================================================================== --- adchpp/trunk/adchpp/TigerHash.h 2008-01-06 19:18:26 UTC (rev 126) +++ adchpp/trunk/adchpp/TigerHash.h 2008-01-15 13:53:57 UTC (rev 127) @@ -23,8 +23,9 @@ class TigerHash { public: - /** Hash size in bytes */ - enum { HASH_SIZE = 24 }; + /** Hash size */ + static const size_t BITS = 192; + static const size_t BYTES = BITS / 8; TigerHash() : pos(0) { res[0]=_ULL(0x0123456789ABCDEF); Modified: adchpp/trunk/changelog.txt =================================================================== --- adchpp/trunk/changelog.txt 2008-01-06 19:18:26 UTC (rev 126) +++ adchpp/trunk/changelog.txt 2008-01-15 13:53:57 UTC (rev 127) @@ -1,2 +1,7 @@ --- 2.1 06.01.2008 -- - * Initial ADC 1.0 release \ No newline at end of file +-- -- +* access.lua: fixed message type for MSG +* Some minor socket fixes +* Initial Bloom filter implementation + +-- 2.1 2008-01-06 -- +* Initial ADC 1.0 release Modified: adchpp/trunk/plugins/Bloom/src/BloomManager.cpp =================================================================== --- adchpp/trunk/plugins/Bloom/src/BloomManager.cpp 2008-01-06 19:18:26 UTC (rev 126) +++ adchpp/trunk/plugins/Bloom/src/BloomManager.cpp 2008-01-15 13:53:57 UTC (rev 127) @@ -32,6 +32,9 @@ BloomManager* BloomManager::instance = 0; const string BloomManager::className = "BloomManager"; +// TODO Make configurable +const size_t h = 24; + BloomManager::BloomManager() : searches(0), tthSearches(0), stopped(0) { LOG(className, "Starting"); ClientManager* cm = ClientManager::getInstance(); @@ -56,7 +59,7 @@ return; } - size_t k = HashBloom::get_k(n); + size_t k = HashBloom::get_k(n, h); size_t m = HashBloom::get_m(n, k); blooms.erase(c.getSID()); @@ -68,6 +71,7 @@ get.addParam("0"); get.addParam(Util::toString(m/8)); get.addParam("BK", Util::toString(k)); + get.addParam("BH", Util::toString(h)); c.send(get); } } else if(cmd.getCommand() == AdcCommand::CMD_SND) { @@ -149,7 +153,7 @@ if(v.size() == get<1>(i->second) / 8) { HashBloom& bloom = blooms[c.getSID()]; - bloom.reset(v, get<2>(i->second)); + bloom.reset(v, get<2>(i->second), h); pending.erase(i); } } Modified: adchpp/trunk/plugins/Bloom/src/HashBloom.cpp =================================================================== --- adchpp/trunk/plugins/Bloom/src/HashBloom.cpp 2008-01-06 19:18:26 UTC (rev 126) +++ adchpp/trunk/plugins/Bloom/src/HashBloom.cpp 2008-01-15 13:53:57 UTC (rev 127) @@ -1,8 +1,9 @@ #include "stdinc.h" + #include "HashBloom.h" -size_t HashBloom::get_k(size_t n) { - for(size_t k = TTHValue::SIZE/3; k > 1; --k) { +size_t HashBloom::get_k(size_t n, size_t h) { + for(size_t k = TTHValue::BITS/h; k > 1; --k) { uint64_t m = get_m(n, k); if(m >> 24 == 0) { return k; @@ -13,8 +14,8 @@ uint64_t HashBloom::get_m(size_t n, size_t k) { uint64_t m = (static_cast<uint64_t>(ceil(static_cast<double>(n) * k / log(2.)))); - // 64-bit boundary allows us to use a bitset based on uint64_t's - return ((m / 64) + 1) * 64; + // 64-bit boundary as per spec + return ((m + 63 )/ 64) * 64; } void HashBloom::add(const TTHValue& tth) { @@ -39,8 +40,9 @@ bloom.push_back(v); } -void HashBloom::reset(ByteVector& v, size_t k_) { +void HashBloom::reset(ByteVector& v, size_t k_, size_t h_) { k = k_; + h = h_; bloom.resize(v.size() * 8); for(size_t i = 0; i < v.size(); ++i) { @@ -51,12 +53,22 @@ } size_t HashBloom::pos(const TTHValue& tth, size_t n) const { - uint32_t x = 0; - for(size_t i = n*3; i < TTHValue::SIZE; i += 3*k) { - x ^= static_cast<uint32_t>(tth.data[i]) << 2*8; - x ^= static_cast<uint32_t>(tth.data[i+1]) << 8; - x ^= static_cast<uint32_t>(tth.data[i+2]); + uint64_t x = 0; + + size_t start = n * h; + if((n+1)*h > TTHValue::BITS) { + return 0; } + + for(size_t i = 0; i < h; ++i) { + size_t bit = start + i; + size_t byte = bit / 8; + size_t pos = bit % 8; + + if(tth.data[byte] & (1 << pos)) { + x |= (1 << i); + } + } return x % bloom.size(); } Modified: adchpp/trunk/plugins/Bloom/src/HashBloom.h =================================================================== --- adchpp/trunk/plugins/Bloom/src/HashBloom.h 2008-01-06 19:18:26 UTC (rev 126) +++ adchpp/trunk/plugins/Bloom/src/HashBloom.h 2008-01-15 13:53:57 UTC (rev 127) @@ -15,14 +15,16 @@ */ class HashBloom { public: + HashBloom() : k(0), h(0) { } + /** Return a suitable value for k based on n */ - static size_t get_k(size_t n); + static size_t get_k(size_t n, size_t h); /** Optimal number of bits to allocate for n elements when using k hashes */ static uint64_t get_m(size_t n, size_t k); void add(const TTHValue& tth); bool match(const TTHValue& tth) const; - void reset(ByteVector& v, size_t k); + void reset(ByteVector& v, size_t k, size_t h); void push_back(bool v); size_t size() const { return bloom.size(); } @@ -32,6 +34,7 @@ std::vector<bool> bloom; size_t k; + size_t h; }; #endif /*HASHBLOOM_H_*/ Modified: adchpp/trunk/plugins/Bloom/src/HashValue.h =================================================================== --- adchpp/trunk/plugins/Bloom/src/HashValue.h 2008-01-06 19:18:26 UTC (rev 126) +++ adchpp/trunk/plugins/Bloom/src/HashValue.h 2008-01-15 13:53:57 UTC (rev 127) @@ -24,21 +24,22 @@ template<class Hasher> struct HashValue { - static const size_t SIZE = Hasher::HASH_SIZE; + static const size_t BITS = Hasher::BITS; + static const size_t BYTES = Hasher::BYTES; HashValue() { } - explicit HashValue(uint8_t* aData) { memcpy(data, aData, SIZE); } - explicit HashValue(const std::string& base32) { Encoder::fromBase32(base32.c_str(), data, SIZE); } - HashValue(const HashValue& rhs) { memcpy(data, rhs.data, SIZE); } - HashValue& operator=(const HashValue& rhs) { memcpy(data, rhs.data, SIZE); return *this; } + explicit HashValue(uint8_t* aData) { memcpy(data, aData, BYTES); } + explicit HashValue(const std::string& base32) { Encoder::fromBase32(base32.c_str(), data, BYTES); } + HashValue(const HashValue& rhs) { memcpy(data, rhs.data, BYTES); } + HashValue& operator=(const HashValue& rhs) { memcpy(data, rhs.data, BYTES); return *this; } bool operator!=(const HashValue& rhs) const { return !(*this == rhs); } - bool operator==(const HashValue& rhs) const { return memcmp(data, rhs.data, SIZE) == 0; } - bool operator<(const HashValue& rhs) const { return memcmp(data, rhs.data, SIZE) < 0; } + bool operator==(const HashValue& rhs) const { return memcmp(data, rhs.data, BYTES) == 0; } + bool operator<(const HashValue& rhs) const { return memcmp(data, rhs.data, BYTES) < 0; } - std::string toBase32() const { return Encoder::toBase32(data, SIZE); } - std::string& toBase32(std::string& tmp) const { return Encoder::toBase32(data, SIZE, tmp); } + std::string toBase32() const { return Encoder::toBase32(data, BYTES); } + std::string& toBase32(std::string& tmp) const { return Encoder::toBase32(data, BYTES, tmp); } - uint8_t data[SIZE]; + uint8_t data[BYTES]; }; namespace std { namespace tr1 { Modified: adchpp/trunk/swig/adchpp.i =================================================================== --- adchpp/trunk/swig/adchpp.i 2008-01-06 19:18:26 UTC (rev 126) +++ adchpp/trunk/swig/adchpp.i 2008-01-15 13:53:57 UTC (rev 127) @@ -680,7 +680,7 @@ class TigerHash { public: /** Hash size in bytes */ - enum { HASH_SIZE = 24 }; + enum { BITS = 192, BYTES = BITS / 8 }; // Keep old name for a while TigerHash(); @@ -689,7 +689,7 @@ self->update(data.data(), data.size()); } std::string finalize() { - return std::string(reinterpret_cast<const char*>(self->finalize()), TigerHash::HASH_SIZE); + return std::string(reinterpret_cast<const char*>(self->finalize()), TigerHash::BYTES); } } }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2008-01-29 17:23:43
|
Revision: 129 http://adchpp.svn.sourceforge.net/adchpp/?rev=129&view=rev Author: arnetheduck Date: 2008-01-29 09:23:40 -0800 (Tue, 29 Jan 2008) Log Message: ----------- resend fix Modified Paths: -------------- adchpp/trunk/adchpp/ManagedSocket.cpp adchpp/trunk/changelog.txt Modified: adchpp/trunk/adchpp/ManagedSocket.cpp =================================================================== --- adchpp/trunk/adchpp/ManagedSocket.cpp 2008-01-18 22:36:54 UTC (rev 128) +++ adchpp/trunk/adchpp/ManagedSocket.cpp 2008-01-29 17:23:40 UTC (rev 129) @@ -98,14 +98,13 @@ // Copy as many buffers as possible // TODO The last copied buffer should be split... size_t done = 0; - BufferList::iterator i; - for(i = outBuf.begin(); i != outBuf.end(); ++i) { + BufferList::iterator i = outBuf.begin(); + do { buffers.push_back(*i); done += (*i)->size(); - if(done > max_send) { - break; - } - } + ++i; + } while((i != outBuf.end()) && (done < max_send)); + outBuf.erase(outBuf.begin(), i); } else { buffers.swap(outBuf); @@ -135,6 +134,7 @@ (*i)->erase_first(diff); } + dcdebug("Tried %u buffers, readding %u buffers, diff is %u\n", buffers.size(), std::distance(i, buffers.end()), diff); outBuf.insert(outBuf.begin(), i, buffers.end()); } Modified: adchpp/trunk/changelog.txt =================================================================== --- adchpp/trunk/changelog.txt 2008-01-18 22:36:54 UTC (rev 128) +++ adchpp/trunk/changelog.txt 2008-01-29 17:23:40 UTC (rev 129) @@ -2,6 +2,7 @@ * access.lua: fixed message type for MSG * Some minor socket fixes * Initial Bloom filter implementation +* Fixed 100% cpu / infinite resend bug -- 2.1 2008-01-06 -- * Initial ADC 1.0 release This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pie...@us...> - 2008-02-12 20:22:00
|
Revision: 132 http://adchpp.svn.sourceforge.net/adchpp/?rev=132&view=rev Author: pietricica Date: 2008-02-12 12:21:54 -0800 (Tue, 12 Feb 2008) Log Message: ----------- updated nsi, version, and changelog Modified Paths: -------------- adchpp/trunk/ADCHPP.nsi adchpp/trunk/adchpp/version.cpp adchpp/trunk/changelog.txt Modified: adchpp/trunk/ADCHPP.nsi =================================================================== --- adchpp/trunk/ADCHPP.nsi 2008-02-11 19:20:52 UTC (rev 131) +++ adchpp/trunk/ADCHPP.nsi 2008-02-12 20:21:54 UTC (rev 132) @@ -2,7 +2,7 @@ ; HM NIS Edit Wizard helper defines !define PRODUCT_NAME "ADCH++" -!define PRODUCT_VERSION "2.1" +!define PRODUCT_VERSION "2.2" !define PRODUCT_PUBLISHER "Jacek Sieka" !define PRODUCT_WEB_SITE "http://adchpp.sourceforge.net" !define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\adchppd.exe" @@ -56,9 +56,8 @@ File "adchppd.exe" File "adchpp.dll" File "_pyadchpp.dll" - File "aintl.dll" - File "alua.dll" File "Bloom.dll" + File "alua.dll" File "changelog.txt" File "License.txt" File "luadchpp.dll" @@ -137,7 +136,6 @@ Delete "$INSTDIR\changelog.txt" Delete "$INSTDIR\Bloom.dll" Delete "$INSTDIR\alua.dll" - Delete "$INSTDIR\aintl.dll" Delete "$INSTDIR\_pyadchpp.dll" Delete "$INSTDIR\adchpp.dll" Delete "$INSTDIR\adchppd.exe" Modified: adchpp/trunk/adchpp/version.cpp =================================================================== --- adchpp/trunk/adchpp/version.cpp 2008-02-11 19:20:52 UTC (rev 131) +++ adchpp/trunk/adchpp/version.cpp 2008-02-12 20:21:54 UTC (rev 132) @@ -9,8 +9,8 @@ #define strver(s) #s #define APPNAME "ADCH++" -#define VERSIONSTRING "2.1.0 (r" xstrver(ADCHPP_REVISION) ")" -#define VERSIONFLOAT 2.1 +#define VERSIONSTRING "2.2.0 (r" xstrver(ADCHPP_REVISION) ")" +#define VERSIONFLOAT 2.2 #ifndef NDEBUG #define BUILDSTRING "Debug" Modified: adchpp/trunk/changelog.txt =================================================================== --- adchpp/trunk/changelog.txt 2008-02-11 19:20:52 UTC (rev 131) +++ adchpp/trunk/changelog.txt 2008-02-12 20:21:54 UTC (rev 132) @@ -1,4 +1,4 @@ --- -- +-- 2.2 2008-02-12 -- * access.lua: fixed message type for MSG * Some minor socket fixes * Initial Bloom filter implementation This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2008-05-02 12:42:22
|
Revision: 134 http://adchpp.svn.sourceforge.net/adchpp/?rev=134&view=rev Author: arnetheduck Date: 2008-05-02 05:42:20 -0700 (Fri, 02 May 2008) Log Message: ----------- add readme conf, include bloom in default config Modified Paths: -------------- adchpp/trunk/etc/adchpp.xml Added Paths: ----------- adchpp/trunk/readme.conf Modified: adchpp/trunk/etc/adchpp.xml =================================================================== --- adchpp/trunk/etc/adchpp.xml 2008-02-13 08:51:30 UTC (rev 133) +++ adchpp/trunk/etc/adchpp.xml 2008-05-02 12:42:20 UTC (rev 134) @@ -68,5 +68,7 @@ <Plugins> <!-- This plugins provides the scripting support. --> <Plugin>Script</Plugin> + <!-- Bloom filter plugin, helps save upload bandwidth at a slight expense of memory and download bandwidth --> + <Plugin>Bloom</Bloom> </Plugins> </ADCHubPlusPlus> Added: adchpp/trunk/readme.conf =================================================================== --- adchpp/trunk/readme.conf (rev 0) +++ adchpp/trunk/readme.conf 2008-05-02 12:42:20 UTC (rev 134) @@ -0,0 +1,8 @@ +[attributes] +numbered +toc +frame="all" +grid="all" + +[tabledef-default] +colspec= This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2007-11-18 20:59:02
|
Revision: 94 http://adchpp.svn.sourceforge.net/adchpp/?rev=94&view=rev Author: arnetheduck Date: 2007-11-18 12:58:59 -0800 (Sun, 18 Nov 2007) Log Message: ----------- Remove StringDefs etc in preparation for gettext Modified Paths: -------------- adchpp/trunk/SConstruct adchpp/trunk/adchpp/CID.h adchpp/trunk/adchpp/ClientManager.cpp adchpp/trunk/adchpp/ClientManager.h adchpp/trunk/adchpp/File.h adchpp/trunk/adchpp/SettingsManager.cpp adchpp/trunk/adchpp/SettingsManager.h adchpp/trunk/adchpp/Util.cpp adchpp/trunk/adchpp/Util.h adchpp/trunk/adchpp/adchpp.cpp adchpp/trunk/swig/adchpp.i adchpp/trunk/swig/lua.i Removed Paths: ------------- adchpp/trunk/adchpp/ResourceManager.cpp adchpp/trunk/adchpp/ResourceManager.h adchpp/trunk/adchpp/StringDefs.cpp adchpp/trunk/adchpp/StringDefs.h adchpp/trunk/makedefs.py Property Changed: ---------------- adchpp/trunk/ adchpp/trunk/plugins/Bloom/src/ adchpp/trunk/plugins/Script/src/ Property changes on: adchpp/trunk ___________________________________________________________________ Name: svn:ignore - build STLport .* + build STLport .* custom.py Modified: adchpp/trunk/SConstruct =================================================================== --- adchpp/trunk/SConstruct 2007-11-18 19:04:42 UTC (rev 93) +++ adchpp/trunk/SConstruct 2007-11-18 20:58:59 UTC (rev 94) @@ -2,17 +2,6 @@ from build_util import Dev -opts = Options('custom.py', ARGUMENTS) - -opts.AddOptions( - EnumOption('tools', 'Toolset to compile with, default = platform default (msvc under windows)', 'mingw', ['mingw', 'default']), - EnumOption('mode', 'Compile mode', 'debug', ['debug', 'release']), - BoolOption('nativestl', 'Use native STL instead of STLPort', 'yes'), - BoolOption('verbose', 'Show verbose command lines', 'no'), - BoolOption('savetemps', 'Save intermediate compilation files (assembly output)', 'no'), - ('prefix', 'Prefix to use when cross compiling', 'i386-mingw32-') -) - gcc_flags = { 'common': ['-ggdb', '-Wall', '-Wextra', '-pipe', '-Wno-unused-parameter', '-Wno-missing-field-initializers', '-fexceptions'], 'debug': [], @@ -67,6 +56,21 @@ import os,sys +plugins = filter(lambda x: os.path.isfile(os.path.join('plugins', x, 'SConscript')), os.listdir('plugins')) + +opts = Options('custom.py', ARGUMENTS) + +opts.AddOptions( + EnumOption('tools', 'Toolset to compile with, default = platform default (msvc under windows)', 'mingw', ['mingw', 'default']), + EnumOption('mode', 'Compile mode', 'debug', ['debug', 'release']), + ListOption('plugins', 'The plugins to compile', 'all', plugins), + BoolOption('nativestl', 'Use native STL instead of STLPort', 'yes'), + BoolOption('verbose', 'Show verbose command lines', 'no'), + BoolOption('savetemps', 'Save intermediate compilation files (assembly output)', 'no'), + ('prefix', 'Prefix to use when cross compiling', 'i386-mingw32-') +) + + if sys.platform == 'win32': tooldef = 'mingw' else: @@ -174,6 +178,6 @@ dev.build('swig/') # Plugins -dev.build('plugins/Script/') -dev.build('plugins/Bloom/') +for plugin in env['plugins']: + dev.build('plugins/' + plugin + '/') Modified: adchpp/trunk/adchpp/CID.h =================================================================== --- adchpp/trunk/adchpp/CID.h 2007-11-18 19:04:42 UTC (rev 93) +++ adchpp/trunk/adchpp/CID.h 2007-11-18 20:58:59 UTC (rev 94) @@ -19,6 +19,7 @@ #ifndef ADCHPP_CID_H #define ADCHPP_CID_H +#include "Util.h" #include "Encoder.h" namespace adchpp { @@ -29,10 +30,6 @@ enum { BASE32_SIZE = 39 }; struct Hash { -#if _MSC_VER >= 1300 - static const size_t bucket_size = 4; - static const size_t min_buckets = 8; -#endif size_t operator()(const CID& c) const { return c.toHash(); } bool operator()(const CID& a, const CID& b) const { return a < b; } }; Modified: adchpp/trunk/adchpp/ClientManager.cpp =================================================================== --- adchpp/trunk/adchpp/ClientManager.cpp 2007-11-18 19:04:42 UTC (rev 93) +++ adchpp/trunk/adchpp/ClientManager.cpp 2007-11-18 20:58:59 UTC (rev 94) @@ -373,7 +373,7 @@ if(j != clients.end()) { j->second->send("\n"); } - c.send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_CID_TAKEN, STRING(CID_TAKEN))); + c.send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_CID_TAKEN, "CID taken, please try again later")); c.disconnect(Util::REASON_CID_TAKEN); return false; } @@ -396,7 +396,7 @@ dcdebug("%s verifying nick\n", AdcCommand::fromSID(c.getSID()).c_str()); for(string::size_type i = 0; i < strtmp.length(); ++i) { if((uint8_t)strtmp[i] < 33) { - c.send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_NICK_INVALID, STRING(NICK_INVALID))); + c.send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_NICK_INVALID, "Invalid character in nick")); c.disconnect(Util::REASON_NICK_INVALID); return false; } @@ -406,7 +406,7 @@ nicks.erase(oldNick); if(nicks.find(strtmp) != nicks.end()) { - c.send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_NICK_TAKEN, STRING(NICK_TAKEN))); + c.send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_NICK_TAKEN, "Nick taken, please pick another one")); c.disconnect(Util::REASON_NICK_TAKEN); return false; } Modified: adchpp/trunk/adchpp/ClientManager.h =================================================================== --- adchpp/trunk/adchpp/ClientManager.h 2007-11-18 19:04:42 UTC (rev 93) +++ adchpp/trunk/adchpp/ClientManager.h 2007-11-18 20:58:59 UTC (rev 94) @@ -19,11 +19,11 @@ #ifndef ADCHPP_CLIENTMANAGER_H #define ADCHPP_CLIENTMANAGER_H -#include "Util.h" #include "CID.h" #include "AdcCommand.h" #include "Signal.h" #include "Client.h" +#include "Singleton.h" namespace adchpp { Modified: adchpp/trunk/adchpp/File.h =================================================================== --- adchpp/trunk/adchpp/File.h 2007-11-18 19:04:42 UTC (rev 93) +++ adchpp/trunk/adchpp/File.h 2007-11-18 20:58:59 UTC (rev 94) @@ -21,7 +21,6 @@ #include "Exception.h" #include "Util.h" -#include "ResourceManager.h" #ifndef _WIN32 #include <sys/stat.h> @@ -150,7 +149,7 @@ if(x == -1) throw FileException(Util::translateError(errno)); if(x < (ssize_t)len) - throw FileException(STRING(DISK_FULL)); + throw FileException("Unable to write, disk full?"); } /** Deleted: adchpp/trunk/adchpp/ResourceManager.cpp =================================================================== --- adchpp/trunk/adchpp/ResourceManager.cpp 2007-11-18 19:04:42 UTC (rev 93) +++ adchpp/trunk/adchpp/ResourceManager.cpp 2007-11-18 20:58:59 UTC (rev 94) @@ -1,66 +0,0 @@ -/* - * Copyright (C) 2006-2007 Jacek Sieka, arnetheduck on gmail point com - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "adchpp.h" - -#include "ResourceManager.h" - -#include "SimpleXML.h" -#include "File.h" -#include "LogManager.h" - -namespace adchpp { - -using namespace std; -using namespace std::tr1; - -ResourceManager* ResourceManager::instance = 0; -const string ResourceManager::className = "ResourceManager"; - -void ResourceManager::loadLanguage(const string& aFile) { - try { - File f(aFile, File::READ, File::OPEN); - SimpleXML xml; - xml.fromXML(f.read()); - - unordered_map<string, int> h; - - for(int i = 0; i < LAST; ++i) { - h[names[i]] = i; - } - - if(xml.findChild("Language")) { - xml.stepIn(); - if(xml.findChild("Strings")) { - xml.stepIn(); - - while(xml.findChild("String")) { - unordered_map<string, int>::iterator j = h.find(xml.getChildAttrib("Name")); - - if(j != h.end()) { - strings[j->second] = xml.getChildData(); - } - } - } - } - } catch(const Exception& e) { - LOGDT(className, "Failed to load language file: " + e.getError()); - } -} - -} Deleted: adchpp/trunk/adchpp/ResourceManager.h =================================================================== --- adchpp/trunk/adchpp/ResourceManager.h 2007-11-18 19:04:42 UTC (rev 93) +++ adchpp/trunk/adchpp/ResourceManager.h 2007-11-18 20:58:59 UTC (rev 94) @@ -1,57 +0,0 @@ -/* - * Copyright (C) 2006-2007 Jacek Sieka, arnetheduck on gmail point com - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef ADCHPP_RESOURCEMANAGER_H -#define ADCHPP_RESOURCEMANAGER_H - -#include "Singleton.h" - -namespace adchpp { - -/** - * This class takes care of internationalization, providing the correct strings. - */ -class ResourceManager : public Singleton<ResourceManager> { -public: - -#include "StringDefs.h" - - void loadLanguage(const std::string& aFile); - const std::string& getString(Strings x) const { return strings[x]; } - -private: - - friend class Singleton<ResourceManager>; - - ADCHPP_DLL static ResourceManager* instance; - - ResourceManager() throw() { } - virtual ~ResourceManager() throw() { } - - ADCHPP_DLL static std::string strings[LAST]; - static std::string names[LAST]; - - static const std::string className; -}; - -#define STRING(x) ResourceManager::getInstance()->getString(ResourceManager::x) -#define CSTRING(x) ResourceManager::getInstance()->getString(ResourceManager::x).c_str() - -} - -#endif // RESOURCEMANAGER_H Modified: adchpp/trunk/adchpp/SettingsManager.cpp =================================================================== --- adchpp/trunk/adchpp/SettingsManager.cpp 2007-11-18 19:04:42 UTC (rev 93) +++ adchpp/trunk/adchpp/SettingsManager.cpp 2007-11-18 20:58:59 UTC (rev 94) @@ -36,7 +36,6 @@ { // Strings "HubName", "ServerIp", "LogFile", "Description", - "LanguageFile", "SENTRY", // Ints "ServerPort", "Log", "KeepSlowUsers", @@ -57,7 +56,6 @@ // set(SERVER_IP, ""); set(LOG_FILE, "logs/adchpp%Y%m.log"); set(DESCRIPTION, versionString); - // set(LANGUAGE_FILE, "Example.adchpp.xml"); set(SERVER_PORT, 2780); set(LOG, 1); set(KEEP_SLOW_USERS, 0); @@ -73,7 +71,7 @@ } bool SettingsManager::getType(const char* name, int& n, int& type) { - for(n = 0; n < INT64_LAST; n++) { + for(n = 0; n < SETTINGS_LAST; n++) { if(strcmp(settingTags[n].c_str(), name) == 0) { if(n < STR_LAST) { type = TYPE_STRING; @@ -81,9 +79,6 @@ } else if(n < INT_LAST) { type = TYPE_INT; return true; - } else { - type = TYPE_INT64; - return true; } } } @@ -127,16 +122,6 @@ LOGDT(className, attr + " missing from settings, using default"); xml.resetCurrentChild(); } - for(i=INT64_FIRST; i<INT64_LAST; i++) { - attr = settingTags[i]; - dcassert(attr.find("SENTRY") == string::npos); - - if(xml.findChild(attr)) - set(Int64Setting(i), Util::toInt64(xml.getChildData())); - else - LOGDT(className, attr + " missing from settings, using default"); - xml.resetCurrentChild(); - } xml.stepOut(); Modified: adchpp/trunk/adchpp/SettingsManager.h =================================================================== --- adchpp/trunk/adchpp/SettingsManager.h 2007-11-18 19:04:42 UTC (rev 93) +++ adchpp/trunk/adchpp/SettingsManager.h 2007-11-18 20:58:59 UTC (rev 94) @@ -21,6 +21,7 @@ #include "Util.h" #include "Signal.h" +#include "Singleton.h" namespace adchpp { @@ -45,11 +46,8 @@ MAX_SEND_SIZE, MAX_BUFFER_SIZE, BUFFER_SIZE, MAX_COMMAND_SIZE, OVERFLOW_TIMEOUT, DISCONNECT_TIMEOUT, FLOOD_ADD, FLOOD_THRESHOLD, LOGIN_TIMEOUT, - INT_LAST }; + INT_LAST, SETTINGS_LAST = INT_LAST }; - enum Int64Setting { INT64_FIRST = INT_LAST + 1, - INT64_LAST = INT64_FIRST, SETTINGS_LAST = INT64_LAST }; - /** * Get the type of setting based on its name. By using the type info you can * convert the n to the proper enum type and get the setting. @@ -72,9 +70,6 @@ int get(IntSetting key) const { return intSettings[key - INT_FIRST]; } - int64_t get(Int64Setting key) const { - return int64Settings[key - INT64_FIRST]; - } bool getBool(IntSetting key) const { return (get(key) > 0); @@ -92,17 +87,6 @@ intSettings[key - INT_FIRST] = Util::toInt(value); } - void set(Int64Setting key, int64_t value) { - int64Settings[key - INT64_FIRST] = value; - } - void set(Int64Setting key, int value) { - int64Settings[key - INT64_FIRST] = value; - } - - template<typename T> void set(Int64Setting key, const T& value) { - int64Settings[key - INT64_FIRST] = Util::toInt64(value); - } - void set(IntSetting key, bool value) { set(key, (int)value); } void load() { Deleted: adchpp/trunk/adchpp/StringDefs.cpp =================================================================== --- adchpp/trunk/adchpp/StringDefs.cpp 2007-11-18 19:04:42 UTC (rev 93) +++ adchpp/trunk/adchpp/StringDefs.cpp 2007-11-18 20:58:59 UTC (rev 94) @@ -1,29 +0,0 @@ -#include "adchpp.h" -#include "ResourceManager.h" -namespace adchpp { -using namespace std; -string ResourceManager::strings[] = { -"B", -"CID taken", -"Disk full?", -"GiB", -"Hub is currently full", -"KiB", -"MiB", -"Your nick contains invalid characters. Adios.", -"Your nick is already taken, please select another one", -"TiB", -}; -string ResourceManager::names[] = { -"B", -"CidTaken", -"DiskFull", -"Gb", -"HubFull", -"Kb", -"Mb", -"NickInvalid", -"NickTaken", -"Tb", -}; -} Deleted: adchpp/trunk/adchpp/StringDefs.h =================================================================== --- adchpp/trunk/adchpp/StringDefs.h 2007-11-18 19:04:42 UTC (rev 93) +++ adchpp/trunk/adchpp/StringDefs.h 2007-11-18 20:58:59 UTC (rev 94) @@ -1,23 +0,0 @@ -// @Prolog: #include "adchpp.h" -// @Prolog: #include "ResourceManager.h" -// @Prolog: namespace adchpp { -// @Prolog: using namespace std; - -// @Strings: string ResourceManager::strings[] -// @Names: string ResourceManager::names[] - -enum Strings { // @DontAdd - B, // "B" - CID_TAKEN, // "CID taken" - DISK_FULL, // "Disk full?" - GB, // "GiB" - HUB_FULL, // "Hub is currently full" - KB, // "KiB" - MB, // "MiB" - NICK_INVALID, // "Your nick contains invalid characters. Adios." - NICK_TAKEN, // "Your nick is already taken, please select another one" - TB, // "TiB" - LAST // @DontAdd -}; - -// @Epilog: } Modified: adchpp/trunk/adchpp/Util.cpp =================================================================== --- adchpp/trunk/adchpp/Util.cpp 2007-11-18 19:04:42 UTC (rev 93) +++ adchpp/trunk/adchpp/Util.cpp 2007-11-18 20:58:59 UTC (rev 94) @@ -232,15 +232,15 @@ string Util::formatBytes(int64_t aBytes) { char buf[64]; if(aBytes < 1024) { - sprintf(buf, "%d %s", (int)(aBytes&0xffffffff), CSTRING(B)); + sprintf(buf, "%d B", (int)(aBytes&0xffffffff)); } else if(aBytes < 1024*1024) { - sprintf(buf, "%.02f %s", (double)aBytes/(1024.0), CSTRING(KB)); + sprintf(buf, "%.02f KiB", (double)aBytes/(1024.0)); } else if(aBytes < 1024*1024*1024) { - sprintf(buf, "%.02f %s", (double)aBytes/(1024.0*1024.0), CSTRING(MB)); + sprintf(buf, "%.02f MiB", (double)aBytes/(1024.0*1024.0)); } else if(aBytes < (int64_t)1024*1024*1024*1024) { - sprintf(buf, "%.02f %s", (double)aBytes/(1024.0*1024.0*1024.0), CSTRING(GB)); + sprintf(buf, "%.02f GiB", (double)aBytes/(1024.0*1024.0*1024.0)); } else { - sprintf(buf, "%.02f %s", (double)aBytes/(1024.0*1024.0*1024.0*1024.0), CSTRING(TB)); + sprintf(buf, "%.02f TiB", (double)aBytes/(1024.0*1024.0*1024.0*1024.0)); } return buf; Modified: adchpp/trunk/adchpp/Util.h =================================================================== --- adchpp/trunk/adchpp/Util.h 2007-11-18 19:04:42 UTC (rev 93) +++ adchpp/trunk/adchpp/Util.h 2007-11-18 20:58:59 UTC (rev 94) @@ -19,7 +19,6 @@ #ifndef ADCHPP_UTIL_H #define ADCHPP_UTIL_H -#include "ResourceManager.h" #include "Pool.h" #include "Mutex.h" Modified: adchpp/trunk/adchpp/adchpp.cpp =================================================================== --- adchpp/trunk/adchpp/adchpp.cpp 2007-11-18 19:04:42 UTC (rev 93) +++ adchpp/trunk/adchpp/adchpp.cpp 2007-11-18 20:58:59 UTC (rev 94) @@ -47,7 +47,6 @@ Util::initialize(configPath); - ResourceManager::newInstance(); SettingsManager::newInstance(); LogManager::newInstance(); TimerManager::newInstance(); @@ -63,14 +62,6 @@ if(!initialized) { throw Exception("adchpp not initialized"); } -/* if(!SETTING(LANGUAGE_FILE).empty()) { - if(File::isAbsolutePath(SETTING(LANGUAGE_FILE))) { - ResourceManager::getInstance()->loadLanguage(SETTING(LANGUAGE_FILE)); - } else { - ResourceManager::getInstance()->loadLanguage(Util::getCfgPath() + SETTING(LANGUAGE_FILE)); - } - } -*/ Stats::startTime = GET_TIME(); if(f) f(); @@ -114,7 +105,6 @@ LogManager::deleteInstance(); SettingsManager::deleteInstance(); TimerManager::deleteInstance(); - ResourceManager::deleteInstance(); #ifdef _WIN32 WSACleanup(); Deleted: adchpp/trunk/makedefs.py =================================================================== --- adchpp/trunk/makedefs.py 2007-11-18 19:04:42 UTC (rev 93) +++ adchpp/trunk/makedefs.py 2007-11-18 20:58:59 UTC (rev 94) @@ -1,64 +0,0 @@ -import re -import codecs -import xml.sax.saxutils - -def makename(oldname): - name = ""; - nextBig = True; - for x in oldname: - if x == '_': - nextBig = True; - else: - if nextBig: - name += x.upper(); - nextBig = False; - else: - name += x.lower(); - - return name; - - -version = re.search("VERSIONFLOAT (\S+)", file("adchpp/version.cpp").read()).group(1) - -varstr = ""; -strings = ""; -varname = ""; -names = ""; - -prolog = ""; -epilog = ""; - -example = '<?xml version="1.0" encoding="utf-8" standalone="yes"?>\n'; -example += '<Language Name="Example Language" Author="arnetheduck" Version=' + version + ' Revision="1">\n' -example += '\t<Strings>\n'; - -lre = re.compile('\s*(\w+),\s*//\s*\"(.+)\"\s*') - -decoder = codecs.getdecoder('cp1252') -encoder = codecs.getencoder('utf8') -recodeattr = lambda s: encoder(decoder(xml.sax.saxutils.quoteattr(s))[0])[0] -recodeval = lambda s: encoder(decoder(xml.sax.saxutils.escape(s, {"\\t" : "\t"}))[0])[0] - -for x in file("adchpp/StringDefs.h", "r"): - if x.startswith("// @Strings: "): - varstr = x[13:].strip(); - elif x.startswith("// @Names: "): - varname = x[11:].strip(); - elif x.startswith("// @Prolog: "): - prolog += x[12:]; - elif x.startswith("// @Epilog: "): - epilog += x[12:]; - elif len(x) >= 5: - match = lre.match(x); - if match is not None: - name , value = match.groups(); - strings += '"' + value + '", \n' - newname = makename(name) - names += '"' + newname + '", \n' - example += '\t\t<String Name=%s>%s</String>\n' % (recodeattr(newname), recodeval(value)) - -example += '\t</Strings>\n'; -example += '</Language>\n'; - -file('adchpp/StringDefs.cpp', 'w').write(prolog + varstr + " = {\n" + strings + "};\n" + varname + " = {\n" + names + "};\n" + epilog); -file('etc/Example.adchpp.xml', 'w').write(example); Property changes on: adchpp/trunk/plugins/Bloom/src ___________________________________________________________________ Name: svn:ignore + stdinc.h.gch Property changes on: adchpp/trunk/plugins/Script/src ___________________________________________________________________ Name: svn:ignore - .sconsign + .sconsign stdinc.h.gch Modified: adchpp/trunk/swig/adchpp.i =================================================================== --- adchpp/trunk/swig/adchpp.i 2007-11-18 19:04:42 UTC (rev 93) +++ adchpp/trunk/swig/adchpp.i 2007-11-18 20:58:59 UTC (rev 94) @@ -624,7 +624,6 @@ enum StrSetting { STR_FIRST, HUB_NAME = STR_FIRST, SERVER_IP, LOG_FILE, DESCRIPTION, - LANGUAGE_FILE, STR_LAST }; enum IntSetting { INT_FIRST = STR_LAST + 1, @@ -634,9 +633,6 @@ LOGIN_TIMEOUT, INT_LAST }; - enum Int64Setting { INT64_FIRST = INT_LAST + 1, - INT64_LAST = INT64_FIRST, SETTINGS_LAST = INT64_LAST }; - //bool getType(const char* name, int& n, int& type); const std::string& getName(int n) { dcassert(n < SETTINGS_LAST); return settingTags[n]; } @@ -647,19 +643,12 @@ int getInt(IntSetting key) { return self->get(key); } - int64_t getInt64(Int64Setting key) { - return self->get(key); - } - void setString(StrSetting key, std::string const& value) { self->set(key, value); } void setInt(IntSetting key, int value) { self->set(key, value); } - void setInt64(Int64Setting key, int64_t value) { - self->set(key, value); - } void setBool(IntSetting key, bool value) { self->set(key, value); } Modified: adchpp/trunk/swig/lua.i =================================================================== --- adchpp/trunk/swig/lua.i 2007-11-18 19:04:42 UTC (rev 93) +++ adchpp/trunk/swig/lua.i 2007-11-18 20:58:59 UTC (rev 94) @@ -158,3 +158,4 @@ return std::string(); } } + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2007-11-19 14:20:25
|
Revision: 95 http://adchpp.svn.sourceforge.net/adchpp/?rev=95&view=rev Author: arnetheduck Date: 2007-11-19 06:20:21 -0800 (Mon, 19 Nov 2007) Log Message: ----------- win32 fixes Modified Paths: -------------- adchpp/trunk/SConstruct adchpp/trunk/adchpp/File.h adchpp/trunk/adchpp/SConscript adchpp/trunk/adchpp/SocketManager.cpp adchpp/trunk/adchpp/adchpp.h adchpp/trunk/build_util.py adchpp/trunk/lua/SConscript adchpp/trunk/swig/SConscript adchpp/trunk/windows/adchppdw.cpp Modified: adchpp/trunk/SConstruct =================================================================== --- adchpp/trunk/SConstruct 2007-11-18 20:58:59 UTC (rev 94) +++ adchpp/trunk/SConstruct 2007-11-19 14:20:21 UTC (rev 95) @@ -60,8 +60,13 @@ opts = Options('custom.py', ARGUMENTS) +if sys.platform == 'win32': + tooldef = 'mingw' +else: + tooldef = 'default' + opts.AddOptions( - EnumOption('tools', 'Toolset to compile with, default = platform default (msvc under windows)', 'mingw', ['mingw', 'default']), + EnumOption('tools', 'Toolset to compile with, default = platform default (msvc under windows)', tooldef, ['mingw', 'default']), EnumOption('mode', 'Compile mode', 'debug', ['debug', 'release']), ListOption('plugins', 'The plugins to compile', 'all', plugins), BoolOption('nativestl', 'Use native STL instead of STLPort', 'yes'), @@ -71,11 +76,6 @@ ) -if sys.platform == 'win32': - tooldef = 'mingw' -else: - tooldef = 'default' - tools = ARGUMENTS.get('tools', tooldef) toolset = [tools, 'swig'] @@ -98,7 +98,7 @@ env.Append(CPPPATH = ["#/boost/boost/tr1/tr1/", "#/boost/"]) -if env['PLATFORM'] != 'win32': +if not dev.is_win32(): env.Append(CPPDEFINES = ['_XOPEN_SOURCE=500'] ) env.Append(CCFLAGS=['-fvisibility=hidden']) @@ -166,7 +166,7 @@ dev.adchpp = dev.build('adchpp/') -if env['PLATFORM'] == 'win32' or env['PLATFORM'] == 'cygwin': +if dev.is_win32(): dev.build('windows/') else: dev.build('unix/') Modified: adchpp/trunk/adchpp/File.h =================================================================== --- adchpp/trunk/adchpp/File.h 2007-11-18 20:58:59 UTC (rev 94) +++ adchpp/trunk/adchpp/File.h 2007-11-19 14:20:21 UTC (rev 95) @@ -107,7 +107,7 @@ throw FileException(Util::translateError(GetLastError())); } if(x < len) { - throw FileException(STRING(DISK_FULL)); + throw FileException("Unable to write, disk full?"); } } @@ -118,8 +118,8 @@ } } - static void deleteFile(const string& aFileName) { ::DeleteFile(aFileName.c_str()); }; - static void renameFile(const string& source, const string& target) { ::MoveFile(source.c_str(), target.c_str()); }; + static void deleteFile(const std::string& aFileName) { ::DeleteFile(aFileName.c_str()); }; + static void renameFile(const std::string& source, const std::string& target) { ::MoveFile(source.c_str(), target.c_str()); }; #else // WIN32 Modified: adchpp/trunk/adchpp/SConscript =================================================================== --- adchpp/trunk/adchpp/SConscript 2007-11-18 20:58:59 UTC (rev 94) +++ adchpp/trunk/adchpp/SConscript 2007-11-19 14:20:21 UTC (rev 95) @@ -35,8 +35,8 @@ if 'HAVE_PTHREAD' in env['CPPDEFINES']: env.Append(LIBS = ['pthread']) -if env['PLATFORM'] == 'win32': - env.Append(LIBS = ['ws2_32', 'mswsock']) +if dev.is_win32(): + env.Append(LIBS = ['ws2_32', 'mswsock']) if 'gcc' in env['TOOLS']: env['GchSh'] = env.GchSh('adchpp.h')[0] @@ -54,5 +54,4 @@ if env['PLATFORM'] != 'win32': dev.env.Append(RPATH = env.Literal('\\$$ORIGIN')) - Return('ret') Modified: adchpp/trunk/adchpp/SocketManager.cpp =================================================================== --- adchpp/trunk/adchpp/SocketManager.cpp 2007-11-18 20:58:59 UTC (rev 94) +++ adchpp/trunk/adchpp/SocketManager.cpp 2007-11-19 14:20:21 UTC (rev 95) @@ -29,7 +29,7 @@ #include "Thread.h" #ifdef _WIN32 -#include <MSWSock.h> +#include <mswsock.h> #endif #ifdef HAVE_SYS_EPOLL_H @@ -39,6 +39,7 @@ namespace adchpp { using namespace std; +using namespace std::tr1; static uint32_t WRITE_TIMEOUT = 100; @@ -537,7 +538,7 @@ Pool<MSOverlapped, ClearOverlapped> pool; - typedef HASH_SET<ManagedSocketPtr, PointerHash<ManagedSocket> > SocketSet; + typedef unordered_set<ManagedSocketPtr, PointerHash<ManagedSocket> > SocketSet; /** Sockets that have a pending read */ SocketSet active; /** Sockets that have a pending accept */ Modified: adchpp/trunk/adchpp/adchpp.h =================================================================== --- adchpp/trunk/adchpp/adchpp.h 2007-11-18 20:58:59 UTC (rev 94) +++ adchpp/trunk/adchpp/adchpp.h 2007-11-19 14:20:21 UTC (rev 95) @@ -99,7 +99,7 @@ # define ADCHPP_DLL __declspec(dllimport) # endif // DLLEXPORT -#include <Winsock2.h> +#include <winsock2.h> #include <windows.h> #include <tchar.h> Modified: adchpp/trunk/build_util.py =================================================================== --- adchpp/trunk/build_util.py 2007-11-18 20:58:59 UTC (rev 94) +++ adchpp/trunk/build_util.py 2007-11-19 14:20:21 UTC (rev 95) @@ -40,6 +40,9 @@ self.env['PROGSUFFIX'] = '.exe' self.env['LIBPREFIX'] = 'lib' self.env['LIBSUFFIX'] = '.a' + + def is_win32(self): + return sys.platform == 'win32' or 'mingw' in self.env['TOOLS'] def get_build_root(self): return '#/build/' + self.mode + '-' + self.tools + '/' Modified: adchpp/trunk/lua/SConscript =================================================================== --- adchpp/trunk/lua/SConscript 2007-11-18 20:58:59 UTC (rev 94) +++ adchpp/trunk/lua/SConscript 2007-11-19 14:20:21 UTC (rev 95) @@ -2,7 +2,7 @@ env, target, sources = dev.prepare_build(source_path, 'alua', 'all.c') -if env['PLATFORM'] == 'win32': +if dev.is_win32(): env.Append(CPPDEFINES=['LUA_BUILD_AS_DLL=1']) else: env.Append(CPPDEFINES=['LUA_USE_LINUX=1']) Modified: adchpp/trunk/swig/SConscript =================================================================== --- adchpp/trunk/swig/SConscript 2007-11-18 20:58:59 UTC (rev 94) +++ adchpp/trunk/swig/SConscript 2007-11-19 14:20:21 UTC (rev 95) @@ -59,6 +59,11 @@ targets.append(rb) def buildPyModule(): + import sys + if dev.is_win32() and sys.platform != 'win32': + print "Cross-compiling python module not supported" + return + env, target, sources = dev.prepare_build(source_path, '_pyadchpp', 'python.i') env.Append(SWIGFLAGS=['-c++','-threads','-Wall','-python', '-O', '-classic']) Modified: adchpp/trunk/windows/adchppdw.cpp =================================================================== --- adchpp/trunk/windows/adchppdw.cpp 2007-11-18 20:58:59 UTC (rev 94) +++ adchpp/trunk/windows/adchppdw.cpp 2007-11-19 14:20:21 UTC (rev 95) @@ -23,8 +23,8 @@ #include <adchpp/File.h> #include <adchpp/version.h> - using namespace adchpp; +using namespace std; static const string modName = "adchpp"; @@ -169,7 +169,7 @@ SetUnhandledExceptionFilter(&DCUnhandledExceptionFilter); #endif - initConfig(configPath); + initialize(configPath); if(asService) LOGDT(modName, versionString + " started as a service"); @@ -189,6 +189,7 @@ EXTENDEDTRACEUNINITIALIZE(); #endif printf(".\n"); + cleanup(); } Semaphore exitSem; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2007-11-25 21:44:38
|
Revision: 96 http://adchpp.svn.sourceforge.net/adchpp/?rev=96&view=rev Author: arnetheduck Date: 2007-11-25 13:44:36 -0800 (Sun, 25 Nov 2007) Log Message: ----------- Add simple gettext support, fix settings Modified Paths: -------------- adchpp/trunk/SConstruct adchpp/trunk/adchpp/ClientManager.cpp adchpp/trunk/adchpp/ClientManager.h adchpp/trunk/adchpp/Exception.h adchpp/trunk/adchpp/ManagedSocket.h adchpp/trunk/adchpp/SConscript adchpp/trunk/adchpp/SettingsManager.cpp adchpp/trunk/adchpp/SettingsManager.h adchpp/trunk/adchpp/SocketManager.cpp adchpp/trunk/adchpp/SocketManager.h adchpp/trunk/adchpp/adchpp.h adchpp/trunk/build_util.py adchpp/trunk/unix/SConscript adchpp/trunk/unix/main.cpp Added Paths: ----------- adchpp/trunk/adchpp/forward.h adchpp/trunk/intl/ adchpp/trunk/intl/COPYING.LIB-2.0 adchpp/trunk/intl/COPYING.LIB-2.1 adchpp/trunk/intl/SConscript adchpp/trunk/intl/bindtextdom.c adchpp/trunk/intl/config.h adchpp/trunk/intl/dcgettext.c adchpp/trunk/intl/dcigettext.c adchpp/trunk/intl/dcngettext.c adchpp/trunk/intl/dgettext.c adchpp/trunk/intl/dngettext.c adchpp/trunk/intl/eval-plural.h adchpp/trunk/intl/explodename.c adchpp/trunk/intl/finddomain.c adchpp/trunk/intl/gettext.c adchpp/trunk/intl/gettextP.h adchpp/trunk/intl/gmo.h adchpp/trunk/intl/hash-string.c adchpp/trunk/intl/hash-string.h adchpp/trunk/intl/intl-compat.c adchpp/trunk/intl/l10nflist.c adchpp/trunk/intl/langprefs.c adchpp/trunk/intl/libgnuintl.h adchpp/trunk/intl/libgnuintl.h.in adchpp/trunk/intl/libintl.h adchpp/trunk/intl/loadinfo.h adchpp/trunk/intl/loadmsgcat.c adchpp/trunk/intl/localcharset.c adchpp/trunk/intl/localcharset.h adchpp/trunk/intl/locale.alias adchpp/trunk/intl/localealias.c adchpp/trunk/intl/localename.c adchpp/trunk/intl/lock.c adchpp/trunk/intl/lock.h adchpp/trunk/intl/log.c adchpp/trunk/intl/ngettext.c adchpp/trunk/intl/plural-exp.c adchpp/trunk/intl/plural-exp.h adchpp/trunk/intl/plural.c adchpp/trunk/intl/plural.y adchpp/trunk/intl/printf-args.c adchpp/trunk/intl/printf-args.h adchpp/trunk/intl/printf-parse.c adchpp/trunk/intl/printf-parse.h adchpp/trunk/intl/printf.c adchpp/trunk/intl/relocatable.c adchpp/trunk/intl/relocatable.h adchpp/trunk/intl/textdomain.c adchpp/trunk/intl/vasnprintf.c adchpp/trunk/intl/vasnprintf.h adchpp/trunk/intl/vasnwprintf.h adchpp/trunk/intl/version.c adchpp/trunk/intl/wprintf-parse.h adchpp/trunk/intl/xsize.h adchpp/trunk/unix/po/ adchpp/trunk/unix/po/adchppd.pot Modified: adchpp/trunk/SConstruct =================================================================== --- adchpp/trunk/SConstruct 2007-11-19 14:20:21 UTC (rev 95) +++ adchpp/trunk/SConstruct 2007-11-25 21:44:36 UTC (rev 96) @@ -72,6 +72,7 @@ BoolOption('nativestl', 'Use native STL instead of STLPort', 'yes'), BoolOption('verbose', 'Show verbose command lines', 'no'), BoolOption('savetemps', 'Save intermediate compilation files (assembly output)', 'no'), + BoolOption('nls', 'Build with internationalization support', 'yes'), ('prefix', 'Prefix to use when cross compiling', 'i386-mingw32-') ) @@ -153,6 +154,63 @@ ) env.Append(SCANNERS=[SWIGScanner]) +# +# internationalization (taken from the ardour build files (ardour.org) +# + +# po_builder: builder function to copy po files to the parent directory while updating them +# +# first source: .po file +# second source: .pot file +# + +def po_builder(target,source,env): + args = [ 'msgmerge', + '--update', + str(target[0]), + str(source[0]) + ] + print 'Updating ' + str(target[0]) + return os.spawnvp (os.P_WAIT, 'msgmerge', args) + +po_bld = Builder (action = po_builder) +env.Append(BUILDERS = {'PoBuild' : po_bld}) + +# mo_builder: builder function for (binary) message catalogs (.mo) +# +# first source: .po file +# +def mo_builder(target,source,env): + args = [ 'msgfmt', + '-c', + '-o', + target[0].get_path(), + source[0].get_path() + ] + return os.spawnvp (os.P_WAIT, 'msgfmt', args) + +mo_bld = Builder (action = mo_builder) +env.Append(BUILDERS = {'MoBuild' : mo_bld}) + +# pot_builder: builder function for message templates (.pot) +# +# source: list of C/C++ etc. files to extract messages from +# +def pot_builder(target,source,env): + args = [ 'xgettext', + '--keyword=_', + '--keyword=N_', + '--from-code=UTF-8', + '-o', target[0].get_path(), + '--foreign-user', + '--package-name="adchpp"' + '--copyright-holder="Jacek Sieka"' ] + args += [ src.get_path() for src in source ] + return os.spawnvp (os.P_WAIT, 'xgettext', args) + +pot_bld = Builder (action = pot_builder) +env.Append(BUILDERS = {'PotBuild' : pot_bld}) + conf = Configure(env) if conf.CheckCHeader('sys/epoll.h'): @@ -164,6 +222,8 @@ env = conf.Finish() +dev.intl = dev.build('intl/') + dev.adchpp = dev.build('adchpp/') if dev.is_win32(): Modified: adchpp/trunk/adchpp/ClientManager.cpp =================================================================== --- adchpp/trunk/adchpp/ClientManager.cpp 2007-11-19 14:20:21 UTC (rev 95) +++ adchpp/trunk/adchpp/ClientManager.cpp 2007-11-25 21:44:36 UTC (rev 96) @@ -40,50 +40,50 @@ ClientManager::ClientManager() throw() { supports.push_back("BASE"); supports.push_back("TIGR"); + + SocketManager::getInstance()->setIncomingHandler(&Client::create); } ClientManager::~ClientManager() throw() { - + } void ClientManager::send(const AdcCommand& cmd, bool lowPrio /* = false */) throw() { const string& txt = cmd.toString(); - switch(cmd.getType()) { - case AdcCommand::TYPE_FEATURE: - case AdcCommand::TYPE_BROADCAST: - { - bool all = (cmd.getType() == AdcCommand::TYPE_BROADCAST); - FastMutex::Lock l(ManagedSocket::getWriteMutex()); - for(ClientIter i = clients.begin(); i != clients.end(); ++i) { - if(all || !i->second->isFiltered(cmd.getFeatures())) - i->second->fastSend(txt, lowPrio); - } + switch (cmd.getType()) { + case AdcCommand::TYPE_FEATURE: + case AdcCommand::TYPE_BROADCAST: { + bool all = (cmd.getType() == AdcCommand::TYPE_BROADCAST); + FastMutex::Lock l(ManagedSocket::getWriteMutex()); + for (ClientIter i = clients.begin(); i != clients.end(); ++i) { + if (all || !i->second->isFiltered(cmd.getFeatures())) + i->second->fastSend(txt, lowPrio); } + } SocketManager::getInstance()->addAllWriters(); break; - case AdcCommand::TYPE_DIRECT: // Fallthrough - case AdcCommand::TYPE_ECHO: - { - ClientIter i = clients.find(cmd.getTo()); - if(i != clients.end()) { + case AdcCommand::TYPE_DIRECT: // Fallthrough + case AdcCommand::TYPE_ECHO: { + ClientIter i = clients.find(cmd.getTo()); + if (i != clients.end()) { + i->second->send(txt); + if (COMPATIBILITY || cmd.getType() == AdcCommand::TYPE_ECHO) { + i = clients.find(cmd.getFrom()); + if (i != clients.end()) { i->second->send(txt); - if(COMPATIBILITY || cmd.getType() == AdcCommand::TYPE_ECHO) { - i = clients.find(cmd.getFrom()); - if(i != clients.end()) { - i->second->send(txt); - } - } } } - break; + } } + break; + } } void ClientManager::sendToAll(const string& cmd) throw() { { FastMutex::Lock l(ManagedSocket::getWriteMutex()); - for(ClientIter i = clients.begin(); i != clients.end(); ++i) { + for (ClientIter i = clients.begin(); i != clients.end(); ++i) { i->second->fastSend(cmd); } } @@ -92,9 +92,9 @@ size_t ClientManager::getQueuedBytes() throw() { size_t total = 0; - + FastMutex::Lock l(ManagedSocket::getWriteMutex()); - for(ClientIter i = clients.begin(); i != clients.end(); ++i) { + for (ClientIter i = clients.begin(); i != clients.end(); ++i) { total += i->second->getQueuedBytes(); } return total; @@ -102,7 +102,7 @@ void ClientManager::sendTo(const AdcCommand& cmd, const uint32_t& to) throw() { ClientIter i = clients.find(to); - if(i != clients.end()) { + if (i != clients.end()) { i->second->send(cmd.toString()); } } @@ -110,36 +110,33 @@ void ClientManager::updateCache() throw() { // Update static strings... AdcCommand s(AdcCommand::CMD_SUP); - for(StringIter i = supports.begin(); i != supports.end(); ++i) + for (StringIter i = supports.begin(); i != supports.end(); ++i) s.addParam("AD" + *i); strings.sup = s.toString(); strings.inf = AdcCommand(AdcCommand::CMD_INF) - .addParam("NI", SETTING(HUB_NAME)) - .addParam("HI1") - .addParam("DE", SETTING(DESCRIPTION)) - .addParam("VE", versionString) - .addParam("CT5") - .addParam("HU1") // ADC <=0.13 - .toString(); + .addParam("NI", SETTING(HUB_NAME)) + .addParam("HI1") + .addParam("DE", SETTING(DESCRIPTION)) + .addParam("VE", versionString) + .addParam("CT5") + .addParam("HU1") // ADC <=0.13 + .toString(); } bool ClientManager::checkFlooding(Client& c, const AdcCommand& cmd) throw() { - time_t add = ((cmd.getType() == AdcCommand::TYPE_BROADCAST || cmd.getType() == AdcCommand::TYPE_FEATURE) ? 1 : 0) * SETTING(FLOOD_ADD); - if(c.isFlooding(add)) { + time_t add = ((cmd.getType() == AdcCommand::TYPE_BROADCAST || cmd.getType() == AdcCommand::TYPE_FEATURE) ? 1 : 0) + * SETTING(FLOOD_ADD); + if (c.isFlooding(add)) { c.disconnect(Util::REASON_FLOODING); return true; } - + return false; } -void ClientManager::incomingConnection(const ManagedSocketPtr& ms) throw() { - Client::create(ms); -} - uint32_t ClientManager::makeSID() { - while(true) { + while (true) { union { uint32_t sid; char chars[4]; @@ -148,7 +145,7 @@ sid.chars[1] = Encoder::base32Alphabet[Util::rand(sizeof(Encoder::base32Alphabet))]; sid.chars[2] = Encoder::base32Alphabet[Util::rand(sizeof(Encoder::base32Alphabet))]; sid.chars[3] = Encoder::base32Alphabet[Util::rand(sizeof(Encoder::base32Alphabet))]; - if(sids.find(sid.sid) == sids.end()) { + if (sids.find(sid.sid) == sids.end()) { sids.insert(sid.sid); return sid.sid; } @@ -157,8 +154,8 @@ void ClientManager::onConnected(Client& c) throw() { // First let's check if any clients have passed the login timeout... - time_t timeout = GET_TIME() - SETTING(LOGIN_TIMEOUT); - while(!logins.empty() && (timeout > logins.front().second) ) { + time_t timeout= GET_TIME() - SETTING(LOGIN_TIMEOUT); + while (!logins.empty() && (timeout > logins.front().second)) { Client* cc = logins.front().first; dcdebug("ClientManager: Login timeout in state %d\n", cc->getState()); @@ -173,31 +170,26 @@ void ClientManager::onReceive(Client& c, AdcCommand& cmd) throw() { int override = 0; - if(!( - cmd.getType() == AdcCommand::TYPE_BROADCAST || - cmd.getType() == AdcCommand::TYPE_DIRECT || - cmd.getType() == AdcCommand::TYPE_ECHO || - cmd.getType() == AdcCommand::TYPE_FEATURE || - cmd.getType() == AdcCommand::TYPE_HUB)) - { + if (!(cmd.getType() == AdcCommand::TYPE_BROADCAST || cmd.getType() == AdcCommand::TYPE_DIRECT || cmd.getType() + == AdcCommand::TYPE_ECHO || cmd.getType() == AdcCommand::TYPE_FEATURE || cmd.getType() == AdcCommand::TYPE_HUB)) { c.send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_PROTOCOL_GENERIC, "Invalid command type")); c.disconnect(Util::REASON_INVALID_COMMAND_TYPE); return; } - if(checkFlooding(c, cmd)) { + if (checkFlooding(c, cmd)) { return; } - + signalReceive_(c, cmd, override); - if(!(override & DONT_DISPATCH)) { - if(!dispatch(c, cmd)) { + if (!(override & DONT_DISPATCH)) { + if (!dispatch(c, cmd)) { return; } } - - if(!(override & DONT_SEND)) { + + if (!(override & DONT_SEND)) { send(cmd); } } @@ -209,24 +201,24 @@ 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& cmd) throw() { - if(c.getState() != Client::STATE_NORMAL) { + if (c.getState() != Client::STATE_NORMAL) { badState(c, cmd); return false; - } - return true; + } + return true; } bool ClientManager::handle(AdcCommand::SUP, Client& c, AdcCommand& cmd) throw() { - if(!verifySUP(c, cmd)) { + if (!verifySUP(c, cmd)) { return false; } - if(c.getState() == Client::STATE_PROTOCOL) { + if (c.getState() == Client::STATE_PROTOCOL) { enterIdentify(c, true); - } else if(c.getState() != Client::STATE_NORMAL) { + } else if (c.getState() != Client::STATE_NORMAL) { badState(c, cmd); return false; } @@ -235,97 +227,100 @@ bool ClientManager::verifySUP(Client& c, AdcCommand& cmd) throw() { c.updateSupports(cmd); - if(!c.supports("BASE")) { - if(COMPATIBILITY && c.supports("BAS0")) { + 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.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) { + + 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.send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_PROTOCOL_GENERIC, + "This hub requires TIGR support")); c.disconnect(Util::REASON_NO_TIGR_SUPPORT); } } - + return true; } bool ClientManager::verifyINF(Client& c, AdcCommand& cmd) throw() { - if(!verifyIp(c, cmd)) + if (!verifyIp(c, cmd)) return false; - if(!verifyCID(c, cmd)) + if (!verifyCID(c, cmd)) return false; - if(!verifyNick(c, cmd)) + if (!verifyNick(c, cmd)) return false; c.updateFields(cmd); return true; } -bool ClientManager::verifyPassword(Client& c, const string& password, const vector<uint8_t>& salt, const string& suppliedHash) { +bool ClientManager::verifyPassword(Client& c, const string& password, const vector<uint8_t>& salt, + const string& suppliedHash) { TigerHash tiger; tiger.update(&password[0], password.size()); tiger.update(&salt[0], salt.size()); uint8_t tmp[TigerHash::HASH_SIZE]; Encoder::fromBase32(suppliedHash.c_str(), tmp, TigerHash::HASH_SIZE); - if(memcmp(tiger.finalize(), tmp, TigerHash::HASH_SIZE) == 0) + if (memcmp(tiger.finalize(), tmp, TigerHash::HASH_SIZE) == 0) return true; - - if(!COMPATIBILITY) + + if (!COMPATIBILITY) return false; - + TigerHash tiger2; // Support dc++ 0.69 for a while string cid = c.getCID().toBase32(); tiger2.update(c.getCID().data(), CID::SIZE); tiger2.update(&password[0], password.size()); tiger2.update(&salt[0], salt.size()); - if(memcmp(tiger2.finalize(), tmp, TigerHash::HASH_SIZE) == 0) { + if (memcmp(tiger2.finalize(), tmp, TigerHash::HASH_SIZE) == 0) { c.send(AdcCommand(AdcCommand::CMD_MSG).addParam("Your client uses an old PAS encoding, please upgrade")); return true; } - return false; + return false; } bool ClientManager::handle(AdcCommand::INF, Client& c, AdcCommand& cmd) throw() { - if(c.getState() != Client::STATE_IDENTIFY && c.getState() != Client::STATE_NORMAL) { + if (c.getState() != Client::STATE_IDENTIFY && c.getState() != Client::STATE_NORMAL) { badState(c, cmd); return false; } - - if(!verifyINF(c, cmd)) + + if (!verifyINF(c, cmd)) return false; - if(c.getState() == Client::STATE_IDENTIFY) { + if (c.getState() == Client::STATE_IDENTIFY) { enterNormal(c, true, false); } - + return true; } bool ClientManager::verifyIp(Client& c, AdcCommand& cmd) throw() { - if(c.isSet(Client::FLAG_OK_IP)) + if (c.isSet(Client::FLAG_OK_IP)) return true; - - for(StringIter j = cmd.getParameters().begin(); j != cmd.getParameters().end(); ++j) { - if(j->compare(0, 2, "I4") == 0) { + + for (StringIter j = cmd.getParameters().begin(); j != cmd.getParameters().end(); ++j) { + if (j->compare(0, 2, "I4") == 0) { dcdebug("%s verifying ip\n", AdcCommand::fromSID(c.getSID()).c_str()); - if(j->size() == 2) { + if (j->size() == 2) { // Clearing is ok - } else if(j->compare(2, j->size()-2, "0.0.0.0") == 0) { + } else if (j->compare(2, j->size()-2, "0.0.0.0") == 0) { c.setField("I4", c.getIp()); *j = "I4" + c.getIp(); cmd.resetString(); - } else if(j->size()-2 != c.getIp().size() || j->compare(2, j->size()-2, c.getIp()) != 0) { + } else if (j->size()-2 != c.getIp().size() || j->compare(2, j->size()-2, c.getIp()) != 0) { c.send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_BAD_IP, "Your ip is " + c.getIp()).addParam("IP", c.getIp())); c.disconnect(Util::REASON_INVALID_IP); return false; @@ -336,41 +331,41 @@ } bool ClientManager::verifyCID(Client& c, AdcCommand& cmd) throw() { - if(cmd.getParam("ID", 0, strtmp)) { + if (cmd.getParam("ID", 0, strtmp)) { dcdebug("%s verifying CID\n", AdcCommand::fromSID(c.getSID()).c_str()); - if(c.getState() != Client::STATE_IDENTIFY) { + if (c.getState() != Client::STATE_IDENTIFY) { c.send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_PROTOCOL_GENERIC, "CID changes not allowed")); c.disconnect(Util::REASON_CID_CHANGE); - return false; + return false; } - + string spid; - if(!cmd.getParam("PD", 0, spid)) { + if (!cmd.getParam("PD", 0, spid)) { c.send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_INF_MISSING, "PID missing").addParam("FLPD")); c.disconnect(Util::REASON_PID_MISSING); return false; } - - if(strtmp.size() != CID::BASE32_SIZE || spid.size() != CID::BASE32_SIZE) { + + if (strtmp.size() != CID::BASE32_SIZE || spid.size() != CID::BASE32_SIZE) { c.send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_PROTOCOL_GENERIC, "Invalid CID/PID length")); c.disconnect(Util::REASON_PID_CID_LENGTH); return false; - } - + } + CID cid(strtmp); CID pid(spid); TigerHash th; th.update(pid.data(), CID::SIZE); - if(!(CID(th.finalize()) == cid)) { + if (!(CID(th.finalize()) == cid)) { c.send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_INVALID_PID, "PID does not correspond to CID")); c.disconnect(Util::REASON_PID_CID_MISMATCH); return false; } CIDMap::iterator i = cids.find(cid); - if(i != cids.end()) { + if (i != cids.end()) { ClientIter j = clients.find(i->second); - if(j != clients.end()) { + if (j != clients.end()) { j->second->send("\n"); } c.send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_CID_TAKEN, "CID taken, please try again later")); @@ -382,8 +377,8 @@ cids.insert(make_pair(c.getCID(), c.getSID())); cmd.delParam("PD", 0); } - - if(cmd.getParam("PD", 0, strtmp)) { + + if (cmd.getParam("PD", 0, strtmp)) { c.send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_PROTOCOL_GENERIC, "CID required when sending PID")); c.disconnect(Util::REASON_PID_WITHOUT_CID); return false; @@ -392,21 +387,22 @@ } bool ClientManager::verifyNick(Client& c, const AdcCommand& cmd) throw() { - if(cmd.getParam("NI", 0, strtmp)) { + 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) { - if((uint8_t)strtmp[i] < 33) { + for (string::size_type i = 0; i < strtmp.length(); ++i) { + if ((uint8_t)strtmp[i] < 33) { c.send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_NICK_INVALID, "Invalid character in nick")); c.disconnect(Util::REASON_NICK_INVALID); return false; } } const string& oldNick = c.getField("NI"); - if(!oldNick.empty()) + if (!oldNick.empty()) nicks.erase(oldNick); - - if(nicks.find(strtmp) != nicks.end()) { - c.send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_NICK_TAKEN, "Nick taken, please pick another one")); + + if (nicks.find(strtmp) != nicks.end()) { + c.send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_NICK_TAKEN, + "Nick taken, please pick another one")); c.disconnect(Util::REASON_NICK_TAKEN); return false; } @@ -426,7 +422,7 @@ 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()); - if(sendData) { + if (sendData) { c.send(strings.sup); c.send(AdcCommand(AdcCommand::CMD_SID).addParam(AdcCommand::fromSID(c.getSID()))); c.send(strings.inf); @@ -438,8 +434,8 @@ dcassert(c.getState() == Client::STATE_IDENTIFY); dcdebug("%s entering VERIFY\n", AdcCommand::fromSID(c.getSID()).c_str()); vector<uint8_t> challenge; - if(sendData) { - for(int i = 0; i < 32/4; ++i) { + if (sendData) { + for (int i = 0; i < 32/4; ++i) { uint32_t r = Util::rand(); challenge.insert(challenge.end(), (uint8_t*)&r, 4 + (uint8_t*)&r); } @@ -453,13 +449,13 @@ dcassert(c.getState() == Client::STATE_IDENTIFY || c.getState() == Client::STATE_VERIFY); dcdebug("%s entering NORMAL\n", AdcCommand::fromSID(c.getSID()).c_str()); - if(sendData) { + if (sendData) { string str; - for(ClientIter i = clients.begin(); i != clients.end(); ++i) { + for (ClientIter i = clients.begin(); i != clients.end(); ++i) { str += i->second->getINF(); } c.send(str); - if(sendOwnInf) { + if (sendOwnInf) { sendToAll(c.getINF()); c.send(c.getINF()); } @@ -474,8 +470,9 @@ } void ClientManager::removeLogins(Client& c) throw() { - deque<pair<Client*, time_t> >::iterator i = find_if(logins.begin(), logins.end(), CompareFirst<Client*, time_t>(&c)); - if(i != logins.end()) { + deque<pair<Client*, time_t> >::iterator i = + find_if(logins.begin(), logins.end(), CompareFirst<Client*, time_t>(&c)); + if (i != logins.end()) { logins.erase(i); } } @@ -483,7 +480,7 @@ void ClientManager::removeClient(Client& c) throw() { signalDisconnected_(c); dcdebug("Removing %s\n", AdcCommand::fromSID(c.getSID()).c_str()); - if(c.getState() == Client::STATE_NORMAL) { + if (c.getState() == Client::STATE_NORMAL) { clients.erase(c.getSID()); sendToAll(AdcCommand(AdcCommand::CMD_QUI).addParam(AdcCommand::fromSID(c.getSID()))); } else { @@ -495,9 +492,9 @@ } void ClientManager::addSupports(const string& str) throw() { - if(find(supports.begin(), supports.end(), str) != supports.end()) + if (find(supports.begin(), supports.end(), str) != supports.end()) return; - + supports.push_back(str); updateCache(); sendToAll(AdcCommand(AdcCommand::CMD_SUP).addParam("AD" + str)); @@ -505,7 +502,7 @@ void ClientManager::removeSupports(const string& str) throw() { StringIter i = find(supports.begin(), supports.end(), str); - if(i != supports.end()) { + if (i != supports.end()) { supports.erase(i); updateCache(); sendToAll(AdcCommand(AdcCommand::CMD_SUP).addParam("RM" + str)); @@ -519,11 +516,11 @@ uint32_t ClientManager::getSID(const CID& cid) const throw() { CIDMap::const_iterator i = cids.find(cid); - return (i == cids.end()) ? 0 : i->second; + return (i == cids.end()) ? 0 : i->second; } void ClientManager::shutdown() { - + } void ClientManager::onFailed(Client& c) throw() { Modified: adchpp/trunk/adchpp/ClientManager.h =================================================================== --- adchpp/trunk/adchpp/ClientManager.h 2007-11-19 14:20:21 UTC (rev 95) +++ adchpp/trunk/adchpp/ClientManager.h 2007-11-25 21:44:36 UTC (rev 96) @@ -146,12 +146,6 @@ ADCHPP_DLL size_t getQueuedBytes() throw(); - /** - * The SocketManager calls this when a new connection has been accepted. - * Don't touch. - */ - void incomingConnection(const ManagedSocketPtr& ms) throw(); - void startup() throw() { updateCache(); } void shutdown(); Modified: adchpp/trunk/adchpp/Exception.h =================================================================== --- adchpp/trunk/adchpp/Exception.h 2007-11-19 14:20:21 UTC (rev 95) +++ adchpp/trunk/adchpp/Exception.h 2007-11-25 21:44:36 UTC (rev 96) @@ -50,7 +50,7 @@ #define STANDARD_EXCEPTION(name) class ADCHPP_VISIBLE name : public Exception { \ public:\ name() throw() : Exception() { } \ - name(const string& aError) throw() : Exception(aError) { } \ + name(const std::string& aError) throw() : Exception(aError) { } \ virtual ~name() throw() { } \ } #endif Modified: adchpp/trunk/adchpp/ManagedSocket.h =================================================================== --- adchpp/trunk/adchpp/ManagedSocket.h 2007-11-19 14:20:21 UTC (rev 95) +++ adchpp/trunk/adchpp/ManagedSocket.h 2007-11-25 21:44:36 UTC (rev 96) @@ -20,6 +20,8 @@ #define ADCHPP_MANAGEDSOCKET_H #include "common.h" + +#include "forward.h" #include "Socket.h" #include "Mutex.h" #include "Signal.h" @@ -27,9 +29,6 @@ namespace adchpp { -class SocketManager; -class Writer; - /** * An asynchronous socket managed by SocketManager. */ @@ -113,8 +112,6 @@ ADCHPP_DLL static FastMutex writeMutex; }; -typedef boost::intrusive_ptr<ManagedSocket> ManagedSocketPtr; - } #endif // MANAGEDSOCKET_H Modified: adchpp/trunk/adchpp/SConscript =================================================================== --- adchpp/trunk/adchpp/SConscript 2007-11-19 14:20:21 UTC (rev 95) +++ adchpp/trunk/adchpp/SConscript 2007-11-25 21:44:36 UTC (rev 96) @@ -53,5 +53,5 @@ if env['PLATFORM'] != 'win32': dev.env.Append(RPATH = env.Literal('\\$$ORIGIN')) - + Return('ret') Modified: adchpp/trunk/adchpp/SettingsManager.cpp =================================================================== --- adchpp/trunk/adchpp/SettingsManager.cpp 2007-11-19 14:20:21 UTC (rev 95) +++ adchpp/trunk/adchpp/SettingsManager.cpp 2007-11-25 21:44:36 UTC (rev 96) @@ -42,9 +42,6 @@ "MaxSendSize", "MaxBufferSize", "BufferSize", "MaxCommandSize", "OverflowTimeout", "DisconnectTimeout", "FloodAdd", "FloodThreshold", "LoginTimeout", - "SENTRY", - // Int64 - "SENTRY" }; Modified: adchpp/trunk/adchpp/SettingsManager.h =================================================================== --- adchpp/trunk/adchpp/SettingsManager.h 2007-11-19 14:20:21 UTC (rev 95) +++ adchpp/trunk/adchpp/SettingsManager.h 2007-11-25 21:44:36 UTC (rev 96) @@ -38,7 +38,6 @@ enum StrSetting { STR_FIRST, HUB_NAME = STR_FIRST, SERVER_IP, LOG_FILE, DESCRIPTION, - LANGUAGE_FILE, STR_LAST }; enum IntSetting { INT_FIRST = STR_LAST + 1, Modified: adchpp/trunk/adchpp/SocketManager.cpp =================================================================== --- adchpp/trunk/adchpp/SocketManager.cpp 2007-11-19 14:20:21 UTC (rev 95) +++ adchpp/trunk/adchpp/SocketManager.cpp 2007-11-25 21:44:36 UTC (rev 96) @@ -22,7 +22,6 @@ #include "LogManager.h" #include "TimerManager.h" -#include "ClientManager.h" #include "SettingsManager.h" #include "Semaphores.h" #include "ManagedSocket.h" @@ -338,8 +337,7 @@ active.insert(ms); accepting.erase(ms); - ClientManager::getInstance()->incomingConnection(ms); - + SocketManager::getInstance()->incomingHandler(ms); ms->completeAccept(); prepareRead(ms); @@ -801,7 +799,7 @@ active.insert(ms); - ClientManager::getInstance()->incomingConnection(ms); + SocketManager::getInstance()->incomingHandler(ms); ms->completeAccept(); @@ -1045,5 +1043,4 @@ writer->getErrors(acceptErrors_, readErrors_, writeErrors_); } - } Modified: adchpp/trunk/adchpp/SocketManager.h =================================================================== --- adchpp/trunk/adchpp/SocketManager.h 2007-11-19 14:20:21 UTC (rev 95) +++ adchpp/trunk/adchpp/SocketManager.h 2007-11-25 21:44:36 UTC (rev 96) @@ -19,6 +19,9 @@ #ifndef ADCHPP_SOCKETMANAGER_H #define ADCHPP_SOCKETMANAGER_H +#include "common.h" + +#include "forward.h" #include "Thread.h" #include "Semaphores.h" #include "Mutex.h" @@ -26,9 +29,6 @@ namespace adchpp { -class ManagedSocket; -class Writer; - class SocketManager : public Singleton<SocketManager>, public Thread { public: typedef std::tr1::function<void()> Callback; @@ -41,6 +41,9 @@ void addDisconnect(const boost::intrusive_ptr<ManagedSocket>& ms) throw(); void addAllWriters() throw(); + typedef std::tr1::function<void (const ManagedSocketPtr&)> IncomingHandler; + void setIncomingHandler(const IncomingHandler& handler) { incomingHandler = handler; } + typedef std::tr1::unordered_map<int, size_t> ErrorMap; ADCHPP_DLL void getErrors(ErrorMap& acceptErrors_, ErrorMap& readErrors_, ErrorMap& writeErrors_); private: @@ -59,6 +62,7 @@ Semaphore processSem; std::auto_ptr<Writer> writer; + IncomingHandler incomingHandler; static const std::string className; Modified: adchpp/trunk/adchpp/adchpp.h =================================================================== --- adchpp/trunk/adchpp/adchpp.h 2007-11-19 14:20:21 UTC (rev 95) +++ adchpp/trunk/adchpp/adchpp.h 2007-11-25 21:44:36 UTC (rev 96) @@ -151,4 +151,10 @@ # endif #endif +// TODO Maybe do this in the implementations? +#ifndef _ +#define _(String) String +#define bindtextdomain(Package, Directory) +#endif + #endif // STDINC_H Added: adchpp/trunk/adchpp/forward.h =================================================================== --- adchpp/trunk/adchpp/forward.h (rev 0) +++ adchpp/trunk/adchpp/forward.h 2007-11-25 21:44:36 UTC (rev 96) @@ -0,0 +1,13 @@ +#ifndef FORWARD_H_ +#define FORWARD_H_ + +namespace adchpp { +class ManagedSocket; +typedef boost::intrusive_ptr<ManagedSocket> ManagedSocketPtr; + +class SocketManager; +class Writer; + +} + +#endif /*FORWARD_H_*/ Modified: adchpp/trunk/build_util.py =================================================================== --- adchpp/trunk/build_util.py 2007-11-19 14:20:21 UTC (rev 95) +++ adchpp/trunk/build_util.py 2007-11-25 21:44:36 UTC (rev 96) @@ -1,5 +1,6 @@ import glob import sys +import os class Dev: def __init__(self, mode, tools, env): @@ -40,6 +41,7 @@ self.env['PROGSUFFIX'] = '.exe' self.env['LIBPREFIX'] = 'lib' self.env['LIBSUFFIX'] = '.a' + self.env['SHLIBSUFFIX'] = '.dll' def is_win32(self): return sys.platform == 'win32' or 'mingw' in self.env['TOOLS'] @@ -72,6 +74,24 @@ full_path = local_env.Dir('.').path + '/' + source_path return local_env.SConscript(source_path + 'SConscript', exports={'dev' : self, 'source_path' : full_path }) + def i18n (self, source_path, buildenv, sources, name): + p_oze = glob.glob('po/*.po') + languages = [ os.path.basename(po).replace ('.po', '') for po in p_oze ] + potfile = 'po/' + name + '.pot' + + ret = buildenv.PotBuild(potfile, sources) + + for po_file in p_oze: + buildenv.Precious(buildenv.PoBuild(po_file, [potfile])) +# mo_file = po_file.replace (".po", ".mo") +# installenv.Alias ('install', buildenv.MoBuild (mo_file, po_file)) + +# for lang in languages: +# modir = (os.path.join (install_prefix, 'share/locale/' + lang + '/LC_MESSAGES/')) +# moname = domain + '.mo' +# installenv.Alias('install', installenv.InstallAs (os.path.join (modir, moname), lang + '.mo')) + return ret + def CheckPKGConfig(context, version): context.Message( 'Checking for pkg-config... ' ) ret = context.TryAction('pkg-config --atleast-pkgconfig-version=%s' % version)[0] Added: adchpp/trunk/intl/COPYING.LIB-2.0 =================================================================== --- adchpp/trunk/intl/COPYING.LIB-2.0 (rev 0) +++ adchpp/trunk/intl/COPYING.LIB-2.0 2007-11-25 21:44:36 UTC (rev 96) @@ -0,0 +1,482 @@ + GNU LIBRARY GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1991 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the library GPL. It is + numbered 2 because it goes with version 2 of the ordinary GPL.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Library General Public License, applies to some +specially designated Free Software Foundation software, and to any +other libraries whose authors decide to use it. You can use it for +your libraries, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if +you distribute copies of the library, or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link a program with the library, you must provide +complete object files to the recipients so that they can relink them +with the library, after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + Our method of protecting your rights has two steps: (1) copyright +the library, and (2) offer you this license which gives you legal +permission to copy, distribute and/or modify the library. + + Also, for each distributor's protection, we want to make certain +that everyone understands that there is no warranty for this free +library. If the library is modified by someone else and passed on, we +want its recipients to know that what they have is not the original +version, so that any problems introduced by others will not reflect on +the original authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that companies distributing free +software will individually obtain patent licenses, thus in effect +transforming the program into proprietary software. To prevent this, +we have made it clear that any patent must be licensed for everyone's +free use or not licensed at all. + + Most GNU software, including some libraries, is covered by the ordinary +GNU General Public License, which was designed for utility programs. This +license, the GNU Library General Public License, applies to certain +designated libraries. This license is quite different from the ordinary +one; be sure to read it in full, and don't assume that anything in it is +the same as in the ordinary license. + + The reason we have a separate public license for some libraries is that +they blur the distinction we usually make between modifying or adding to a +program and simply using it. Linking a program with a library, without +changing the library, is in some sense simply using the library, and is +analogous to running a utility program or application program. However, in +a textual and legal sense, the linked executable is a combined work, a +derivative of the original library, and the ordinary General Public License +treats it as such. + + Because of this blurred distinction, using the ordinary General +Public License for libraries did not effectively promote software +sharing, because most developers did not use the libraries. We +concluded that weaker conditions might promote sharing better. + + However, unrestricted linking of non-free programs would deprive the +users of those programs of all benefit from the free status of the +libraries themselves. This Library General Public License is intended to +permit developers of non-free programs to use free libraries, while +preserving your freedom as a user of such programs to change the free +libraries that are incorporated in them. (We have not seen how to achieve +this as regards changes in header files, but we have achieved it as regards +changes in the actual functions of the Library.) The hope is that this +will lead to faster development of free libraries. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, while the latter only +works together with the library. + + Note that it is possible for a library to be covered by the ordinary +General Public License rather than by this special one. + + GNU LIBRARY GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library which +contains a notice placed by the copyright holder or other authorized +party saying it may be distributed under the terms of this Library +General Public License (also called "this License"). Each licensee is +addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also compile or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + c) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + d) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the source code distributed need not include anything that is normally +distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Library General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + Appendix: How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + <one line to give the library's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + <signature of Ty Coon>, 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! Added: adchpp/trunk/intl/COPYING.LIB-2.1 =================================================================== --- adchpp/trunk/intl/COPYING.LIB-2.1 (rev 0) +++ adchpp/trunk/intl/COPYING.LIB-2.1 2007-11-25 21:44:36 UTC (rev 96) @@ -0,0 +1,516 @@ + + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations +below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library a... [truncated message content] |
From: <arn...@us...> - 2007-12-02 22:02:05
|
Revision: 97 http://adchpp.svn.sourceforge.net/adchpp/?rev=97&view=rev Author: arnetheduck Date: 2007-12-02 14:01:57 -0800 (Sun, 02 Dec 2007) Log Message: ----------- Some adc 1.0 issues fixed, bring back lua on track, lua 5.1.2 Modified Paths: -------------- adchpp/trunk/adchpp/AdcCommand.h adchpp/trunk/adchpp/Client.h adchpp/trunk/adchpp/SettingsManager.cpp adchpp/trunk/adchpp/SettingsManager.h adchpp/trunk/adchpp/SocketManager.cpp adchpp/trunk/etc/adchpp.xml adchpp/trunk/lua/Makefile adchpp/trunk/lua/lbaselib.c adchpp/trunk/lua/lcode.c adchpp/trunk/lua/ldebug.c adchpp/trunk/lua/lfunc.c adchpp/trunk/lua/loadlib.c adchpp/trunk/lua/loslib.c adchpp/trunk/lua/lparser.c adchpp/trunk/lua/lstrlib.c adchpp/trunk/lua/lua.h adchpp/trunk/lua/luaconf.h adchpp/trunk/lua/lvm.c adchpp/trunk/lua/print.c adchpp/trunk/plugins/Script/examples/access.lua adchpp/trunk/readme.txt adchpp/trunk/swig/SConscript adchpp/trunk/swig/adchpp.i adchpp/trunk/swig/lua.i Removed Paths: ------------- adchpp/trunk/etc/Example.adchpp.xml Modified: adchpp/trunk/adchpp/AdcCommand.h =================================================================== --- adchpp/trunk/adchpp/AdcCommand.h 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/adchpp/AdcCommand.h 2007-12-02 22:01:57 UTC (rev 97) @@ -57,10 +57,12 @@ ERROR_BAD_STATE = 44, ERROR_FEATURE_MISSING = 45, ERROR_BAD_IP = 46, + ERROR_NO_HUB_HASH = 47, ERROR_TRANSFER_GENERIC = 50, ERROR_FILE_NOT_AVAILABLE = 51, ERROR_FILE_PART_NOT_AVAILABLE = 52, - ERROR_SLOTS_FULL = 53 + ERROR_SLOTS_FULL = 53, + ERROR_NO_CLIENT_HASH = 54 }; enum Severity { @@ -100,7 +102,7 @@ C(CMD, 'C','M','D'); #undef C - enum { HUB_SID = 0x41414141 }; + enum { HUB_SID = 0xffffffff }; uint32_t toCMD(uint8_t a, uint8_t b, uint8_t c) { return (((uint32_t)a) | (((uint32_t)b)<<8) | (((uint32_t)c)<<16)); } Modified: adchpp/trunk/adchpp/Client.h =================================================================== --- adchpp/trunk/adchpp/Client.h 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/adchpp/Client.h 2007-12-02 22:01:57 UTC (rev 97) @@ -50,9 +50,10 @@ FLAG_BOT = 0x01, 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_SU = 0x08, + FLAG_OWNER = 0x10, + FLAG_HUB = 0x20, + MASK_CLIENT_TYPE = FLAG_BOT | FLAG_REGISTERED | FLAG_OP | FLAG_SU | FLAG_OWNER | FLAG_HUB, FLAG_PASSWORD = 0x100, FLAG_HIDDEN = 0x101, /** Extended away, no need to send msg */ Modified: adchpp/trunk/adchpp/SettingsManager.cpp =================================================================== --- adchpp/trunk/adchpp/SettingsManager.cpp 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/adchpp/SettingsManager.cpp 2007-12-02 22:01:57 UTC (rev 97) @@ -47,7 +47,6 @@ SettingsManager::SettingsManager() throw() { memset(intSettings, 0, sizeof(intSettings)); - memset(int64Settings, 0, sizeof(int64Settings)); set(HUB_NAME, appName); // set(SERVER_IP, ""); Modified: adchpp/trunk/adchpp/SettingsManager.h =================================================================== --- adchpp/trunk/adchpp/SettingsManager.h 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/adchpp/SettingsManager.h 2007-12-02 22:01:57 UTC (rev 97) @@ -109,7 +109,6 @@ std::string strSettings[STR_LAST - STR_FIRST]; int intSettings[INT_LAST - INT_FIRST]; - int64_t int64Settings[/*INT64_LAST - INT64_FIRST*/1]; SignalLoad::Signal signalLoad_; }; Modified: adchpp/trunk/adchpp/SocketManager.cpp =================================================================== --- adchpp/trunk/adchpp/SocketManager.cpp 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/adchpp/SocketManager.cpp 2007-12-02 22:01:57 UTC (rev 97) @@ -581,12 +581,18 @@ bool get(vector<epoll_event>& events) { events.resize(1024); - int n = epoll_wait(poll_fd, &events[0], events.size(), WRITE_TIMEOUT); - if(n == -1) { - return false; + while(true) { + int n = epoll_wait(poll_fd, &events[0], events.size(), WRITE_TIMEOUT); + if(n == -1) { + if(errno != EINTR) { + return false; + } + // Keep looping + } else { + events.resize(n); + return true; + } } - events.resize(n); - return true; } void remove(const ManagedSocketPtr& ms) { Deleted: adchpp/trunk/etc/Example.adchpp.xml =================================================================== --- adchpp/trunk/etc/Example.adchpp.xml 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/etc/Example.adchpp.xml 2007-12-02 22:01:57 UTC (rev 97) @@ -1,15 +0,0 @@ -<?xml version="1.0" encoding="utf-8" standalone="yes"?> -<Language Name="Example Language" Author="arnetheduck" Version=2.0 Revision="1"> - <Strings> - <String Name="B">B</String> - <String Name="CidTaken">CID taken</String> - <String Name="DiskFull">Disk full?</String> - <String Name="Gb">GiB</String> - <String Name="HubFull">Hub is currently full</String> - <String Name="Kb">KiB</String> - <String Name="Mb">MiB</String> - <String Name="NickInvalid">Your nick contains invalid characters. Adios.</String> - <String Name="NickTaken">Your nick is already taken, please select another one</String> - <String Name="Tb">TiB</String> - </Strings> -</Language> Modified: adchpp/trunk/etc/adchpp.xml =================================================================== --- adchpp/trunk/etc/adchpp.xml 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/etc/adchpp.xml 2007-12-02 22:01:57 UTC (rev 97) @@ -1,9 +1,6 @@ <?xml version="1.0" encoding="utf-8" standalone="yes"?> <ADCHubPlusPlus> <Settings> -<!-- Language file --> - <!-- The strings in the language file is used when messages are sent out to the user by the hub --> - <LanguageFile type="string">Example.adchpp.xml</LanguageFile> <!-- Hub name and message of the day --> <!-- This is the name of the hub as it should be reported to the clients during @@ -27,17 +24,6 @@ on the same port, which facilates hub blocking. --> <ServerPort type="int">2780</ServerPort> -<!-- Maximum users --> - <!-- The maximum number of users that should be allowed into the hub at any time, - 0 = disable --> - <MaxUsers type="int">0</MaxUsers> - -<!-- Redirection settings --> - <!-- The server to redirect to (if enabled) when full --> - <RedirectServer>adc://wza.digitalbrains.com:1416</RedirectServer> - <!-- Enable/disable redirect when full --> - <RedirectFull>0</RedirectFull> - <!-- Flood protection --> <FloodAdd>1</FloodAdd> <FloodThreshold>25</FloodThreshold> Modified: adchpp/trunk/lua/Makefile =================================================================== --- adchpp/trunk/lua/Makefile 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/lua/Makefile 2007-12-02 22:01:57 UTC (rev 97) @@ -20,7 +20,7 @@ # == END OF USER SETTINGS. NO NEED TO CHANGE ANYTHING BELOW THIS LINE ========= -PLATS= aix ansi bsd generic linux macosx mingw posix solaris +PLATS= aix ansi bsd freebsd generic linux macosx mingw posix solaris LUA_A= liblua.a CORE_O= lapi.o lcode.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o \ @@ -77,7 +77,8 @@ # convenience targets for popular platforms none: - @echo "Please choose a platform: $(PLATS)" + @echo "Please choose a platform:" + @echo " $(PLATS)" aix: $(MAKE) all CC="xlc" CFLAGS="-O2 -DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-ldl" MYLDFLAGS="-brtl -bexpall" @@ -88,6 +89,9 @@ bsd: $(MAKE) all MYCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-Wl,-E" +freebsd: + $(MAKE) all MYCFLAGS="-DLUA_USE_LINUX" MYLIBS="-Wl,-E -lreadline" + generic: $(MAKE) all MYCFLAGS= @@ -103,6 +107,7 @@ $(MAKE) "LUA_A=lua51.dll" "LUA_T=lua.exe" \ "AR=$(CC) -shared -o" "RANLIB=strip --strip-unneeded" \ "MYCFLAGS=-DLUA_BUILD_AS_DLL" "MYLIBS=" "MYLDFLAGS=-s" lua.exe + $(MAKE) "LUAC_T=luac.exe" luac.exe posix: $(MAKE) all MYCFLAGS=-DLUA_USE_POSIX Modified: adchpp/trunk/lua/lbaselib.c =================================================================== --- adchpp/trunk/lua/lbaselib.c 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/lua/lbaselib.c 2007-12-02 22:01:57 UTC (rev 97) @@ -1,5 +1,5 @@ /* -** $Id: lbaselib.c,v 1.191 2006/06/02 15:34:00 roberto Exp $ +** $Id: lbaselib.c,v 1.191a 2006/06/02 15:34:00 roberto Exp $ ** Basic library ** See Copyright Notice in lua.h */ @@ -114,11 +114,11 @@ } -static void getfunc (lua_State *L) { +static void getfunc (lua_State *L, int opt) { if (lua_isfunction(L, 1)) lua_pushvalue(L, 1); else { lua_Debug ar; - int level = luaL_optint(L, 1, 1); + int level = opt ? luaL_optint(L, 1, 1) : luaL_checkint(L, 1); luaL_argcheck(L, level >= 0, 1, "level must be non-negative"); if (lua_getstack(L, level, &ar) == 0) luaL_argerror(L, 1, "invalid level"); @@ -131,7 +131,7 @@ static int luaB_getfenv (lua_State *L) { - getfunc(L); + getfunc(L, 1); if (lua_iscfunction(L, -1)) /* is a C function? */ lua_pushvalue(L, LUA_GLOBALSINDEX); /* return the thread's global env. */ else @@ -142,7 +142,7 @@ static int luaB_setfenv (lua_State *L) { luaL_checktype(L, 2, LUA_TTABLE); - getfunc(L); + getfunc(L, 0); lua_pushvalue(L, 2); if (lua_isnumber(L, 1) && lua_tonumber(L, 1) == 0) { /* change environment of current thread */ Modified: adchpp/trunk/lua/lcode.c =================================================================== --- adchpp/trunk/lua/lcode.c 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/lua/lcode.c 2007-12-02 22:01:57 UTC (rev 97) @@ -1,5 +1,5 @@ /* -** $Id: lcode.c,v 2.25 2006/03/21 19:28:49 roberto Exp $ +** $Id: lcode.c,v 2.25a 2006/03/21 19:28:49 roberto Exp $ ** Code generator for Lua ** See Copyright Notice in lua.h */ @@ -35,15 +35,20 @@ void luaK_nil (FuncState *fs, int from, int n) { Instruction *previous; if (fs->pc > fs->lasttarget) { /* no jumps to current position? */ - if (fs->pc == 0) /* function start? */ - return; /* positions are already clean */ - if (GET_OPCODE(*(previous = &fs->f->code[fs->pc-1])) == OP_LOADNIL) { - int pfrom = GETARG_A(*previous); - int pto = GETARG_B(*previous); - if (pfrom <= from && from <= pto+1) { /* can connect both? */ - if (from+n-1 > pto) - SETARG_B(*previous, from+n-1); - return; + if (fs->pc == 0) { /* function start? */ + if (from >= fs->nactvar) + return; /* positions are already clean */ + } + else { + previous = &fs->f->code[fs->pc-1]; + if (GET_OPCODE(*previous) == OP_LOADNIL) { + int pfrom = GETARG_A(*previous); + int pto = GETARG_B(*previous); + if (pfrom <= from && from <= pto+1) { /* can connect both? */ + if (from+n-1 > pto) + SETARG_B(*previous, from+n-1); + return; + } } } } @@ -657,10 +662,16 @@ if (constfolding(op, e1, e2)) return; else { + int o2 = (op != OP_UNM && op != OP_LEN) ? luaK_exp2RK(fs, e2) : 0; int o1 = luaK_exp2RK(fs, e1); - int o2 = (op != OP_UNM && op != OP_LEN) ? luaK_exp2RK(fs, e2) : 0; - freeexp(fs, e2); - freeexp(fs, e1); + if (o1 > o2) { + freeexp(fs, e1); + freeexp(fs, e2); + } + else { + freeexp(fs, e2); + freeexp(fs, e1); + } e1->u.s.info = luaK_codeABC(fs, op, 0, o1, o2); e1->k = VRELOCABLE; } @@ -718,10 +729,15 @@ luaK_exp2nextreg(fs, v); /* operand must be on the `stack' */ break; } - default: { + case OPR_ADD: case OPR_SUB: case OPR_MUL: case OPR_DIV: + case OPR_MOD: case OPR_POW: { if (!isnumeral(v)) luaK_exp2RK(fs, v); break; } + default: { + luaK_exp2RK(fs, v); + break; + } } } Modified: adchpp/trunk/lua/ldebug.c =================================================================== --- adchpp/trunk/lua/ldebug.c 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/lua/ldebug.c 2007-12-02 22:01:57 UTC (rev 97) @@ -1,5 +1,5 @@ /* -** $Id: ldebug.c,v 2.29 2005/12/22 16:19:56 roberto Exp $ +** $Id: ldebug.c,v 2.29a 2005/12/22 16:19:56 roberto Exp $ ** Debug Interface ** See Copyright Notice in lua.h */ @@ -432,14 +432,16 @@ break; } case OP_CLOSURE: { - int nup; + int nup, j; check(b < pt->sizep); nup = pt->p[b]->nups; check(pc + nup < pt->sizecode); - for (; nup>0; nup--) { - OpCode op1 = GET_OPCODE(pt->code[pc+nup]); + for (j = 1; j <= nup; j++) { + OpCode op1 = GET_OPCODE(pt->code[pc + j]); check(op1 == OP_GETUPVAL || op1 == OP_MOVE); } + if (reg != NO_REG) /* tracing? */ + pc += nup; /* do not 'execute' these pseudo-instructions */ break; } case OP_VARARG: { Modified: adchpp/trunk/lua/lfunc.c =================================================================== --- adchpp/trunk/lua/lfunc.c 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/lua/lfunc.c 2007-12-02 22:01:57 UTC (rev 97) @@ -1,5 +1,5 @@ /* -** $Id: lfunc.c,v 2.12 2005/12/22 16:19:56 roberto Exp $ +** $Id: lfunc.c,v 2.12a 2005/12/22 16:19:56 roberto Exp $ ** Auxiliary functions to manipulate prototypes and closures ** See Copyright Notice in lua.h */ @@ -55,7 +55,7 @@ GCObject **pp = &L->openupval; UpVal *p; UpVal *uv; - while ((p = ngcotouv(*pp)) != NULL && p->v >= level) { + while (*pp != NULL && (p = ngcotouv(*pp))->v >= level) { lua_assert(p->v != &p->u.value); if (p->v == level) { /* found a corresponding upvalue? */ if (isdead(g, obj2gco(p))) /* is it dead? */ @@ -96,7 +96,7 @@ void luaF_close (lua_State *L, StkId level) { UpVal *uv; global_State *g = G(L); - while ((uv = ngcotouv(L->openupval)) != NULL && uv->v >= level) { + while (L->openupval != NULL && (uv = ngcotouv(L->openupval))->v >= level) { GCObject *o = obj2gco(uv); lua_assert(!isblack(o) && uv->v != &uv->u.value); L->openupval = uv->next; /* remove from `open' list */ Modified: adchpp/trunk/lua/loadlib.c =================================================================== --- adchpp/trunk/lua/loadlib.c 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/lua/loadlib.c 2007-12-02 22:01:57 UTC (rev 97) @@ -1,5 +1,5 @@ /* -** $Id: loadlib.c,v 1.52 2006/04/10 18:27:23 roberto Exp $ +** $Id: loadlib.c,v 1.54a 2006/07/03 20:16:49 roberto Exp $ ** Dynamic library loader for Lua ** See Copyright Notice in lua.h ** @@ -16,9 +16,9 @@ #define loadlib_c #define LUA_LIB +#include "lua.h" + #include "lauxlib.h" -#include "lobject.h" -#include "lua.h" #include "lualib.h" @@ -98,7 +98,7 @@ char buff[MAX_PATH + 1]; char *lb; DWORD nsize = sizeof(buff)/sizeof(char); - DWORD n = GetModuleFileName(NULL, buff, nsize); + DWORD n = GetModuleFileNameA(NULL, buff, nsize); if (n == 0 || n == nsize || (lb = strrchr(buff, '\\')) == NULL) luaL_error(L, "unable to get ModuleFileName"); else { @@ -112,7 +112,7 @@ static void pusherror (lua_State *L) { int error = GetLastError(); char buffer[128]; - if (FormatMessage(FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM, + if (FormatMessageA(FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM, NULL, error, 0, buffer, sizeof(buffer), NULL)) lua_pushstring(L, buffer); else @@ -125,7 +125,7 @@ static void *ll_load (lua_State *L, const char *path) { - HINSTANCE lib = LoadLibrary(path); + HINSTANCE lib = LoadLibraryA(path); if (lib == NULL) pusherror(L); return lib; } @@ -356,15 +356,16 @@ path = lua_tostring(L, -1); if (path == NULL) luaL_error(L, LUA_QL("package.%s") " must be a string", pname); - lua_pushstring(L, ""); /* error accumulator */ + lua_pushliteral(L, ""); /* error accumulator */ while ((path = pushnexttemplate(L, path)) != NULL) { const char *filename; filename = luaL_gsub(L, lua_tostring(L, -1), LUA_PATH_MARK, name); + lua_remove(L, -2); /* remove path template */ if (readable(filename)) /* does file exist and is readable? */ return filename; /* return that file name */ - lua_pop(L, 2); /* remove path template and file name */ - luaO_pushfstring(L, "\n\tno file " LUA_QS, filename); - lua_concat(L, 2); + lua_pushfstring(L, "\n\tno file " LUA_QS, filename); + lua_remove(L, -2); /* remove file name */ + lua_concat(L, 2); /* add entry to possible error message */ } return NULL; /* not found */ } @@ -423,8 +424,8 @@ funcname = mkfuncname(L, name); if ((stat = ll_loadfunc(L, filename, funcname)) != 0) { if (stat != ERRFUNC) loaderror(L, filename); /* real error */ - luaO_pushfstring(L, "\n\tno module " LUA_QS " in file " LUA_QS, - name, filename); + lua_pushfstring(L, "\n\tno module " LUA_QS " in file " LUA_QS, + name, filename); return 1; /* function not found */ } return 1; @@ -438,7 +439,7 @@ luaL_error(L, LUA_QL("package.preload") " must be a table"); lua_getfield(L, -1, name); if (lua_isnil(L, -1)) /* not found? */ - luaO_pushfstring(L, "\n\tno field package.preload['%s']", name); + lua_pushfstring(L, "\n\tno field package.preload['%s']", name); return 1; } @@ -462,7 +463,7 @@ lua_getfield(L, LUA_ENVIRONINDEX, "loaders"); if (!lua_istable(L, -1)) luaL_error(L, LUA_QL("package.loaders") " must be a table"); - lua_pushstring(L, ""); /* error message accumulator */ + lua_pushliteral(L, ""); /* error message accumulator */ for (i=1; ; i++) { lua_rawgeti(L, -2, i); /* get a loader */ if (lua_isnil(L, -1)) @@ -646,8 +647,8 @@ setpath(L, "path", LUA_PATH, LUA_PATH_DEFAULT); /* set field `path' */ setpath(L, "cpath", LUA_CPATH, LUA_CPATH_DEFAULT); /* set field `cpath' */ /* store config information */ - lua_pushstring(L, LUA_DIRSEP "\n" LUA_PATHSEP "\n" LUA_PATH_MARK "\n" - LUA_EXECDIR "\n" LUA_IGMARK); + lua_pushliteral(L, LUA_DIRSEP "\n" LUA_PATHSEP "\n" LUA_PATH_MARK "\n" + LUA_EXECDIR "\n" LUA_IGMARK); lua_setfield(L, -2, "config"); /* set field `loaded' */ luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 2); Modified: adchpp/trunk/lua/loslib.c =================================================================== --- adchpp/trunk/lua/loslib.c 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/lua/loslib.c 2007-12-02 22:01:57 UTC (rev 97) @@ -1,5 +1,5 @@ /* -** $Id: loslib.c,v 1.19 2006/04/26 18:19:49 roberto Exp $ +** $Id: loslib.c,v 1.20 2006/09/19 13:57:08 roberto Exp $ ** Standard Operating System library ** See Copyright Notice in lua.h */ @@ -146,11 +146,22 @@ setboolfield(L, "isdst", stm->tm_isdst); } else { - char b[256]; - if (strftime(b, sizeof(b), s, stm)) - lua_pushstring(L, b); - else - return luaL_error(L, LUA_QL("date") " format too long"); + char cc[3]; + luaL_Buffer b; + cc[0] = '%'; cc[2] = '\0'; + luaL_buffinit(L, &b); + for (; *s; s++) { + if (*s != '%' || *(s + 1) == '\0') /* no conversion specifier? */ + luaL_addchar(&b, *s); + else { + size_t reslen; + char buff[200]; /* should be big enough for any conversion result */ + cc[1] = *(++s); + reslen = strftime(buff, sizeof(buff), cc, stm); + luaL_addlstring(&b, buff, reslen); + } + } + luaL_pushresult(&b); } return 1; } Modified: adchpp/trunk/lua/lparser.c =================================================================== --- adchpp/trunk/lua/lparser.c 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/lua/lparser.c 2007-12-02 22:01:57 UTC (rev 97) @@ -1,5 +1,5 @@ /* -** $Id: lparser.c,v 2.42 2006/06/05 15:57:59 roberto Exp $ +** $Id: lparser.c,v 2.42a 2006/06/05 15:57:59 roberto Exp $ ** Lua Parser ** See Copyright Notice in lua.h */ @@ -489,7 +489,7 @@ static void listfield (LexState *ls, struct ConsControl *cc) { expr(ls, &cc->v); - luaY_checklimit(ls->fs, cc->na, MAXARG_Bx, "items in a constructor"); + luaY_checklimit(ls->fs, cc->na, MAX_INT, "items in a constructor"); cc->na++; cc->tostore++; } Modified: adchpp/trunk/lua/lstrlib.c =================================================================== --- adchpp/trunk/lua/lstrlib.c 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/lua/lstrlib.c 2007-12-02 22:01:57 UTC (rev 97) @@ -1,5 +1,5 @@ /* -** $Id: lstrlib.c,v 1.132 2006/04/26 20:41:19 roberto Exp $ +** $Id: lstrlib.c,v 1.132a 2006/04/26 20:41:19 roberto Exp $ ** Standard library for string operations and pattern-matching ** See Copyright Notice in lua.h */ @@ -723,7 +723,7 @@ static const char *scanformat (lua_State *L, const char *strfrmt, char *form) { const char *p = strfrmt; - while (strchr(FLAGS, *p)) p++; /* skip flags */ + while (*p != '\0' && strchr(FLAGS, *p) != NULL) p++; /* skip flags */ if ((size_t)(p - strfrmt) >= sizeof(FLAGS)) luaL_error(L, "invalid format (repeated flags)"); if (isdigit(uchar(*p))) p++; /* skip width */ Modified: adchpp/trunk/lua/lua.h =================================================================== --- adchpp/trunk/lua/lua.h 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/lua/lua.h 2007-12-02 22:01:57 UTC (rev 97) @@ -1,5 +1,5 @@ /* -** $Id: lua.h,v 1.218 2006/06/02 15:34:00 roberto Exp $ +** $Id: lua.h,v 1.218a 2006/06/02 15:34:00 roberto Exp $ ** Lua - An Extensible Extension Language ** Lua.org, PUC-Rio, Brazil (http://www.lua.org) ** See Copyright Notice at the end of this file @@ -17,9 +17,9 @@ #define LUA_VERSION "Lua 5.1" -#define LUA_RELEASE "Lua 5.1.1" +#define LUA_RELEASE "Lua 5.1.2" #define LUA_VERSION_NUM 501 -#define LUA_COPYRIGHT "Copyright (C) 1994-2006 Lua.org, PUC-Rio" +#define LUA_COPYRIGHT "Copyright (C) 1994-2007 Lua.org, PUC-Rio" #define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo & W. Celes" @@ -359,7 +359,7 @@ /****************************************************************************** -* Copyright (C) 1994-2006 Lua.org, PUC-Rio. All rights reserved. +* Copyright (C) 1994-2007 Lua.org, PUC-Rio. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the Modified: adchpp/trunk/lua/luaconf.h =================================================================== --- adchpp/trunk/lua/luaconf.h 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/lua/luaconf.h 2007-12-02 22:01:57 UTC (rev 97) @@ -1,5 +1,5 @@ /* -** $Id: luaconf.h,v 1.82 2006/04/10 18:27:23 roberto Exp $ +** $Id: luaconf.h,v 1.82a 2006/04/10 18:27:23 roberto Exp $ ** Configuration file for Lua ** See Copyright Notice in lua.h */ @@ -216,7 +216,7 @@ ** =================================================================== */ -#if defined(lua_c) +#if defined(lua_c) || defined(luaall_c) /* @@ lua_stdin_is_tty detects whether the standard input is a 'tty' (that @@ -360,7 +360,7 @@ /* @@ LUA_COMPAT_OPENLIB controls compatibility with old 'luaL_openlib' @* behavior. -** CHANGE it to undefined as soon as you replace to 'luaL_registry' +** CHANGE it to undefined as soon as you replace to 'luaL_register' ** your uses of 'luaL_openlib' */ #define LUA_COMPAT_OPENLIB Modified: adchpp/trunk/lua/lvm.c =================================================================== --- adchpp/trunk/lua/lvm.c 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/lua/lvm.c 2007-12-02 22:01:57 UTC (rev 97) @@ -1,5 +1,5 @@ /* -** $Id: lvm.c,v 2.63 2006/06/05 15:58:59 roberto Exp $ +** $Id: lvm.c,v 2.63a 2006/06/05 15:58:59 roberto Exp $ ** Lua virtual machine ** See Copyright Notice in lua.h */ @@ -165,7 +165,7 @@ const TValue *tm = luaT_gettmbyobj(L, p1, event); /* try first operand */ if (ttisnil(tm)) tm = luaT_gettmbyobj(L, p2, event); /* try second operand */ - if (!ttisfunction(tm)) return 0; + if (ttisnil(tm)) return 0; callTMres(L, res, tm, p1, p2); return 1; } @@ -281,10 +281,12 @@ do { StkId top = L->base + last + 1; int n = 2; /* number of elements handled in this pass (at least 2) */ - if (!tostring(L, top-2) || !tostring(L, top-1)) { + if (!(ttisstring(top-2) || ttisnumber(top-2)) || !tostring(L, top-1)) { if (!call_binTM(L, top-2, top-1, top-2, TM_CONCAT)) luaG_concaterror(L, top-2, top-1); - } else if (tsvalue(top-1)->len > 0) { /* if len=0, do nothing */ + } else if (tsvalue(top-1)->len == 0) /* second op is empty? */ + (void)tostring(L, top - 2); /* result is first op (as string) */ + else { /* at least two string values; get as many as possible */ size_t tl = tsvalue(top-1)->len; char *buffer; Modified: adchpp/trunk/lua/print.c =================================================================== --- adchpp/trunk/lua/print.c 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/lua/print.c 2007-12-02 22:01:57 UTC (rev 97) @@ -1,5 +1,5 @@ /* -** $Id: print.c,v 1.55 2006/05/31 13:30:05 lhf Exp $ +** $Id: print.c,v 1.55a 2006/05/31 13:30:05 lhf Exp $ ** print bytecodes ** See Copyright Notice in lua.h */ @@ -23,8 +23,7 @@ static void PrintString(const TString* ts) { const char* s=getstr(ts); - int n=ts->tsv.len; - int i; + size_t i,n=ts->tsv.len; putchar('"'); for (i=0; i<n; i++) { @@ -32,6 +31,7 @@ switch (c) { case '"': printf("\\\""); break; + case '\\': printf("\\\\"); break; case '\a': printf("\\a"); break; case '\b': printf("\\b"); break; case '\f': printf("\\f"); break; Modified: adchpp/trunk/plugins/Script/examples/access.lua =================================================================== --- adchpp/trunk/plugins/Script/examples/access.lua 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/plugins/Script/examples/access.lua 2007-12-02 22:01:57 UTC (rev 97) @@ -5,14 +5,6 @@ adchpp = luadchpp --- Temporary fixes for SWIG 1.3.29 -adchpp.TYPE_BROADCAST = string.char(adchpp.TYPE_BROADCAST) -adchpp.TYPE_DIRECT = string.char(adchpp.TYPE_DIRECT) -adchpp.TYPE_ECHO = string.char(adchpp.TYPE_ECHO) -adchpp.TYPE_FEATURE = string.char(adchpp.TYPE_FEATURE) -adchpp.TYPE_INFO = string.char(adchpp.TYPE_INFO) -adchpp.TYPE_HUB = string.char(adchpp.TYPE_HUB) - -- Configuration local users_file = adchpp.Util_getCfgPath() .. "users.txt" @@ -59,21 +51,21 @@ local context_send = "[BFD]" local command_contexts = { - [adchpp.CMD_STA] = context_hub, - [adchpp.CMD_SUP] = context_hub, - [adchpp.CMD_SID] = context_hub, - [adchpp.CMD_INF] = context_bcast, - [adchpp.CMD_MSG] = context_send, - [adchpp.CMD_SCH] = context_send, - [adchpp.CMD_RES] = context_direct, - [adchpp.CMD_CTM] = context_direct, - [adchpp.CMD_RCM] = context_direct, - [adchpp.CMD_GPA] = context_hub, - [adchpp.CMD_PAS] = context_hub, - [adchpp.CMD_QUI] = context_hub, - [adchpp.CMD_GET] = context_hub, - [adchpp.CMD_GFI] = context_hub, - [adchpp.CMD_SND] = context_hub, + [adchpp.AdcCommand_CMD_STA] = context_hub, + [adchpp.AdcCommand_CMD_SUP] = context_hub, + [adchpp.AdcCommand_CMD_SID] = context_hub, + [adchpp.AdcCommand_CMD_INF] = context_bcast, + [adchpp.AdcCommand_CMD_MSG] = context_send, + [adchpp.AdcCommand_CMD_SCH] = context_send, + [adchpp.AdcCommand_CMD_RES] = context_direct, + [adchpp.AdcCommand_CMD_CTM] = context_direct, + [adchpp.AdcCommand_CMD_RCM] = context_direct, + [adchpp.AdcCommand_CMD_GPA] = context_hub, + [adchpp.AdcCommand_CMD_PAS] = context_hub, + [adchpp.AdcCommand_CMD_QUI] = context_hub, + [adchpp.AdcCommand_CMD_GET] = context_hub, + [adchpp.AdcCommand_CMD_GFI] = context_hub, + [adchpp.AdcCommand_CMD_SND] = context_hub, } local user_commands = { @@ -242,7 +234,7 @@ save_users() end -local command_processed = adchpp.DONT_DISPATCH + adchpp.DONT_SEND +local command_processed = adchpp.ClientManager_DONT_DISPATCH + adchpp.ClientManager_DONT_SEND local function onINF(c, cmd) Modified: adchpp/trunk/readme.txt =================================================================== --- adchpp/trunk/readme.txt 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/readme.txt 2007-12-02 22:01:57 UTC (rev 97) @@ -18,7 +18,7 @@ gcc 4.2+ (linux or mingw) boost (http://www.boost.org) scons (http://www.scons.org) -swig 1.3.31+ +swig 1.3.31 ** Important!! The hub will _NOT_ run on Win9x/ME. ** Modified: adchpp/trunk/swig/SConscript =================================================================== --- adchpp/trunk/swig/SConscript 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/swig/SConscript 2007-12-02 22:01:57 UTC (rev 97) @@ -104,7 +104,7 @@ # We assume the lua from the script plugin will be used... env.Append(CPPPATH=['#', '#/lua/']) - + if env['PLATFORM'] == 'win32': env.Append(CPPDEFINES=['LUA_BUILD_AS_DLL=1']) else: Modified: adchpp/trunk/swig/adchpp.i =================================================================== --- adchpp/trunk/swig/adchpp.i 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/swig/adchpp.i 2007-12-02 22:01:57 UTC (rev 97) @@ -278,21 +278,15 @@ SEV_FATAL = 2 }; -#ifdef SWIGLUA - static const short TYPE_BROADCAST = 'B'; - static const short TYPE_DIRECT = 'D'; - static const short TYPE_ECHO = 'E'; - static const short TYPE_FEATURE = 'F'; - static const short TYPE_INFO = 'I'; - static const short TYPE_HUB = 'H'; -#else static const char TYPE_BROADCAST = 'B'; + static const char TYPE_CLIENT = 'C'; static const char TYPE_DIRECT = 'D'; static const char TYPE_ECHO = 'E'; static const char TYPE_FEATURE = 'F'; static const char TYPE_INFO = 'I'; static const char TYPE_HUB = 'H'; -#endif + static const char TYPE_UDP = 'U'; + // Known commands... #define C(n, a, b, c) static const unsigned int CMD_##n = (((uint32_t)a) | (((uint32_t)b)<<8) | (((uint32_t)c)<<16)); // Base commands @@ -315,7 +309,7 @@ C(CMD, 'C','M','D'); #undef C - enum { HUB_SID = 0x41414141 }; + enum { HUB_SID = 0xffffffff }; AdcCommand(); explicit AdcCommand(Severity sev, Error err, const std::string& desc, char aType); @@ -389,9 +383,10 @@ FLAG_BOT = 0x01, 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_SU = 0x08, + FLAG_OWNER = 0x10, + FLAG_HUB = 0x20, + MASK_CLIENT_TYPE = FLAG_BOT | FLAG_REGISTERED | FLAG_OP | FLAG_SU | FLAG_OWNER | FLAG_HUB, FLAG_PASSWORD = 0x100, FLAG_HIDDEN = 0x101, /** Extended away, no need to send msg */ @@ -460,6 +455,62 @@ void logDateTime(const std::string& area, const std::string& msg) throw(); }; +%template(SignalC) Signal<void (Client&)>; +%template(SignalTraitsC) SignalTraits<void (Client&)>; +%template(SignalCA) Signal<void (Client&, AdcCommand&)>; +%template(SignalTraitsCA) SignalTraits<void (Client&, AdcCommand&)>; +%template(SignalCAI) Signal<void (Client&, AdcCommand&, int&)>; +%template(SignalTraitsCAI) SignalTraits<void (Client&, AdcCommand&, int&)>; +%template(SignalCI) Signal<void (Client&, int)>; +%template(SignalTraitsCI) SignalTraits<void (Client&, int)>; +%template(SignalCS) Signal<void (Client&, const std::string&)>; +%template(SignalTraitsCS) SignalTraits<void (Client&, const std::string&)>; +%template(SignalS) Signal<void (const SimpleXML&)>; +%template(SignalTraitsS) SignalTraits<void (const SimpleXML&)>; + +%template(ManagedC) boost::intrusive_ptr<ManagedConnection<Signal<void (Client&)> > >; +%template(ManagedCA) boost::intrusive_ptr<ManagedConnection<Signal<void (Client&, AdcCommand&)> > >; +%template(ManagedCAI) boost::intrusive_ptr<ManagedConnection<Signal<void (Client&, AdcCommand&, int&)> > >; +%template(ManagedCI) boost::intrusive_ptr<ManagedConnection<Signal<void (Client&, int)> > >; +%template(ManagedCS) boost::intrusive_ptr<ManagedConnection<Signal<void (Client&, const std::string&)> > >; +%template(ManagedS) boost::intrusive_ptr<ManagedConnection<Signal<const SimpleXML&> > >; + +%extend Signal<void (Client&)> { + SignalTraits<void (Client&)>::ManagedConnection connect(std::tr1::function<void (Client&)> f) { + return manage(self, f); + } +} + +%extend Signal<void (Client&, AdcCommand&)> { + SignalTraits<void (Client&, AdcCommand&)>::ManagedConnection connect(std::tr1::function<void (Client&, AdcCommand&)> f) { + return manage(self, f); + } +} + +%extend Signal<void (Client&, AdcCommand&, int&)> { + SignalTraits<void (Client&, AdcCommand&, int&)>::ManagedConnection connect(std::tr1::function<void (Client&, AdcCommand&, int&)> f) { + return manage(self, f); + } +} + +%extend Signal<void (Client&, int)> { + SignalTraits<void (Client&, int)>::ManagedConnection connect(std::tr1::function<void (Client&, int)> f) { + return manage(self, f); + } +} + +%extend Signal<void (Client&, const std::string&)> { + SignalTraits<void (Client&, const std::string&)>::ManagedConnection connect(std::tr1::function<void (Client&, const std::string&)> f) { + return manage(self, f); + } +} + +%extend Signal<void (const SimpleXML&)> { + SignalTraits<void (const SimpleXML&)>::ManagedConnection connect(std::tr1::function<void (const SimpleXML&)> f) { + return manage(self, f); + } +} + class SocketManager { public: %extend { @@ -541,7 +592,7 @@ void enterIdentify(Client& c, bool sendData) throw(); - vector<uint8_t> enterVerify(Client& c, bool sendData) throw(); + ByteVector enterVerify(Client& c, bool sendData) throw(); bool enterNormal(Client& c, bool sendData, bool sendOwnInf) throw(); bool verifySUP(Client& c, AdcCommand& cmd) throw(); @@ -659,40 +710,6 @@ SignalLoad::Signal& signalLoad(); }; -%template(SignalC) Signal<void (Client&)>; -%template(SignalCA) Signal<void (Client&, AdcCommand&)>; -%template(SignalCAI) Signal<void (Client&, AdcCommand&, int&)>; -%template(SignalS) Signal<void (const SimpleXML&)>; - -%template(ManagedC) boost::intrusive_ptr<ManagedConnection<Signal<void (Client&)> > >; -%template(ManagedCAI) boost::intrusive_ptr<ManagedConnection<Signal<void (Client&, AdcCommand&, int&)> > >; -%template(ManagedCS) boost::intrusive_ptr<ManagedConnection<Signal<void (Client&, const std::string&)> > >; -%template(ManagedCI) boost::intrusive_ptr<ManagedConnection<Signal<void (Client&, int)> > >; - -%extend Signal<void (Client&)> { - boost::intrusive_ptr<ManagedConnection<Signal<void (Client&)> > > connect(std::tr1::function<void (Client&)> f) { - return manage(self, f); - } -} - -%extend Signal<void (Client&, AdcCommand&)> { - boost::intrusive_ptr<ManagedConnection<Signal<void (Client&, AdcCommand&)> > > connect(std::tr1::function<void (Client&, AdcCommand&)> f) { - return manage(self, f); - } -} - -%extend Signal<void (Client&, AdcCommand&, int&)> { - boost::intrusive_ptr<ManagedConnection<Signal<void (Client&, AdcCommand&, int&)> > > connect(std::tr1::function<void (Client&, AdcCommand&, int&)> f) { - return manage(self, f); - } -} - -%extend Signal<void (Client&, std::string&)> { - boost::intrusive_ptr<ManagedConnection<Signal<void (Client&, std::string&)> > > connect(std::tr1::function<void (Client&, std::string&)> f) { - return manage(self, f)); - } -} - class TigerHash { public: /** Hash size in bytes */ Modified: adchpp/trunk/swig/lua.i =================================================================== --- adchpp/trunk/swig/lua.i 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/swig/lua.i 2007-12-02 22:01:57 UTC (rev 97) @@ -5,23 +5,23 @@ %wrapper %{ static int traceback (lua_State *L) { - lua_getfield(L, LUA_GLOBALSINDEX, "debug"); - if (!lua_istable(L, -1)) { - printf("No debug table\n"); - lua_pop(L, 1); - return 1; - } - lua_getfield(L, -1, "traceback"); - if (!lua_isfunction(L, -1)) { - printf("No traceback in debug\n"); - lua_pop(L, 2); - return 1; - } + lua_getfield(L, LUA_GLOBALSINDEX, "debug"); + if (!lua_istable(L, -1)) { + printf("No debug table\n"); + lua_pop(L, 1); + return 1; + } + lua_getfield(L, -1, "traceback"); + if (!lua_isfunction(L, -1)) { + printf("No traceback in debug\n"); + lua_pop(L, 2); + return 1; + } - lua_pushvalue(L, 1); /* pass error message */ - lua_pushinteger(L, 2); /* skip this function and traceback */ - lua_call(L, 2, 1); /* call debug.traceback */ - return 1; + lua_pushvalue(L, 1); /* pass error message */ + lua_pushinteger(L, 2); /* skip this function and traceback */ + lua_call(L, 2, 1); /* call debug.traceback */ + return 1; } class RegistryItem : private boost::noncopyable { @@ -92,6 +92,14 @@ lua_pop(L, 1); } + void operator()(const adchpp::SimpleXML& s) { + pushFunction(); + + SWIG_NewPointerObj(L, &s, SWIGTYPE_p_adchpp__SimpleXML, 0); + docall(1, 0); + } + + private: void pushFunction() { registryItem->push(); } @@ -147,6 +155,18 @@ $1 = LuaFunction(L); } +%typemap(in) std::tr1::function<void (adchpp::Client &, int) > { + $1 = LuaFunction(L); +} + +%typemap(in) std::tr1::function<void (adchpp::Client &, const std::string&) > { + $1 = LuaFunction(L); +} + +%typemap(in) std::tr1::function<void (const SimpleXML&) > { + $1 = LuaFunction(L); +} + %include "adchpp.i" %extend adchpp::AdcCommand { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2007-12-04 22:04:23
|
Revision: 98 http://adchpp.svn.sourceforge.net/adchpp/?rev=98&view=rev Author: arnetheduck Date: 2007-12-04 14:04:21 -0800 (Tue, 04 Dec 2007) Log Message: ----------- More access fixes Modified Paths: -------------- adchpp/trunk/adchpp/ClientManager.cpp adchpp/trunk/plugins/Script/examples/access.lua adchpp/trunk/swig/adchpp.i Modified: adchpp/trunk/adchpp/ClientManager.cpp =================================================================== --- adchpp/trunk/adchpp/ClientManager.cpp 2007-12-02 22:01:57 UTC (rev 97) +++ adchpp/trunk/adchpp/ClientManager.cpp 2007-12-04 22:04:21 UTC (rev 98) @@ -265,21 +265,22 @@ return true; } -bool ClientManager::verifyPassword(Client& c, const string& password, const vector<uint8_t>& salt, +bool ClientManager::verifyPassword(Client& c, const string& password, const ByteVector& salt, const string& suppliedHash) { TigerHash tiger; tiger.update(&password[0], password.size()); tiger.update(&salt[0], salt.size()); uint8_t tmp[TigerHash::HASH_SIZE]; Encoder::fromBase32(suppliedHash.c_str(), tmp, TigerHash::HASH_SIZE); - if (memcmp(tiger.finalize(), tmp, TigerHash::HASH_SIZE) == 0) + if (memcmp(tiger.finalize(), tmp, TigerHash::HASH_SIZE) == 0) { return true; + } if (!COMPATIBILITY) return false; TigerHash tiger2; - // Support dc++ 0.69 for a while + // Support dc++ <=0.703 for a while string cid = c.getCID().toBase32(); tiger2.update(c.getCID().data(), CID::SIZE); tiger2.update(&password[0], password.size()); Modified: adchpp/trunk/plugins/Script/examples/access.lua =================================================================== --- adchpp/trunk/plugins/Script/examples/access.lua 2007-12-02 22:01:57 UTC (rev 97) +++ adchpp/trunk/plugins/Script/examples/access.lua 2007-12-04 22:04:21 UTC (rev 98) @@ -158,14 +158,14 @@ end local function dump(c, code, msg) - answer = adchpp.AdcCommand(adchpp.CMD_STA, adchpp.TYPE_INFO, adchpp.HUB_SID) - answer:addParam("" .. adchpp.SEV_FATAL .. code):addParam(msg) + answer = adchpp.AdcCommand(adchpp.AdcCommand_CMD_STA, adchpp.AdcCommand_TYPE_INFO, adchpp.AdcCommand_HUB_SID) + answer:addParam("" .. tostring(adchpp.AdcCommand_SEV_FATAL) .. code):addParam(msg) c:send(answer) c:disconnect() end local function reply(c, msg) - answer = adchpp.AdcCommand(adchpp.CMD_MSG, adchpp.TYPE_INFO, adchpp.HUB_SID) + answer = adchpp.AdcCommand(adchpp.AdcCommand_CMD_MSG, adchpp.AdcCommand_TYPE_INFO, adchpp.AdcCommand_HUB_SID) answer:addParam(msg) c:send(answer) end @@ -248,31 +248,31 @@ end if #cmd:getParam("HI", 0) > 0 then - dump(c, adchpp.ERROR_PROTOCOL_GENERIC, "Don't hide") + dump(c, adchpp.AdcCommand_ERROR_PROTOCOL_GENERIC, "Don't hide") return command_processed end if #cmd:getParam("OP", 0) > 0 then - dump(c, adchpp.ERROR_PROTOCOL_GENERIC, "I decide who's an OP") + dump(c, adchpp.AdcCommand_ERROR_PROTOCOL_GENERIC, "I decide who's an OP") return command_processed end if #cmd:getParam("RG", 0) > 0 then - dump(c, adchpp.ERROR_PROTOCOL_GENERIC, "I decide who's registered") + dump(c, adchpp.AdcCommand_ERROR_PROTOCOL_GENERIC, "I decide who's registered") return command_processed end if #cmd:getParam("HU", 0) > 0 then - dump(c, adchpp.ERROR_PROTOCOL_GENERIC, "I'm the hub, not you") + dump(c, adchpp.AdcCommand_ERROR_PROTOCOL_GENERIC, "I'm the hub, not you") return command_processed end if #cmd:getParam("BO", 0) > 0 then - dump(c, adchpp.ERROR_PROTOCOL_GENERIC, "You're not a bot") + dump(c, adchpp.AdcCommand_ERROR_PROTOCOL_GENERIC, "You're not a bot") return command_processed end - if c:getState() == adchpp.STATE_NORMAL then + if c:getState() == adchpp.Client_STATE_NORMAL then return 0 end @@ -280,7 +280,7 @@ local cid = cmd:getParam("ID", 0) if #nick == 0 or #cid == 0 then - dump(c, adchpp.ERROR_PROTOCOL_GENERIC, "No valid nick/CID supplied") + dump(c, adchpp.AdcCommand_ERROR_PROTOCOL_GENERIC, "No valid nick/CID supplied") return command_processed end @@ -304,15 +304,15 @@ end local function onPAS(c, cmd) - if c:getState() ~= adchpp.STATE_VERIFY then - dump(c, adchpp.ERROR_PROTOCOL_GENERIC, "Not in VERIFY state") + if c:getState() ~= adchpp.Client_STATE_VERIFY then + dump(c, adchpp.AdcCommand_ERROR_PROTOCOL_GENERIC, "Not in VERIFY state") return command_processed end local salt = salts[c:getSID()] if not salt then - dump(c, adchpp.ERROR_PROTOCOL_GENERIC, "You didn't get any salt?") + dump(c, adchpp.AdcCommand_ERROR_PROTOCOL_GENERIC, "You didn't get any salt?") return command_processed end @@ -322,7 +322,7 @@ local user = get_user(c:getCID():toBase32(), c:getField("NI")) if not user then print("User sending PAS not found (?)") - dump(c, adchpp.ERROR_PROTOCOL_GENERIC, "Can't find you now") + dump(c, adchpp.AdcCommand_ERROR_PROTOCOL_GENERIC, "Can't find you now") return command_processed end @@ -332,13 +332,13 @@ end if not cm:verifyPassword(c, password, salt, cmd:getParam(0)) then - dump(c, adchpp.ERROR_BAD_PASSWORD, "Invalid password") + dump(c, adchpp.AdcCommand_ERROR_BAD_PASSWORD, "Invalid password") return command_processed end local updateOk, message = update_user(user, cid:toBase32(), nick) if not updateOk then - dump(c, adchpp.ERROR_PROTOCOL_GENERIC, message) + dump(c, adchpp.AdcCommand_ERROR_PROTOCOL_GENERIC, message) return command_processed end @@ -351,7 +351,7 @@ if user.level > 1 and c:supports("UCMD") then for k, v in pairs(user_commands) do - ucmd = adchpp.AdcCommand(adchpp.CMD_CMD, adchpp.TYPE_INFO, adchpp.HUB_SID) + ucmd = adchpp.AdcCommand(adchpp.AdcCommand_CMD_CMD, adchpp.AdcCommand_TYPE_INFO, adchpp.AdcCommand_HUB_SID) ucmd:addParam(k) ucmd:addParam("TT", v) ucmd:addParam("CT", "2") @@ -386,7 +386,7 @@ local function onMSG(c, cmd) msg = cmd:getParam(0) - + print("got message") local command, parameters = msg:match("^%+(%a+) ?(.*)") if not command then @@ -402,28 +402,28 @@ if command == "test" then reply(c, "Test ok") - return adchpp.DONT_SEND + return adchpp.AdcCommand_DONT_SEND elseif command == "error" then xxxxyyyy() - return adchpp.DONT_SEND + return adchpp.AdcCommand_DONT_SEND elseif command == "help" then reply(c, "+test, +help, +regme password, +regnick nick password level") - return adchpp.DONT_SEND + return adchpp.AdcCommand_DONT_SEND elseif command == "regme" then if not parameters:match("%S+") then reply(c, "You need to supply a password without whitespace") - return adchpp.DONT_SEND + return adchpp.AdcCommand_DONT_SEND end register_user(c:getCID():toBase32(), c:getField("NI"), parameters, 1) reply(c, "You're now registered") - return adchpp.DONT_SEND + return adchpp.AdcCommand_DONT_SEND elseif command == "regnick" then local nick, password, level = parameters:match("^(%S+) (%S+) (%d+)") if not nick or not password or not level then reply(c, "You must supply nick, password and level!") - return adchpp.DONT_SEND + return adchpp.AdcCommand_DONT_SEND end level = tonumber(level) @@ -439,17 +439,17 @@ if not my_user then reply(c, "Only registered users may register others") - return adchpp.DONT_SEND + return adchpp.AdcCommand_DONT_SEND end if level >= my_user.level then reply(c, "You may only register to a lower level than your own") - return adchpp.DONT_SEND + return adchpp.AdcCommand_DONT_SEND end if level < 1 then reply(c, "Level too low") - return adchpp.DONT_SEND + return adchpp.AdcCommand_DONT_SEND end register_user(cid, nick, password, level) @@ -460,7 +460,7 @@ reply(other, "You've been registered with password " .. password) end - return adchpp.DONT_SEND + return adchpp.AdcCommand_DONT_SEND elseif command == "stats" then local now = os.time() local scripttime = os.difftime(now, start_time) @@ -522,7 +522,7 @@ str = str .. recvCalls .. "\tReceive calls (" .. adchpp.Util_formatBytes(recvBytes/recvCalls) .. "/call)\n" reply(c, str) - return adchpp.DONT_SEND + return adchpp.AdcCommand_DONT_SEND end return 0 @@ -543,7 +543,6 @@ end local function onReceive(c, cmd, override) - cmdstr = cmd:getCommandString() if stats[cmdstr] then stats[cmdstr] = stats[cmdstr] + 1 @@ -564,7 +563,7 @@ end end - if c:getState() == adchpp.STATE_NORMAL then + if c:getState() == adchpp.Client_STATE_NORMAL then local allowed_level = command_min_levels[cmd:getCommand()] if allowed_level then user = get_user(c:getCID(), c:getField("NI")) @@ -575,12 +574,13 @@ end end end - - if cmd:getCommand() == adchpp.CMD_INF then + + print("command is " .. cmd:getCommand() .. " msg is " .. adchpp.AdcCommand_CMD_MSG) + if cmd:getCommand() == adchpp.AdcCommand_CMD_INF then return onINF(c, cmd) - elseif cmd:getCommand() == adchpp.CMD_PAS then + elseif cmd:getCommand() == adchpp.AdcCommand_CMD_PAS then return onPAS(c, cmd) - elseif cmd:getCommand() == adchpp.CMD_MSG then + elseif cmd:getCommand() == adchpp.AdcCommand_CMD_MSG then return onMSG(c, cmd) elseif cmd:getCommandString() == "DSC" then return onDSC(c, cmd) Modified: adchpp/trunk/swig/adchpp.i =================================================================== --- adchpp/trunk/swig/adchpp.i 2007-12-02 22:01:57 UTC (rev 97) +++ adchpp/trunk/swig/adchpp.i 2007-12-04 22:04:21 UTC (rev 98) @@ -69,12 +69,15 @@ namespace adchpp { class Client; } + %template(TErrorPair) std::pair<int, size_t>; %template(TErrorList) std::vector<std::pair<int, size_t> >; %template(TClientList) std::vector<adchpp::Client*>; %template(TStringList) std::vector<std::string>; +%template(TByteVector) std::vector<uint8_t>; + typedef std::vector<std::string> StringList; %inline%{ typedef std::vector<adchpp::Client*> ClientList; @@ -598,7 +601,7 @@ bool verifySUP(Client& c, AdcCommand& cmd) throw(); bool verifyINF(Client& c, AdcCommand& cmd) throw(); bool verifyNick(Client& c, const AdcCommand& cmd) throw(); - bool verifyPassword(Client& c, const std::string& password, const vector<uint8_t>& salt, const std::string& suppliedHash); + bool verifyPassword(Client& c, const std::string& password, const ByteVector& salt, const std::string& suppliedHash); bool verifyIp(Client& c, AdcCommand& cmd) throw(); bool verifyCID(Client& c, AdcCommand& cmd) throw(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2007-12-09 18:44:51
|
Revision: 99 http://adchpp.svn.sourceforge.net/adchpp/?rev=99&view=rev Author: arnetheduck Date: 2007-12-09 10:44:45 -0800 (Sun, 09 Dec 2007) Log Message: ----------- Simplified writers some Modified Paths: -------------- adchpp/trunk/SConstruct adchpp/trunk/adchpp/ManagedSocket.cpp adchpp/trunk/adchpp/ManagedSocket.h adchpp/trunk/adchpp/Socket.cpp adchpp/trunk/adchpp/SocketManager.cpp adchpp/trunk/adchpp/SocketManager.h adchpp/trunk/adchpp/Util.cpp adchpp/trunk/plugins/Script/examples/access.lua adchpp/trunk/readme.txt adchpp/trunk/swig/adchpp.i adchpp/trunk/swig/lua.i adchpp/trunk/swig/python.i adchpp/trunk/test/PyClient.py adchpp/trunk/unix/po/adchppd.pot Modified: adchpp/trunk/SConstruct =================================================================== --- adchpp/trunk/SConstruct 2007-12-04 22:04:21 UTC (rev 98) +++ adchpp/trunk/SConstruct 2007-12-09 18:44:45 UTC (rev 99) @@ -213,6 +213,8 @@ conf = Configure(env) +if conf.CheckCHeader('poll.h'): + conf.env.Append(CPPDEFINES='HAVE_POLL_H') if conf.CheckCHeader('sys/epoll.h'): conf.env.Append(CPPDEFINES=['HAVE_SYS_EPOLL_H']) if conf.CheckLib('dl', 'dlopen'): Modified: adchpp/trunk/adchpp/ManagedSocket.cpp =================================================================== --- adchpp/trunk/adchpp/ManagedSocket.cpp 2007-12-04 22:04:21 UTC (rev 98) +++ adchpp/trunk/adchpp/ManagedSocket.cpp 2007-12-09 18:44:45 UTC (rev 99) @@ -34,6 +34,8 @@ ManagedSocket::ManagedSocket() throw() : outBuf(0), overFlow(0), disc(0) #ifdef _WIN32 , writeBuf(0) +#else +, blocked(false) #endif { } @@ -92,8 +94,12 @@ } ByteVector* ManagedSocket::prepareWrite() { - ByteVector* buffer = 0; + if(isBlocked()) { + return 0; + } + ByteVector* buffer = 0; + { FastMutex::Lock l(writeMutex); @@ -153,11 +159,11 @@ } void ManagedSocket::completeAccept() throw() { - SocketManager::getInstance()->addJob(std::tr1::bind(&ManagedSocket::processIncoming, this)); + SocketManager::getInstance()->addJob(connectedHandler); } -void ManagedSocket::failSocket() throw() { - SocketManager::getInstance()->addJob(std::tr1::bind(&ManagedSocket::processFail, this)); +void ManagedSocket::failSocket(int) throw() { + SocketManager::getInstance()->addJob(failedHandler); } void ManagedSocket::disconnect(Util::Reason reason) throw() { @@ -165,22 +171,14 @@ return; } - disc = GET_TICK(); + disc = GET_TICK() + SETTING(DISCONNECT_TIMEOUT); Util::reasons[reason]++; SocketManager::getInstance()->addDisconnect(this); } -void ManagedSocket::processIncoming() throw() { - connectedHandler(); -} - void ManagedSocket::processData(ByteVector* buf) throw() { dataHandler(*buf); Util::freeBuf = buf; } -void ManagedSocket::processFail() throw() { - failedHandler(); } - -} Modified: adchpp/trunk/adchpp/ManagedSocket.h =================================================================== --- adchpp/trunk/adchpp/ManagedSocket.h 2007-12-04 22:04:21 UTC (rev 98) +++ adchpp/trunk/adchpp/ManagedSocket.h 2007-12-09 18:44:45 UTC (rev 99) @@ -73,15 +73,13 @@ void completeAccept() throw(); bool completeWrite(ByteVector* buf, size_t written) throw(); bool completeRead(ByteVector* buf) throw(); - void failSocket() throw(); + void failSocket(int error) throw(); void shutdown() { sock.shutdown(); } void close() { sock.disconnect(); } // Functions processing events - void processIncoming() throw(); void processData(ByteVector* buf) throw(); - void processFail() throw(); // No copies ManagedSocket(const ManagedSocket&); @@ -103,6 +101,12 @@ ByteVector* writeBuf; /** WSABUF for data being sent */ WSABUF wsabuf; + + bool isBlocked() { return writeBuf != 0; } +#else + bool blocked; + bool isBlocked() { return blocked; } + void setBlocked(bool blocked_) { blocked = blocked_; } #endif ConnectedHandler connectedHandler; Modified: adchpp/trunk/adchpp/Socket.cpp =================================================================== --- adchpp/trunk/adchpp/Socket.cpp 2007-12-04 22:04:21 UTC (rev 98) +++ adchpp/trunk/adchpp/Socket.cpp 2007-12-09 18:44:45 UTC (rev 99) @@ -20,6 +20,10 @@ #include "Socket.h" +#ifdef HAVE_POLL_H +#include <poll.h> +#endif + namespace adchpp { using namespace std; @@ -37,13 +41,12 @@ { #ifdef _WIN32 checksocket(sock = WSASocket(AF_INET, SOCK_STREAM, IPPROTO_TCP, 0, 0, WSA_FLAG_OVERLAPPED)); - setBlocking(false); DWORD x = 0; setsockopt(sock, SOL_SOCKET, SO_SNDBUF, (char*)&x, sizeof(x)); #else checksocket(sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)); - setBlocking(false); #endif + setBlocking(false); } break; case TYPE_UDP: @@ -75,13 +78,14 @@ #else sock = ::socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); #endif - int x = 1; - ::setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char*)&x, sizeof(int)); if(sock == (socket_t)-1) { throw SocketException(socket_errno); } + int x = 1; + ::setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char*)&x, sizeof(int)); + tcpaddr.sin_family = AF_INET; tcpaddr.sin_port = htons(aPort); tcpaddr.sin_addr.s_addr = htonl(INADDR_ANY); @@ -254,25 +258,21 @@ if(waitFor & WAIT_READ || waitFor & WAIT_CONNECT) { fd.events |= POLLIN; } - if(waifFor & WAIT_WRITE) { + if(waitFor & WAIT_WRITE) { fd.events |= POLLOUT; } - int result = poll(&fd, 1, millis)); + int result = poll(&fd, 1, millis); if(result == 1) { if(fd.revents & POLLERR) { int y = 0; socklen_t z = sizeof(y); checksockerr(getsockopt(sock, SOL_SOCKET, SO_ERROR, (char*)&y, &z)); - if(y != 0) { - throw SocketException(y); - } - // Should never happen - throw SocketException("Unknown socket error"); + throw SocketException(y); } int ret = 0; - if(fr.revents & POLLIN) { + if(fd.revents & POLLIN) { ret |= waitFor & (WAIT_READ | WAIT_CONNECT); } if(fd.revents & POLLOUT) { @@ -384,9 +384,8 @@ void Socket::disconnect() throw() { if(sock != INVALID_SOCKET) { closesocket(sock); + sock = INVALID_SOCKET; } - - sock = INVALID_SOCKET; } } Modified: adchpp/trunk/adchpp/SocketManager.cpp =================================================================== --- adchpp/trunk/adchpp/SocketManager.cpp 2007-12-04 22:04:21 UTC (rev 98) +++ adchpp/trunk/adchpp/SocketManager.cpp 2007-12-09 18:44:45 UTC (rev 99) @@ -48,12 +48,9 @@ struct MSOverlapped : OVERLAPPED { enum Types { - ACCEPT, + ACCEPT_DONE, READ_DONE, WRITE_DONE, - WRITE_WAITING, - WRITE_ALL, - DISCONNECT, SHUTDOWN } type; ManagedSocketPtr ms; @@ -69,17 +66,17 @@ } }; -class CompletionPort { +class Poller { public: - CompletionPort() : handle(INVALID_HANDLE_VALUE) { + Poller() : handle(INVALID_HANDLE_VALUE) { } - ~CompletionPort() { + ~Poller() { if(handle != INVALID_HANDLE_VALUE) ::CloseHandle(handle); } - bool create() { + bool init() { handle = ::CreateIoCompletionPort(INVALID_HANDLE_VALUE, 0, 0, 0); return handle != NULL; } @@ -102,89 +99,124 @@ HANDLE handle; }; -class Writer : public Thread { -public: - static const size_t PREPARED_SOCKETS = 32; - - Writer() : stop(false) { + +#elif defined(HAVE_SYS_EPOLL_H) + +struct Poller { + Poller() : poll_fd(-1) { } - void addWriter(ManagedSocketPtr /*ms */) { - if(stop) - return; -#if 0 - MSOverlapped* overlapped = pool.get(); - *overlapped = MSOverlapped(MSOverlapped::WRITE_WAITING, ms); - - if(!port.post(overlapped)) { - LOGDT(SocketManager::className, "Fatal error while posting write to completion port: " + Util::translateError(::GetLastError())); + ~Poller() { + if(poll_fd != -1) { + close(poll_fd); } -#endif } - void addAllWriters() { - if(stop) - return; -#if 0 - MSOverlapped* overlapped = pool.get(); - *overlapped = MSOverlapped(MSOverlapped::WRITE_ALL); + bool init() { + poll_fd = epoll_create(1024); + if(poll_fd == -1) + return false; - if(!port.post(overlapped)) { - LOGDT(SocketManager::className, "Fatal error while posting writeAll to completion port: " + Util::translateError(::GetLastError())); + return true; + } + + bool associate(const ManagedSocketPtr& ms) { + struct epoll_event ev; + ev.data.ptr = reinterpret_cast<void*>(ms.get()); + ev.events = EPOLLIN | EPOLLOUT | EPOLLET; + return epoll_ctl(poll_fd, EPOLL_CTL_ADD, ms->getSocket(), &ev) == 0; + } + + bool associate(int fd) { + struct epoll_event ev; + ev.data.fd = fd; + ev.events = EPOLLIN; + return epoll_ctl(poll_fd, EPOLL_CTL_ADD, fd, &ev) == 0; + } + + bool get(vector<epoll_event>& events) { + events.clear(); + events.resize(1024); + while(true) { + int n = epoll_wait(poll_fd, &events[0], events.size(), WRITE_TIMEOUT); + if(n == -1) { + if(errno != EINTR) { + return false; + } + // Keep looping + } else { + events.resize(n); + return true; + } } -#endif } - void addDisconnect(ManagedSocketPtr ms) { - if(stop) - return; - - MSOverlapped* overlapped = pool.get(); - *overlapped = MSOverlapped(MSOverlapped::DISCONNECT, ms); - - if(!port.post(overlapped)) { - LOGDT(SocketManager::className, "Fatal error while posting disconnect to completion port: " + Util::translateError(::GetLastError())); - } - } + int poll_fd; +}; + +#else +#error No socket implementation for your platform +#endif // _WIN32 + +class Writer : public Thread { +public: + Writer() : stop(false) { + } + +#ifdef _WIN32 void shutdown() { stop = true; MSOverlapped* overlapped = pool.get(); *overlapped = MSOverlapped(MSOverlapped::SHUTDOWN); - if(!port.post(overlapped)) { + if(!poller.post(overlapped)) { LOGDT(SocketManager::className, "Fatal error while posting shutdown to completion port: " + Util::translateError(::GetLastError())); } join(); } +#else + void shutdown() { + stop = true; - void getErrors(SocketManager::ErrorMap& acceptErrors_, SocketManager::ErrorMap& readErrors_, SocketManager::ErrorMap& writeErrors_) { - FastMutex::Lock l(errorMutex); - acceptErrors_ = acceptErrors; - readErrors_ = readErrors; - writeErrors_ = writeErrors; + char ev = 0; + ::write(event[0], &ev, sizeof(ev)); + + join(); } - +#endif private: bool init() { - if(!port.create()) { - LOGDT(SocketManager::className, "Unable to create IO Completion port: " + Util::translateError(::GetLastError())); + if(!poller.init()) { + LOGDT(SocketManager::className, "Unable to start poller: " + Util::translateError(socket_errno)); return false; } try { - srv.listen(static_cast<short>(SETTING(SERVER_PORT))); + srv.listen(SETTING(SERVER_PORT)); + srv.setBlocking(false); } catch(const SocketException& e) { LOGDT(SocketManager::className, "Unable to create server socket: " + e.getError()); return false; } - if(!port.associate(srv.getSocket())) { - LOGDT(SocketManager::className, "Unable to associate IO Completion port: " + Util::translateError(::GetLastError())); + if(!poller.associate(srv.getSocket())) { + LOGDT(SocketManager::className, "Unable to associate server socket with poller: " + Util::translateError(socket_errno)); return false; } - + +#ifndef _WIN32 + if(socketpair(AF_UNIX, SOCK_STREAM, 0, event) == -1) { + LOGDT(SocketManager::className, "Unable to create event socketpair: " + Util::translateError(errno)); + return false; + } + + if(!poller.associate(event[1])) { + LOGDT(SocketManager::className, "Unable to associate event: " + Util::translateError(errno)); + return false; + } +#endif return true; } @@ -194,77 +226,18 @@ return 0; } - prepareAccept(); - - DWORD bytes = 0; - MSOverlapped* overlapped = 0; - uint32_t lastWrite = 0; - while(!stop || !accepting.empty() || !active.empty()) { - bool ret = port.get(&bytes, &overlapped); - //dcdebug("Event: %x, %x, %x, %x, %x, %x\n", (unsigned int)ret, (unsigned int)bytes, (unsigned int)ms, (unsigned int)overlapped, (unsigned int)overlapped->ms, (unsigned int)overlapped->type); +#ifdef _WIN32 + prepareAccept(); +#endif + while(!stop || !active.empty()) { + handleEvents(); - if(!ret) { - int error = ::GetLastError(); - if(overlapped == 0) { - if(error != WAIT_TIMEOUT) { - LOGDT(SocketManager::className, "Fatal error while getting status from completion port: " + Util::translateError(error)); - return error; - } - } else if(overlapped->type == MSOverlapped::ACCEPT) { - dcdebug("Error accepting: %s\n", Util::translateError(error).c_str()); - failAccept(overlapped->ms, error); - } else if(overlapped->type == MSOverlapped::READ_DONE) { - dcdebug("Error reading: %s\n", Util::translateError(error).c_str()); - failRead(overlapped->ms, error); - } else if(overlapped->type == MSOverlapped::WRITE_DONE) { - dcdebug("Error writing: %s\n", Util::translateError(error).c_str()); - failWrite(overlapped->ms, error); - } else { - dcdebug("Unknown error %d when waiting\n", overlapped->type); - } - } else { - switch(overlapped->type) { - case MSOverlapped::ACCEPT: { - checkDisconnects(); - handleAccept(overlapped->ms); - break; - } - case MSOverlapped::READ_DONE: { - handleReadDone(overlapped->ms); - break; - } - case MSOverlapped::WRITE_DONE: { - handleWriteDone(overlapped->ms, bytes); - break; - } - case MSOverlapped::WRITE_WAITING: { - prepareWrite(overlapped->ms); - break; - } - case MSOverlapped::WRITE_ALL: { - writeAll(); - break; - } - case MSOverlapped::DISCONNECT: { - handleDisconnect(overlapped->ms); - break; - } - case MSOverlapped::SHUTDOWN: { - handleShutdown(); - break; - } - } - } - if(overlapped != 0) { - pool.put(overlapped); - } - uint32_t now = GET_TICK(); if(now > lastWrite + WRITE_TIMEOUT) { - checkDisconnects(); writeAll(); + removeDisconnected(); lastWrite = now; } @@ -273,6 +246,57 @@ return 0; } +#ifdef _WIN32 + void handleEvents() { + DWORD bytes = 0; + MSOverlapped* overlapped = 0; + bool ret = poller.get(&bytes, &overlapped); + //dcdebug("Event: %x, %x, %x, %x, %x, %x\n", (unsigned int)ret, (unsigned int)bytes, (unsigned int)ms, (unsigned int)overlapped, (unsigned int)overlapped->ms, (unsigned int)overlapped->type); + + if(!ret) { + int error = ::GetLastError(); + if(overlapped == 0) { + if(error != WAIT_TIMEOUT) { + LOGDT(SocketManager::className, "Fatal error while getting status from completion port: " + Util::translateError(error)); + return; + } + } else if(overlapped->type == MSOverlapped::ACCEPT_DONE) { + dcdebug("Error accepting: %s\n", Util::translateError(error).c_str()); + failAccept(overlapped->ms, error); + } else if(overlapped->type == MSOverlapped::READ_DONE) { + dcdebug("Error reading: %s\n", Util::translateError(error).c_str()); + disconnect(overlapped->ms, error); + } else if(overlapped->type == MSOverlapped::WRITE_DONE) { + dcdebug("Error writing: %s\n", Util::translateError(error).c_str()); + failWrite(overlapped->ms, error); + } else { + dcdebug("Unknown error %d when waiting\n", overlapped->type); + } + } else { + switch(overlapped->type) { + case MSOverlapped::ACCEPT_DONE: { + handleAccept(overlapped->ms); + break; + } + case MSOverlapped::READ_DONE: { + handleReadDone(overlapped->ms); + break; + } + case MSOverlapped::WRITE_DONE: { + handleWriteDone(overlapped->ms, bytes); + break; + } + case MSOverlapped::SHUTDOWN: { + handleShutdown(); + break; + } + } + } + if(overlapped != 0) { + pool.put(overlapped); + } + } + void prepareAccept() throw() { if(stop) return; @@ -290,8 +314,8 @@ return; } - if(!port.associate(ms->getSocket())) { - LOGDT(SocketManager::className, "Unable to associate IO Completion port: " + Util::translateError(::GetLastError())); + if(!poller.associate(ms->getSocket())) { + LOGDT(SocketManager::className, "Unable to associate poller: " + Util::translateError(::GetLastError())); return; } @@ -301,7 +325,7 @@ ms->writeBuf->resize(ACCEPT_BUF_SIZE); MSOverlapped* overlapped = pool.get(); - *overlapped = MSOverlapped(MSOverlapped::ACCEPT, ms); + *overlapped = MSOverlapped(MSOverlapped::ACCEPT_DONE, ms); if(!::AcceptEx(srv.getSocket(), ms->getSocket(), &(*ms->writeBuf)[0], 0, ACCEPT_BUF_SIZE/2, ACCEPT_BUF_SIZE/2, &x, overlapped)) { int error = ::WSAGetLastError(); @@ -312,9 +336,6 @@ pool.put(overlapped); - FastMutex::Lock l(errorMutex); - acceptErrors[error]++; - return; } } @@ -340,7 +361,7 @@ SocketManager::getInstance()->incomingHandler(ms); ms->completeAccept(); - prepareRead(ms); + read(ms); // Prepare a new socket to replace this one... prepareAccept(); } @@ -348,14 +369,10 @@ void failAccept(ManagedSocketPtr& ms, int error) throw() { accepting.erase(ms); - prepareAccept(); - - FastMutex::Lock l(errorMutex); - acceptErrors[error]++; } - - void prepareRead(const ManagedSocketPtr& ms) throw() { + + void read(const ManagedSocketPtr& ms) throw() { if(stop) return; @@ -370,7 +387,7 @@ int error = ::WSAGetLastError(); if(error != WSA_IO_PENDING) { dcdebug("Error preparing read: %s\n", Util::translateError(error).c_str()); - failRead(ms, error); + disconnect(ms, error); } } } @@ -391,58 +408,38 @@ int error = ::WSAGetLastError(); if(error != WSAEWOULDBLOCK) { // Socket failed... - failRead(ms, error); + disconnect(ms, error); return; } - prepareRead(ms); + read(ms); return; } if(bytes == 0) { Util::freeBuf = readBuf; - failRead(ms, 0); + disconnect(ms, 0); return; } readBuf->resize(bytes); ms->completeRead(readBuf); - prepareRead(ms); + read(ms); } - void failRead(const ManagedSocketPtr& ms, int error) throw() { - if(active.find(ms) == active.end()) { + void write(const ManagedSocketPtr& ms) throw() { + if(stop || !(*ms)) { return; } - if(error != 0) { - FastMutex::Lock l(errorMutex); - readErrors[error]++; - } - - ms->close(); - - SocketSet::iterator i = disconnecting.find(ms); - if(i == disconnecting.end()) { - ms->failSocket(); - } else { - disconnecting.erase(i); - } - - active.erase(ms); - } - - void prepareWrite(const ManagedSocketPtr& ms) throw() { - if(stop || ms->writeBuf) { - return; - } - ms->writeBuf = ms->prepareWrite(); if(!ms->writeBuf) { - if(ms->disc) { - ms->close(); + uint32_t now = GET_TICK(); + + if(ms->disc || (ms->isBlocked() && ms->disc < now)) { + disconnect(ms, 0); } return; } @@ -457,11 +454,10 @@ if(::WSASend(ms->getSocket(), &ms->wsabuf, 1, &x, 0, reinterpret_cast<LPWSAOVERLAPPED>(overlapped), 0) != 0) { int error = ::WSAGetLastError(); if(error != WSA_IO_PENDING) { - failWrite(ms, error); pool.put(overlapped); + disconnect(ms, error); } } - return; } void handleWriteDone(const ManagedSocketPtr& ms, DWORD bytes) throw() { @@ -472,328 +468,51 @@ dcdebug("No buffer in handleWriteDone??\n"); return; } - if(ms->completeWrite(buf, bytes)) { - prepareWrite(ms); - } + ms->completeWrite(buf, bytes); } void failWrite(const ManagedSocketPtr& ms, int error) throw() { Util::freeBuf = ms->writeBuf; ms->writeBuf = 0; - - FastMutex::Lock l(errorMutex); - writeErrors[error]++; + disconnect(ms, error); } - - void writeAll() throw() { - for(SocketSet::iterator i = active.begin(); i != active.end(); ++i) { - prepareWrite(*i); - } - } - - void handleDisconnect(const ManagedSocketPtr& ms) throw() { - if(active.find(ms) == active.end()) { - return; - } - - if(disconnecting.find(ms) != disconnecting.end()) { - return; - } - - prepareWrite(ms); - disconnecting.insert(ms); - ms->failSocket(); - } - - void checkDisconnects() throw() { - uint32_t now = GET_TICK(); - for(SocketSet::iterator i = disconnecting.begin(); i != disconnecting.end(); ++i) { - const ManagedSocketPtr& ms = *i; - if(ms->disc + (uint32_t)SETTING(DISCONNECT_TIMEOUT) < now) { - ms->close(); - } - } - } - + void handleShutdown() throw() { for(SocketSet::iterator i = accepting.begin(); i != accepting.end(); ++i) { (*i)->close(); } for(SocketSet::iterator i = active.begin(); i != active.end(); ++i) { - (*i)->close(); + disconnect(*i, 0); } } - - FastMutex errorMutex; - SocketManager::ErrorMap acceptErrors; - SocketManager::ErrorMap readErrors; - SocketManager::ErrorMap writeErrors; - - CompletionPort port; - Socket srv; - - bool stop; - - Pool<MSOverlapped, ClearOverlapped> pool; - - typedef unordered_set<ManagedSocketPtr, PointerHash<ManagedSocket> > SocketSet; - /** Sockets that have a pending read */ - SocketSet active; - /** Sockets that have a pending accept */ - SocketSet accepting; - /** Sockets that are being written to but should be disconnected if timeout it reached */ - SocketSet disconnecting; -}; -#elif defined(HAVE_SYS_EPOLL_H) - -struct EPoll { - EPoll() : poll_fd(-1) { - } +#else - ~EPoll() { - if(poll_fd != -1) { - close(poll_fd); + void handleEvents() { + vector<epoll_event> events; + if(!poller.get(events)) { + LOGDT(SocketManager::className, "Poller failed: " + Util::translateError(errno)); } - } - - bool init() { - poll_fd = epoll_create(1024); - if(poll_fd == -1) - return false; - - return true; - } - - bool associate(const ManagedSocketPtr& ms) { - struct epoll_event ev; - ev.data.ptr = reinterpret_cast<void*>(ms.get()); - ev.events = EPOLLIN | EPOLLOUT | EPOLLET; - return epoll_ctl(poll_fd, EPOLL_CTL_ADD, ms->getSocket(), &ev) == 0; - } - - bool associate(int fd) { - struct epoll_event ev; - ev.data.fd = fd; - ev.events = EPOLLIN; - return epoll_ctl(poll_fd, EPOLL_CTL_ADD, fd, &ev) == 0; - } - - bool get(vector<epoll_event>& events) { - events.resize(1024); - while(true) { - int n = epoll_wait(poll_fd, &events[0], events.size(), WRITE_TIMEOUT); - if(n == -1) { - if(errno != EINTR) { - return false; - } - // Keep looping + for(vector<epoll_event>::iterator i = events.begin(); i != events.end(); ++i) { + epoll_event& ev = *i; + if(ev.data.fd == srv.getSocket()) { + accept(); + } else if(ev.data.fd == event[1]) { + handleShutdown(); } else { - events.resize(n); - return true; - } - } - } - - void remove(const ManagedSocketPtr& ms) { - // Buggy pre-2.6.9 kernels require non-null for last param - epoll_event e; - epoll_ctl(poll_fd, EPOLL_CTL_DEL, ms->getSocket(), &e); - } - - int poll_fd; -}; - -struct Event { - enum Type { - WRITE, - WRITE_ALL, - DISCONNECT, - REMOVE, - SHUTDOWN - } event; - ManagedSocketPtr ms; - - Event(Type event_, const ManagedSocketPtr& ms_) : event(event_), ms(ms_) { } - Event() : event(WRITE), ms(0) { } -}; - -struct ClearEvent { - void operator()(Event& evt) { - evt.ms = 0; - } -}; - -class Writer : public Thread { -public: - Writer() : stop(false) { - } - - void addWriter(const ManagedSocketPtr& ms) { - if(stop) - return; -/* - Event* ev = pool.get(); - *ev = Event(Event::WRITE, ms); - ::write(event[0], &ev, sizeof(ev));*/ - } - - void addAllWriters() { - if(stop) - return; -/* Event* ev = pool.get(); - *ev = Event(Event::WRITE_ALL, 0); - ::write(event[0], &ev, sizeof(ev));*/ - } - - void addDisconnect(const ManagedSocketPtr& ms) { - if(stop) - return; - - Event* ev = pool.get(); - *ev = Event(Event::DISCONNECT, ms); - ::write(event[0], &ev, sizeof(ev)); - } - - void shutdown() { - stop = true; - - Event* ev = pool.get(); - *ev = Event(Event::SHUTDOWN, 0); - ::write(event[0], &ev, sizeof(ev)); - - join(); - } - - void getErrors(SocketManager::ErrorMap& acceptErrors_, SocketManager::ErrorMap& readErrors_, SocketManager::ErrorMap& writeErrors_) { - FastMutex::Lock l(errorMutex); - acceptErrors_ = acceptErrors; - readErrors_ = readErrors; - writeErrors_ = writeErrors; - } - -private: - bool init() { - if(!poller.init()) { - LOGDT(SocketManager::className, "Unable to create initialize epoll: " + Util::translateError(errno)); - return false; - } - - try { - srv.listen(SETTING(SERVER_PORT)); - srv.setBlocking(false); - } catch(const SocketException& e) { - LOGDT(SocketManager::className, "Unable to create server socket: " + e.getError()); - return false; - } - - if(!poller.associate(srv.getSocket())) { - LOGDT(SocketManager::className, "Unable to set epoll: " + Util::translateError(errno)); - return false; - } - - if(socketpair(AF_UNIX, SOCK_STREAM, 0, event) == -1) { - LOGDT(SocketManager::className, "Unable to create event socketpair: " + Util::translateError(errno)); - return false; - } - if(!poller.associate(event[1])) { - LOGDT(SocketManager::className, "Unable to associate event: " + Util::translateError(errno)); - return false; - } - return true; - } - - virtual int run() { - LOGDT(SocketManager::className, "Writer starting"); - if(!init()) { - return 0; - } - - uint32_t lastWrite = 0; - std::vector<epoll_event> events; - while(!stop || !active.empty()) { - events.clear(); - - if(!poller.get(events)) { - LOGDT(SocketManager::className, "Poller failed: " + Util::translateError(errno)); - } - bool doevents = false; - for(std::vector<epoll_event>::iterator i = events.begin(); i != events.end(); ++i) { - epoll_event& ev = *i; - if(ev.data.fd == srv.getSocket()) { - accept(); - } else if(ev.data.fd == event[1]) { - doevents = true; - } else { - ManagedSocketPtr ms(reinterpret_cast<ManagedSocket*>(ev.data.ptr)); - if(ev.events & (EPOLLIN | EPOLLHUP | EPOLLERR)) { - if(!read(ms)) - continue; - } - if(ev.events & EPOLLOUT) { - write(ms); - } + ManagedSocketPtr ms(reinterpret_cast<ManagedSocket*>(ev.data.ptr)); + if(ev.events & (EPOLLIN | EPOLLHUP | EPOLLERR)) { + if(!read(ms)) + continue; } + if(ev.events & EPOLLOUT) { + ms->setBlocked(false); + } } - - if(doevents) { - handleEvents(); - } - - uint32_t now = GET_TICK(); - if(now > lastWrite + WRITE_TIMEOUT) { - checkDisconnects(); - writeAll(); - lastWrite = now; - } } - LOGDT(SocketManager::className, "Writer shutting down"); - return 0; } - - void handleEvents() { - while(true) { - size_t start = ev.size(); - ev.resize(64 * sizeof(Event*)); - int bytes = ::recv(event[1], &ev[0] + start, ev.size() - start, MSG_DONTWAIT); - if(bytes == -1) { - ev.resize(start); - int err = errno; - if(err == EAGAIN) { - return; - } - LOGDT(SocketManager::className, "Error reading from event[1]: " + Util::translateError(err)); - return; - } - ev.resize(bytes); - size_t events = bytes / sizeof(Event*); - for(size_t i = 0; i < events; ++i) { - Event** ee = reinterpret_cast<Event**>(&ev[i*sizeof(Event*)]); - Event* e = *ee; - switch(e->event) { - case Event::WRITE: { - write(e->ms); - } break; - case Event::WRITE_ALL: { - writeAll(); - } break; - case Event::DISCONNECT: { - disconnect(e->ms); - } break; - case Event::REMOVE: { - failRead(e->ms, 0); - } break; - case Event::SHUTDOWN: { - handleShutdown(); - } break; - } - pool.put(e); - } - ev.erase(ev.begin(), ev.begin() + events*sizeof(Event*)); - } - } - - void accept() throw() { + + void accept() { ManagedSocketPtr ms(new ManagedSocket()); try { ms->setIp(ms->sock.accept(srv)); @@ -812,15 +531,11 @@ read(ms); } catch (const SocketException& e) { LOGDT(SocketManager::className, "Unable to create socket: " + e.getError()); - if(e.getErrorCode() != 0) { - FastMutex::Lock l(errorMutex); - acceptErrors[e.getErrorCode()]++; - } return; } } - bool read(const ManagedSocketPtr& ms) throw() { + bool read(const ManagedSocketPtr& ms) { if(stop || !(*ms)) return false; @@ -834,14 +549,16 @@ Util::freeBuf = readBuf; int error = errno; - if(error != EAGAIN) { - failRead(ms, error); + if(error != EAGAIN && error != EINTR) { + ms->close(); + disconnect(ms, error); return false; } break; } else if(bytes == 0) { Util::freeBuf = readBuf; - failRead(ms, 0); + ms->close(); + disconnect(ms, 0); return false; } @@ -851,28 +568,7 @@ return true; } - void failRead(const ManagedSocketPtr& ms, int error) throw() { - if(!(*ms)) { - return; - } - - SocketSet::iterator i = disconnecting.find(ms); - if(i == disconnecting.end()) { - ms->failSocket(); - } else { - disconnecting.erase(i); - } - - poller.remove(ms); - ms->close(); - active.erase(ms); - if(error != 0) { - FastMutex::Lock l(errorMutex); - readErrors[error]++; - } - } - - void write(const ManagedSocketPtr& ms) throw() { + void write(const ManagedSocketPtr& ms) { if(stop || !(*ms)) { return; } @@ -881,8 +577,9 @@ ByteVector* writeBuf = ms->prepareWrite(); if(!writeBuf) { - if(ms->disc) { - addRemove(ms); + uint32_t now = GET_TICK(); + if(ms->disc || (ms->isBlocked() && ms->disc < now)) { + disconnect(ms, 0); } return; } @@ -895,7 +592,7 @@ return; } Util::freeBuf = writeBuf; - failWrite(ms, error); + disconnect(ms, error); return; } if(!ms->completeWrite(writeBuf, bytes)) { @@ -903,87 +600,88 @@ } } } - - void failWrite(const ManagedSocketPtr& ms, int error) throw() { - addRemove(ms); - if(error != 0) { - FastMutex::Lock l(errorMutex); - writeErrors[error]++; + + void handleShutdown() { + char buf; + int bytes = ::recv(event[1], &buf, 1, MSG_DONTWAIT); + if(bytes == -1) { + + int err = errno; + if(err == EAGAIN || err == EINTR) { + return; + } + LOGDT(SocketManager::className, "Error reading from event[1]: " + Util::translateError(err)); + return; } + + srv.disconnect(); + + for(SocketSet::iterator i = active.begin(); i != active.end(); ++i) { + disconnect(*i, 0); + } } + +#endif void writeAll() throw() { - for(SocketSet::iterator i = active.begin(); i != active.end(); ++i) { + if(active.empty()) { + return; + } + SocketSet::iterator start = active.begin(); + SocketSet::iterator end = active.end(); + SocketSet::iterator mid = start; + // Start at a random position each time in order not to favorise the first sockets... + std::advance(mid, Util::rand(active.size())); + + for(SocketSet::iterator i = mid; i != end; ++i) { write(*i); } + for(SocketSet::iterator i = start; i != mid; ++i) { + write(*i); + } } - void disconnect(const ManagedSocketPtr& ms) throw() { - if(!(*ms)) - return; - + void disconnect(const ManagedSocketPtr& ms, int error) { if(disconnecting.find(ms) != disconnecting.end()) { return; } - + disconnecting.insert(ms); - ms->failSocket(); - write(ms); + + ms->failSocket(error); } - void checkDisconnects() throw() { - uint32_t now = GET_TICK(); + void removeDisconnected() { for(SocketSet::iterator i = disconnecting.begin(); i != disconnecting.end(); ++i) { - const ManagedSocketPtr& ms = *i; - if(ms->disc + (uint32_t)SETTING(DISCONNECT_TIMEOUT) < now) { - ms->shutdown(); - } + (*i)->close(); + active.erase(*i); } } - void handleShutdown() throw() { - srv.disconnect(); - - for(SocketSet::iterator i = active.begin(); i != active.end(); ++i) { - addRemove(*i); - } - } - - // This is needed because calling close() on the socket - // will remove it from the epoll set (so the main loop won't - // be notified) - void addRemove(const ManagedSocketPtr& ms) { - Event* ev = pool.get(); - *ev = Event(Event::REMOVE, ms); - ::write(event[0], &ev, sizeof(ev)); - } - - EPoll poller; + Poller poller; Socket srv; - FastMutex errorMutex; - SocketManager::ErrorMap acceptErrors; - SocketManager::ErrorMap readErrors; - SocketManager::ErrorMap writeErrors; - bool stop; - - int event[2]; - std::vector<uint8_t> ev; - Pool<Event, ClearEvent> pool; - - typedef std::tr1::unordered_set<ManagedSocketPtr, PointerHash<ManagedSocket> > SocketSet; + typedef unordered_set<ManagedSocketPtr, PointerHash<ManagedSocket> > SocketSet; /** Sockets that have a pending read */ SocketSet active; /** Sockets that are being written to but should be disconnected if timeout it reached */ SocketSet disconnecting; -}; - + +#ifdef _WIN32 + Pool<MSOverlapped, ClearOverlapped> pool; + static const size_t PREPARED_SOCKETS = 32; + + /** Sockets that have a pending accept */ + SocketSet accepting; #else -#error No socket implementation for your platform -#endif // _WIN32 + int event[2]; + +#endif +}; + SocketManager::SocketManager() : writer(new Writer()) { } @@ -998,10 +696,12 @@ writer->start(); writer->setThreadPriority(Thread::HIGH); + ProcessQueue workQueue; + while(true) { processSem.wait(); { - FastMutex::Lock l(processCS); + FastMutex::Lock l(processMutex); workQueue.swap(processQueue); } for(ProcessQueue::iterator i = workQueue.begin(); i != workQueue.end(); ++i) { @@ -1018,19 +718,16 @@ } void SocketManager::addWriter(const ManagedSocketPtr& ms) throw() { - writer->addWriter(ms); } void SocketManager::addAllWriters() throw() { - writer->addAllWriters(); } void SocketManager::addDisconnect(const ManagedSocketPtr& ms) throw() { - writer->addDisconnect(ms); } void SocketManager::addJob(const Callback& callback) throw() { - FastMutex::Lock l(processCS); + FastMutex::Lock l(processMutex); processQueue.push_back(callback); processSem.signal(); @@ -1045,8 +742,4 @@ writer.release(); } -void SocketManager::getErrors(ErrorMap& acceptErrors_, ErrorMap& readErrors_, ErrorMap& writeErrors_) { - writer->getErrors(acceptErrors_, readErrors_, writeErrors_); } - -} Modified: adchpp/trunk/adchpp/SocketManager.h =================================================================== --- adchpp/trunk/adchpp/SocketManager.h 2007-12-04 22:04:21 UTC (rev 98) +++ adchpp/trunk/adchpp/SocketManager.h 2007-12-09 18:44:45 UTC (rev 99) @@ -23,8 +23,8 @@ #include "forward.h" #include "Thread.h" -#include "Semaphores.h" #include "Mutex.h" +#include "Semaphores.h" #include "Singleton.h" namespace adchpp { @@ -37,15 +37,13 @@ void startup() throw(ThreadException) { start(); } void shutdown(); - void addWriter(const boost::intrusive_ptr<ManagedSocket>& ms) throw(); - void addDisconnect(const boost::intrusive_ptr<ManagedSocket>& ms) throw(); + void addWriter(const ManagedSocketPtr& ms) throw(); + void addDisconnect(const ManagedSocketPtr& ms) throw(); void addAllWriters() throw(); typedef std::tr1::function<void (const ManagedSocketPtr&)> IncomingHandler; void setIncomingHandler(const IncomingHandler& handler) { incomingHandler = handler; } - typedef std::tr1::unordered_map<int, size_t> ErrorMap; - ADCHPP_DLL void getErrors(ErrorMap& acceptErrors_, ErrorMap& readErrors_, ErrorMap& writeErrors_); private: friend class ManagedSocket; friend class Writer; @@ -54,10 +52,9 @@ typedef std::vector<Callback> ProcessQueue; - FastMutex processCS; + FastMutex processMutex; ProcessQueue processQueue; - ProcessQueue workQueue; Semaphore processSem; Modified: adchpp/trunk/adchpp/Util.cpp =================================================================== --- adchpp/trunk/adchpp/Util.cpp 2007-12-04 22:04:21 UTC (rev 98) +++ adchpp/trunk/adchpp/Util.cpp 2007-12-09 18:44:45 UTC (rev 99) @@ -123,6 +123,7 @@ // Only the server should be left now... aServer = url.substr(i, k-i); } + string Util::toAcp(const wstring& wString) { if(wString.empty()) return emptyString; Modified: adchpp/trunk/plugins/Script/examples/access.lua =================================================================== --- adchpp/trunk/plugins/Script/examples/access.lua 2007-12-04 22:04:21 UTC (rev 98) +++ adchpp/trunk/plugins/Script/examples/access.lua 2007-12-09 18:44:45 UTC (rev 99) @@ -483,27 +483,6 @@ end end - sm = adchpp.getSocketManager() - a = sm:getAcceptErrors() - r = sm:getReadErrors() - w = sm:getWriteErrors() - str = str .. "\nSocket errors: \n" - str = str .. " - Accept errors: \n" - for i = 0, a:size()-1 do - e = a[i] - str = str .. e.first .. "\t" .. e.second .. "\t" .. adchpp.Util_translateError(e.first) .. "\n" - end - str = str .. " - Read errors: \n" - for i = 0, r:size()-1 do - e = r[i] - str = str .. e.first .. "\t" .. e.second .. "\t" .. adchpp.Util_translateError(e.first) .. "\n" - end - str = str .. " - Write errors: \n" - for i = 0, w:size()-1 do - e = w[i] - str = str .. e.first .. "\t" .. e.second .. "\t" .. adchpp.Util_translateError(e.first) .. "\n" - end - local queued = cm:getQueuedBytes() local queueBytes = adchpp.Stats_queueBytes local queueCalls = adchpp.Stats_queueCalls Modified: adchpp/trunk/readme.txt =================================================================== --- adchpp/trunk/readme.txt 2007-12-04 22:04:21 UTC (rev 98) +++ adchpp/trunk/readme.txt 2007-12-09 18:44:45 UTC (rev 99) @@ -18,7 +18,7 @@ gcc 4.2+ (linux or mingw) boost (http://www.boost.org) scons (http://www.scons.org) -swig 1.3.31 +swig 1.3.33 ** Important!! The hub will _NOT_ run on Win9x/ME. ** Modified: adchpp/trunk/swig/adchpp.i =================================================================== --- adchpp/trunk/swig/adchpp.i 2007-12-04 22:04:21 UTC (rev 98) +++ adchpp/trunk/swig/adchpp.i 2007-12-09 18:44:45 UTC (rev 99) @@ -516,35 +516,6 @@ class SocketManager { public: - %extend { - std::vector<std::pair<int, size_t> > getAcceptErrors() { - std::vector<std::pair<int, size_t> > tmp; - adchpp::SocketManager::ErrorMap a, r, w; - self->getErrors(a, r, w); - for(SocketManager::ErrorMap::iterator i = a.begin(); i != a.end(); ++i) { - tmp.push_back(std::make_pair(i->first, i->second)); - } - return tmp; - } - std::vector<std::pair<int, size_t> > getReadErrors() { - std::vector<std::pair<int, size_t> > tmp; - adchpp::SocketManager::ErrorMap a, r, w; - self->getErrors(a, r, w); - for(SocketManager::ErrorMap::iterator i = r.begin(); i != r.end(); ++i) { - tmp.push_back(std::make_pair(i->first, i->second)); - } - return tmp; - } - std::vector<std::pair<int, size_t> > getWriteErrors() { - std::vector<std::pair<int, size_t> > tmp; - adchpp::SocketManager::ErrorMap a, r, w; - self->getErrors(a, r, w); - for(SocketManager::ErrorMap::iterator i = w.begin(); i != w.end(); ++i) { - tmp.push_back(std::make_pair(i->first, i->second)); - } - return tmp; - } - } }; class ClientManager Modified: adchpp/trunk/swig/lua.i =================================================================== --- adchpp/trunk/swig/lua.i 2007-12-04 22:04:21 UTC (rev 98) +++ adchpp/trunk/swig/lua.i 2007-12-09 18:44:45 UTC (rev 99) @@ -1,5 +1,6 @@ %module luadchpp + typedef unsigned int size_t; %wrapper %{ Modified: adchpp/trunk/swig/python.i =================================================================== --- adchpp/trunk/swig/python.i 2007-12-04 22:04:21 UTC (rev 98) +++ adchpp/trunk/swig/python.i 2007-12-09 18:44:45 UTC (rev 99) @@ -1,5 +1,6 @@ %module pyadchpp + %{ // Python pollution #undef socklen_t Modified: adchpp/trunk/test/PyClient.py =================================================================== --- adchpp/trunk/test/PyClient.py 2007-12-04 22:04:21 UTC (rev 98) +++ adchpp/trunk/test/PyClient.py 2007-12-09 18:44:45 UTC (rev 99) @@ -1,7 +1,7 @@ #!/usr/bin/python import sys -sys.path.append('../build/debug-mingw/bin') +sys.path.append('../build/debug-default/bin') CLIENTS = 100 @@ -60,7 +60,7 @@ def login(self, ipport): self.connect(ipport) cmd = AdcCommand(AdcCommand.CMD_SUP, AdcCommand.TYPE_HUB, 0) - cmd.addParam("ADBASE") + cmd.addParam("ADBASE").addParam("ADTIGR") self.command(cmd) self.expect(AdcCommand.CMD_SUP) sid = self.expect(AdcCommand.CMD_SID) Modified: adchpp/trunk/unix/po/adchppd.pot =================================================================== --- adchpp/trunk/unix/po/adchppd.pot 2007-12-04 22:04:21 UTC (rev 98) +++ adchpp/trunk/unix/po/adchppd.pot 2007-12-09 18:44:45 UTC (rev 99) @@ -7,7 +7,7 @@ msgstr "" "Project-Id-Version: \"adchpp\"--copyright-holder=\"Jacek Sieka\"\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2007-11-25 22:39+0100\n" +"POT-Creation-Date: 2007-12-09 18:46+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL...@li...>\n" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2007-12-10 12:04:10
|
Revision: 103 http://adchpp.svn.sourceforge.net/adchpp/?rev=103&view=rev Author: arnetheduck Date: 2007-12-10 04:04:03 -0800 (Mon, 10 Dec 2007) Log Message: ----------- more compile experiments Modified Paths: -------------- adchpp/trunk/SConstruct adchpp/trunk/swig/SConscript Modified: adchpp/trunk/SConstruct =================================================================== --- adchpp/trunk/SConstruct 2007-12-10 11:00:24 UTC (rev 102) +++ adchpp/trunk/SConstruct 2007-12-10 12:04:03 UTC (rev 103) @@ -54,7 +54,7 @@ # --- cut --- -import os,sys +import os,sys,distutils.sysconfig plugins = filter(lambda x: os.path.isfile(os.path.join('plugins', x, 'SConscript')), os.listdir('plugins')) @@ -73,10 +73,10 @@ BoolOption('verbose', 'Show verbose command lines', 'no'), BoolOption('savetemps', 'Save intermediate compilation files (assembly output)', 'no'), BoolOption('nls', 'Build with internationalization support', 'yes'), - ('prefix', 'Prefix to use when cross compiling', 'i386-mingw32-') + ('prefix', 'Prefix to use when cross compiling', 'i386-mingw32-'), + ('python', 'Python path to use when compiling python extensions', distutils.sysconfig.get_config_var('prefix')) ) - tools = ARGUMENTS.get('tools', tooldef) toolset = [tools, 'swig'] Modified: adchpp/trunk/swig/SConscript =================================================================== --- adchpp/trunk/swig/SConscript 2007-12-10 11:00:24 UTC (rev 102) +++ adchpp/trunk/swig/SConscript 2007-12-10 12:04:03 UTC (rev 103) @@ -1,3 +1,5 @@ +# vim: set filetype: py + Import('dev source_path') targets = [] @@ -60,36 +62,38 @@ def buildPyModule(): import sys - if dev.is_win32() and sys.platform != 'win32': - print "Cross-compiling python module not supported" - return env, target, sources = dev.prepare_build(source_path, '_pyadchpp', 'python.i') env.Append(SWIGFLAGS=['-c++','-threads','-Wall','-python', '-O', '-classic']) - import distutils.sysconfig,distutils.cygwinccompiler + import distutils.sysconfig - env.Append(CPPPATH=['#', distutils.sysconfig.get_python_inc()]) + env.Append(CPPPATH=['#']) if '_DEBUG' in env['CPPDEFINES']: env['CPPDEFINES'].remove('_DEBUG') if '/MDd' in env['CCFLAGS']: env['CCFLAGS'].remove('/MDd') env['CCFLAGS'].append('/MD') - if 'mingw' in env['TOOLS']: - compiler = distutils.cygwinccompiler.Mingw32CCompiler() - env.Append(LIBS=compiler.dll_libraries) + import os,distutils,sys + if dev.is_win32(): + pyprefix = env['python'] + incpath = os.path.join(pyprefix, "include") + libpath = os.path.join(pyprefix, "libs") + version = '25' # We only support 2.5.x for now - import os,distutils,sys - if env['PLATFORM'] == 'win32': if 'mingw' in env['TOOLS']: - env.Append(LIBPATH=[distutils.sysconfig.get_config_var('prefix')]) + sources += [File(os.path.join(libpath, "python" + version + ".lib"))] + env.Append(LIBS=['msvcr71']) else: - env.Append(LIBPATH=[os.path.join(distutils.sysconfig.get_config_var('prefix'),"libs")]) - env.Append(LIBS=["python"+"".join(sys.version[0:3].split(".")), 'adchpp']) + env.Append(LIBPATH=[libpath]) + env.Append(LIBS=["python"+version]) + env.Append(CPPPATH=[incpath]) else: - env.Append(LIBS=['python2.4', 'adchpp']) + env.Append(CPPPATH=[distutils.sysconfig.get_python_inc()]) + env.Append(LIBS=['python2.4']) + env.Append(LIBS=['adchpp']) wrapper = build_path + 'python_wrap.cc' pyfile = build_path + 'pyadchpp.py' pytarget = dev.get_target(source_path, 'pyadchpp.py') @@ -126,3 +130,4 @@ buildLuaModule() Return('targets') + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2007-12-17 23:13:38
|
Revision: 106 http://adchpp.svn.sourceforge.net/adchpp/?rev=106&view=rev Author: arnetheduck Date: 2007-12-17 15:13:35 -0800 (Mon, 17 Dec 2007) Log Message: ----------- Update bloom filter to use multiple hashes, fix access script Modified Paths: -------------- adchpp/trunk/adchpp/CID.h adchpp/trunk/adchpp/ClientManager.cpp adchpp/trunk/adchpp/ClientManager.h adchpp/trunk/plugins/Bloom/src/BloomManager.cpp adchpp/trunk/plugins/Bloom/src/BloomManager.h adchpp/trunk/plugins/Bloom/src/HashBloom.h adchpp/trunk/plugins/Bloom/src/HashValue.h adchpp/trunk/plugins/Script/examples/access.lua Added Paths: ----------- adchpp/trunk/plugins/Bloom/src/HashBloom.cpp Modified: adchpp/trunk/adchpp/CID.h =================================================================== --- adchpp/trunk/adchpp/CID.h 2007-12-14 15:16:58 UTC (rev 105) +++ adchpp/trunk/adchpp/CID.h 2007-12-17 23:13:35 UTC (rev 106) @@ -29,10 +29,6 @@ enum { SIZE = 192 / 8 }; enum { BASE32_SIZE = 39 }; - struct Hash { - size_t operator()(const CID& c) const { return c.toHash(); } - bool operator()(const CID& a, const CID& b) const { return a < b; } - }; CID() { memset(cid, 0, sizeof(cid)); } explicit CID(const uint8_t* data) { memcpy(cid, data, sizeof(cid)); } explicit CID(const std::string& base32) { Encoder::fromBase32(base32.c_str(), cid, sizeof(cid)); } @@ -62,4 +58,14 @@ } +namespace std { namespace tr1 { +template<> +struct hash<adchpp::CID> { + size_t operator()(const adchpp::CID& rhs) const { + return *reinterpret_cast<const size_t*>(rhs.data()); + } +}; +} +} + #endif Modified: adchpp/trunk/adchpp/ClientManager.cpp =================================================================== --- adchpp/trunk/adchpp/ClientManager.cpp 2007-12-14 15:16:58 UTC (rev 105) +++ adchpp/trunk/adchpp/ClientManager.cpp 2007-12-17 23:13:35 UTC (rev 106) @@ -431,10 +431,10 @@ setState(c, Client::STATE_IDENTIFY); } -vector<uint8_t> ClientManager::enterVerify(Client& c, bool sendData) throw() { +ByteVector ClientManager::enterVerify(Client& c, bool sendData) throw() { dcassert(c.getState() == Client::STATE_IDENTIFY); dcdebug("%s entering VERIFY\n", AdcCommand::fromSID(c.getSID()).c_str()); - vector<uint8_t> challenge; + ByteVector challenge; if (sendData) { for (int i = 0; i < 32/4; ++i) { uint32_t r = Util::rand(); Modified: adchpp/trunk/adchpp/ClientManager.h =================================================================== --- adchpp/trunk/adchpp/ClientManager.h 2007-12-14 15:16:58 UTC (rev 105) +++ adchpp/trunk/adchpp/ClientManager.h 2007-12-17 23:13:35 UTC (rev 106) @@ -176,7 +176,7 @@ ClientMap clients; typedef std::tr1::unordered_map<std::string, uint32_t> NickMap; NickMap nicks; - typedef std::tr1::unordered_map<CID, uint32_t, CID::Hash> CIDMap; + typedef std::tr1::unordered_map<CID, uint32_t> CIDMap; CIDMap cids; typedef std::tr1::unordered_set<uint32_t> SIDSet; SIDSet sids; Modified: adchpp/trunk/plugins/Bloom/src/BloomManager.cpp =================================================================== --- adchpp/trunk/plugins/Bloom/src/BloomManager.cpp 2007-12-14 15:16:58 UTC (rev 105) +++ adchpp/trunk/plugins/Bloom/src/BloomManager.cpp 2007-12-17 23:13:35 UTC (rev 106) @@ -20,9 +20,13 @@ #include "BloomManager.h" #include <adchpp/LogManager.h> +#include <adchpp/Client.h> +#include <adchpp/AdcCommand.h> +#include <adchpp/Util.h> using namespace std; using namespace std::tr1::placeholders; +using namespace adchpp; BloomManager* BloomManager::instance = 0; const string BloomManager::className = "BloomManager"; @@ -38,18 +42,33 @@ LOG(className, "Shutting down"); } -static const std::string FEATURE = "BLOM"; +static const std::string FEATURE = "BLO0"; void BloomManager::onReceive(Client& c, AdcCommand& cmd, int& override) { - std::string tth; + string tmp; if(cmd.getCommand() == AdcCommand::CMD_INF && c.supports(FEATURE)) { - AdcCommand get(AdcCommand::CMD_GET); - get.addParam("blom"); - get.addParam("/"); - get.addParam("0"); - get.addParam("-1"); - c.send(get); + if(cmd.getParam("SF", 0, tmp)) { + size_t n = adchpp::Util::toInt(tmp); + if(n == 0) { + return; + } + + size_t k = HashBloom::get_k(n); + size_t m = HashBloom::get_m(n, k); + + HashBloom bloom = blooms[c.getCID()]; + + bloom.reset(k); + + AdcCommand get(AdcCommand::CMD_GET); + get.addParam("blom"); + get.addParam("/"); + get.addParam("0"); + get.addParam(Util::toString(m/8)); + get.addParam("BK", Util::toString(k)); + c.send(get); + } } else if(cmd.getCommand() == AdcCommand::CMD_SND) { if(cmd.getParameters().size() < 4) { return; @@ -58,14 +77,15 @@ return; } - int64_t bytes = Util::toInt(cmd.getParam(4)); + int64_t bytes = Util::toInt(cmd.getParam(3)); c.setDataMode(std::tr1::bind(&BloomManager::onData, this, _1, _2, _3), bytes); - } else if(cmd.getCommand() == AdcCommand::CMD_SCH && cmd.getParam("TH", 0, tth)) { - + override |= ClientManager::DONT_DISPATCH | ClientManager::DONT_SEND; + } else if(cmd.getCommand() == AdcCommand::CMD_SCH && cmd.getParam("TR", 0, tmp)) { BloomMap::const_iterator i = blooms.find(c.getCID()); - if(i != blooms.end() && i->second.match(TTHValue(tth))) { + if(i != blooms.end() && !i->second.match(TTHValue(tmp))) { // Stop it + dcdebug("Stopping search\n"); override |= ClientManager::DONT_DISPATCH | ClientManager::DONT_SEND; } } @@ -83,4 +103,3 @@ void BloomManager::onDisconnected(Client& c) { blooms.erase(c.getCID()); } - Modified: adchpp/trunk/plugins/Bloom/src/BloomManager.h =================================================================== --- adchpp/trunk/plugins/Bloom/src/BloomManager.h 2007-12-14 15:16:58 UTC (rev 105) +++ adchpp/trunk/plugins/Bloom/src/BloomManager.h 2007-12-17 23:13:35 UTC (rev 106) @@ -64,7 +64,7 @@ friend class Singleton<BloomManager>; static BloomManager* instance; - typedef std::tr1::unordered_map<CID, HashBloom, CID::Hash> BloomMap; + typedef std::tr1::unordered_map<CID, HashBloom> BloomMap; BloomMap blooms; ClientManager::SignalReceive::ManagedConnection receiveConn; Added: adchpp/trunk/plugins/Bloom/src/HashBloom.cpp =================================================================== --- adchpp/trunk/plugins/Bloom/src/HashBloom.cpp (rev 0) +++ adchpp/trunk/plugins/Bloom/src/HashBloom.cpp 2007-12-17 23:13:35 UTC (rev 106) @@ -0,0 +1,54 @@ +#include "stdinc.h" +#include "HashBloom.h" + + +size_t HashBloom::get_k(size_t n) { + const size_t bits = TTHValue::SIZE * 8; + for(size_t k = static_cast<size_t>(sqrt(bits)); k > 1; --k) { + // We only want the k's where the bits will end up on a byte boundary to ease hash implementation + if((bits % k) == 0 && (bits / k) % 8 == 0) { + uint64_t m = get_m(n, k); + if(m >> (TTHValue::SIZE * 8 / k) == 0) { + return k; + } + } + } + return 1; +} + +uint64_t HashBloom::get_m(size_t n, size_t k) { + uint64_t m = (static_cast<uint64_t>(ceil(static_cast<double>(n) * k / log(2.)))); + return ((m / 8) + 1) * 8; +} + +void HashBloom::add(const TTHValue& tth) { + for(size_t i = 0; i < k; ++i) { + bloom[pos(tth, i)] = true; + } +} + +bool HashBloom::match(const TTHValue& tth) const { + if(bloom.empty()) { + return true; + } + for(size_t i = 0; i < k; ++i) { + if(!bloom[pos(tth, i)]) { + return false; + } + } + return true; +} + +void HashBloom::push_back(bool v) { + bloom.push_back(v); +} + +void HashBloom::reset(size_t k_) { + bloom.resize(0); + k = k; +} + +size_t HashBloom::pos(const TTHValue& tth, size_t n) const { + return (*(size_t*)(tth.data + (TTHValue::SIZE / k) * n)) % bloom.size(); +} + Modified: adchpp/trunk/plugins/Bloom/src/HashBloom.h =================================================================== --- adchpp/trunk/plugins/Bloom/src/HashBloom.h 2007-12-14 15:16:58 UTC (rev 105) +++ adchpp/trunk/plugins/Bloom/src/HashBloom.h 2007-12-17 23:13:35 UTC (rev 106) @@ -3,19 +3,33 @@ #include "HashValue.h" +/** + * According to http://www.eecs.harvard.edu/~michaelm/NEWWORK/postscripts/BloomFilterSurvey.pdf + * the optimal number of hashes k is (m/n)*ln(2), m = number of bits in the filter and n = number + * of items added. The largest k that we can get from a single TTH value depends on the number of + * bits we need to address the bloom structure, which in turn depends on m, so the optimal size + * for our filter is m = n * k / ln(2) where n is the number of TTH values, or in our case, number of + * files in share since each file is identified by one TTH value. We try that for each even dividend + * of the key size (2, 3, 4, 6, 8, 12) and if m fits within the bits we're able to address (2^(keysize/k)), + * we can use that value when requesting the bloom filter. + */ class HashBloom { public: - void add(const TTHValue& tth) { bloom[pos(tth)] = true; } - bool match(const TTHValue& tth) const { return bloom[pos(tth)]; } - void resize(size_t hashes) { bloom.resize(hashes); std::fill(bloom.begin(), bloom.end(), false); } - void push_back(bool v) { bloom.push_back(v); } + /** Return the largest k such that get_m returns a value smaller than 2^(TTHValue::SIZE/k) */ + static size_t get_k(size_t n); + /** Optimal number of bits to allocate for n elements when using k hashes */ + static uint64_t get_m(size_t n, size_t k); + + void add(const TTHValue& tth); + bool match(const TTHValue& tth) const; + void reset(size_t k); + void push_back(bool v); private: - size_t pos(const TTHValue& tth) const { - return (*(size_t*)tth.data) % bloom.size(); - } + size_t pos(const TTHValue& tth, size_t n) const; std::vector<bool> bloom; + size_t k; }; #endif /*HASHBLOOM_H_*/ Modified: adchpp/trunk/plugins/Bloom/src/HashValue.h =================================================================== --- adchpp/trunk/plugins/Bloom/src/HashValue.h 2007-12-14 15:16:58 UTC (rev 105) +++ adchpp/trunk/plugins/Bloom/src/HashValue.h 2007-12-17 23:13:35 UTC (rev 106) @@ -1,5 +1,5 @@ /* - * Copyright (C) 2001-2006 Jacek Sieka, arnetheduck on gmail point com + * Copyright (C) 2001-2007 Jacek Sieka, arnetheduck on gmail point com * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,24 +16,16 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#if !defined(HASH_VALUE_H) -#define HASH_VALUE_H +#ifndef BLOOM_HASH_VALUE_H +#define BLOOM_HASH_VALUE_H #include <adchpp/TigerHash.h> +#include <adchpp/Encoder.h> template<class Hasher> struct HashValue { static const size_t SIZE = Hasher::HASH_SIZE; - struct Hash { -#ifdef _MSC_VER - static const size_t bucket_size = 4; - static const size_t min_buckets = 8; -#endif - size_t operator()(const HashValue& rhs) const { return *(size_t*)&rhs; } - bool operator()(const HashValue& a, const HashValue& b) const { return a < b; } - }; - HashValue() { } explicit HashValue(uint8_t* aData) { memcpy(data, aData, SIZE); } explicit HashValue(const std::string& base32) { Encoder::fromBase32(base32.c_str(), data, SIZE); } @@ -49,6 +41,15 @@ uint8_t data[SIZE]; }; +namespace std { namespace tr1 { +template<> +template<typename T> +struct hash<HashValue<T> > { + size_t operator()(const HashValue<T>& rhs) const { return *(size_t*)rhs.data; } +}; +} +} + typedef HashValue<TigerHash> TTHValue; #endif // !defined(HASH_VALUE_H) Modified: adchpp/trunk/plugins/Script/examples/access.lua =================================================================== --- adchpp/trunk/plugins/Script/examples/access.lua 2007-12-14 15:16:58 UTC (rev 105) +++ adchpp/trunk/plugins/Script/examples/access.lua 2007-12-17 23:13:35 UTC (rev 106) @@ -355,7 +355,7 @@ reply(c, "Welcome back") cm:enterNormal(c, true, true) - if user.level > 1 and (c:supports("UCMD") or c:supports("UCM0") then + if user.level > 1 and (c:supports("UCMD") or c:supports("UCM0")) then for k, v in pairs(user_commands) do ucmd = adchpp.AdcCommand(adchpp.AdcCommand_CMD_CMD, adchpp.AdcCommand_TYPE_INFO, adchpp.AdcCommand_HUB_SID) ucmd:addParam(k) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2007-12-20 09:53:34
|
Revision: 108 http://adchpp.svn.sourceforge.net/adchpp/?rev=108&view=rev Author: arnetheduck Date: 2007-12-20 01:53:30 -0800 (Thu, 20 Dec 2007) Log Message: ----------- Bloom manager fixes, version display format Modified Paths: -------------- adchpp/trunk/adchpp/version.cpp adchpp/trunk/plugins/Bloom/src/BloomManager.cpp adchpp/trunk/plugins/Bloom/src/HashBloom.cpp Modified: adchpp/trunk/adchpp/version.cpp =================================================================== --- adchpp/trunk/adchpp/version.cpp 2007-12-19 09:35:58 UTC (rev 107) +++ adchpp/trunk/adchpp/version.cpp 2007-12-20 09:53:30 UTC (rev 108) @@ -9,8 +9,8 @@ #define strver(s) #s #define APPNAME "ADCH++" -#define VERSIONSTRING "2.0." xstrver(ADCHPP_REVISION) -#define VERSIONFLOAT 2.0 +#define VERSIONSTRING "2.1.0 (r" xstrver(ADCHPP_REVISION) ")" +#define VERSIONFLOAT 2.1 #ifndef NDEBUG #define BUILDSTRING "Debug" @@ -27,5 +27,5 @@ string appName = APPNAME; string versionString = FULLVERSIONSTRING; float versionFloat = VERSIONFLOAT; - + } Modified: adchpp/trunk/plugins/Bloom/src/BloomManager.cpp =================================================================== --- adchpp/trunk/plugins/Bloom/src/BloomManager.cpp 2007-12-19 09:35:58 UTC (rev 107) +++ adchpp/trunk/plugins/Bloom/src/BloomManager.cpp 2007-12-20 09:53:30 UTC (rev 108) @@ -57,7 +57,7 @@ size_t k = HashBloom::get_k(n); size_t m = HashBloom::get_m(n, k); - HashBloom bloom = blooms[c.getCID()]; + HashBloom& bloom = blooms[c.getCID()]; bloom.reset(k); @@ -95,7 +95,7 @@ HashBloom& bloom = blooms[c.getCID()]; for(size_t i = 0; i < len; ++i) { for(size_t j = 0; j < 8; ++j) { - bloom.push_back(data[i] & 1 << j); + bloom.push_back(data[i] & (1 << j)); } } } Modified: adchpp/trunk/plugins/Bloom/src/HashBloom.cpp =================================================================== --- adchpp/trunk/plugins/Bloom/src/HashBloom.cpp 2007-12-19 09:35:58 UTC (rev 107) +++ adchpp/trunk/plugins/Bloom/src/HashBloom.cpp 2007-12-20 09:53:30 UTC (rev 108) @@ -2,14 +2,10 @@ #include "HashBloom.h" size_t HashBloom::get_k(size_t n) { - const size_t bits = TTHValue::SIZE * 8; - for(size_t k = static_cast<size_t>(sqrt(bits)); k > 1; --k) { - // We only want the k's where the bits will end up on a byte boundary to ease hash implementation - if((bits % k) == 0 && (bits / k) % 8 == 0) { - uint64_t m = get_m(n, k); - if(m >> (TTHValue::SIZE * 8 / k) == 0) { - return k; - } + for(size_t k = TTHValue::SIZE/3; k > 1; --k) { + uint64_t m = get_m(n, k); + if(m >> 24 == 0) { + return k; } } return 1; @@ -29,13 +25,15 @@ bool HashBloom::match(const TTHValue& tth) const { if(bloom.empty()) { - return true; + return false; } for(size_t i = 0; i < k; ++i) { if(!bloom[pos(tth, i)]) { + printf("no match\n"); return false; } } + printf("match\n"); return true; } @@ -49,6 +47,12 @@ } size_t HashBloom::pos(const TTHValue& tth, size_t n) const { - return (*(size_t*)(tth.data + (TTHValue::SIZE / k) * n)) % bloom.size(); + uint32_t x = 0; + for(size_t i = n*3; i < TTHValue::SIZE; i += 3*k) { + x ^= static_cast<uint32_t>(tth.data[i]) << 2*8; + x ^= static_cast<uint32_t>(tth.data[i+1]) << 8; + x ^= static_cast<uint32_t>(tth.data[i+2]); + } + return x % bloom.size(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |