1
0
mirror of https://github.com/anope/anope.git synced 2026-07-03 02:13:12 +02:00

Core prep for p10 stuff

This commit is contained in:
Adam
2014-05-21 08:50:40 -04:00
parent 5a1257b7f0
commit f627a3bacd
27 changed files with 166 additions and 138 deletions
+44 -27
View File
@@ -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> &params)
{
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;
}