diff options
-rw-r--r-- | include/modules/whois.h | 54 | ||||
-rw-r--r-- | src/coremods/core_whois.cpp | 36 | ||||
-rw-r--r-- | src/modules/m_botmode.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_customtitle.cpp | 6 | ||||
-rw-r--r-- | src/modules/m_helpop.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_hidechans.cpp | 4 | ||||
-rw-r--r-- | src/modules/m_hideoper.cpp | 4 | ||||
-rw-r--r-- | src/modules/m_services_account.cpp | 4 | ||||
-rw-r--r-- | src/modules/m_servprotect.cpp | 6 | ||||
-rw-r--r-- | src/modules/m_sslinfo.cpp | 4 | ||||
-rw-r--r-- | src/modules/m_swhois.cpp | 6 |
11 files changed, 77 insertions, 51 deletions
diff --git a/include/modules/whois.h b/include/modules/whois.h index b64d46410..4f09d268b 100644 --- a/include/modules/whois.h +++ b/include/modules/whois.h @@ -55,12 +55,11 @@ class Whois::LineEventListener : public Events::ModuleEventListener * the values numeric and text, but you cannot change the user the * numeric is sent to. * @param whois Whois context, can be used to send numerics - * @param numeric The numeric of the line being sent - * @param text The text of the numeric, including any parameters + * @param numeric Numeric being sent * @return MOD_RES_DENY to drop the line completely so that the user does not * receive it, or MOD_RES_PASSTHRU to allow the line to be sent. */ - virtual ModResult OnWhoisLine(Context& whois, unsigned int& numeric, std::string& text) = 0; + virtual ModResult OnWhoisLine(Context& whois, Numeric::Numeric& numeric) = 0; }; class Whois::Context @@ -97,20 +96,51 @@ class Whois::Context User* GetTarget() const { return target; } /** Send a line of WHOIS data to the source of the WHOIS - * @param numeric Numeric to send - * @param format Format string for the numeric - * @param ... Parameters for the format string */ - void SendLine(unsigned int numeric, const char* format, ...) CUSTOM_PRINTF(3, 4) + template <typename T1> + void SendLine(unsigned int numeric, T1 p1) + { + Numeric::Numeric n(numeric); + n.push(target->nick); + n.push(p1); + SendLine(n); + } + + template <typename T1, typename T2> + void SendLine(unsigned int numeric, T1 p1, T2 p2) + { + Numeric::Numeric n(numeric); + n.push(target->nick); + n.push(p1); + n.push(p2); + SendLine(n); + } + + template <typename T1, typename T2, typename T3> + void SendLine(unsigned int numeric, T1 p1, T2 p2, T3 p3) + { + Numeric::Numeric n(numeric); + n.push(target->nick); + n.push(p1); + n.push(p2); + n.push(p3); + SendLine(n); + } + + template <typename T1, typename T2, typename T3, typename T4> + void SendLine(unsigned int numeric, T1 p1, T2 p2, T3 p3, T4 p4) { - std::string textbuffer; - VAFORMAT(textbuffer, format, format) - SendLine(numeric, textbuffer); + Numeric::Numeric n(numeric); + n.push(target->nick); + n.push(p1); + n.push(p2); + n.push(p3); + n.push(p4); + SendLine(n); } /** Send a line of WHOIS data to the source of the WHOIS * @param numeric Numeric to send - * @param text Text of the numeric */ - virtual void SendLine(unsigned int numeric, const std::string& text) = 0; + virtual void SendLine(Numeric::Numeric& numeric) = 0; }; diff --git a/src/coremods/core_whois.cpp b/src/coremods/core_whois.cpp index 0645eda4c..90a630f9c 100644 --- a/src/coremods/core_whois.cpp +++ b/src/coremods/core_whois.cpp @@ -33,20 +33,16 @@ class WhoisContextImpl : public Whois::Context } using Whois::Context::SendLine; - void SendLine(unsigned int numeric, const std::string& text) CXX11_OVERRIDE; + void SendLine(Numeric::Numeric& numeric) CXX11_OVERRIDE; }; -void WhoisContextImpl::SendLine(unsigned int numeric, const std::string& text) +void WhoisContextImpl::SendLine(Numeric::Numeric& numeric) { - std::string copy_text = target->nick; - copy_text.push_back(' '); - copy_text.append(text); - ModResult MOD_RESULT; - FIRST_MOD_RESULT_CUSTOM(lineevprov, Whois::LineEventListener, OnWhoisLine, MOD_RESULT, (*this, numeric, copy_text)); + FIRST_MOD_RESULT_CUSTOM(lineevprov, Whois::LineEventListener, OnWhoisLine, MOD_RESULT, (*this, numeric)); if (MOD_RESULT != MOD_RES_DENY) - source->WriteNumeric(numeric, copy_text); + source->WriteNumeric(numeric); } /** Handle /WHOIS. @@ -150,7 +146,7 @@ class WhoisChanList { num.Flush(); if (!spynum.IsEmpty()) - whois.SendLine(336, ":is on private/secret channels:"); + whois.SendLine(336, "is on private/secret channels:"); spynum.Flush(); } }; @@ -180,45 +176,45 @@ void CommandWhois::DoWhois(LocalUser* user, User* dest, unsigned long signon, un { WhoisContextImpl whois(user, dest, lineevprov); - whois.SendLine(311, "%s %s * :%s", dest->ident.c_str(), dest->dhost.c_str(), dest->fullname.c_str()); + whois.SendLine(311, dest->ident, dest->dhost, '*', dest->fullname); if (whois.IsSelfWhois() || user->HasPrivPermission("users/auspex")) { - whois.SendLine(378, ":is connecting from %s@%s %s", dest->ident.c_str(), dest->host.c_str(), dest->GetIPString().c_str()); + whois.SendLine(378, InspIRCd::Format("is connecting from %s@%s %s", dest->ident.c_str(), dest->host.c_str(), dest->GetIPString().c_str())); } SendChanList(whois); if (!whois.IsSelfWhois() && !ServerInstance->Config->HideWhoisServer.empty() && !user->HasPrivPermission("servers/auspex")) { - whois.SendLine(312, "%s :%s", ServerInstance->Config->HideWhoisServer.c_str(), ServerInstance->Config->Network.c_str()); + whois.SendLine(312, ServerInstance->Config->HideWhoisServer, ServerInstance->Config->Network); } else { - whois.SendLine(312, "%s :%s", dest->server->GetName().c_str(), dest->server->GetDesc().c_str()); + whois.SendLine(312, dest->server->GetName(), dest->server->GetDesc()); } if (dest->IsAway()) { - whois.SendLine(301, ":%s", dest->awaymsg.c_str()); + whois.SendLine(301, dest->awaymsg); } if (dest->IsOper()) { if (ServerInstance->Config->GenericOper) - whois.SendLine(313, ":is an IRC operator"); + whois.SendLine(313, "is an IRC operator"); else - whois.SendLine(313, ":is %s %s on %s", (strchr("AEIOUaeiou",dest->oper->name[0]) ? "an" : "a"),dest->oper->name.c_str(), ServerInstance->Config->Network.c_str()); + whois.SendLine(313, InspIRCd::Format("is %s %s on %s", (strchr("AEIOUaeiou",dest->oper->name[0]) ? "an" : "a"), dest->oper->name.c_str(), ServerInstance->Config->Network.c_str())); } if (whois.IsSelfWhois() || user->HasPrivPermission("users/auspex")) { if (dest->IsModeSet(snomaskmode)) { - whois.SendLine(379, ":is using modes +%s %s", dest->FormatModes(), snomaskmode->GetUserParameter(dest).c_str()); + whois.SendLine(379, InspIRCd::Format("is using modes +%s %s", dest->FormatModes(), snomaskmode->GetUserParameter(dest).c_str())); } else { - whois.SendLine(379, ":is using modes +%s", dest->FormatModes()); + whois.SendLine(379, InspIRCd::Format("is using modes +%s", dest->FormatModes())); } } @@ -230,10 +226,10 @@ void CommandWhois::DoWhois(LocalUser* user, User* dest, unsigned long signon, un */ if ((idle) || (signon)) { - whois.SendLine(317, "%lu %lu :seconds idle, signon time", idle, signon); + whois.SendLine(317, idle, signon, "seconds idle, signon time"); } - whois.SendLine(318, ":End of /WHOIS list."); + whois.SendLine(318, "End of /WHOIS list."); } CmdResult CommandWhois::HandleRemote(const std::vector<std::string>& parameters, RemoteUser* target) diff --git a/src/modules/m_botmode.cpp b/src/modules/m_botmode.cpp index 419af0153..e0236bc17 100644 --- a/src/modules/m_botmode.cpp +++ b/src/modules/m_botmode.cpp @@ -48,7 +48,7 @@ class ModuleBotMode : public Module, public Whois::EventListener { if (whois.GetTarget()->IsModeSet(bm)) { - whois.SendLine(335, ":is a bot on " + ServerInstance->Config->Network); + whois.SendLine(335, "is a bot on " + ServerInstance->Config->Network); } } }; diff --git a/src/modules/m_customtitle.cpp b/src/modules/m_customtitle.cpp index b86bf1809..30c0aa4f2 100644 --- a/src/modules/m_customtitle.cpp +++ b/src/modules/m_customtitle.cpp @@ -82,16 +82,16 @@ class ModuleCustomTitle : public Module, public Whois::LineEventListener } // :kenny.chatspike.net 320 Brain Azhrarn :is getting paid to play games. - ModResult OnWhoisLine(Whois::Context& whois, unsigned int& numeric, std::string& text) CXX11_OVERRIDE + ModResult OnWhoisLine(Whois::Context& whois, Numeric::Numeric& numeric) CXX11_OVERRIDE { /* We use this and not OnWhois because this triggers for remote, too */ - if (numeric == 312) + if (numeric.GetNumeric() == 312) { /* Insert our numeric before 312 */ const std::string* ctitle = cmd.ctitle.get(whois.GetTarget()); if (ctitle) { - whois.SendLine(320, ":%s", ctitle->c_str()); + whois.SendLine(320, ctitle); } } /* Don't block anything */ diff --git a/src/modules/m_helpop.cpp b/src/modules/m_helpop.cpp index f567aa076..95f69774b 100644 --- a/src/modules/m_helpop.cpp +++ b/src/modules/m_helpop.cpp @@ -145,7 +145,7 @@ class ModuleHelpop : public Module, public Whois::EventListener { if (whois.GetTarget()->IsModeSet(ho)) { - whois.SendLine(310, ":is available for help."); + whois.SendLine(310, "is available for help."); } } diff --git a/src/modules/m_hidechans.cpp b/src/modules/m_hidechans.cpp index 431b7b968..08caae6b2 100644 --- a/src/modules/m_hidechans.cpp +++ b/src/modules/m_hidechans.cpp @@ -49,14 +49,14 @@ class ModuleHideChans : public Module, public Whois::LineEventListener AffectsOpers = ServerInstance->Config->ConfValue("hidechans")->getBool("affectsopers"); } - ModResult OnWhoisLine(Whois::Context& whois, unsigned int& numeric, std::string& text) CXX11_OVERRIDE + ModResult OnWhoisLine(Whois::Context& whois, Numeric::Numeric& numeric) CXX11_OVERRIDE { /* always show to self */ if (whois.IsSelfWhois()) return MOD_RES_PASSTHRU; /* don't touch anything except 319 */ - if (numeric != 319) + if (numeric.GetNumeric() != 319) return MOD_RES_PASSTHRU; /* don't touch if -I */ diff --git a/src/modules/m_hideoper.cpp b/src/modules/m_hideoper.cpp index b90f3f234..92af045d5 100644 --- a/src/modules/m_hideoper.cpp +++ b/src/modules/m_hideoper.cpp @@ -87,12 +87,12 @@ class ModuleHideOper : public Module, public Whois::LineEventListener return MOD_RES_DENY; } - ModResult OnWhoisLine(Whois::Context& whois, unsigned int& numeric, std::string& text) CXX11_OVERRIDE + ModResult OnWhoisLine(Whois::Context& whois, Numeric::Numeric& numeric) CXX11_OVERRIDE { /* Dont display numeric 313 (RPL_WHOISOPER) if they have +H set and the * person doing the WHOIS is not an oper */ - if (numeric != 313) + if (numeric.GetNumeric() != 313) return MOD_RES_PASSTHRU; if (!whois.GetTarget()->IsModeSet(hm)) diff --git a/src/modules/m_services_account.cpp b/src/modules/m_services_account.cpp index 048e04a5a..559f28ea8 100644 --- a/src/modules/m_services_account.cpp +++ b/src/modules/m_services_account.cpp @@ -168,13 +168,13 @@ class ModuleServicesAccount : public Module, public Whois::EventListener if (account) { - whois.SendLine(330, "%s :is logged in as", account->c_str()); + whois.SendLine(330, *account, "is logged in as"); } if (whois.GetTarget()->IsModeSet(m5)) { /* user is registered */ - whois.SendLine(307, ":is a registered nick"); + whois.SendLine(307, "is a registered nick"); } } diff --git a/src/modules/m_servprotect.cpp b/src/modules/m_servprotect.cpp index 34f730c62..88bde9b57 100644 --- a/src/modules/m_servprotect.cpp +++ b/src/modules/m_servprotect.cpp @@ -62,7 +62,7 @@ class ModuleServProtectMode : public Module, public Whois::EventListener, public { if (whois.GetTarget()->IsModeSet(bm)) { - whois.SendLine(310, ":is a Network Service on " + ServerInstance->Config->Network); + whois.SendLine(310, "is a Network Service on " + ServerInstance->Config->Network); } } @@ -120,9 +120,9 @@ class ModuleServProtectMode : public Module, public Whois::EventListener, public return MOD_RES_PASSTHRU; } - ModResult OnWhoisLine(Whois::Context& whois, unsigned int& numeric, std::string& text) CXX11_OVERRIDE + ModResult OnWhoisLine(Whois::Context& whois, Numeric::Numeric& numeric) CXX11_OVERRIDE { - return ((numeric == 319) && whois.GetTarget()->IsModeSet(bm)) ? MOD_RES_DENY : MOD_RES_PASSTHRU; + return ((numeric.GetNumeric() == 319) && whois.GetTarget()->IsModeSet(bm)) ? MOD_RES_DENY : MOD_RES_PASSTHRU; } }; diff --git a/src/modules/m_sslinfo.cpp b/src/modules/m_sslinfo.cpp index ac02908c4..6a29d3bde 100644 --- a/src/modules/m_sslinfo.cpp +++ b/src/modules/m_sslinfo.cpp @@ -162,10 +162,10 @@ class ModuleSSLInfo : public Module, public Whois::EventListener ssl_cert* cert = cmd.CertExt.get(whois.GetTarget()); if (cert) { - whois.SendLine(671, ":is using a secure connection"); + whois.SendLine(671, "is using a secure connection"); bool operonlyfp = ServerInstance->Config->ConfValue("sslinfo")->getBool("operonly"); if ((!operonlyfp || whois.IsSelfWhois() || whois.GetSource()->IsOper()) && !cert->fingerprint.empty()) - whois.SendLine(276, ":has client certificate fingerprint %s", cert->fingerprint.c_str()); + whois.SendLine(276, InspIRCd::Format("has client certificate fingerprint %s", cert->fingerprint.c_str())); } } diff --git a/src/modules/m_swhois.cpp b/src/modules/m_swhois.cpp index 46d96a952..9a433e154 100644 --- a/src/modules/m_swhois.cpp +++ b/src/modules/m_swhois.cpp @@ -93,16 +93,16 @@ class ModuleSWhois : public Module, public Whois::LineEventListener } // :kenny.chatspike.net 320 Brain Azhrarn :is getting paid to play games. - ModResult OnWhoisLine(Whois::Context& whois, unsigned int& numeric, std::string& text) CXX11_OVERRIDE + ModResult OnWhoisLine(Whois::Context& whois, Numeric::Numeric& numeric) CXX11_OVERRIDE { /* We use this and not OnWhois because this triggers for remote, too */ - if (numeric == 312) + if (numeric.GetNumeric() == 312) { /* Insert our numeric before 312 */ std::string* swhois = cmd.swhois.get(whois.GetTarget()); if (swhois) { - whois.SendLine(320, ":%s", swhois->c_str()); + whois.SendLine(320, *swhois); } } |