From d33a0f75a5c0c584fbb7cc0076da36d494f39494 Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 22 Nov 2012 00:50:33 -0500 Subject: Pretty large coding style cleanup, in source doc cleanup, and allow protocol mods to depend on each other --- src/process.cpp | 48 ++++++++++++++++++++---------------------------- 1 file changed, 20 insertions(+), 28 deletions(-) (limited to 'src/process.cpp') diff --git a/src/process.cpp b/src/process.cpp index dfc4f5563..cc2b32a27 100644 --- a/src/process.cpp +++ b/src/process.cpp @@ -11,16 +11,12 @@ #include "services.h" #include "modules.h" -#include "extern.h" #include "protocol.h" #include "servers.h" #include "users.h" #include "regchannel.h" -/** Main process routine - * @param buffer A raw line from the uplink to do things with - */ -void process(const Anope::string &buffer) +void Anope::Process(const Anope::string &buffer) { /* If debugging, log the buffer */ Log(LOG_RAWIO) << "Received: " << buffer; @@ -46,12 +42,11 @@ void process(const Anope::string &buffer) } spacesepstream buf_sep(buf); - Anope::string buf_token; Anope::string command = buf; - if (buf_sep.GetToken(buf_token)) - command = buf_token; + buf_sep.GetToken(command); + Anope::string buf_token; std::vector params; while (buf_sep.GetToken(buf_token)) { @@ -67,7 +62,7 @@ void process(const Anope::string &buffer) params.push_back(buf_token); } - if (protocoldebug) + if (Anope::ProtocolDebug) { Log() << "Source : " << (source.empty() ? "No source" : source); Log() << "Command: " << command; @@ -79,29 +74,26 @@ void process(const Anope::string &buffer) Log() << "params " << i << ": " << params[i]; } - const std::vector *messages = IRCDMessage::Find(command); + static const Anope::string proto_name = ModuleManager::FindFirstOf(PROTOCOL) ? ModuleManager::FindFirstOf(PROTOCOL)->name : ""; + + // event - if (messages && !messages->empty()) + ServiceReference m("IRCDMessage", proto_name + "/" + command.lower()); + if (!m) { - MessageSource src(source); + Log(LOG_DEBUG) << "unknown message from server (" << buffer << ")"; + return; + } - bool retVal = true; - /* Newer messages take priority */ - for (unsigned i = messages->size(); retVal && i > 0; --i) - { - IRCDMessage *m = messages->at(i - 1); + MessageSource src(source); - if (m->HasFlag(IRCDMESSAGE_SOFT_LIMIT) ? (params.size() < m->GetParamCount()) : (params.size() != m->GetParamCount())) - Log(LOG_DEBUG) << "invalid parameters for " << command << ": " << params.size() << " != " << m->GetParamCount(); - else if (m->HasFlag(IRCDMESSAGE_REQUIRE_USER) && !src.GetUser()) - Log(LOG_DEBUG) << "unexpected non-user source " << source << " for " << command; - else if (m->HasFlag(IRCDMESSAGE_REQUIRE_SERVER) && !source.empty() && !src.GetServer()) - Log(LOG_DEBUG) << "unexpected non-server soruce " << source << " for " << command; - else - retVal = m->Run(src, params); - } - } + if (m->HasFlag(IRCDMESSAGE_SOFT_LIMIT) ? (params.size() < m->GetParamCount()) : (params.size() != m->GetParamCount())) + Log(LOG_DEBUG) << "invalid parameters for " << command << ": " << params.size() << " != " << m->GetParamCount(); + else if (m->HasFlag(IRCDMESSAGE_REQUIRE_USER) && !src.GetUser()) + Log(LOG_DEBUG) << "unexpected non-user source " << source << " for " << command; + else if (m->HasFlag(IRCDMESSAGE_REQUIRE_SERVER) && !source.empty() && !src.GetServer()) + Log(LOG_DEBUG) << "unexpected non-server soruce " << source << " for " << command; else - Log(LOG_DEBUG) << "unknown message from server (" << buffer << ")"; + m->Run(src, params); } -- cgit