diff options
author | Adam <Adam@anope.org> | 2014-05-21 08:50:40 -0400 |
---|---|---|
committer | Adam <Adam@anope.org> | 2014-05-21 08:50:40 -0400 |
commit | f627a3bacd0d058e94260dac1555790cafd9a926 (patch) | |
tree | 4ba71bf94b44ba07abc627ba0c26f3b8b94da439 /src/process.cpp | |
parent | 5a1257b7f0b44ee3fd4639e5be288d160ceb5095 (diff) |
Core prep for p10 stuff
Diffstat (limited to 'src/process.cpp')
-rw-r--r-- | src/process.cpp | 71 |
1 files changed, 44 insertions, 27 deletions
diff --git a/src/process.cpp b/src/process.cpp index 16373b144..2d7a1561a 100644 --- a/src/process.cpp +++ b/src/process.cpp @@ -24,34 +24,10 @@ void Anope::Process(const Anope::string &buffer) if (buffer.empty()) return; - spacesepstream buf_sep(buffer); - - Anope::string source; - if (buffer[0] == ':') - { - buf_sep.GetToken(source); - source.erase(0, 1); - } - - Anope::string command; - if (!buf_sep.GetToken(command)) - return; - - Anope::string buf_token; + Anope::string source, command; std::vector<Anope::string> params; - while (buf_sep.GetToken(buf_token)) - { - if (buf_token[0] == ':') - { - if (!buf_sep.StreamEnd()) - params.push_back(buf_token.substr(1) + " " + buf_sep.GetRemaining()); - else - params.push_back(buf_token.substr(1)); - break; - } - else - params.push_back(buf_token); - } + + IRCD->Parse(buffer, source, command, params); if (Anope::ProtocolDebug) { @@ -65,6 +41,12 @@ void Anope::Process(const Anope::string &buffer) Log() << "params " << i << ": " << params[i]; } + if (command.empty()) + { + Log(LOG_DEBUG) << "No command? " << buffer; + return; + } + static const Anope::string proto_name = ModuleManager::FindFirstOf(PROTOCOL) ? ModuleManager::FindFirstOf(PROTOCOL)->name : ""; MessageSource src(source); @@ -91,3 +73,38 @@ void Anope::Process(const Anope::string &buffer) m->Run(src, params); } +void IRCDProto::Parse(const Anope::string &buffer, Anope::string &source, Anope::string &command, std::vector<Anope::string> ¶ms) +{ + spacesepstream sep(buffer); + + if (buffer[0] == ':') + { + sep.GetToken(source); + source.erase(0, 1); + } + + sep.GetToken(command); + + for (Anope::string token; sep.GetToken(token);) + { + if (token[0] == ':') + { + if (!sep.StreamEnd()) + params.push_back(token.substr(1) + " " + sep.GetRemaining()); + else + params.push_back(token.substr(1)); + break; + } + else + params.push_back(token); + } +} + +Anope::string IRCDProto::Format(const Anope::string &source, const Anope::string &message) +{ + if (!source.empty()) + return ":" + source + " " + message; + else + return message; +} + |