diff options
author | Adam <Adam@anope.org> | 2014-06-23 09:45:15 -0400 |
---|---|---|
committer | Adam <Adam@anope.org> | 2014-06-23 09:45:15 -0400 |
commit | fd9bb0ea7e3c8a39f1632c2ebbdc25d0fac192a0 (patch) | |
tree | 1d68e86065e0b012aee41533d4f9b289ee0707ac /src/process.cpp | |
parent | 148b26f687ce85dc01e852a2358b03d493757ada (diff) | |
parent | 9a947fa4359c667be58ebae4634d9ac0e53d5db4 (diff) |
Merge branch '2.0' into 2.1
Conflicts:
cmake/Anope.cmake
cmake/FindGettext.cmake
include/access.h
include/messages.h
include/modes.h
include/modules.h
include/users.h
modules/CMakeLists.txt
modules/commands/bs_bot.cpp
modules/commands/cs_access.cpp
modules/commands/cs_ban.cpp
modules/commands/cs_clone.cpp
modules/commands/cs_flags.cpp
modules/commands/cs_info.cpp
modules/commands/cs_list.cpp
modules/commands/cs_log.cpp
modules/commands/cs_mode.cpp
modules/commands/cs_status.cpp
modules/commands/cs_suspend.cpp
modules/commands/cs_updown.cpp
modules/commands/cs_xop.cpp
modules/commands/ms_check.cpp
modules/commands/ns_access.cpp
modules/commands/ns_cert.cpp
modules/commands/ns_group.cpp
modules/commands/ns_register.cpp
modules/commands/ns_set.cpp
modules/commands/ns_suspend.cpp
modules/commands/os_session.cpp
modules/commands/os_svs.cpp
modules/extra/m_ldap_authentication.cpp
modules/extra/m_regex_pcre.cpp
modules/extra/m_sql_authentication.cpp
modules/extra/stats/m_chanstats.cpp
modules/protocol/bahamut.cpp
modules/protocol/hybrid.cpp
modules/protocol/inspircd12.cpp
modules/protocol/inspircd20.cpp
modules/protocol/unreal.cpp
modules/pseudoclients/chanserv.cpp
modules/pseudoclients/chanserv/channel.cpp
modules/pseudoclients/nickserv/nickserv.cpp
modules/webcpanel/pages/chanserv/access.cpp
src/access.cpp
src/bots.cpp
src/channels.cpp
src/language.cpp
src/modes.cpp
src/modulemanager.cpp
src/process.cpp
src/users.cpp
src/version.sh
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 70849243b..d14d8d589 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; +} + |