]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Convert WriteNumeric() calls to pass the parameters of the numeric as method parameters
authorAttila Molnar <attilamolnar@hush.com>
Thu, 25 Feb 2016 15:12:09 +0000 (16:12 +0100)
committerAttila Molnar <attilamolnar@hush.com>
Thu, 25 Feb 2016 15:12:09 +0000 (16:12 +0100)
120 files changed:
include/isupportmanager.h
include/modules.h
include/numericbuilder.h
include/users.h
src/channels.cpp
src/command_parse.cpp
src/configreader.cpp
src/coremods/core_channel/cmd_invite.cpp
src/coremods/core_channel/cmd_join.cpp
src/coremods/core_channel/cmd_kick.cpp
src/coremods/core_channel/cmd_names.cpp
src/coremods/core_channel/cmd_topic.cpp
src/coremods/core_info/cmd_commands.cpp
src/coremods/core_info/cmd_version.cpp
src/coremods/core_list.cpp
src/coremods/core_loadmodule.cpp
src/coremods/core_lusers.cpp
src/coremods/core_oper/cmd_kill.cpp
src/coremods/core_oper/cmd_oper.cpp
src/coremods/core_oper/cmd_rehash.cpp
src/coremods/core_privmsg.cpp
src/coremods/core_reloadmodule.cpp
src/coremods/core_stub.cpp
src/coremods/core_user/cmd_away.cpp
src/coremods/core_user/cmd_mode.cpp
src/coremods/core_user/cmd_nick.cpp
src/coremods/core_user/cmd_part.cpp
src/coremods/core_user/cmd_user.cpp
src/coremods/core_user/core_user.cpp
src/coremods/core_who.cpp
src/coremods/core_whois.cpp
src/coremods/core_whowas.cpp
src/coremods/core_xline/core_xline.cpp
src/listmode.cpp
src/mode.cpp
src/modes/umode_s.cpp
src/modules.cpp
src/modules/m_abbreviation.cpp
src/modules/m_alias.cpp
src/modules/m_allowinvite.cpp
src/modules/m_autoop.cpp
src/modules/m_banredirect.cpp
src/modules/m_blockcaps.cpp
src/modules/m_blockcolor.cpp
src/modules/m_callerid.cpp
src/modules/m_cap.cpp
src/modules/m_cban.cpp
src/modules/m_censor.cpp
src/modules/m_chanfilter.cpp
src/modules/m_chghost.cpp
src/modules/m_chgident.cpp
src/modules/m_chgname.cpp
src/modules/m_commonchans.cpp
src/modules/m_cycle.cpp
src/modules/m_dccallow.cpp
src/modules/m_delaymsg.cpp
src/modules/m_denychans.cpp
src/modules/m_dnsbl.cpp
src/modules/m_exemptchanops.cpp
src/modules/m_filter.cpp
src/modules/m_globalload.cpp
src/modules/m_helpop.cpp
src/modules/m_hidelist.cpp
src/modules/m_hideoper.cpp
src/modules/m_httpd_stats.cpp
src/modules/m_joinflood.cpp
src/modules/m_jumpserver.cpp
src/modules/m_kicknorejoin.cpp
src/modules/m_knock.cpp
src/modules/m_lockserv.cpp
src/modules/m_messageflood.cpp
src/modules/m_mlock.cpp
src/modules/m_monitor.cpp
src/modules/m_muteban.cpp
src/modules/m_namedmodes.cpp
src/modules/m_nickflood.cpp
src/modules/m_nicklock.cpp
src/modules/m_noctcp.cpp
src/modules/m_nokicks.cpp
src/modules/m_nonicks.cpp
src/modules/m_nonotice.cpp
src/modules/m_ojoin.cpp
src/modules/m_operchans.cpp
src/modules/m_operlevels.cpp
src/modules/m_redirect.cpp
src/modules/m_regonlycreate.cpp
src/modules/m_remove.cpp
src/modules/m_restrictchans.cpp
src/modules/m_restrictmsg.cpp
src/modules/m_sajoin.cpp
src/modules/m_sakick.cpp
src/modules/m_samode.cpp
src/modules/m_sanick.cpp
src/modules/m_sapart.cpp
src/modules/m_saquit.cpp
src/modules/m_sasl.cpp
src/modules/m_satopic.cpp
src/modules/m_securelist.cpp
src/modules/m_services_account.cpp
src/modules/m_servprotect.cpp
src/modules/m_setidle.cpp
src/modules/m_silence.cpp
src/modules/m_spanningtree/main.cpp
src/modules/m_spanningtree/override_map.cpp
src/modules/m_spanningtree/override_whois.cpp
src/modules/m_spanningtree/uid.cpp
src/modules/m_sslinfo.cpp
src/modules/m_sslmodes.cpp
src/modules/m_starttls.cpp
src/modules/m_svshold.cpp
src/modules/m_swhois.cpp
src/modules/m_timedbans.cpp
src/modules/m_topiclock.cpp
src/modules/m_uninvite.cpp
src/modules/m_userip.cpp
src/modules/m_watch.cpp
src/server.cpp
src/usermanager.cpp
src/users.cpp
src/xline.cpp

index 1f41de5d2ed64581f3f84ff49fb0b6e1504488b9..3a0df78f940f698c8bd58c799465831e2464aa10 100644 (file)
@@ -24,7 +24,7 @@ class CoreExport ISupportManager
 {
  private:
        /** The generated lines which are sent to clients. */
-       std::vector<std::string> cachedlines;
+       std::vector<Numeric::Numeric> cachedlines;
 
  public:
        /** (Re)build the ISUPPORT vector.
@@ -34,9 +34,9 @@ class CoreExport ISupportManager
        void Build();
 
        /** Returns the cached std::vector of ISUPPORT lines.
-        * @return A list of strings prepared for sending to users
+        * @return A list of Numeric::Numeric objects prepared for sending to users
         */
-       const std::vector<std::string>& GetLines() const { return cachedlines; }
+       const std::vector<Numeric::Numeric>& GetLines() const { return cachedlines; }
 
        /** Send the 005 numerics (ISUPPORT) to a user.
         * @param user The user to send the ISUPPORT numerics to
index 526c283b2f1a96fa8426b4e754fb166a278f146b..86ee7f4f3397341748d98fd76a31f16add378446 100644 (file)
@@ -987,7 +987,7 @@ class CoreExport Module : public classbase, public usecountbase
         */
        virtual ModResult OnNamesListItem(User* issuer, Membership* item, std::string& prefixes, std::string& nick);
 
-       virtual ModResult OnNumeric(User* user, unsigned int numeric, const std::string &text);
+       virtual ModResult OnNumeric(User* user, const Numeric::Numeric& numeric);
 
        /** Called whenever a result from /WHO is about to be returned
         * @param source The user running the /WHO query
index 371f275a91b44afc694204afd708d74259cfe9b7..726aeff3f5c78f8cff1ff7a6c59d5d810e49caf9 100644 (file)
@@ -40,9 +40,9 @@ class Numeric::WriteNumericSink
        {
        }
 
-       void operator()(unsigned int numeric, const std::string& params) const
+       void operator()(Numeric& numeric) const
        {
-               user->WriteNumeric(numeric, params);
+               user->WriteNumeric(numeric);
        }
 };
 
@@ -50,14 +50,12 @@ template <char Sep, bool SendEmpty, typename Sink>
 class Numeric::GenericBuilder
 {
        Sink sink;
-       std::string data;
-       const unsigned int numeric;
+       Numeric numeric;
        const std::string::size_type max;
-       std::string::size_type beginpos;
 
        bool HasRoom(const std::string::size_type additional) const
        {
-               return (data.size() + additional <= max);
+               return (numeric.GetParams().back().size() + additional <= max);
        }
 
  public:
@@ -67,28 +65,28 @@ class Numeric::GenericBuilder
                , max(ServerInstance->Config->Limits.MaxLine - ServerInstance->Config->ServerName.size() - additionalsize - 9)
        {
                if (addparam)
-                       data.push_back(':');
-               SaveBeginPos();
+                       numeric.push(std::string());
        }
 
-       std::string& GetNumeric() { return data; }
+       Numeric& GetNumeric() { return numeric; }
 
        void Add(const std::string& entry)
        {
                if (!HasRoom(entry.size()))
                        Flush();
-               data.append(entry).push_back(Sep);
+               numeric.GetParams().back().append(entry).push_back(Sep);
        }
 
        void Add(const std::string& entry1, const std::string& entry2)
        {
                if (!HasRoom(entry1.size() + entry2.size()))
                        Flush();
-               data.append(entry1).append(entry2).push_back(Sep);
+               numeric.GetParams().back().append(entry1).append(entry2).push_back(Sep);
        }
 
        void Flush()
        {
+               std::string& data = numeric.GetParams().back();
                if (IsEmpty())
                {
                        if (!SendEmpty)
@@ -99,13 +97,11 @@ class Numeric::GenericBuilder
                        data.erase(data.size()-1);
                }
 
-               sink(numeric, data);
-               if (data.size() > beginpos)
-                       data.erase(beginpos);
+               sink(numeric);
+               data.clear();
        }
 
-       bool IsEmpty() const { return (data.size() == beginpos); }
-       void SaveBeginPos() { beginpos = data.size(); }
+       bool IsEmpty() const { return (numeric.GetParams().back().empty()); }
 };
 
 template <char Sep, bool SendEmpty>
index fa346a32968f2164a93aed14c447ef9ba25d7e42..8aa88798c310a10364ebec45bb5a72a8c172138d 100644 (file)
@@ -519,9 +519,58 @@ class CoreExport User : public Extensible
         */
        void WriteNotice(const std::string& text) { this->WriteCommand("NOTICE", ":" + text); }
 
-       void WriteNumeric(unsigned int numeric, const char* text, ...) CUSTOM_PRINTF(3, 4);
 
-       void WriteNumeric(unsigned int numeric, const std::string &text);
+       void WriteNumeric(const Numeric::Numeric& numeric);
+
+       template <typename T1>
+       void WriteNumeric(unsigned int numeric, T1 p1)
+       {
+               Numeric::Numeric n(numeric);
+               n.push(p1);
+               WriteNumeric(n);
+       }
+
+       template <typename T1, typename T2>
+       void WriteNumeric(unsigned int numeric, T1 p1, T2 p2)
+       {
+               Numeric::Numeric n(numeric);
+               n.push(p1);
+               n.push(p2);
+               WriteNumeric(n);
+       }
+
+       template <typename T1, typename T2, typename T3>
+       void WriteNumeric(unsigned int numeric, T1 p1, T2 p2, T3 p3)
+       {
+               Numeric::Numeric n(numeric);
+               n.push(p1);
+               n.push(p2);
+               n.push(p3);
+               WriteNumeric(n);
+       }
+
+       template <typename T1, typename T2, typename T3, typename T4>
+       void WriteNumeric(unsigned int numeric, T1 p1, T2 p2, T3 p3, T4 p4)
+       {
+               Numeric::Numeric n(numeric);
+               n.push(p1);
+               n.push(p2);
+               n.push(p3);
+               n.push(p4);
+               WriteNumeric(n);
+       }
+
+       template <typename T1, typename T2, typename T3, typename T4, typename T5>
+       void WriteNumeric(unsigned int numeric, T1 p1, T2 p2, T3 p3, T4 p4, T5 p5)
+       {
+               Numeric::Numeric n(numeric);
+               n.push(p1);
+               n.push(p2);
+               n.push(p3);
+               n.push(p4);
+               n.push(p5);
+               WriteNumeric(n);
+       }
 
        /** Write text to this user, appending CR/LF and prepending :nick!user\@host of the user provided in the first parameter.
         * @param user The user to prepend the :nick!user\@host of
index 99da0070810b1f6b4463977e58c078c436b651d4..a2d5c4a30f1831c8a72fcc63ff83c51c78ce330e 100644 (file)
@@ -180,7 +180,7 @@ Channel* Channel::JoinUser(LocalUser* user, std::string cname, bool override, co
                }
                if (user->chans.size() >= maxchans)
                {
-                       user->WriteNumeric(ERR_TOOMANYCHANNELS, "%s :You are on too many channels", cname.c_str());
+                       user->WriteNumeric(ERR_TOOMANYCHANNELS, cname, "You are on too many channels");
                        return NULL;
                }
        }
@@ -240,7 +240,7 @@ Channel* Channel::JoinUser(LocalUser* user, std::string cname, bool override, co
                                        if (!MOD_RESULT.check(InspIRCd::TimingSafeCompare(ckey, key)))
                                        {
                                                // If no key provided, or key is not the right one, and can't bypass +k (not invited or option not enabled)
-                                               user->WriteNumeric(ERR_BADCHANNELKEY, "%s :Cannot join channel (Incorrect channel key)", chan->name.c_str());
+                                               user->WriteNumeric(ERR_BADCHANNELKEY, chan->name, "Cannot join channel (Incorrect channel key)");
                                                return NULL;
                                        }
                                }
@@ -250,7 +250,7 @@ Channel* Channel::JoinUser(LocalUser* user, std::string cname, bool override, co
                                        FIRST_MOD_RESULT(OnCheckInvite, MOD_RESULT, (user, chan));
                                        if (MOD_RESULT != MOD_RES_ALLOW)
                                        {
-                                               user->WriteNumeric(ERR_INVITEONLYCHAN, "%s :Cannot join channel (Invite only)", chan->name.c_str());
+                                               user->WriteNumeric(ERR_INVITEONLYCHAN, chan->name, "Cannot join channel (Invite only)");
                                                return NULL;
                                        }
                                }
@@ -261,14 +261,14 @@ Channel* Channel::JoinUser(LocalUser* user, std::string cname, bool override, co
                                        FIRST_MOD_RESULT(OnCheckLimit, MOD_RESULT, (user, chan));
                                        if (!MOD_RESULT.check((chan->GetUserCounter() < atol(limit.c_str()))))
                                        {
-                                               user->WriteNumeric(ERR_CHANNELISFULL, "%s :Cannot join channel (Channel is full)", chan->name.c_str());
+                                               user->WriteNumeric(ERR_CHANNELISFULL, chan->name, "Cannot join channel (Channel is full)");
                                                return NULL;
                                        }
                                }
 
                                if (chan->IsBanned(user))
                                {
-                                       user->WriteNumeric(ERR_BANNEDFROMCHAN, "%s :Cannot join channel (You're banned)", chan->name.c_str());
+                                       user->WriteNumeric(ERR_BANNEDFROMCHAN, chan->name, "Cannot join channel (You're banned)");
                                        return NULL;
                                }
                        }
index c123353b0a96b94da8c6ded03762afdc7c92be3e..514394a572e2ec3a0f2cd5ad37b53ef4ab03d659 100644 (file)
@@ -217,7 +217,7 @@ void CommandParser::ProcessCommand(LocalUser *user, std::string &cmd)
                if (!handler)
                {
                        if (user->registered == REG_ALL)
-                               user->WriteNumeric(ERR_UNKNOWNCOMMAND, "%s :Unknown command",command.c_str());
+                               user->WriteNumeric(ERR_UNKNOWNCOMMAND, command, "Unknown command");
                        ServerInstance->stats.Unknown++;
                        return;
                }
@@ -268,15 +268,15 @@ void CommandParser::ProcessCommand(LocalUser *user, std::string &cmd)
                if (!user->IsModeSet(handler->flags_needed))
                {
                        user->CommandFloodPenalty += failpenalty;
-                       user->WriteNumeric(ERR_NOPRIVILEGES, ":Permission Denied - You do not have the required operator privileges");
+                       user->WriteNumeric(ERR_NOPRIVILEGES, "Permission Denied - You do not have the required operator privileges");
                        return;
                }
 
                if (!user->HasPermission(command))
                {
                        user->CommandFloodPenalty += failpenalty;
-                       user->WriteNumeric(ERR_NOPRIVILEGES, ":Permission Denied - Oper type %s does not have access to command %s",
-                               user->oper->name.c_str(), command.c_str());
+                       user->WriteNumeric(ERR_NOPRIVILEGES, InspIRCd::Format("Permission Denied - Oper type %s does not have access to command %s",
+                               user->oper->name.c_str(), command.c_str()));
                        return;
                }
        }
@@ -287,11 +287,11 @@ void CommandParser::ProcessCommand(LocalUser *user, std::string &cmd)
                user->CommandFloodPenalty += failpenalty;
                if (ServerInstance->Config->DisabledDontExist)
                {
-                       user->WriteNumeric(ERR_UNKNOWNCOMMAND, "%s :Unknown command", command.c_str());
+                       user->WriteNumeric(ERR_UNKNOWNCOMMAND, command, "Unknown command");
                }
                else
                {
-                       user->WriteNumeric(ERR_UNKNOWNCOMMAND, "%s :This command has been disabled.", command.c_str());
+                       user->WriteNumeric(ERR_UNKNOWNCOMMAND, command, "This command has been disabled.");
                }
 
                ServerInstance->SNO->WriteToSnoMask('a', "%s denied for %s (%s@%s)",
@@ -305,16 +305,16 @@ void CommandParser::ProcessCommand(LocalUser *user, std::string &cmd)
        if (command_p.size() < handler->min_params)
        {
                user->CommandFloodPenalty += failpenalty;
-               user->WriteNumeric(ERR_NEEDMOREPARAMS, "%s :Not enough parameters.", command.c_str());
+               user->WriteNumeric(ERR_NEEDMOREPARAMS, command, "Not enough parameters.");
                if ((ServerInstance->Config->SyntaxHints) && (user->registered == REG_ALL) && (handler->syntax.length()))
-                       user->WriteNumeric(RPL_SYNTAX, ":SYNTAX %s %s", handler->name.c_str(), handler->syntax.c_str());
+                       user->WriteNumeric(RPL_SYNTAX, InspIRCd::Format("SYNTAX %s %s", handler->name.c_str(), handler->syntax.c_str()));
                return;
        }
 
        if ((user->registered != REG_ALL) && (!handler->WorksBeforeReg()))
        {
                user->CommandFloodPenalty += failpenalty;
-               user->WriteNumeric(ERR_NOTREGISTERED, "%s :You have not registered",command.c_str());
+               user->WriteNumeric(ERR_NOTREGISTERED, command, "You have not registered");
        }
        else
        {
index 2c31fa0ae97f5e67774d1fca6f226502eaa11056..cec4be3d3d068a93041f6755d65dbedcee6443e0 100644 (file)
@@ -688,14 +688,14 @@ void ServerConfig::ApplyModules(User* user)
                        ServerInstance->SNO->WriteGlobalSno('a', "*** REHASH UNLOADED MODULE: %s", modname.c_str());
 
                        if (user)
-                               user->WriteNumeric(RPL_UNLOADEDMODULE, "%s :Module %s successfully unloaded.", modname.c_str(), modname.c_str());
+                               user->WriteNumeric(RPL_UNLOADEDMODULE, modname, InspIRCd::Format("Module %s successfully unloaded.", modname.c_str()));
                        else
                                ServerInstance->SNO->WriteGlobalSno('a', "Module %s successfully unloaded.", modname.c_str());
                }
                else
                {
                        if (user)
-                               user->WriteNumeric(ERR_CANTUNLOADMODULE, "%s :Failed to unload module %s: %s", modname.c_str(), modname.c_str(), ServerInstance->Modules->LastError().c_str());
+                               user->WriteNumeric(ERR_CANTUNLOADMODULE, modname, InspIRCd::Format("Failed to unload module %s: %s", modname.c_str(), ServerInstance->Modules->LastError().c_str()));
                        else
                                ServerInstance->SNO->WriteGlobalSno('a', "Failed to unload module %s: %s", modname.c_str(), ServerInstance->Modules->LastError().c_str());
                }
@@ -707,14 +707,14 @@ void ServerConfig::ApplyModules(User* user)
                {
                        ServerInstance->SNO->WriteGlobalSno('a', "*** REHASH LOADED MODULE: %s",adding->c_str());
                        if (user)
-                               user->WriteNumeric(RPL_LOADEDMODULE, "%s :Module %s successfully loaded.", adding->c_str(), adding->c_str());
+                               user->WriteNumeric(RPL_LOADEDMODULE, *adding, InspIRCd::Format("Module %s successfully loaded.", adding->c_str()));
                        else
                                ServerInstance->SNO->WriteGlobalSno('a', "Module %s successfully loaded.", adding->c_str());
                }
                else
                {
                        if (user)
-                               user->WriteNumeric(ERR_CANTLOADMODULE, "%s :Failed to load module %s: %s", adding->c_str(), adding->c_str(), ServerInstance->Modules->LastError().c_str());
+                               user->WriteNumeric(ERR_CANTLOADMODULE, *adding, InspIRCd::Format("Failed to load module %s: %s", adding->c_str(), ServerInstance->Modules->LastError().c_str()));
                        else
                                ServerInstance->SNO->WriteGlobalSno('a', "Failed to load module %s: %s", adding->c_str(), ServerInstance->Modules->LastError().c_str());
                }
index c1f1b00c7bd4be6067bcb2692d148454e186a648..a1319ebc049651d2099faf6149b33c960622128b 100644 (file)
@@ -58,7 +58,7 @@ CmdResult CommandInvite::Handle (const std::vector<std::string>& parameters, Use
 
                if ((!c) || (!u) || (u->registered != REG_ALL))
                {
-                       user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", c ? parameters[0].c_str() : parameters[1].c_str());
+                       user->WriteNumeric(Numerics::NoSuchNick(c ? parameters[0] : parameters[1]));
                        return CMD_FAILURE;
                }
 
@@ -77,13 +77,13 @@ CmdResult CommandInvite::Handle (const std::vector<std::string>& parameters, Use
 
                if ((IS_LOCAL(user)) && (!c->HasUser(user)))
                {
-                       user->WriteNumeric(ERR_NOTONCHANNEL, "%s :You're not on that channel!", c->name.c_str());
+                       user->WriteNumeric(ERR_NOTONCHANNEL, c->name, "You're not on that channel!");
                        return CMD_FAILURE;
                }
 
                if (c->HasUser(u))
                {
-                       user->WriteNumeric(ERR_USERONCHANNEL, "%s %s :is already on channel", u->nick.c_str(), c->name.c_str());
+                       user->WriteNumeric(ERR_USERONCHANNEL, u->nick, c->name, "is already on channel");
                        return CMD_FAILURE;
                }
 
@@ -102,8 +102,8 @@ CmdResult CommandInvite::Handle (const std::vector<std::string>& parameters, Use
                                {
                                        // Check whether halfop mode is available and phrase error message accordingly
                                        ModeHandler* mh = ServerInstance->Modes->FindMode('h', MODETYPE_CHANNEL);
-                                       user->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s :You must be a channel %soperator",
-                                               c->name.c_str(), (mh && mh->name == "halfop" ? "half-" : ""));
+                                       user->WriteNumeric(ERR_CHANOPRIVSNEEDED, c->name, InspIRCd::Format("You must be a channel %soperator",
+                                               (mh && mh->name == "halfop" ? "half-" : "")));
                                        return CMD_FAILURE;
                                }
                        }
@@ -117,9 +117,9 @@ CmdResult CommandInvite::Handle (const std::vector<std::string>& parameters, Use
 
                if (IS_LOCAL(user))
                {
-                       user->WriteNumeric(RPL_INVITING, "%s %s", u->nick.c_str(),c->name.c_str());
+                       user->WriteNumeric(RPL_INVITING, u->nick, c->name);
                        if (u->IsAway())
-                               user->WriteNumeric(RPL_AWAY, "%s :%s", u->nick.c_str(), u->awaymsg.c_str());
+                               user->WriteNumeric(RPL_AWAY, u->nick, u->awaymsg);
                }
 
                char prefix = 0;
@@ -161,9 +161,9 @@ CmdResult CommandInvite::Handle (const std::vector<std::string>& parameters, Use
                if (list)
                {
                        for (Invite::List::const_iterator i = list->begin(); i != list->end(); ++i)
-                               user->WriteNumeric(RPL_INVITELIST, ":%s", (*i)->chan->name.c_str());
+                               user->WriteNumeric(RPL_INVITELIST, (*i)->chan->name);
                }
-               user->WriteNumeric(RPL_ENDOFINVITELIST, ":End of INVITE list");
+               user->WriteNumeric(RPL_ENDOFINVITELIST, "End of INVITE list");
        }
        return CMD_SUCCESS;
 }
index 1945bf52e2484a2a8d1df83815e00d31b5e5fcf3..06e203ead68a11b3b2a1c282050d82097a9194c4 100644 (file)
@@ -55,6 +55,6 @@ CmdResult CommandJoin::HandleLocal(const std::vector<std::string>& parameters, L
                }
        }
 
-       user->WriteNumeric(ERR_NOSUCHCHANNEL, "%s :Invalid channel name", parameters[0].c_str());
+       user->WriteNumeric(ERR_NOSUCHCHANNEL, parameters[0], "Invalid channel name");
        return CMD_FAILURE;
 }
index 44f511bc1196554097ab95d1c68bf1a66e9effde..7f8a8a3291d28d0c445db47e8d34df945917c7b6 100644 (file)
@@ -44,7 +44,7 @@ CmdResult CommandKick::Handle (const std::vector<std::string>& parameters, User
 
        if ((!u) || (!c) || (u->registered != REG_ALL))
        {
-               user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", c ? parameters[1].c_str() : parameters[0].c_str());
+               user->WriteNumeric(Numerics::NoSuchNick(c ? parameters[1] : parameters[0]));
                return CMD_FAILURE;
        }
 
@@ -54,13 +54,13 @@ CmdResult CommandKick::Handle (const std::vector<std::string>& parameters, User
                srcmemb = c->GetUser(user);
                if (!srcmemb)
                {
-                       user->WriteNumeric(ERR_NOTONCHANNEL, "%s :You're not on that channel!", parameters[0].c_str());
+                       user->WriteNumeric(ERR_NOTONCHANNEL, parameters[0], "You're not on that channel!");
                        return CMD_FAILURE;
                }
 
                if (u->server->IsULine())
                {
-                       user->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s :You may not kick a u-lined client", c->name.c_str());
+                       user->WriteNumeric(ERR_CHANOPRIVSNEEDED, c->name, "You may not kick a u-lined client");
                        return CMD_FAILURE;
                }
        }
@@ -68,7 +68,7 @@ CmdResult CommandKick::Handle (const std::vector<std::string>& parameters, User
        const Channel::MemberMap::iterator victimiter = c->userlist.find(u);
        if (victimiter == c->userlist.end())
        {
-               user->WriteNumeric(ERR_USERNOTINCHANNEL, "%s %s :They are not on that channel", u->nick.c_str(), c->name.c_str());
+               user->WriteNumeric(ERR_USERNOTINCHANNEL, u->nick, c->name, "They are not on that channel");
                return CMD_FAILURE;
        }
        Membership* const memb = victimiter->second;
@@ -110,8 +110,8 @@ CmdResult CommandKick::Handle (const std::vector<std::string>& parameters, User
 
                        if (them < req)
                        {
-                               user->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s :You must be a channel %soperator",
-                                       c->name.c_str(), req > HALFOP_VALUE ? "" : "half-");
+                               user->WriteNumeric(ERR_CHANOPRIVSNEEDED, c->name, InspIRCd::Format("You must be a channel %soperator",
+                                       req > HALFOP_VALUE ? "" : "half-"));
                                return CMD_FAILURE;
                        }
                }
index 986dbe01889d7daa65b3c5822603f0c20f586c6d..53934b5e3a06bf36d5a5416b124b4410560acf02 100644 (file)
@@ -38,7 +38,7 @@ CmdResult CommandNames::HandleLocal(const std::vector<std::string>& parameters,
 
        if (!parameters.size())
        {
-               user->WriteNumeric(RPL_ENDOFNAMES, "* :End of /NAMES list.");
+               user->WriteNumeric(RPL_ENDOFNAMES, '*', "End of /NAMES list.");
                return CMD_SUCCESS;
        }
 
@@ -62,24 +62,23 @@ CmdResult CommandNames::HandleLocal(const std::vector<std::string>& parameters,
                }
        }
 
-       user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", parameters[0].c_str());
+       user->WriteNumeric(Numerics::NoSuchNick(parameters[0]));
        return CMD_FAILURE;
 }
 
 void CommandNames::SendNames(LocalUser* user, Channel* chan, bool show_invisible)
 {
-       Numeric::Builder<' '> reply(user, RPL_NAMREPLY, false);
-       std::string& list = reply.GetNumeric();
+       Numeric::Builder<' '> reply(user, RPL_NAMREPLY, false, chan->name.size() + 4);
+       Numeric::Numeric& numeric = reply.GetNumeric();
        if (chan->IsModeSet(secretmode))
-               list.push_back('@');
+               numeric.push(std::string(1, '@'));
        else if (chan->IsModeSet(privatemode))
-               list.push_back('*');
+               numeric.push(std::string(1, '*'));
        else
-               list.push_back('=');
+               numeric.push(std::string(1, '='));
 
-       list.push_back(' ');
-       list.append(chan->name).append(" :");
-       reply.SaveBeginPos();
+       numeric.push(chan->name);
+       numeric.push(std::string());
 
        std::string prefixlist;
        std::string nick;
@@ -111,5 +110,5 @@ void CommandNames::SendNames(LocalUser* user, Channel* chan, bool show_invisible
        }
 
        reply.Flush();
-       user->WriteNumeric(RPL_ENDOFNAMES, "%s :End of /NAMES list.", chan->name.c_str());
+       user->WriteNumeric(RPL_ENDOFNAMES, chan->name, "End of /NAMES list.");
 }
index 8d65d764a1a7aac3e75854cf3723d4134a8bb0bf..b421489399953867c169af5712d60a418d5e9d05 100644 (file)
@@ -37,7 +37,7 @@ CmdResult CommandTopic::HandleLocal(const std::vector<std::string>& parameters,
        Channel* c = ServerInstance->FindChan(parameters[0]);
        if (!c)
        {
-               user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", parameters[0].c_str());
+               user->WriteNumeric(Numerics::NoSuchNick(parameters[0]));
                return CMD_FAILURE;
        }
 
@@ -45,7 +45,7 @@ CmdResult CommandTopic::HandleLocal(const std::vector<std::string>& parameters,
        {
                if ((c->IsModeSet(secretmode)) && (!c->HasUser(user)))
                {
-                       user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", c->name.c_str());
+                       user->WriteNumeric(Numerics::NoSuchNick(c->name));
                        return CMD_FAILURE;
                }
 
@@ -55,7 +55,7 @@ CmdResult CommandTopic::HandleLocal(const std::vector<std::string>& parameters,
                }
                else
                {
-                       user->WriteNumeric(RPL_NOTOPICSET, "%s :No topic is set.", c->name.c_str());
+                       user->WriteNumeric(RPL_NOTOPICSET, c->name, "No topic is set.");
                }
                return CMD_SUCCESS;
        }
@@ -70,12 +70,12 @@ CmdResult CommandTopic::HandleLocal(const std::vector<std::string>& parameters,
        {
                if (!c->HasUser(user))
                {
-                       user->WriteNumeric(ERR_NOTONCHANNEL, "%s :You're not on that channel!", c->name.c_str());
+                       user->WriteNumeric(ERR_NOTONCHANNEL, c->name, "You're not on that channel!");
                        return CMD_FAILURE;
                }
                if (c->IsModeSet(topiclockmode) && !ServerInstance->OnCheckExemption(user, c, "topiclock").check(c->GetPrefixValue(user) >= HALFOP_VALUE))
                {
-                       user->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s :You do not have access to change the topic on this channel", c->name.c_str());
+                       user->WriteNumeric(ERR_CHANOPRIVSNEEDED, c->name, "You do not have access to change the topic on this channel");
                        return CMD_FAILURE;
                }
        }
@@ -86,6 +86,6 @@ CmdResult CommandTopic::HandleLocal(const std::vector<std::string>& parameters,
 
 void Topic::ShowTopic(LocalUser* user, Channel* chan)
 {
-       user->WriteNumeric(RPL_TOPIC, "%s :%s", chan->name.c_str(), chan->topic.c_str());
-       user->WriteNumeric(RPL_TOPICTIME, "%s %s %lu", chan->name.c_str(), chan->setby.c_str(), (unsigned long)chan->topicset);
+       user->WriteNumeric(RPL_TOPIC, chan->name, chan->topic);
+       user->WriteNumeric(RPL_TOPICTIME, chan->name, chan->setby, (unsigned long)chan->topicset);
 }
index 3ff6728d8b7d075aff6585f2d2e7c9b02fee9a41..e15d178f55a36702e53a403adde429ecb8d460a3 100644 (file)
@@ -48,6 +48,6 @@ CmdResult CommandCommands::Handle (const std::vector<std::string>&, User *user)
        std::sort(list.begin(), list.end());
        for(unsigned int i=0; i < list.size(); i++)
                user->Write(list[i]);
-       user->WriteNumeric(RPL_COMMANDSEND, ":End of COMMANDS list");
+       user->WriteNumeric(RPL_COMMANDSEND, "End of COMMANDS list");
        return CMD_SUCCESS;
 }
index eb3ab2c4e7670238a85395790aa69abba30fd753..9ec0108b13123ed675572ebf88debae05af44aa3 100644 (file)
@@ -30,7 +30,7 @@ CommandVersion::CommandVersion(Module* parent)
 CmdResult CommandVersion::Handle (const std::vector<std::string>&, User *user)
 {
        std::string version = ServerInstance->GetVersionString((user->IsOper()));
-       user->WriteNumeric(RPL_VERSION, ":%s", version.c_str());
+       user->WriteNumeric(RPL_VERSION, version);
        LocalUser *lu = IS_LOCAL(user);
        if (lu != NULL)
        {
index 278e6044d0e31fd2792d14a6ad89229849b0bbe6..67829a55edf472715d7075e5c592ede7c6f2612a 100644 (file)
@@ -53,7 +53,7 @@ CmdResult CommandList::Handle (const std::vector<std::string>& parameters, User
 {
        int minusers = 0, maxusers = 0;
 
-       user->WriteNumeric(RPL_LISTSTART, "Channel :Users Name");
+       user->WriteNumeric(RPL_LISTSTART, "Channel", "Users Name");
 
        /* Work around mIRC suckyness. YOU SUCK, KHALED! */
        if (parameters.size() == 1)
@@ -100,16 +100,16 @@ CmdResult CommandList::Handle (const std::vector<std::string>& parameters, User
                        if ((!n) && (chan->IsModeSet(privatemode)))
                        {
                                // Channel is private (+p) and user is outside/not privileged
-                               user->WriteNumeric(RPL_LIST, "* %ld :", users);
+                               user->WriteNumeric(RPL_LIST, '*', users, "");
                        }
                        else
                        {
                                /* User is in the channel/privileged, channel is not +s */
-                               user->WriteNumeric(RPL_LIST, "%s %ld :[+%s] %s", chan->name.c_str(), users, chan->ChanModes(n), chan->topic.c_str());
+                               user->WriteNumeric(RPL_LIST, chan->name, users, InspIRCd::Format("[+%s] %s", chan->ChanModes(n), chan->topic.c_str()));
                        }
                }
        }
-       user->WriteNumeric(RPL_LISTEND, ":End of channel list.");
+       user->WriteNumeric(RPL_LISTEND, "End of channel list.");
 
        return CMD_SUCCESS;
 }
index 1d49d89d0eb391386c9f640454de15765b34b910..09c0441988d9c70ce859431770db3ba53bb5b499 100644 (file)
@@ -43,12 +43,12 @@ CmdResult CommandLoadmodule::Handle (const std::vector<std::string>& parameters,
        if (ServerInstance->Modules->Load(parameters[0]))
        {
                ServerInstance->SNO->WriteGlobalSno('a', "NEW MODULE: %s loaded %s",user->nick.c_str(), parameters[0].c_str());
-               user->WriteNumeric(RPL_LOADEDMODULE, "%s :Module successfully loaded.", parameters[0].c_str());
+               user->WriteNumeric(RPL_LOADEDMODULE, parameters[0], "Module successfully loaded.");
                return CMD_SUCCESS;
        }
        else
        {
-               user->WriteNumeric(ERR_CANTLOADMODULE, "%s :%s", parameters[0].c_str(), ServerInstance->Modules->LastError().c_str());
+               user->WriteNumeric(ERR_CANTLOADMODULE, parameters[0], ServerInstance->Modules->LastError());
                return CMD_FAILURE;
        }
 }
@@ -80,26 +80,25 @@ CmdResult CommandUnloadmodule::Handle(const std::vector<std::string>& parameters
        if (!ServerInstance->Config->ConfValue("security")->getBool("allowcoreunload") &&
                InspIRCd::Match(parameters[0], "core_*.so", ascii_case_insensitive_map))
        {
-               user->WriteNumeric(ERR_CANTUNLOADMODULE, "%s :You cannot unload core commands!", parameters[0].c_str());
+               user->WriteNumeric(ERR_CANTUNLOADMODULE, parameters[0], "You cannot unload core commands!");
                return CMD_FAILURE;
        }
 
        Module* m = ServerInstance->Modules->Find(parameters[0]);
        if (m == creator)
        {
-               user->WriteNumeric(ERR_CANTUNLOADMODULE, "%s :You cannot unload module loading commands!", parameters[0].c_str());
+               user->WriteNumeric(ERR_CANTUNLOADMODULE, parameters[0], "You cannot unload module loading commands!");
                return CMD_FAILURE;
        }
 
        if (m && ServerInstance->Modules->Unload(m))
        {
                ServerInstance->SNO->WriteGlobalSno('a', "MODULE UNLOADED: %s unloaded %s", user->nick.c_str(), parameters[0].c_str());
-               user->WriteNumeric(RPL_UNLOADEDMODULE, "%s :Module successfully unloaded.", parameters[0].c_str());
+               user->WriteNumeric(RPL_UNLOADEDMODULE, parameters[0], "Module successfully unloaded.");
        }
        else
        {
-               user->WriteNumeric(ERR_CANTUNLOADMODULE, "%s :%s", parameters[0].c_str(),
-                       m ? ServerInstance->Modules->LastError().c_str() : "No such module");
+               user->WriteNumeric(ERR_CANTUNLOADMODULE, parameters[0], (m ? ServerInstance->Modules->LastError() : "No such module"));
                return CMD_FAILURE;
        }
 
index 2529ca42bd37fddc06aa2baeaebfbb358c863402..a0d0d0205ee26a310358e407978696da3cb8a690 100644 (file)
@@ -84,19 +84,19 @@ CmdResult CommandLusers::Handle (const std::vector<std::string>&, User *user)
 
        counters.UpdateMaxUsers();
 
-       user->WriteNumeric(RPL_LUSERCLIENT, ":There are %d users and %d invisible on %d servers",
-                       n_users - counters.invisible, counters.invisible, n_serv);
+       user->WriteNumeric(RPL_LUSERCLIENT, InspIRCd::Format("There are %d users and %d invisible on %d servers",
+                       n_users - counters.invisible, counters.invisible, n_serv));
 
        if (ServerInstance->Users->OperCount())
-               user->WriteNumeric(RPL_LUSEROP, "%d :operator(s) online", ServerInstance->Users->OperCount());
+               user->WriteNumeric(RPL_LUSEROP, ServerInstance->Users.OperCount(), "operator(s) online");
 
        if (ServerInstance->Users->UnregisteredUserCount())
-               user->WriteNumeric(RPL_LUSERUNKNOWN, "%d :unknown connections", ServerInstance->Users->UnregisteredUserCount());
+               user->WriteNumeric(RPL_LUSERUNKNOWN, ServerInstance->Users.UnregisteredUserCount(), "unknown connections");
 
-       user->WriteNumeric(RPL_LUSERCHANNELS, "%lu :channels formed", (unsigned long)ServerInstance->GetChans().size());
-       user->WriteNumeric(RPL_LUSERME, ":I have %d clients and %d servers", ServerInstance->Users->LocalUserCount(),n_local_servs);
-       user->WriteNumeric(RPL_LOCALUSERS, ":Current local users: %d  Max: %d", ServerInstance->Users->LocalUserCount(), counters.max_local);
-       user->WriteNumeric(RPL_GLOBALUSERS, ":Current global users: %d  Max: %d", n_users, counters.max_global);
+       user->WriteNumeric(RPL_LUSERCHANNELS, ServerInstance->GetChans().size(), "channels formed");
+       user->WriteNumeric(RPL_LUSERME, InspIRCd::Format("I have %d clients and %d servers", ServerInstance->Users.LocalUserCount(), n_local_servs));
+       user->WriteNumeric(RPL_LOCALUSERS, InspIRCd::Format("Current local users: %d  Max: %d", ServerInstance->Users.LocalUserCount(), counters.max_local));
+       user->WriteNumeric(RPL_GLOBALUSERS, InspIRCd::Format("Current global users: %d  Max: %d", n_users, counters.max_global));
 
        return CMD_SUCCESS;
 }
index 4a0cb2f28eb1cc380f9d4ee98aae65ab7fd19831..0d111ce02e911f5cd13a3758b547c39b4b6a3efb 100644 (file)
@@ -129,7 +129,7 @@ CmdResult CommandKill::Handle (const std::vector<std::string>& parameters, User
        }
        else
        {
-               user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", parameters[0].c_str());
+               user->WriteNumeric(Numerics::NoSuchNick(parameters[0]));
                return CMD_FAILURE;
        }
 
index e4ba69549e6f7a6ffb6adce0da1a754c8c15bd3d..9c06583a8a7f595481c3ab09204d00dcfcc8d499 100644 (file)
@@ -63,7 +63,7 @@ CmdResult CommandOper::HandleLocal(const std::vector<std::string>& parameters, L
                fields.append("hosts");
 
        // tell them they suck, and lag them up to help prevent brute-force attacks
-       user->WriteNumeric(ERR_NOOPERHOST, ":Invalid oper credentials");
+       user->WriteNumeric(ERR_NOOPERHOST, "Invalid oper credentials");
        user->CommandFloodPenalty += 10000;
 
        ServerInstance->SNO->WriteGlobalSno('o', "WARNING! Failed oper attempt by %s using login '%s': The following fields do not match: %s", user->GetFullRealHost().c_str(), parameters[0].c_str(), fields.c_str());
index 19d2fa8c20260657c5a05b7e5c68971a5d3d0686..5ce38eb2c39cd8e1f82867eaa0922dd37f481dfe 100644 (file)
@@ -68,7 +68,7 @@ CmdResult CommandRehash::Handle (const std::vector<std::string>& parameters, Use
                ServerInstance->SNO->WriteGlobalSno('a', m);
 
                if (IS_LOCAL(user))
-                       user->WriteNumeric(RPL_REHASHING, "%s :Rehashing", FileSystem::GetFileName(ServerInstance->ConfigFileName).c_str());
+                       user->WriteNumeric(RPL_REHASHING, FileSystem::GetFileName(ServerInstance->ConfigFileName), "Rehashing");
                else
                        ServerInstance->PI->SendUserNotice(user, "*** Rehashing server " + FileSystem::GetFileName(ServerInstance->ConfigFileName));
 
index d691464c0660eff89ab8883239908044cc41892d..cccba0850501f1ac6c7ba7138c570327d8237fd9 100644 (file)
@@ -130,13 +130,13 @@ CmdResult MessageCommandBase::HandleMessage(const std::vector<std::string>& para
                        {
                                if (chan->IsModeSet(noextmsgmode) && !chan->HasUser(user))
                                {
-                                       user->WriteNumeric(ERR_CANNOTSENDTOCHAN, "%s :Cannot send to channel (no external messages)", chan->name.c_str());
+                                       user->WriteNumeric(ERR_CANNOTSENDTOCHAN, chan->name, "Cannot send to channel (no external messages)");
                                        return CMD_FAILURE;
                                }
 
                                if (chan->IsModeSet(moderatedmode))
                                {
-                                       user->WriteNumeric(ERR_CANNOTSENDTOCHAN, "%s :Cannot send to channel (+m)", chan->name.c_str());
+                                       user->WriteNumeric(ERR_CANNOTSENDTOCHAN, chan->name, "Cannot send to channel (+m)");
                                        return CMD_FAILURE;
                                }
 
@@ -144,7 +144,7 @@ CmdResult MessageCommandBase::HandleMessage(const std::vector<std::string>& para
                                {
                                        if (chan->IsBanned(user))
                                        {
-                                               user->WriteNumeric(ERR_CANNOTSENDTOCHAN, "%s :Cannot send to channel (you're banned)", chan->name.c_str());
+                                               user->WriteNumeric(ERR_CANNOTSENDTOCHAN, chan->name, "Cannot send to channel (you're banned)");
                                                return CMD_FAILURE;
                                        }
                                }
@@ -161,7 +161,7 @@ CmdResult MessageCommandBase::HandleMessage(const std::vector<std::string>& para
                        /* Check again, a module may have zapped the input string */
                        if (temp.empty())
                        {
-                               user->WriteNumeric(ERR_NOTEXTTOSEND, ":No text to send");
+                               user->WriteNumeric(ERR_NOTEXTTOSEND, "No text to send");
                                return CMD_FAILURE;
                        }
 
@@ -181,7 +181,7 @@ CmdResult MessageCommandBase::HandleMessage(const std::vector<std::string>& para
                else
                {
                        /* no such nick/channel */
-                       user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", target);
+                       user->WriteNumeric(Numerics::NoSuchNick(target));
                        return CMD_FAILURE;
                }
                return CMD_SUCCESS;
@@ -202,7 +202,7 @@ CmdResult MessageCommandBase::HandleMessage(const std::vector<std::string>& para
                        if (dest && strcasecmp(dest->server->GetName().c_str(), targetserver + 1))
                        {
                                /* Incorrect server for user */
-                               user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", parameters[0].c_str());
+                               user->WriteNumeric(Numerics::NoSuchNick(parameters[0]));
                                return CMD_FAILURE;
                        }
                }
@@ -216,14 +216,14 @@ CmdResult MessageCommandBase::HandleMessage(const std::vector<std::string>& para
        {
                if (parameters[1].empty())
                {
-                       user->WriteNumeric(ERR_NOTEXTTOSEND, ":No text to send");
+                       user->WriteNumeric(ERR_NOTEXTTOSEND, "No text to send");
                        return CMD_FAILURE;
                }
 
                if ((dest->IsAway()) && (mt == MSG_PRIVMSG))
                {
                        /* auto respond with aweh msg */
-                       user->WriteNumeric(RPL_AWAY, "%s :%s", dest->nick.c_str(), dest->awaymsg.c_str());
+                       user->WriteNumeric(RPL_AWAY, dest->nick, dest->awaymsg);
                }
 
                ModResult MOD_RESULT;
@@ -248,7 +248,7 @@ CmdResult MessageCommandBase::HandleMessage(const std::vector<std::string>& para
        else
        {
                /* no such nick/channel */
-               user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", parameters[0].c_str());
+               user->WriteNumeric(Numerics::NoSuchNick(parameters[0]));
                return CMD_FAILURE;
        }
        return CMD_SUCCESS;
index 0d01d9e856519a44c7fb9bd5c7fab2cfc33545a9..6fcec8ac20cbb0a0f55c13c73d5913320ade5639 100644 (file)
@@ -601,7 +601,7 @@ class ReloadAction : public HandlerBase0<void>
                ServerInstance->SNO->WriteGlobalSno('a', "RELOAD MODULE: %s %ssuccessfully reloaded", passedname.c_str(), result ? "" : "un");
                User* user = ServerInstance->FindUUID(uuid);
                if (user)
-                       user->WriteNumeric(RPL_LOADEDMODULE, "%s :Module %ssuccessfully reloaded.", passedname.c_str(), result ? "" : "un");
+                       user->WriteNumeric(RPL_LOADEDMODULE, passedname, InspIRCd::Format("Module %ssuccessfully reloaded.", (result ? "" : "un")));
 
                ServerInstance->GlobalCulls.AddItem(this);
        }
@@ -612,8 +612,7 @@ CmdResult CommandReloadmodule::Handle (const std::vector<std::string>& parameter
        Module* m = ServerInstance->Modules->Find(parameters[0]);
        if (m == creator)
        {
-               user->WriteNumeric(RPL_LOADEDMODULE, "%s :You cannot reload core_reloadmodule.so (unload and load it)",
-                       parameters[0].c_str());
+               user->WriteNumeric(RPL_LOADEDMODULE, parameters[0], "You cannot reload core_reloadmodule.so (unload and load it)");
                return CMD_FAILURE;
        }
 
@@ -627,7 +626,7 @@ CmdResult CommandReloadmodule::Handle (const std::vector<std::string>& parameter
        }
        else
        {
-               user->WriteNumeric(RPL_LOADEDMODULE, "%s :Could not find module by that name", parameters[0].c_str());
+               user->WriteNumeric(RPL_LOADEDMODULE, parameters[0], "Could not find module by that name");
                return CMD_FAILURE;
        }
 }
index 20f6888b5c54af5967d3555637c09c476c4db329..91fc162419d4bb48dd892d686d4ca93d53a7c292 100644 (file)
@@ -70,8 +70,8 @@ class CommandLinks : public Command
         */
        CmdResult Handle(const std::vector<std::string>& parameters, User* user)
        {
-               user->WriteNumeric(RPL_LINKS, "%s %s :0 %s", ServerInstance->Config->ServerName.c_str(),ServerInstance->Config->ServerName.c_str(),ServerInstance->Config->ServerDesc.c_str());
-               user->WriteNumeric(RPL_ENDOFLINKS, "* :End of /LINKS list.");
+               user->WriteNumeric(RPL_LINKS, ServerInstance->Config->ServerName, ServerInstance->Config->ServerName, InspIRCd::Format("0 %s", ServerInstance->Config->ServerDesc.c_str()));
+               user->WriteNumeric(RPL_ENDOFLINKS, '*', "End of /LINKS list.");
                return CMD_SUCCESS;
        }
 };
@@ -98,11 +98,11 @@ class CommandServer : public Command
        {
                if (user->registered == REG_ALL)
                {
-                       user->WriteNumeric(ERR_ALREADYREGISTERED, ":You are already registered. (Perhaps your IRC client does not have a /SERVER command).");
+                       user->WriteNumeric(ERR_ALREADYREGISTERED, "You are already registered. (Perhaps your IRC client does not have a /SERVER command).");
                }
                else
                {
-                       user->WriteNumeric(ERR_NOTREGISTERED, "SERVER :You may not register as a server (servers have separate ports from clients, change your config)");
+                       user->WriteNumeric(ERR_NOTREGISTERED, "SERVER", "You may not register as a server (servers have separate ports from clients, change your config)");
                }
                return CMD_FAILURE;
        }
index adc6e6c18a17b59e46e483e00013edf7360888d7..fb720a5a7d61da7fcdf97a568e32da6fd6b1b1d2 100644 (file)
@@ -43,7 +43,7 @@ CmdResult CommandAway::Handle (const std::vector<std::string>& parameters, User
                user->awaytime = ServerInstance->Time();
                user->awaymsg.assign(parameters[0], 0, ServerInstance->Config->Limits.MaxAway);
 
-               user->WriteNumeric(RPL_NOWAWAY, ":You have been marked as being away");
+               user->WriteNumeric(RPL_NOWAWAY, "You have been marked as being away");
        }
        else
        {
@@ -53,7 +53,7 @@ CmdResult CommandAway::Handle (const std::vector<std::string>& parameters, User
                        return CMD_FAILURE;
 
                user->awaymsg.clear();
-               user->WriteNumeric(RPL_UNAWAY, ":You are no longer marked as being away");
+               user->WriteNumeric(RPL_UNAWAY, "You are no longer marked as being away");
        }
 
        return CMD_SUCCESS;
index a62bf51ca47f7647583a3857f169494e0032c01a..b1790bb89eb77d133b5cce795bf1c233fbcdfa5d 100644 (file)
@@ -45,7 +45,7 @@ CmdResult CommandMode::Handle(const std::vector<std::string>& parameters, User*
 
        if ((!targetchannel) && (!targetuser))
        {
-               user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", target.c_str());
+               user->WriteNumeric(Numerics::NoSuchNick(target));
                return CMD_FAILURE;
        }
        if (parameters.size() == 1)
@@ -70,7 +70,7 @@ CmdResult CommandMode::Handle(const std::vector<std::string>& parameters, User*
                        if ((targetuser) && (user != targetuser))
                        {
                                // Local users may only change the modes of other users if a module explicitly allows it
-                               user->WriteNumeric(ERR_USERSDONTMATCH, ":Can't change mode for other users");
+                               user->WriteNumeric(ERR_USERSDONTMATCH, "Can't change mode for other users");
                                return CMD_FAILURE;
                        }
 
@@ -135,8 +135,8 @@ void CommandMode::DisplayCurrentModes(User* user, User* targetuser, Channel* tar
        if (targetchannel)
        {
                // Display channel's current mode string
-               user->WriteNumeric(RPL_CHANNELMODEIS, "%s +%s", targetchannel->name.c_str(), targetchannel->ChanModes(targetchannel->HasUser(user)));
-               user->WriteNumeric(RPL_CHANNELCREATED, "%s %lu", targetchannel->name.c_str(), (unsigned long)targetchannel->age);
+               user->WriteNumeric(RPL_CHANNELMODEIS, targetchannel->name, (std::string("+") + targetchannel->ChanModes(targetchannel->HasUser(user))));
+               user->WriteNumeric(RPL_CHANNELCREATED, targetchannel->name, (unsigned long)targetchannel->age);
        }
        else
        {
@@ -157,7 +157,7 @@ void CommandMode::DisplayCurrentModes(User* user, User* targetuser, Channel* tar
                }
                else
                {
-                       user->WriteNumeric(ERR_USERSDONTMATCH, ":Can't view modes for other users");
+                       user->WriteNumeric(ERR_USERSDONTMATCH, "Can't view modes for other users");
                }
        }
 }
index a62e1c207ca87717b6d6fa1237e0e6effa9432e2..45e7adae59e229041da73d5a8e06b36f6bdcdc49 100644 (file)
@@ -47,7 +47,7 @@ CmdResult CommandNick::HandleLocal(const std::vector<std::string>& parameters, L
 
        if (newnick.empty())
        {
-               user->WriteNumeric(ERR_ERRONEUSNICKNAME, "* :Erroneous Nickname");
+               user->WriteNumeric(ERR_ERRONEUSNICKNAME, '*', "Erroneous Nickname");
                return CMD_FAILURE;
        }
 
@@ -57,7 +57,7 @@ CmdResult CommandNick::HandleLocal(const std::vector<std::string>& parameters, L
        }
        else if (!ServerInstance->IsNick(newnick))
        {
-               user->WriteNumeric(ERR_ERRONEUSNICKNAME, "%s :Erroneous Nickname", newnick.c_str());
+               user->WriteNumeric(ERR_ERRONEUSNICKNAME, newnick, "Erroneous Nickname");
                return CMD_FAILURE;
        }
 
@@ -77,7 +77,7 @@ CmdResult CommandNick::HandleLocal(const std::vector<std::string>& parameters, L
                        Channel* chan = (*i)->chan;
                        if (chan->GetPrefixValue(user) < VOICE_VALUE && chan->IsBanned(user))
                        {
-                               user->WriteNumeric(ERR_CANNOTSENDTOCHAN, "%s :Cannot send to channel (you're banned)", chan->name.c_str());
+                               user->WriteNumeric(ERR_CANNOTSENDTOCHAN, chan->name, "Cannot send to channel (you're banned)");
                                return CMD_FAILURE;
                        }
                }
index 77aafd1b37380c803975d455e28cba15e1829653..4da2787d902b13f4d958e1d65ab0d1c8d86bdd2e 100644 (file)
@@ -46,13 +46,13 @@ CmdResult CommandPart::Handle (const std::vector<std::string>& parameters, User
 
        if (!c)
        {
-               user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", parameters[0].c_str());
+               user->WriteNumeric(Numerics::NoSuchNick(parameters[0]));
                return CMD_FAILURE;
        }
 
        if (!c->PartUser(user, reason))
        {
-               user->WriteNumeric(ERR_NOTONCHANNEL, "%s :You're not on that channel", c->name.c_str());
+               user->WriteNumeric(ERR_NOTONCHANNEL, c->name, "You're not on that channel");
                return CMD_FAILURE;
        }
 
index cbf4f5e08b97ae1487561c28946d96304ca06ec2..37ac116df54280c8a660b28df13a0b061d4bd138 100644 (file)
@@ -40,7 +40,7 @@ CmdResult CommandUser::HandleLocal(const std::vector<std::string>& parameters, L
                         * RFC says we must use this numeric, so we do. Let's make it a little more nub friendly though. :)
                         *  -- Craig, and then w00t.
                         */
-                       user->WriteNumeric(ERR_NEEDMOREPARAMS, "USER :Your username is not valid");
+                       user->WriteNumeric(ERR_NEEDMOREPARAMS, name, "Your username is not valid");
                        return CMD_FAILURE;
                }
                else
@@ -57,7 +57,7 @@ CmdResult CommandUser::HandleLocal(const std::vector<std::string>& parameters, L
        }
        else
        {
-               user->WriteNumeric(ERR_ALREADYREGISTERED, ":You may not reregister");
+               user->WriteNumeric(ERR_ALREADYREGISTERED, "You may not reregister");
                user->CommandFloodPenalty += 1000;
                return CMD_FAILURE;
        }
index dd778548ab95514a37e87157c92756ff70b9e9e6..a2ffc009ebd9283b670a706329242800d53c7be3 100644 (file)
@@ -46,7 +46,7 @@ class CommandPass : public SplitCommand
                if (user->registered == REG_ALL)
                {
                        user->CommandFloodPenalty += 1000;
-                       user->WriteNumeric(ERR_ALREADYREGISTERED, ":You may not reregister");
+                       user->WriteNumeric(ERR_ALREADYREGISTERED, "You may not reregister");
                        return CMD_FAILURE;
                }
                user->password = parameters[0];
index 8b9258d71d374160f2bbb8a3e792a93697436ad6..1bc03c78e0cb3d038ec8defe271b34f320a5795c 100644 (file)
@@ -385,7 +385,7 @@ CmdResult CommandWho::Handle (const std::vector<std::string>& parameters, User *
        /* Send the results out */
        for (std::vector<std::string>::const_iterator n = whoresults.begin(); n != whoresults.end(); n++)
                user->WriteServ(*n);
-       user->WriteNumeric(RPL_ENDOFWHO, "%s :End of /WHO list.", *parameters[0].c_str() ? parameters[0].c_str() : "*");
+       user->WriteNumeric(RPL_ENDOFWHO, (*parameters[0].c_str() ? parameters[0] : "*"), "End of /WHO list.");
 
        // Penalize the user a bit for large queries
        // (add one unit of penalty per 200 results)
index ecc406a8cff8f52435d604de956a6b61071a2f99..0645eda4c0b8c999f90f8b4d5f0d868d8fe33498 100644 (file)
@@ -95,9 +95,9 @@ class WhoisNumericSink
        {
        }
 
-       void operator()(unsigned int numeric, const std::string& text) const
+       void operator()(Numeric::Numeric& numeric) const
        {
-               whois.SendLine(numeric, text);
+               whois.SendLine(numeric);
        }
 };
 
@@ -296,8 +296,8 @@ CmdResult CommandWhois::HandleLocal(const std::vector<std::string>& parameters,
        else
        {
                /* no such nick/channel */
-               user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", !parameters[userindex].empty() ? parameters[userindex].c_str() : "*");
-               user->WriteNumeric(RPL_ENDOFWHOIS, "%s :End of /WHOIS list.", !parameters[userindex].empty() ? parameters[userindex].c_str() : "*");
+               user->WriteNumeric(Numerics::NoSuchNick(!parameters[userindex].empty() ? parameters[userindex] : "*"));
+               user->WriteNumeric(RPL_ENDOFWHOIS, (!parameters[userindex].empty() ? parameters[userindex] : "*"), "End of /WHOIS list.");
                return CMD_FAILURE;
        }
 
index 79ce94cc9f8f8b3603816c2ec43d9976b698d1dc..e04a69200ac010a83ce679b0c9a877d88b1decca 100644 (file)
@@ -35,14 +35,14 @@ CmdResult CommandWhowas::Handle (const std::vector<std::string>& parameters, Use
        /* if whowas disabled in config */
        if (!manager.IsEnabled())
        {
-               user->WriteNumeric(ERR_UNKNOWNCOMMAND, "%s :This command has been disabled.", name.c_str());
+               user->WriteNumeric(ERR_UNKNOWNCOMMAND, name, "This command has been disabled.");
                return CMD_FAILURE;
        }
 
        const WhoWas::Nick* const nick = manager.FindNick(parameters[0]);
        if (!nick)
        {
-               user->WriteNumeric(ERR_WASNOSUCHNICK, "%s :There was no such nickname", parameters[0].c_str());
+               user->WriteNumeric(ERR_WASNOSUCHNICK, parameters[0], "There was no such nickname");
        }
        else
        {
@@ -51,18 +51,18 @@ CmdResult CommandWhowas::Handle (const std::vector<std::string>& parameters, Use
                {
                        WhoWas::Entry* u = *i;
 
-                       user->WriteNumeric(RPL_WHOWASUSER, "%s %s %s * :%s", parameters[0].c_str(), u->ident.c_str(),u->dhost.c_str(),u->gecos.c_str());
+                       user->WriteNumeric(RPL_WHOWASUSER, parameters[0], u->ident, u->dhost, '*', u->gecos);
 
                        if (user->HasPrivPermission("users/auspex"))
-                               user->WriteNumeric(RPL_WHOWASIP, "%s :was connecting from *@%s", parameters[0].c_str(), u->host.c_str());
+                               user->WriteNumeric(RPL_WHOWASIP, parameters[0], InspIRCd::Format("was connecting from *@%s", u->host.c_str()));
 
                        std::string signon = InspIRCd::TimeString(u->signon);
                        bool hide_server = (!ServerInstance->Config->HideWhoisServer.empty() && !user->HasPrivPermission("servers/auspex"));
-                       user->WriteNumeric(RPL_WHOISSERVER, "%s %s :%s", parameters[0].c_str(), (hide_server ? ServerInstance->Config->HideWhoisServer.c_str() : u->server.c_str()), signon.c_str());
+                       user->WriteNumeric(RPL_WHOISSERVER, parameters[0], (hide_server ? ServerInstance->Config->HideWhoisServer : u->server), signon);
                }
        }
 
-       user->WriteNumeric(RPL_ENDOFWHOWAS, "%s :End of WHOWAS", parameters[0].c_str());
+       user->WriteNumeric(RPL_ENDOFWHOWAS, parameters[0], "End of WHOWAS");
        return CMD_SUCCESS;
 }
 
index 7fa7da0197369fb412955489fb1e261473e11443..93ac1db311868040137f1a63269eb4daceb770cc 100644 (file)
@@ -80,7 +80,7 @@ class CoreModXLine : public Module
                }
 
                // Send a numeric because if we deny then the core doesn't reply anything
-               user->WriteNumeric(ERR_ERRONEUSNICKNAME, "%s :Invalid nickname: %s", newnick.c_str(), xline->reason.c_str());
+               user->WriteNumeric(ERR_ERRONEUSNICKNAME, newnick, InspIRCd::Format("Invalid nickname: %s", xline->reason.c_str()));
                return MOD_RES_DENY;
        }
 
index 35964dfb3396d9f893f78e63aa2d682d0c39e53d..cd034688c8ec2b6be81b8ce47f7c929d17fd7cc3 100644 (file)
@@ -35,15 +35,15 @@ void ListModeBase::DisplayList(User* user, Channel* channel)
        {
                for (ModeList::const_iterator it = cd->list.begin(); it != cd->list.end(); ++it)
                {
-                       user->WriteNumeric(listnumeric, "%s %s %s %lu", channel->name.c_str(), it->mask.c_str(), it->setter.c_str(), (unsigned long) it->time);
+                       user->WriteNumeric(listnumeric, channel->name, it->mask, it->setter, (unsigned long) it->time);
                }
        }
-       user->WriteNumeric(endoflistnumeric, "%s :%s", channel->name.c_str(), endofliststring.c_str());
+       user->WriteNumeric(endoflistnumeric, channel->name, endofliststring);
 }
 
 void ListModeBase::DisplayEmptyList(User* user, Channel* channel)
 {
-       user->WriteNumeric(endoflistnumeric, "%s :%s", channel->name.c_str(), endofliststring.c_str());
+       user->WriteNumeric(endoflistnumeric, channel->name, endofliststring);
 }
 
 void ListModeBase::RemoveMode(Channel* channel, Modes::ChangeList& changelist)
@@ -212,7 +212,7 @@ bool ListModeBase::ValidateParam(User*, Channel*, std::string&)
 
 void ListModeBase::TellListTooLong(User* source, Channel* channel, std::string& parameter)
 {
-       source->WriteNumeric(ERR_BANLISTFULL, "%s %s :Channel ban list is full", channel->name.c_str(), parameter.c_str());
+       source->WriteNumeric(ERR_BANLISTFULL, channel->name, parameter, "Channel ban list is full");
 }
 
 void ListModeBase::TellAlreadyOnList(User*, Channel*, std::string&)
index 6038f6f5b0a04771516ae3f90f922fd7c37d5fdd..b29eda828e197a01f5f9bb2a0a65f8c9c7c647ac 100644 (file)
@@ -175,7 +175,7 @@ ModeAction PrefixMode::OnModeChange(User* source, User*, Channel* chan, std::str
 
        if (!target)
        {
-               source->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", parameter.c_str());
+               source->WriteNumeric(Numerics::NoSuchNick(parameter));
                return MODEACTION_DENY;
        }
 
@@ -263,11 +263,10 @@ ModeAction ModeParser::TryMode(User* user, User* targetuser, Channel* chan, Mode
                                        }
                                }
                                if (neededmh)
-                                       user->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s :You must have channel %s access or above to %sset channel mode %c",
-                                               chan->name.c_str(), neededmh->name.c_str(), adding ? "" : "un", modechar);
+                                       user->WriteNumeric(ERR_CHANOPRIVSNEEDED, chan->name, InspIRCd::Format("You must have channel %s access or above to %sset channel mode %c",
+                                               neededmh->name.c_str(), adding ? "" : "un", modechar));
                                else
-                                       user->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s :You cannot %sset channel mode %c",
-                                               chan->name.c_str(), adding ? "" : "un", modechar);
+                                       user->WriteNumeric(ERR_CHANOPRIVSNEEDED, chan->name, InspIRCd::Format("You cannot %sset channel mode %c", (adding ? "" : "un"), modechar));
                                return MODEACTION_DENY;
                        }
                }
@@ -294,8 +293,8 @@ ModeAction ModeParser::TryMode(User* user, User* targetuser, Channel* chan, Mode
                char* disabled = (type == MODETYPE_CHANNEL) ? ServerInstance->Config->DisabledCModes : ServerInstance->Config->DisabledUModes;
                if (disabled[modechar - 'A'])
                {
-                       user->WriteNumeric(ERR_NOPRIVILEGES, ":Permission Denied - %s mode %c has been locked by the administrator",
-                               type == MODETYPE_CHANNEL ? "channel" : "user", modechar);
+                       user->WriteNumeric(ERR_NOPRIVILEGES, InspIRCd::Format("Permission Denied - %s mode %c has been locked by the administrator",
+                               type == MODETYPE_CHANNEL ? "channel" : "user", modechar));
                        return MODEACTION_DENY;
                }
        }
@@ -305,13 +304,13 @@ ModeAction ModeParser::TryMode(User* user, User* targetuser, Channel* chan, Mode
                /* It's an oper only mode, and they don't have access to it. */
                if (user->IsOper())
                {
-                       user->WriteNumeric(ERR_NOPRIVILEGES, ":Permission Denied - Oper type %s does not have access to set %s mode %c",
-                                       user->oper->name.c_str(), type == MODETYPE_CHANNEL ? "channel" : "user", modechar);
+                       user->WriteNumeric(ERR_NOPRIVILEGES, InspIRCd::Format("Permission Denied - Oper type %s does not have access to set %s mode %c",
+                                       user->oper->name.c_str(), type == MODETYPE_CHANNEL ? "channel" : "user", modechar));
                }
                else
                {
-                       user->WriteNumeric(ERR_NOPRIVILEGES, ":Permission Denied - Only operators may set %s mode %c",
-                                       type == MODETYPE_CHANNEL ? "channel" : "user", modechar);
+                       user->WriteNumeric(ERR_NOPRIVILEGES, InspIRCd::Format("Permission Denied - Only operators may set %s mode %c",
+                                       type == MODETYPE_CHANNEL ? "channel" : "user", modechar));
                }
                return MODEACTION_DENY;
        }
@@ -359,7 +358,7 @@ void ModeParser::ModeParamsToChangeList(User* user, ModeType type, const std::ve
                if (!mh)
                {
                        /* No mode handler? Unknown mode character then. */
-                       user->WriteNumeric(type == MODETYPE_CHANNEL ? ERR_UNKNOWNMODE : ERR_UNKNOWNSNOMASK, "%c :is unknown mode char to me", modechar);
+                       user->WriteNumeric(type == MODETYPE_CHANNEL ? ERR_UNKNOWNMODE : ERR_UNKNOWNSNOMASK, modechar, "is unknown mode char to me");
                        continue;
                }
 
index 08ee7f562486dc4190a9f6cf94867106402d8bf3..f0fa5e94bb784a8cd97db6da64f9dbfcd0809421 100644 (file)
@@ -99,7 +99,7 @@ std::string ModeUserServerNoticeMask::ProcessNoticeMasks(User* user, const std::
                                {
                                        if (!ServerInstance->SNO->IsSnomaskUsable(*i))
                                        {
-                                               user->WriteNumeric(ERR_UNKNOWNSNOMASK, "%c :is unknown snomask char to me", *i);
+                                               user->WriteNumeric(ERR_UNKNOWNSNOMASK, *i, "is unknown snomask char to me");
                                                continue;
                                        }
                                }
index 292986df500327b8ae4ed1584e14584a0ef2d5f9..28ded66d84dca6acc8e737404b0a13c2f9ff3971 100644 (file)
@@ -135,7 +135,7 @@ void                Module::OnGarbageCollect() { DetachEvent(I_OnGarbageCollect); }
 ModResult      Module::OnSetConnectClass(LocalUser* user, ConnectClass* myclass) { DetachEvent(I_OnSetConnectClass); return MOD_RES_PASSTHRU; }
 void           Module::OnText(User*, void*, int, const std::string&, char, CUList&) { DetachEvent(I_OnText); }
 ModResult      Module::OnNamesListItem(User*, Membership*, std::string&, std::string&) { DetachEvent(I_OnNamesListItem); return MOD_RES_PASSTHRU; }
-ModResult      Module::OnNumeric(User*, unsigned int, const std::string&) { DetachEvent(I_OnNumeric); return MOD_RES_PASSTHRU; }
+ModResult      Module::OnNumeric(User*, const Numeric::Numeric&) { DetachEvent(I_OnNumeric); return MOD_RES_PASSTHRU; }
 ModResult   Module::OnAcceptConnection(int, ListenSocket*, irc::sockets::sockaddrs*, irc::sockets::sockaddrs*) { DetachEvent(I_OnAcceptConnection); return MOD_RES_PASSTHRU; }
 void           Module::OnSendWhoLine(User*, const std::vector<std::string>&, User*, Membership*, std::string&) { DetachEvent(I_OnSendWhoLine); }
 void           Module::OnSetUserIP(LocalUser*) { DetachEvent(I_OnSetUserIP); }
index d2fa09c4ebad1106a5f37776c50c85a5832ea6e7..85709080f8e1436c43ae1957d0b11c4366a8aee6 100644 (file)
@@ -49,7 +49,7 @@ class ModuleAbbreviation : public Module
                        {
                                if (matchlist.length() > 450)
                                {
-                                       user->WriteNumeric(420, ":Ambiguous abbreviation and too many possible matches.");
+                                       user->WriteNumeric(420, "Ambiguous abbreviation and too many possible matches.");
                                        return MOD_RES_DENY;
                                }
 
@@ -67,7 +67,7 @@ class ModuleAbbreviation : public Module
                /* Ambiguous command, list the matches */
                if (!matchlist.empty())
                {
-                       user->WriteNumeric(420, ":Ambiguous abbreviation, possible matches: %s%s", foundcommand.c_str(), matchlist.c_str());
+                       user->WriteNumeric(420, InspIRCd::Format("Ambiguous abbreviation, possible matches: %s%s", foundcommand.c_str(), matchlist.c_str()));
                        return MOD_RES_DENY;
                }
 
index 3a4bf5348c2de554d0323aaa62615cebc80f010c..9184b10af407ba83af17366e94a9db83a317ccb3 100644 (file)
@@ -253,14 +253,14 @@ class ModuleAlias : public Module
                        User* u = ServerInstance->FindNick(a->RequiredNick);
                        if (!u)
                        {
-                               user->WriteNumeric(ERR_NOSUCHNICK, a->RequiredNick + " :is currently unavailable. Please try again later.");
+                               user->WriteNumeric(ERR_NOSUCHNICK, a->RequiredNick, "is currently unavailable. Please try again later.");
                                return 1;
                        }
 
                        if ((a->ULineOnly) && (!u->server->IsULine()))
                        {
                                ServerInstance->SNO->WriteToSnoMask('a', "NOTICE -- Service "+a->RequiredNick+" required by alias "+a->AliasedCommand+" is not on a u-lined server, possibly underhanded antics detected!");
-                               user->WriteNumeric(ERR_NOSUCHNICK, a->RequiredNick + " :is an imposter! Please inform an IRC operator as soon as possible.");
+                               user->WriteNumeric(ERR_NOSUCHNICK, a->RequiredNick, "is an imposter! Please inform an IRC operator as soon as possible.");
                                return 1;
                        }
                }
index 05e76113affb7fda59fe3f0311c57d5d85961299..6a4db18227def74a42c5c3c8b8f0e546acf2ed72 100644 (file)
@@ -47,7 +47,7 @@ class ModuleAllowInvite : public Module
                        if (res == MOD_RES_DENY)
                        {
                                // Matching extban, explicitly deny /invite
-                               user->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s :You are banned from using INVITE", channel->name.c_str());
+                               user->WriteNumeric(ERR_CHANOPRIVSNEEDED, channel->name, "You are banned from using INVITE");
                                return res;
                        }
                        if (channel->IsModeSet(ni) || res == MOD_RES_ALLOW)
index 2b9c2e1c21c28edfaf62adc6d3513a1ffa0ee08f..8c7f300daba11b60cbcbd85d79de719edf69e425 100644 (file)
@@ -52,8 +52,7 @@ class AutoOpList : public ListModeBase
 
                if (adding && !mh)
                {
-                       source->WriteNumeric(415, "%s :Cannot find prefix mode '%s' for autoop",
-                               mid.c_str(), mid.c_str());
+                       source->WriteNumeric(415, mid, InspIRCd::Format("Cannot find prefix mode '%s' for autoop", mid.c_str()));
                        return MOD_RES_DENY;
                }
                else if (!mh)
@@ -64,8 +63,7 @@ class AutoOpList : public ListModeBase
                        return MOD_RES_DENY;
                if (mh->GetLevelRequired() > mylevel)
                {
-                       source->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s :You must be able to set mode '%s' to include it in an autoop",
-                               channel->name.c_str(), mid.c_str());
+                       source->WriteNumeric(ERR_CHANOPRIVSNEEDED, channel->name, InspIRCd::Format("You must be able to set mode '%s' to include it in an autoop", mid.c_str()));
                        return MOD_RES_DENY;
                }
                return MOD_RES_PASSTHRU;
index d3490acc062aab9eeb569ff4d4ebf9c4fd791916..c44a10f05c35896f0543b63d8635b6fbb5768eaf 100644 (file)
@@ -82,7 +82,7 @@ class BanRedirect : public ModeWatcher
                        ListModeBase::ModeList* list = banlm->GetList(channel);
                        if ((list) && (adding) && (maxbans <= list->size()))
                        {
-                               source->WriteNumeric(ERR_BANLISTFULL, "%s :Channel ban list for %s is full (maximum entries for this channel is %u)", channel->name.c_str(), channel->name.c_str(), maxbans);
+                               source->WriteNumeric(ERR_BANLISTFULL, channel->name, InspIRCd::Format("Channel ban list for %s is full (maximum entries for this channel is %u)", channel->name.c_str(), maxbans));
                                return false;
                        }
 
@@ -150,25 +150,25 @@ class BanRedirect : public ModeWatcher
                                {
                                        if (!ServerInstance->IsChannel(mask[CHAN]))
                                        {
-                                               source->WriteNumeric(ERR_NOSUCHCHANNEL, "%s :Invalid channel name in redirection (%s)", channel->name.c_str(), mask[CHAN].c_str());
+                                               source->WriteNumeric(ERR_NOSUCHCHANNEL, channel->name, InspIRCd::Format("Invalid channel name in redirection (%s)", mask[CHAN].c_str()));
                                                return false;
                                        }
 
                                        Channel *c = ServerInstance->FindChan(mask[CHAN]);
                                        if (!c)
                                        {
-                                               source->WriteNumeric(690, ":Target channel %s must exist to be set as a redirect.", mask[CHAN].c_str());
+                                               source->WriteNumeric(690, InspIRCd::Format("Target channel %s must exist to be set as a redirect.", mask[CHAN].c_str()));
                                                return false;
                                        }
                                        else if (adding && c->GetPrefixValue(source) < OP_VALUE)
                                        {
-                                               source->WriteNumeric(690, ":You must be opped on %s to set it as a redirect.", mask[CHAN].c_str());
+                                               source->WriteNumeric(690, InspIRCd::Format("You must be opped on %s to set it as a redirect.", mask[CHAN].c_str()));
                                                return false;
                                        }
 
                                        if (assign(channel->name) == mask[CHAN])
                                        {
-                                               source->WriteNumeric(690, "%s :You cannot set a ban redirection to the channel the ban is on", channel->name.c_str());
+                                               source->WriteNumeric(690, channel->name, "You cannot set a ban redirection to the channel the ban is on");
                                                return false;
                                        }
                                }
@@ -311,13 +311,13 @@ class ModuleBanRedirect : public Module
 
                                                if(destchan && destchan->IsModeSet(redirectmode) && !destlimit.empty() && (destchan->GetUserCounter() >= atoi(destlimit.c_str())))
                                                {
-                                                       user->WriteNumeric(ERR_BANNEDFROMCHAN, "%s :Cannot join channel (You are banned)", chan->name.c_str());
+                                                       user->WriteNumeric(ERR_BANNEDFROMCHAN, chan->name, "Cannot join channel (You are banned)");
                                                        return MOD_RES_DENY;
                                                }
                                                else
                                                {
-                                                       user->WriteNumeric(ERR_BANNEDFROMCHAN, "%s :Cannot join channel (You are banned)", chan->name.c_str());
-                                                       user->WriteNumeric(470, "%s %s :You are banned from this channel, so you are automatically transferred to the redirected channel.", chan->name.c_str(), redir->targetchan.c_str());
+                                                       user->WriteNumeric(ERR_BANNEDFROMCHAN, chan->name, "Cannot join channel (You are banned)");
+                                                       user->WriteNumeric(470, chan->name, redir->targetchan, "You are banned from this channel, so you are automatically transferred to the redirected channel.");
                                                        nofollow = true;
                                                        Channel::JoinUser(user, redir->targetchan);
                                                        nofollow = false;
index 57f86afd125b1f30e208b9f1fbc8086ed41d18f1..cd7698d69564d2104650e8710d701798d8c20ef2 100644 (file)
@@ -74,7 +74,7 @@ public:
 
                                if (((caps * 100) / text.length()) >= percent)
                                {
-                                       user->WriteNumeric(ERR_CANNOTSENDTOCHAN, "%s :Your message cannot contain %d%% or more capital letters if it's longer than %d characters", c->name.c_str(), percent, minlen);
+                                       user->WriteNumeric(ERR_CANNOTSENDTOCHAN, c->name, InspIRCd::Format("Your message cannot contain %d%% or more capital letters if it's longer than %d characters", percent, minlen));
                                        return MOD_RES_DENY;
                                }
                        }
index a08ad7c6f0dabca419445a767703489070824139..567bdb24951e961f1ee304a9062ed6706faace86 100644 (file)
@@ -67,7 +67,7 @@ class ModuleBlockColor : public Module
                                                case 21:
                                                case 22:
                                                case 31:
-                                                       user->WriteNumeric(ERR_CANNOTSENDTOCHAN, "%s :Can't send colors to channel (+c set)", c->name.c_str());
+                                                       user->WriteNumeric(ERR_CANNOTSENDTOCHAN, c->name, "Can't send colors to channel (+c set)");
                                                        return MOD_RES_DENY;
                                                break;
                                        }
index 0eb208138276a6b7d4ee3673b2d3af18d4b3b776..149767f1821cd58ebff5a72b20ceb0828c787d60 100644 (file)
@@ -225,7 +225,7 @@ public:
                ACCEPTAction action = GetTargetAndAction(tok, user);
                if (!action.first)
                {
-                       user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", tok.c_str());
+                       user->WriteNumeric(Numerics::NoSuchNick(tok));
                        return CMD_FAILURE;
                }
 
@@ -271,7 +271,7 @@ public:
                        for (callerid_data::UserSet::iterator i = dat->accepting.begin(); i != dat->accepting.end(); ++i)
                                user->WriteNumeric(RPL_ACCEPTLIST, (*i)->nick);
                }
-               user->WriteNumeric(RPL_ENDOFACCEPT, ":End of ACCEPT list");
+               user->WriteNumeric(RPL_ENDOFACCEPT, "End of ACCEPT list");
        }
 
        bool AddAccept(User* user, User* whotoadd)
@@ -280,12 +280,12 @@ public:
                callerid_data* dat = extInfo.get(user, true);
                if (dat->accepting.size() >= maxaccepts)
                {
-                       user->WriteNumeric(ERR_ACCEPTFULL, ":Accept list is full (limit is %d)", maxaccepts);
+                       user->WriteNumeric(ERR_ACCEPTFULL, InspIRCd::Format("Accept list is full (limit is %d)", maxaccepts));
                        return false;
                }
                if (!dat->accepting.insert(whotoadd).second)
                {
-                       user->WriteNumeric(ERR_ACCEPTEXIST, "%s :is already on your accept list", whotoadd->nick.c_str());
+                       user->WriteNumeric(ERR_ACCEPTEXIST, whotoadd->nick, "is already on your accept list");
                        return false;
                }
 
@@ -303,12 +303,12 @@ public:
                callerid_data* dat = extInfo.get(user, false);
                if (!dat)
                {
-                       user->WriteNumeric(ERR_ACCEPTNOT, "%s :is not on your accept list", whotoremove->nick.c_str());
+                       user->WriteNumeric(ERR_ACCEPTNOT, whotoremove->nick, "is not on your accept list");
                        return false;
                }
                if (!dat->accepting.erase(whotoremove))
                {
-                       user->WriteNumeric(ERR_ACCEPTNOT, "%s :is not on your accept list", whotoremove->nick.c_str());
+                       user->WriteNumeric(ERR_ACCEPTNOT, whotoremove->nick, "is not on your accept list");
                        return false;
                }
 
@@ -395,10 +395,10 @@ public:
                {
                        time_t now = ServerInstance->Time();
                        /* +g and *not* accepted */
-                       user->WriteNumeric(ERR_TARGUMODEG, "%s :is in +g mode (server-side ignore).", dest->nick.c_str());
+                       user->WriteNumeric(ERR_TARGUMODEG, dest->nick, "is in +g mode (server-side ignore).");
                        if (now > (dat->lastnotify + (time_t)notify_cooldown))
                        {
-                               user->WriteNumeric(RPL_TARGNOTIFY, "%s :has been informed that you messaged them.", dest->nick.c_str());
+                               user->WriteNumeric(RPL_TARGNOTIFY, dest->nick, "has been informed that you messaged them.");
                                dest->SendText(":%s %03d %s %s %s@%s :is messaging you, and you have umode +g. Use /ACCEPT +%s to allow.",
                                                ServerInstance->Config->ServerName.c_str(), RPL_UMODEGMSG, dest->nick.c_str(), user->nick.c_str(), user->ident.c_str(), user->dhost.c_str(), user->nick.c_str());
                                dat->lastnotify = now;
index 09d5e604dd12c3e617c3b88a9b799f503a4cdabb..e6e01570d83153a0aff3410041f9cca2a1a82260 100644 (file)
@@ -398,7 +398,7 @@ class CommandCap : public SplitCommand
                }
                else
                {
-                       user->WriteNumeric(ERR_INVALIDCAPSUBCOMMAND, "%s :Invalid CAP subcommand", subcommand.c_str());
+                       user->WriteNumeric(ERR_INVALIDCAPSUBCOMMAND, subcommand, "Invalid CAP subcommand");
                        return CMD_FAILURE;
                }
 
index 4fb0653a91b1014e6da68ff377f9d17dfa5947df..1ddc625db5fd69c96a3ad4dd92d8c2d1d58934d9 100644 (file)
@@ -181,7 +181,7 @@ class ModuleCBan : public Module
                if (rl)
                {
                        // Channel is banned.
-                       user->WriteNumeric(384, "%s :Cannot join channel, CBANed (%s)", cname.c_str(), rl->reason.c_str());
+                       user->WriteNumeric(384, cname, InspIRCd::Format("Cannot join channel, CBANed (%s)", rl->reason.c_str()));
                        ServerInstance->SNO->WriteGlobalSno('a', "%s tried to join %s which is CBANed (%s)",
                                 user->nick.c_str(), cname.c_str(), rl->reason.c_str());
                        return MOD_RES_DENY;
index da22b5153627745b2e44824406610123ca9df013..7d8c74024a8f0b5a5a877d6dcdabdbef0b0bb871 100644 (file)
@@ -79,7 +79,7 @@ class ModuleCensor : public Module
                        {
                                if (index->second.empty())
                                {
-                                       user->WriteNumeric(ERR_WORDFILTERED, "%s %s :Your message contained a censored word, and was blocked", ((Channel*)dest)->name.c_str(), index->first.c_str());
+                                       user->WriteNumeric(ERR_WORDFILTERED, ((Channel*)dest)->name, index->first, "Your message contained a censored word, and was blocked");
                                        return MOD_RES_DENY;
                                }
 
index 53428a5a871af08f19274155a4a7ebb31ba810bb..a7bc215570c221e54e6419ff2a623d55b8d99c33 100644 (file)
@@ -37,7 +37,7 @@ class ChanFilter : public ListModeBase
        {
                if (word.length() > 35)
                {
-                       user->WriteNumeric(935, "%s %s :word is too long for censor list", chan->name.c_str(), word.c_str());
+                       user->WriteNumeric(935, chan->name, word, "%word is too long for censor list");
                        return false;
                }
 
@@ -46,17 +46,17 @@ class ChanFilter : public ListModeBase
 
        void TellListTooLong(User* user, Channel* chan, std::string &word)
        {
-               user->WriteNumeric(939, "%s %s :Channel spamfilter list is full", chan->name.c_str(), word.c_str());
+               user->WriteNumeric(939, chan->name, word, "Channel spamfilter list is full");
        }
 
        void TellAlreadyOnList(User* user, Channel* chan, std::string &word)
        {
-               user->WriteNumeric(937, "%s :The word %s is already on the spamfilter list", chan->name.c_str(), word.c_str());
+               user->WriteNumeric(937, chan->name, InspIRCd::Format("The word %s is already on the spamfilter list", word.c_str()));
        }
 
        void TellNotSet(User* user, Channel* chan, std::string &word)
        {
-               user->WriteNumeric(938, "%s :No such spamfilter word is set", chan->name.c_str());
+               user->WriteNumeric(938, chan->name, "No such spamfilter word is set");
        }
 };
 
@@ -98,9 +98,9 @@ class ModuleChanFilter : public Module
                                if (InspIRCd::Match(text, i->mask))
                                {
                                        if (hidemask)
-                                               user->WriteNumeric(ERR_CANNOTSENDTOCHAN, "%s :Cannot send to channel (your message contained a censored word)", chan->name.c_str());
+                                               user->WriteNumeric(ERR_CANNOTSENDTOCHAN, chan->name, "Cannot send to channel (your message contained a censored word)");
                                        else
-                                               user->WriteNumeric(ERR_CANNOTSENDTOCHAN, "%s %s :Cannot send to channel (your message contained a censored word)", chan->name.c_str(), i->mask.c_str());
+                                               user->WriteNumeric(ERR_CANNOTSENDTOCHAN, chan->name, i->mask, "Cannot send to channel (your message contained a censored word)");
                                        return MOD_RES_DENY;
                                }
                        }
index 43b2a323ba4fb84478d2e8c65de77a11f6052852..163f1f2ebf45abc60cea315a1ad32e2d751d9c91 100644 (file)
@@ -59,7 +59,7 @@ class CommandChghost : public Command
                // Allow services to change the host of unregistered users
                if ((!dest) || ((dest->registered != REG_ALL) && (!user->server->IsULine())))
                {
-                       user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", parameters[0].c_str());
+                       user->WriteNumeric(Numerics::NoSuchNick(parameters[0]));
                        return CMD_FAILURE;
                }
 
index c855216bfd4d91028e4df35e3134a2e9012bdded..0b4e78f127628362424e596f7df08082a34faf0a 100644 (file)
@@ -41,7 +41,7 @@ class CommandChgident : public Command
 
                if ((!dest) || (dest->registered != REG_ALL))
                {
-                       user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", parameters[0].c_str());
+                       user->WriteNumeric(Numerics::NoSuchNick(parameters[0]));
                        return CMD_FAILURE;
                }
 
index 830d5070b60c1b47ed50bfd0ac2031026663ce39..3ad9cede918b916084c1f076873fa128ace82855 100644 (file)
@@ -39,7 +39,7 @@ class CommandChgname : public Command
 
                if ((!dest) || (dest->registered != REG_ALL))
                {
-                       user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", parameters[0].c_str());
+                       user->WriteNumeric(Numerics::NoSuchNick(parameters[0]));
                        return CMD_FAILURE;
                }
 
index eab53b9bc92573a973e15bcbcc71be69d680cb3b..e04217e71f16d42ff45bb74bee97f78b4d0713d1 100644 (file)
@@ -47,7 +47,7 @@ class ModulePrivacyMode : public Module
                        User* t = (User*)dest;
                        if (!user->IsOper() && (t->IsModeSet(pm)) && (!user->server->IsULine()) && !user->SharesChannelWith(t))
                        {
-                               user->WriteNumeric(ERR_CANTSENDTOUSER, "%s :You are not permitted to send private messages to this user (+c set)", t->nick.c_str());
+                               user->WriteNumeric(ERR_CANTSENDTOUSER, t->nick, "You are not permitted to send private messages to this user (+c set)");
                                return MOD_RES_DENY;
                        }
                }
index c8b6bd8b4b82ec923e433c602a313da3ffa7d812..202cb123ffbff6aa1de368e5c0ecf5d8a6baab68 100644 (file)
@@ -44,7 +44,7 @@ class CommandCycle : public SplitCommand
 
                if (!channel)
                {
-                       user->WriteNumeric(ERR_NOSUCHCHANNEL, "%s :No such channel", parameters[0].c_str());
+                       user->WriteNumeric(ERR_NOSUCHCHANNEL, parameters[0], "No such channel");
                        return CMD_FAILURE;
                }
 
@@ -64,7 +64,7 @@ class CommandCycle : public SplitCommand
                }
                else
                {
-                       user->WriteNumeric(ERR_NOTONCHANNEL, "%s :You're not on that channel", channel->name.c_str());
+                       user->WriteNumeric(ERR_NOTONCHANNEL, channel->name, "You're not on that channel");
                }
 
                return CMD_FAILURE;
index 45a2304651bf29e4ecb45fc08c60a7d899b3d272..21cc97aa5156198e1073d8c2b828405b87ffb67c 100644 (file)
@@ -120,7 +120,7 @@ class CommandDccallow : public Command
                                }
                                else
                                {
-                                       user->WriteNumeric(998, ":DCCALLOW command not understood. For help on DCCALLOW, type /DCCALLOW HELP");
+                                       user->WriteNumeric(998, "DCCALLOW command not understood. For help on DCCALLOW, type /DCCALLOW HELP");
                                        return CMD_FAILURE;
                                }
                        }
@@ -143,7 +143,7 @@ class CommandDccallow : public Command
                                                        if (i->nickname == target->nick)
                                                        {
                                                                dl->erase(i);
-                                                               user->WriteNumeric(995, "%s :Removed %s from your DCCALLOW list", user->nick.c_str(), target->nick.c_str());
+                                                               user->WriteNumeric(995, user->nick, InspIRCd::Format("Removed %s from your DCCALLOW list", target->nick.c_str()));
                                                                break;
                                                        }
                                                }
@@ -153,7 +153,7 @@ class CommandDccallow : public Command
                                {
                                        if (target == user)
                                        {
-                                               user->WriteNumeric(996, "%s :You cannot add yourself to your own DCCALLOW list!", user->nick.c_str());
+                                               user->WriteNumeric(996, user->nick, "You cannot add yourself to your own DCCALLOW list!");
                                                return CMD_FAILURE;
                                        }
 
@@ -168,7 +168,7 @@ class CommandDccallow : public Command
 
                                        if (dl->size() >= maxentries)
                                        {
-                                               user->WriteNumeric(996, "%s :Too many nicks on DCCALLOW list", user->nick.c_str());
+                                               user->WriteNumeric(996, user->nick, "Too many nicks on DCCALLOW list");
                                                return CMD_FAILURE;
                                        }
 
@@ -176,7 +176,7 @@ class CommandDccallow : public Command
                                        {
                                                if (k->nickname == target->nick)
                                                {
-                                                       user->WriteNumeric(996, "%s :%s is already on your DCCALLOW list", user->nick.c_str(), target->nick.c_str());
+                                                       user->WriteNumeric(996, user->nick, InspIRCd::Format("%s is already on your DCCALLOW list", target->nick.c_str()));
                                                        return CMD_FAILURE;
                                                }
                                        }
@@ -207,11 +207,11 @@ class CommandDccallow : public Command
 
                                        if (length > 0)
                                        {
-                                               user->WriteNumeric(993, "%s :Added %s to DCCALLOW list for %ld seconds", user->nick.c_str(), target->nick.c_str(), length);
+                                               user->WriteNumeric(993, user->nick, InspIRCd::Format("Added %s to DCCALLOW list for %ld seconds", target->nick.c_str(), length));
                                        }
                                        else
                                        {
-                                               user->WriteNumeric(994, "%s :Added %s to DCCALLOW list for this session", user->nick.c_str(), target->nick.c_str());
+                                               user->WriteNumeric(994, user->nick, InspIRCd::Format("Added %s to DCCALLOW list for this session", target->nick.c_str()));
                                        }
 
                                        /* route it. */
@@ -221,7 +221,7 @@ class CommandDccallow : public Command
                        else
                        {
                                // nick doesn't exist
-                               user->WriteNumeric(401, "%s :No such nick/channel", nick.c_str());
+                               user->WriteNumeric(Numerics::NoSuchNick(nick));
                                return CMD_FAILURE;
                        }
                }
@@ -236,8 +236,8 @@ class CommandDccallow : public Command
        void DisplayHelp(User* user)
        {
                for (size_t i = 0; i < sizeof(helptext)/sizeof(helptext[0]); i++)
-                       user->WriteNumeric(998, ":%s", helptext[i]);
-               user->WriteNumeric(999, ":End of DCCALLOW HELP");
+                       user->WriteNumeric(998, helptext[i]);
+               user->WriteNumeric(999, "End of DCCALLOW HELP");
 
                LocalUser* localuser = IS_LOCAL(user);
                if (localuser)
@@ -247,18 +247,18 @@ class CommandDccallow : public Command
        void DisplayDCCAllowList(User* user)
        {
                 // display current DCCALLOW list
-               user->WriteNumeric(990, ":Users on your DCCALLOW list:");
+               user->WriteNumeric(990, "Users on your DCCALLOW list:");
 
                dl = ext.get(user);
                if (dl)
                {
                        for (dccallowlist::const_iterator c = dl->begin(); c != dl->end(); ++c)
                        {
-                               user->WriteNumeric(991, "%s :%s (%s)", user->nick.c_str(), c->nickname.c_str(), c->hostmask.c_str());
+                               user->WriteNumeric(991, user->nick, InspIRCd::Format("%s (%s)", c->nickname.c_str(), c->hostmask.c_str()));
                        }
                }
 
-               user->WriteNumeric(992, ":End of DCCALLOW list");
+               user->WriteNumeric(992, "End of DCCALLOW list");
        }
 
 };
@@ -400,7 +400,7 @@ class ModuleDCCAllow : public Module
                                        {
                                                if (iter2->length != 0 && (iter2->set_on + iter2->length) <= ServerInstance->Time())
                                                {
-                                                       u->WriteNumeric(997, "%s :DCCALLOW entry for %s has expired", u->nick.c_str(), iter2->nickname.c_str());
+                                                       u->WriteNumeric(997, u->nick, InspIRCd::Format("DCCALLOW entry for %s has expired", iter2->nickname.c_str()));
                                                        iter2 = dl->erase(iter2);
                                                }
                                                else
@@ -435,7 +435,7 @@ class ModuleDCCAllow : public Module
                                                {
 
                                                        u->WriteNotice(i->nickname + " left the network or changed their nickname and has been removed from your DCCALLOW list");
-                                                       u->WriteNumeric(995, "%s :Removed %s from your DCCALLOW list", u->nick.c_str(), i->nickname.c_str());
+                                                       u->WriteNumeric(995, u->nick, InspIRCd::Format("Removed %s from your DCCALLOW list", i->nickname.c_str()));
                                                        dl->erase(i);
                                                        break;
                                                }
index f64297e15b8c678ce29d0969b8583400175e2ebf..1ad41cc57f23395199da3d5efe184b4ba5aca30f 100644 (file)
@@ -118,8 +118,7 @@ ModResult ModuleDelayMsg::OnUserPreMessage(User* user, void* dest, int target_ty
        {
                if (channel->GetPrefixValue(user) < VOICE_VALUE)
                {
-                       user->WriteNumeric(ERR_CANNOTSENDTOCHAN, "%s :You must wait %d seconds after joining to send to channel (+d)",
-                               channel->name.c_str(), len);
+                       user->WriteNumeric(ERR_CANNOTSENDTOCHAN, channel->name, InspIRCd::Format("You must wait %d seconds after joining to send to channel (+d)", len));
                        return MOD_RES_DENY;
                }
        }
index 6378ba2733c75b0f2aa23e283d31ec0896fd3a44..467c8a03b3dfe6f0c02a2ea18506cdc00949c941 100644 (file)
@@ -113,13 +113,13 @@ class ModuleDenyChannels : public Module
                                                Channel *newchan = ServerInstance->FindChan(redirect);
                                                if ((!newchan) || (!newchan->IsModeSet(redirectmode)))
                                                {
-                                                       user->WriteNumeric(926, "%s :Channel %s is forbidden, redirecting to %s: %s", cname.c_str(),cname.c_str(),redirect.c_str(), reason.c_str());
+                                                       user->WriteNumeric(926, cname, InspIRCd::Format("Channel %s is forbidden, redirecting to %s: %s", cname.c_str(), redirect.c_str(), reason.c_str()));
                                                        Channel::JoinUser(user, redirect);
                                                        return MOD_RES_DENY;
                                                }
                                        }
 
-                                       user->WriteNumeric(926, "%s :Channel %s is forbidden: %s", cname.c_str(),cname.c_str(),reason.c_str());
+                                       user->WriteNumeric(926, cname, InspIRCd::Format("Channel %s is forbidden: %s", cname.c_str(), reason.c_str()));
                                        return MOD_RES_DENY;
                                }
                        }
index 5eaa8c279abce71526b1ff611930d2e89f503163..726ee13510d08c6eeb08de0f69954667f7f74736 100644 (file)
@@ -117,13 +117,13 @@ class DNSBLResolver : public DNS::Request
                                {
                                        if (!ConfEntry->ident.empty())
                                        {
-                                               them->WriteNumeric(304, ":Your ident has been set to " + ConfEntry->ident + " because you matched " + reason);
+                                               them->WriteNumeric(304, "Your ident has been set to " + ConfEntry->ident + " because you matched " + reason);
                                                them->ChangeIdent(ConfEntry->ident);
                                        }
 
                                        if (!ConfEntry->host.empty())
                                        {
-                                               them->WriteNumeric(304, ":Your host has been set to " + ConfEntry->host + " because you matched " + reason);
+                                               them->WriteNumeric(304, "Your host has been set to " + ConfEntry->host + " because you matched " + reason);
                                                them->ChangeDisplayedHost(ConfEntry->host);
                                        }
 
index 076445644ba2bfa84644d94eadff7b170a3ea5ed..2884385fb6cec18b068640277791e928b56ee31c 100644 (file)
@@ -32,7 +32,7 @@ class ExemptChanOps : public ListModeBase
                std::string::size_type p = word.find(':');
                if (p == std::string::npos)
                {
-                       user->WriteNumeric(955, "%s %s :Invalid exemptchanops entry, format is <restriction>:<prefix>", chan->name.c_str(), word.c_str());
+                       user->WriteNumeric(955, chan->name, word, "Invalid exemptchanops entry, format is <restriction>:<prefix>");
                        return false;
                }
 
@@ -45,7 +45,7 @@ class ExemptChanOps : public ListModeBase
 
                if (!ServerInstance->Modes->FindMode(restriction, MODETYPE_CHANNEL))
                {
-                       user->WriteNumeric(955, "%s %s :Unknown restriction", chan->name.c_str(), restriction.c_str());
+                       user->WriteNumeric(955, chan->name, restriction, "Unknown restriction");
                        return false;
                }
 
@@ -54,17 +54,17 @@ class ExemptChanOps : public ListModeBase
 
        void TellListTooLong(User* user, Channel* chan, std::string &word)
        {
-               user->WriteNumeric(959, "%s %s :Channel exemptchanops list is full", chan->name.c_str(), word.c_str());
+               user->WriteNumeric(959, chan->name, word, "Channel exemptchanops list is full");
        }
 
        void TellAlreadyOnList(User* user, Channel* chan, std::string &word)
        {
-               user->WriteNumeric(957, "%s :The word %s is already on the exemptchanops list", chan->name.c_str(), word.c_str());
+               user->WriteNumeric(957, chan->name, InspIRCd::Format("The word %s is already on the exemptchanops list", word.c_str()));
        }
 
        void TellNotSet(User* user, Channel* chan, std::string &word)
        {
-               user->WriteNumeric(958, "%s :No such exemptchanops word is set", chan->name.c_str());
+               user->WriteNumeric(958, chan->name, "No such exemptchanops word is set");
        }
 };
 
index 34d0bebb3cce91d865a14cde6f912b69ee4175b6..bd1022a0824a291340dd53cb36820c62095d589c 100644 (file)
@@ -343,14 +343,14 @@ ModResult ModuleFilter::OnUserPreMessage(User* user, void* dest, int target_type
                {
                        ServerInstance->SNO->WriteGlobalSno('a', "FILTER: "+user->nick+" had their message filtered, target was "+target+": "+f->reason);
                        if (target_type == TYPE_CHANNEL)
-                               user->WriteNumeric(ERR_CANNOTSENDTOCHAN, "%s :Message to channel blocked and opers notified (%s)", target.c_str(), f->reason.c_str());
+                               user->WriteNumeric(ERR_CANNOTSENDTOCHAN, target, InspIRCd::Format("Message to channel blocked and opers notified (%s)", f->reason.c_str()));
                        else
                                user->WriteNotice("Your message to "+target+" was blocked and opers notified: "+f->reason);
                }
                else if (f->action == FA_SILENT)
                {
                        if (target_type == TYPE_CHANNEL)
-                               user->WriteNumeric(ERR_CANNOTSENDTOCHAN, "%s :Message to channel blocked (%s)", target.c_str(), f->reason.c_str());
+                               user->WriteNumeric(ERR_CANNOTSENDTOCHAN, target, InspIRCd::Format("Message to channel blocked (%s)", f->reason.c_str()));
                        else
                                user->WriteNotice("Your message to "+target+" was blocked: "+f->reason);
                }
index 294187fa5c81bea51b6b8d775c0c72fa374861ac..2355cc979644005cf251a82c23aa8c77cb68a62e 100644 (file)
@@ -44,11 +44,11 @@ class CommandGloadmodule : public Command
                        if (ServerInstance->Modules->Load(parameters[0].c_str()))
                        {
                                ServerInstance->SNO->WriteToSnoMask('a', "NEW MODULE '%s' GLOBALLY LOADED BY '%s'",parameters[0].c_str(), user->nick.c_str());
-                               user->WriteNumeric(RPL_LOADEDMODULE, "%s :Module successfully loaded.", parameters[0].c_str());
+                               user->WriteNumeric(RPL_LOADEDMODULE, parameters[0], "Module successfully loaded.");
                        }
                        else
                        {
-                               user->WriteNumeric(ERR_CANTLOADMODULE, "%s :%s", parameters[0].c_str(), ServerInstance->Modules->LastError().c_str());
+                               user->WriteNumeric(ERR_CANTLOADMODULE, parameters[0], ServerInstance->Modules->LastError());
                        }
                }
                else
@@ -79,7 +79,7 @@ class CommandGunloadmodule : public Command
                if (!ServerInstance->Config->ConfValue("security")->getBool("allowcoreunload") &&
                        InspIRCd::Match(parameters[0], "core_*.so", ascii_case_insensitive_map))
                {
-                       user->WriteNumeric(ERR_CANTUNLOADMODULE, "%s :You cannot unload core commands!", parameters[0].c_str());
+                       user->WriteNumeric(ERR_CANTUNLOADMODULE, parameters[0], "You cannot unload core commands!");
                        return CMD_FAILURE;
                }
 
@@ -98,7 +98,7 @@ class CommandGunloadmodule : public Command
                                }
                                else
                                {
-                                       user->WriteNumeric(ERR_CANTUNLOADMODULE, "%s :%s", parameters[0].c_str(), ServerInstance->Modules->LastError().c_str());
+                                       user->WriteNumeric(ERR_CANTUNLOADMODULE, parameters[0], ServerInstance->Modules->LastError());
                                }
                        }
                        else
@@ -140,7 +140,7 @@ class CommandGreloadmodule : public Command
                        }
                        else
                        {
-                               user->WriteNumeric(RPL_LOADEDMODULE, "%s :Could not find module by that name", parameters[0].c_str());
+                               user->WriteNumeric(RPL_LOADEDMODULE, parameters[0], "Could not find module by that name");
                                return CMD_FAILURE;
                        }
                }
index ef9ae5e22e8e7d8ffcccaa8396f9c04bd6723e54..f567aa0767d7440ea065fd064036a0ee8dfe70e0 100644 (file)
@@ -57,15 +57,15 @@ class CommandHelpop : public Command
                if (parameter == "index")
                {
                        /* iterate over all helpop items */
-                       user->WriteNumeric(290, ":HELPOP topic index");
+                       user->WriteNumeric(290, "HELPOP topic index");
                        for (HelpopMap::const_iterator iter = helpop_map.begin(); iter != helpop_map.end(); iter++)
-                               user->WriteNumeric(292, ":  %s", iter->first.c_str());
-                       user->WriteNumeric(292, ":*** End of HELPOP topic index");
+                               user->WriteNumeric(292, InspIRCd::Format("  %s", iter->first.c_str()));
+                       user->WriteNumeric(292, "*** End of HELPOP topic index");
                }
                else
                {
-                       user->WriteNumeric(290, ":*** HELPOP for %s", parameter.c_str());
-                       user->WriteNumeric(292, ": -");
+                       user->WriteNumeric(290, InspIRCd::Format("*** HELPOP for %s", parameter.c_str()));
+                       user->WriteNumeric(292, " -");
 
                        HelpopMap::const_iterator iter = helpop_map.find(parameter);
 
@@ -82,13 +82,13 @@ class CommandHelpop : public Command
                        {
                                // Writing a blank line will not work with some clients
                                if (token.empty())
-                                       user->WriteNumeric(292, ": ");
+                                       user->WriteNumeric(292, ' ');
                                else
-                                       user->WriteNumeric(292, ":%s", token.c_str());
+                                       user->WriteNumeric(292, token);
                        }
 
-                       user->WriteNumeric(292, ": -");
-                       user->WriteNumeric(292, ":*** End of HELPOP");
+                       user->WriteNumeric(292, " -");
+                       user->WriteNumeric(292, "*** End of HELPOP");
                }
                return CMD_SUCCESS;
        }
index cde8371fc6293d681fbb48774dd84931d3b5f2f8..97173c14b03513dbe8b67935a7cedbe9864f2043 100644 (file)
@@ -46,7 +46,7 @@ class ListWatcher : public ModeWatcher
                if (user->HasPrivPermission("channels/auspex"))
                        return true;
 
-               user->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s :You do not have access to view the %s list", chan->name.c_str(), GetModeName().c_str());
+               user->WriteNumeric(ERR_CHANOPRIVSNEEDED, chan->name, InspIRCd::Format("You do not have access to view the %s list", GetModeName().c_str()));
                return false;
        }
 };
index 03f6745ee9796ed887b4ff843a3a10e9b2aa9d1b..b90f3f2343e0652c9147c75808af47ea8f28ece6 100644 (file)
@@ -71,9 +71,9 @@ class ModuleHideOper : public Module, public Whois::LineEventListener
                        hm.opercount--;
        }
 
-       ModResult OnNumeric(User* user, unsigned int numeric, const std::string& text) CXX11_OVERRIDE
+       ModResult OnNumeric(User* user, const Numeric::Numeric& numeric) CXX11_OVERRIDE
        {
-               if (numeric != 252 || active || user->HasPrivPermission("users/auspex"))
+               if (numeric.GetNumeric() != 252 || active || user->HasPrivPermission("users/auspex"))
                        return MOD_RES_PASSTHRU;
 
                // If there are no visible operators then we shouldn't send the numeric.
@@ -81,7 +81,7 @@ class ModuleHideOper : public Module, public Whois::LineEventListener
                if (opercount)
                {
                        active = true;
-                       user->WriteNumeric(252, "%lu :operator(s) online", opercount);
+                       user->WriteNumeric(252, opercount, "operator(s) online");
                        active = false;
                }
                return MOD_RES_DENY;
index 541e080f56a7ad999f4c7632fe85f88f5dfe5533..eb8e856acde4e150e28aab4917c916ed18673a31 100644 (file)
@@ -109,10 +109,12 @@ class ModuleHttpStats : public Module, public HTTPRequestEventListener
                                data << "<uptime><boot_time_t>" << ServerInstance->startup_time << "</boot_time_t></uptime>";
 
                                data << "<isupport>";
-                               const std::vector<std::string>& isupport = ServerInstance->ISupport.GetLines();
-                               for (std::vector<std::string>::const_iterator it = isupport.begin(); it != isupport.end(); it++)
+                               const std::vector<Numeric::Numeric>& isupport = ServerInstance->ISupport.GetLines();
+                               for (std::vector<Numeric::Numeric>::const_iterator i = isupport.begin(); i != isupport.end(); ++i)
                                {
-                                       data << Sanitize(*it) << std::endl;
+                                       const Numeric::Numeric& num = *i;
+                                       for (std::vector<std::string>::const_iterator j = num.GetParams().begin(); j != num.GetParams().end()-1; ++j)
+                                               data << "<token>" << Sanitize(*j) << "</token>" << std::endl;
                                }
                                data << "</isupport></general><xlines>";
                                std::vector<std::string> xltypes = ServerInstance->XLines->GetAllTypes();
index 52802f168884fd2a1783b2b41b0cae08b984b001..56e109c1a828697fc93f0510dfce336f35e7dcab 100644 (file)
@@ -95,7 +95,7 @@ class JoinFlood : public ParamMode<JoinFlood, SimpleExtItem<joinfloodsettings> >
                std::string::size_type colon = parameter.find(':');
                if ((colon == std::string::npos) || (parameter.find('-') != std::string::npos))
                {
-                       source->WriteNumeric(608, "%s :Invalid flood parameter",channel->name.c_str());
+                       source->WriteNumeric(608, channel->name, "Invalid flood parameter");
                        return MODEACTION_DENY;
                }
 
@@ -104,7 +104,7 @@ class JoinFlood : public ParamMode<JoinFlood, SimpleExtItem<joinfloodsettings> >
                unsigned int nsecs = ConvToInt(parameter.substr(colon+1));
                if ((njoins<1) || (nsecs<1))
                {
-                       source->WriteNumeric(608, "%s :Invalid flood parameter",channel->name.c_str());
+                       source->WriteNumeric(608, channel->name, "Invalid flood parameter");
                        return MODEACTION_DENY;
                }
 
@@ -136,7 +136,7 @@ class ModuleJoinFlood : public Module
                        joinfloodsettings *f = jf.ext.get(chan);
                        if (f && f->islocked())
                        {
-                               user->WriteNumeric(609, "%s :This channel is temporarily unavailable (+j). Please try again later.",chan->name.c_str());
+                               user->WriteNumeric(609, chan->name, "This channel is temporarily unavailable (+j). Please try again later.");
                                return MOD_RES_DENY;
                        }
                }
index e9c07f45fda18816a003a1017d8f3d150a7ff184..33b9bcd3567d4beb423ebce200ca131599376d1a 100644 (file)
@@ -116,7 +116,7 @@ class CommandJumpserver : public Command
                                        ++i;
                                        if (!t->IsOper())
                                        {
-                                               t->WriteNumeric(RPL_REDIR, "%s %d :Please use this Server/Port instead", parameters[0].c_str(), GetPort(t));
+                                               t->WriteNumeric(RPL_REDIR, parameters[0], GetPort(t), "Please use this Server/Port instead");
                                                ServerInstance->Users->QuitUser(t, reason);
                                                n_done++;
                                        }
@@ -160,8 +160,7 @@ class ModuleJumpServer : public Module
                if (js.redirect_new_users)
                {
                        int port = js.GetPort(user);
-                       user->WriteNumeric(RPL_REDIR, "%s %d :Please use this Server/Port instead",
-                               js.redirect_to.c_str(), port);
+                       user->WriteNumeric(RPL_REDIR, js.redirect_to, port, "Please use this Server/Port instead");
                        ServerInstance->Users->QuitUser(user, js.reason);
                        return MOD_RES_PASSTHRU;
                }
index b8a7766675e8e191ea0cb45331ba495058f695d9..ad8bfdcb6d1c60b283f8f604d8c341cb0f288907 100644 (file)
@@ -132,7 +132,7 @@ public:
                        const KickRejoinData* data = kr.ext.get(chan);
                        if ((data) && (!data->canjoin(user)))
                        {
-                               user->WriteNumeric(ERR_DELAYREJOIN, "%s :You must wait %u seconds after being kicked to rejoin (+J)", chan->name.c_str(), data->delay);
+                               user->WriteNumeric(ERR_DELAYREJOIN, chan, InspIRCd::Format("You must wait %u seconds after being kicked to rejoin (+J)", data->delay));
                                return MOD_RES_DENY;
                        }
                }
index 26397bc9c17f94e135e4f2604a173e30480bcd81..545c2dc14c11232202959ce7e3916a55578f15f9 100644 (file)
@@ -45,25 +45,25 @@ class CommandKnock : public Command
                Channel* c = ServerInstance->FindChan(parameters[0]);
                if (!c)
                {
-                       user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such channel", parameters[0].c_str());
+                       user->WriteNumeric(Numerics::NoSuchNick(parameters[0]));
                        return CMD_FAILURE;
                }
 
                if (c->HasUser(user))
                {
-                       user->WriteNumeric(ERR_KNOCKONCHAN, "%s :Can't KNOCK on %s, you are already on that channel.", c->name.c_str(), c->name.c_str());
+                       user->WriteNumeric(ERR_KNOCKONCHAN, c->name, InspIRCd::Format("Can't KNOCK on %s, you are already on that channel.", c->name.c_str()));
                        return CMD_FAILURE;
                }
 
                if (c->IsModeSet(noknockmode))
                {
-                       user->WriteNumeric(480, ":Can't KNOCK on %s, +K is set.", c->name.c_str());
+                       user->WriteNumeric(480, InspIRCd::Format("Can't KNOCK on %s, +K is set.", c->name.c_str()));
                        return CMD_FAILURE;
                }
 
                if (!c->IsModeSet(inviteonlymode))
                {
-                       user->WriteNumeric(ERR_CHANOPEN, "%s :Can't KNOCK on %s, channel is not invite only so knocking is pointless!", c->name.c_str(), c->name.c_str());
+                       user->WriteNumeric(ERR_CHANOPEN, c->name, InspIRCd::Format("Can't KNOCK on %s, channel is not invite only so knocking is pointless!", c->name.c_str()));
                        return CMD_FAILURE;
                }
 
index 65b9aa036349141cdcfe4164a37b1ae1f0a6b589..ffcc04682d639b94c6f9eeeb306e6a662fdda6d2 100644 (file)
@@ -44,7 +44,7 @@ class CommandLockserv : public Command
                }
 
                locked = true;
-               user->WriteNumeric(988, "%s :Closed for new connections", user->server->GetName().c_str());
+               user->WriteNumeric(988, user->server->GetName(), "Closed for new connections");
                ServerInstance->SNO->WriteGlobalSno('a', "Oper %s used LOCKSERV to temporarily disallow new connections", user->nick.c_str());
                return CMD_SUCCESS;
        }
@@ -69,7 +69,7 @@ class CommandUnlockserv : public Command
                }
 
                locked = false;
-               user->WriteNumeric(989, "%s :Open for new connections", user->server->GetName().c_str());
+               user->WriteNumeric(989, user->server->GetName(), "Open for new connections");
                ServerInstance->SNO->WriteGlobalSno('a', "Oper %s used UNLOCKSERV to allow new connections", user->nick.c_str());
                return CMD_SUCCESS;
        }
index 1faf3bfb99e5a1d04c449b9798201088f72edb6d..c5c872169ea1a2b360ff24d60a240e756a790b05 100644 (file)
@@ -73,7 +73,7 @@ class MsgFlood : public ParamMode<MsgFlood, SimpleExtItem<floodsettings> >
                std::string::size_type colon = parameter.find(':');
                if ((colon == std::string::npos) || (parameter.find('-') != std::string::npos))
                {
-                       source->WriteNumeric(608, "%s :Invalid flood parameter", channel->name.c_str());
+                       source->WriteNumeric(608, channel->name, "Invalid flood parameter");
                        return MODEACTION_DENY;
                }
 
@@ -84,7 +84,7 @@ class MsgFlood : public ParamMode<MsgFlood, SimpleExtItem<floodsettings> >
 
                if ((nlines<2) || (nsecs<1))
                {
-                       source->WriteNumeric(608, "%s :Invalid flood parameter", channel->name.c_str());
+                       source->WriteNumeric(608, channel->name, "Invalid flood parameter");
                        return MODEACTION_DENY;
                }
 
index 9b0fa8dab0b8438a49fe8e1b83f608bc936ea3ba..d3ab5b9fd2af0700fb6b26e2e95cad0b59183020 100644 (file)
@@ -50,8 +50,7 @@ class ModuleMLock : public Module
                std::string::size_type p = mlock_str->find(mode);
                if (p != std::string::npos)
                {
-                       source->WriteNumeric(742, "%s %c %s :MODE cannot be set due to channel having an active MLOCK restriction policy",
-                                            channel->name.c_str(), mode, mlock_str->c_str());
+                       source->WriteNumeric(742, channel->name, mode, *mlock_str, "MODE cannot be set due to channel having an active MLOCK restriction policy");
                        return MOD_RES_DENY;
                }
 
index 139c70e7646697016ac9faaadc08eda376fd73f5..b2e06f191df7858abced7d89bbe7fc9a4440135a 100644 (file)
@@ -285,7 +285,7 @@ class CommandMonitor : public SplitCommand
                        if (result == IRCv3::Monitor::Manager::WR_TOOMANY)
                        {
                                // List is full, send error which includes the remaining nicks that were not processed
-                               user->WriteNumeric(ERR_MONLISTFULL, "%u %s%s%s :Monitor list is full", maxmonitor, nick.c_str(), (ss.StreamEnd() ? "" : ","), ss.GetRemaining().c_str());
+                               user->WriteNumeric(ERR_MONLISTFULL, maxmonitor, InspIRCd::Format("%s%s%s", nick.c_str(), (ss.StreamEnd() ? "" : ","), ss.GetRemaining().c_str()), "Monitor list is full");
                                break;
                        }
                        else if (result != IRCv3::Monitor::Manager::WR_OK)
@@ -346,7 +346,7 @@ class CommandMonitor : public SplitCommand
                                out.Add(entry->GetNick());
                        }
                        out.Flush();
-                       user->WriteNumeric(RPL_ENDOFMONLIST, ":End of MONITOR list");
+                       user->WriteNumeric(RPL_ENDOFMONLIST, "End of MONITOR list");
                }
                else if (subcmd == 'S')
                {
index 72c4acd47ca12c57baf8f577880542dcab279f20..c9caf6a6ad8e7345b7e7949886091483505dc214 100644 (file)
@@ -36,7 +36,7 @@ class ModuleQuietBan : public Module
                Channel* chan = static_cast<Channel*>(dest);
                if (chan->GetExtBanStatus(user, 'm') == MOD_RES_DENY && chan->GetPrefixValue(user) < VOICE_VALUE)
                {
-                       user->WriteNumeric(ERR_CANNOTSENDTOCHAN, "%s :Cannot send to channel (you're muted)", chan->name.c_str());
+                       user->WriteNumeric(ERR_CANNOTSENDTOCHAN, chan->name, "Cannot send to channel (you're muted)");
                        return MOD_RES_DENY;
                }
 
index 617ee43b368f5a3f6f48e588e4ab15ea5f227b35..10bef981a3bee03425bbce9dfca8671103d1a277 100644 (file)
@@ -39,7 +39,7 @@ static void DisplayList(User* user, Channel* channel)
        }
        const std::string line = ":" + ServerInstance->Config->ServerName + " 961 " + user->nick + " " + channel->name;
        user->SendText(line, items);
-       user->WriteNumeric(960, "%s :End of mode list", channel->name.c_str());
+       user->WriteNumeric(960, channel->name, "End of mode list");
 }
 
 class CommandProp : public Command
@@ -55,7 +55,7 @@ class CommandProp : public Command
                Channel* const chan = ServerInstance->FindChan(parameters[0]);
                if (!chan)
                {
-                       src->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", parameters[0].c_str());
+                       src->WriteNumeric(Numerics::NoSuchNick(parameters[0]));
                        return CMD_FAILURE;
                }
 
index cade0b1db751ace5a5dd7829510b0d58275094e5..0af1041f913225757982c3fd544d0898a7de1ac6 100644 (file)
@@ -91,7 +91,7 @@ class NickFlood : public ParamMode<NickFlood, SimpleExtItem<nickfloodsettings> >
                std::string::size_type colon = parameter.find(':');
                if ((colon == std::string::npos) || (parameter.find('-') != std::string::npos))
                {
-                       source->WriteNumeric(608, "%s :Invalid flood parameter",channel->name.c_str());
+                       source->WriteNumeric(608, channel->name, "Invalid flood parameter");
                        return MODEACTION_DENY;
                }
 
@@ -101,7 +101,7 @@ class NickFlood : public ParamMode<NickFlood, SimpleExtItem<nickfloodsettings> >
 
                if ((nnicks<1) || (nsecs<1))
                {
-                       source->WriteNumeric(608, "%s :Invalid flood parameter",channel->name.c_str());
+                       source->WriteNumeric(608, channel->name, "Invalid flood parameter");
                        return MODEACTION_DENY;
                }
 
@@ -142,7 +142,7 @@ class ModuleNickFlood : public Module
 
                                if (f->islocked())
                                {
-                                       user->WriteNumeric(ERR_CANTCHANGENICK, ":%s has been locked for nickchanges for 60 seconds because there have been more than %u nick changes in %u seconds", channel->name.c_str(), f->nicks, f->secs);
+                                       user->WriteNumeric(ERR_CANTCHANGENICK, InspIRCd::Format("%s has been locked for nickchanges for 60 seconds because there have been more than %u nick changes in %u seconds", channel->name.c_str(), f->nicks, f->secs));
                                        return MOD_RES_DENY;
                                }
 
index a99628bf1258396e1bb5d82f21935f4755a9a155..634982d14dc72a8d226a8674098362633cd91125 100644 (file)
@@ -55,7 +55,7 @@ class CommandNicklock : public Command
                                return CMD_FAILURE;
                        }
 
-                       user->WriteNumeric(947, "%s :Nickname now locked.", parameters[1].c_str());
+                       user->WriteNumeric(947, parameters[1], "Nickname now locked.");
                }
 
                /* If we made it this far, extend the user */
@@ -159,7 +159,7 @@ class ModuleNickLock : public Module
        {
                if (locked.get(user))
                {
-                       user->WriteNumeric(ERR_CANTCHANGENICK, ":You cannot change your nickname (your nick is locked)");
+                       user->WriteNumeric(ERR_CANTCHANGENICK, "You cannot change your nickname (your nick is locked)");
                        return MOD_RES_DENY;
                }
                return MOD_RES_PASSTHRU;
index 953557d90ff165549acab2a3fd2a76734a8186cf..49b53ee950f93af1eccfc93fede8f4f96b0e51e8 100644 (file)
@@ -56,7 +56,7 @@ class ModuleNoCTCP : public Module
 
                        if (!c->GetExtBanStatus(user, 'C').check(!c->IsModeSet(nc)))
                        {
-                               user->WriteNumeric(ERR_NOCTCPALLOWED, "%s :Can't send CTCP to channel (+C set)", c->name.c_str());
+                               user->WriteNumeric(ERR_NOCTCPALLOWED, c->name, "Can't send CTCP to channel (+C set)");
                                return MOD_RES_DENY;
                        }
                }
index 0acf841187a7f3e91c0e4039fd377b25ed9040e1..fb3455567b53621ca12b1e7809e384601c980775 100644 (file)
@@ -48,7 +48,7 @@ class ModuleNoKicks : public Module
                if (!memb->chan->GetExtBanStatus(source, 'Q').check(!memb->chan->IsModeSet(nk)))
                {
                        // Can't kick with Q in place, not even opers with override, and founders
-                       source->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s :Can't kick user %s from channel (+Q set)", memb->chan->name.c_str(), memb->user->nick.c_str());
+                       source->WriteNumeric(ERR_CHANOPRIVSNEEDED, memb->chan->name, InspIRCd::Format("Can't kick user %s from channel (+Q set)", memb->user->nick.c_str()));
                        return MOD_RES_DENY;
                }
                return MOD_RES_PASSTHRU;
index 63815f2bf7ef329675082187470e1ff14cbac773..d4da3e95139b251dc5f8b7add2321d5c55579c6c 100644 (file)
@@ -62,8 +62,8 @@ class ModuleNoNickChange : public Module
 
                        if (!curr->GetExtBanStatus(user, 'N').check(!curr->IsModeSet(nn)))
                        {
-                               user->WriteNumeric(ERR_CANTCHANGENICK, ":Can't change nickname while on %s (+N is set)",
-                                       curr->name.c_str());
+                               user->WriteNumeric(ERR_CANTCHANGENICK, InspIRCd::Format("Can't change nickname while on %s (+N is set)",
+                                       curr->name.c_str()));
                                return MOD_RES_DENY;
                        }
                }
index cab367ad9e6abe49e879a275911a1feb79d57c3a..3d6d0bb099422808e9f8af07c8fe385e50fbc2db 100644 (file)
@@ -55,7 +55,7 @@ class ModuleNoNotice : public Module
                                        return MOD_RES_PASSTHRU;
                                else
                                {
-                                       user->WriteNumeric(ERR_CANNOTSENDTOCHAN, "%s :Can't send NOTICE to channel (+T set)", c->name.c_str());
+                                       user->WriteNumeric(ERR_CANNOTSENDTOCHAN, c->name, "Can't send NOTICE to channel (+T set)");
                                        return MOD_RES_DENY;
                                }
                        }
index 1444f93ad691a3ab37174b02e10f51e0dfdcf755..88b63bef25f405d0f25c3d2360566a04a961eb26 100644 (file)
@@ -146,7 +146,7 @@ class ModuleOjoin : public Module
                if (source == memb->user)
                        return MOD_RES_PASSTHRU;
 
-               source->WriteNumeric(ERR_RESTRICTED, memb->chan->name+" :Can't kick "+memb->user->nick+" as they're on official network business.");
+               source->WriteNumeric(ERR_RESTRICTED, memb->chan->name, "Can't kick "+memb->user->nick+" as they're on official network business.");
                return MOD_RES_DENY;
        }
 
index 3c6b4cd59c96f72de160d9a208da70b6ef9bc009..0b074ebab4247a183ea2360d7def1f986015a15b 100644 (file)
@@ -44,8 +44,7 @@ class ModuleOperChans : public Module
        {
                if (chan && chan->IsModeSet(oc) && !user->IsOper())
                {
-                       user->WriteNumeric(ERR_CANTJOINOPERSONLY, "%s :Only IRC operators may join %s (+O is set)",
-                               chan->name.c_str(), chan->name.c_str());
+                       user->WriteNumeric(ERR_CANTJOINOPERSONLY, chan->name, InspIRCd::Format("Only IRC operators may join %s (+O is set)", chan->name.c_str()));
                        return MOD_RES_DENY;
                }
                return MOD_RES_PASSTHRU;
index ac7178a93385ac12881ef467b481997d54e19a40..bf758b1f76812d894c2693a290110c83d8d46eaa 100644 (file)
@@ -44,7 +44,7 @@ class ModuleOperLevels : public Module
                                {
                                        if (IS_LOCAL(source)) ServerInstance->SNO->WriteGlobalSno('a', "Oper %s (level %ld) attempted to /kill a higher oper: %s (level %ld): Reason: %s",source->nick.c_str(),source_level,dest->nick.c_str(),dest_level,reason.c_str());
                                        dest->WriteNotice("*** Oper " + source->nick + " attempted to /kill you!");
-                                       source->WriteNumeric(ERR_NOPRIVILEGES, ":Permission Denied - Oper %s is a higher level than you", dest->nick.c_str());
+                                       source->WriteNumeric(ERR_NOPRIVILEGES, InspIRCd::Format("Permission Denied - Oper %s is a higher level than you", dest->nick.c_str()));
                                        return MOD_RES_DENY;
                                }
                        }
index e822676bf7357c102233cbcd69f5768110a4daf7..b14de9ff91eeecda7d8eda473c4a858f2354db7f 100644 (file)
@@ -38,7 +38,7 @@ class Redirect : public ParamMode<Redirect, LocalStringExt>
                {
                        if (!ServerInstance->IsChannel(parameter))
                        {
-                               source->WriteNumeric(ERR_NOSUCHCHANNEL, "%s :Invalid channel name", parameter.c_str());
+                               source->WriteNumeric(ERR_NOSUCHCHANNEL, parameter, "Invalid channel name");
                                return MODEACTION_DENY;
                        }
                }
@@ -48,12 +48,12 @@ class Redirect : public ParamMode<Redirect, LocalStringExt>
                        Channel* c = ServerInstance->FindChan(parameter);
                        if (!c)
                        {
-                               source->WriteNumeric(690, ":Target channel %s must exist to be set as a redirect.",parameter.c_str());
+                               source->WriteNumeric(690, InspIRCd::Format("Target channel %s must exist to be set as a redirect.", parameter.c_str()));
                                return MODEACTION_DENY;
                        }
                        else if (c->GetPrefixValue(source) < OP_VALUE)
                        {
-                               source->WriteNumeric(690, ":You must be opped on %s to set it as a redirect.",parameter.c_str());
+                               source->WriteNumeric(690, InspIRCd::Format("You must be opped on %s to set it as a redirect.", parameter.c_str()));
                                return MODEACTION_DENY;
                        }
                }
@@ -119,19 +119,19 @@ class ModuleRedirect : public Module
                                        Channel* destchan = ServerInstance->FindChan(channel);
                                        if (destchan && destchan->IsModeSet(re))
                                        {
-                                               user->WriteNumeric(470, "%s * :You may not join this channel. A redirect is set, but you may not be redirected as it is a circular loop.", cname.c_str());
+                                               user->WriteNumeric(470, cname, '*', "You may not join this channel. A redirect is set, but you may not be redirected as it is a circular loop.");
                                                return MOD_RES_DENY;
                                        }
                                        /* We check the bool value here to make sure we have it enabled, if we don't then
                                                usermode +L might be assigned to something else. */
                                        if (UseUsermode && user->IsModeSet(re_u))
                                        {
-                                               user->WriteNumeric(470, "%s %s :Force redirection stopped.", cname.c_str(), channel.c_str());
+                                               user->WriteNumeric(470, cname, channel, "Force redirection stopped.");
                                                return MOD_RES_DENY;
                                        }
                                        else
                                        {
-                                               user->WriteNumeric(470, "%s %s :You may not join this channel, so you are automatically being transferred to the redirect channel.", cname.c_str(), channel.c_str());
+                                               user->WriteNumeric(470, cname, channel, "You may not join this channel, so you are automatically being transferred to the redirect channel.");
                                                Channel::JoinUser(user, channel);
                                                return MOD_RES_DENY;
                                        }
index 0ffe5e085010f43a62bdc846d4d2334e11c1f553..78b20ef6b9f96206c1711f65176431d59039218c 100644 (file)
@@ -49,7 +49,7 @@ class ModuleRegOnlyCreate : public Module
                        return MOD_RES_PASSTHRU;
 
                // XXX. there may be a better numeric for this..
-               user->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s :You must have a registered nickname to create a new channel", cname.c_str());
+               user->WriteNumeric(ERR_CHANOPRIVSNEEDED, cname, "You must have a registered nickname to create a new channel");
                return MOD_RES_DENY;
        }
 
index 8d0009d71330baca2816c421a412c102d7cbbadf..5b0efe2a27a6e14c095d06a7c92fbb4af6cafc6e 100644 (file)
@@ -76,7 +76,7 @@ class RemoveBase : public Command
                /* Fix by brain - someone needs to learn to validate their input! */
                if ((!target) || (target->registered != REG_ALL) || (!channel))
                {
-                       user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", !channel ? channame.c_str() : username.c_str());
+                       user->WriteNumeric(Numerics::NoSuchNick(channel ? username.c_str() : channame.c_str()));
                        return CMD_FAILURE;
                }
 
@@ -88,7 +88,7 @@ class RemoveBase : public Command
 
                if (target->server->IsULine())
                {
-                       user->WriteNumeric(482, "%s :Only a u-line may remove a u-line from a channel.", channame.c_str());
+                       user->WriteNumeric(482, channame, "Only a u-line may remove a u-line from a channel.");
                        return CMD_FAILURE;
                }
 
@@ -144,7 +144,7 @@ class RemoveBase : public Command
                else
                {
                        /* m_nokicks.so was loaded and +Q was set, block! */
-                       user->WriteNumeric(ERR_RESTRICTED, "%s :Can't remove user %s from channel (nokicks mode is set)", channel->name.c_str(), target->nick.c_str());
+                       user->WriteNumeric(ERR_RESTRICTED, channel->name, InspIRCd::Format("Can't remove user %s from channel (nokicks mode is set)", target->nick.c_str()));
                        return CMD_FAILURE;
                }
 
index 9e660e8ed16f0d1843b480384ff5a6a772fdc212..9c7ed1213ee2cfdfa230ae0bc1d5af0c6ef831d7 100644 (file)
@@ -47,7 +47,7 @@ class ModuleRestrictChans : public Module
                        // user is not an oper and its not in the allow list
                        if ((!user->IsOper()) && (allowchans.find(cname) == allowchans.end()))
                        {
-                               user->WriteNumeric(ERR_BANNEDFROMCHAN, "%s :Only IRC operators may create new channels", cname.c_str());
+                               user->WriteNumeric(ERR_BANNEDFROMCHAN, cname, "Only IRC operators may create new channels");
                                return MOD_RES_DENY;
                        }
                }
index 279775d480570621bb58a9f3464c390271a0d0b7..8ca531ed5ba5ee45942ab773ab3a97a3f1538db3 100644 (file)
@@ -39,7 +39,7 @@ class ModuleRestrictMsg : public Module
                        {
                                return MOD_RES_PASSTHRU;
                        }
-                       user->WriteNumeric(ERR_CANTSENDTOUSER, "%s :You are not permitted to send private messages to this user", u->nick.c_str());
+                       user->WriteNumeric(ERR_CANTSENDTOUSER, u->nick, "You are not permitted to send private messages to this user");
                        return MOD_RES_DENY;
                }
 
index d1321947b2bb54979ecf8618a19556ae05581321..9696b08a1aaea186623b55afdbe894dd9442d89a 100644 (file)
@@ -53,7 +53,7 @@ class CommandSajoin : public Command
 
                        if (dest->server->IsULine())
                        {
-                               user->WriteNumeric(ERR_NOPRIVILEGES, ":Cannot use an SA command on a u-lined client");
+                               user->WriteNumeric(ERR_NOPRIVILEGES, "Cannot use an SA command on a u-lined client");
                                return CMD_FAILURE;
                        }
                        if (IS_LOCAL(user) && !ServerInstance->IsChannel(channel))
index 911b826dc0ac25190bd74b6a04c5a0199d185d31..8fc6e741be1fab8d66fdd9e25063978111ff6b23 100644 (file)
@@ -42,7 +42,7 @@ class CommandSakick : public Command
 
                        if (dest->server->IsULine())
                        {
-                               user->WriteNumeric(ERR_NOPRIVILEGES, ":Cannot use an SA command on a u-lined client");
+                               user->WriteNumeric(ERR_NOPRIVILEGES, "Cannot use an SA command on a u-lined client");
                                return CMD_FAILURE;
                        }
 
index 8b06118ee536f05b9a152879193cca98634209cc..bcb876d5b41906c5ca20383517b807852cd210a7 100644 (file)
@@ -42,7 +42,7 @@ class CommandSamode : public Command
                        User* target = ServerInstance->FindNickOnly(parameters[0]);
                        if ((!target) || (target->registered != REG_ALL))
                        {
-                               user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", parameters[0].c_str());
+                               user->WriteNumeric(Numerics::NoSuchNick(parameters[0]));
                                return CMD_FAILURE;
                        }
 
index ba265fddd29acaeb2d9e7059f2d2d074634e081d..fd9a825dda7f58361ae56bc02fc3b11133648905 100644 (file)
@@ -42,7 +42,7 @@ class CommandSanick : public Command
                {
                        if (target && target->server->IsULine())
                        {
-                               user->WriteNumeric(ERR_NOPRIVILEGES, ":Cannot use an SA command on a u-lined client");
+                               user->WriteNumeric(ERR_NOPRIVILEGES, "Cannot use an SA command on a u-lined client");
                                return CMD_FAILURE;
                        }
 
index 730bf08234f4aba5c6e00d704355a1ab03ff08f9..65c32cd8aa71212550752e5fb3bb5fa62bfd1ce2 100644 (file)
@@ -48,7 +48,7 @@ class CommandSapart : public Command
 
                        if (dest->server->IsULine())
                        {
-                               user->WriteNumeric(ERR_NOPRIVILEGES, ":Cannot use an SA command on a u-lined client");
+                               user->WriteNumeric(ERR_NOPRIVILEGES, "Cannot use an SA command on a u-lined client");
                                return CMD_FAILURE;
                        }
 
index fb1c67564350144ae7acefc0ff27e146098b3773..4d5ac6e22a985904306ad6343e938384b1effe50 100644 (file)
@@ -39,7 +39,7 @@ class CommandSaquit : public Command
                {
                        if (dest->server->IsULine())
                        {
-                               user->WriteNumeric(ERR_NOPRIVILEGES, ":Cannot use an SA command on a u-lined client");
+                               user->WriteNumeric(ERR_NOPRIVILEGES, "Cannot use an SA command on a u-lined client");
                                return CMD_FAILURE;
                        }
 
index 6e308693073ec727f7b84ef2cad36c380ff8e34d..e749d16b475106abd71212636a7fdb5d713ac963 100644 (file)
@@ -142,7 +142,7 @@ class SaslAuthenticator
                                this->result = this->GetSaslResult(msg[3]);
                        }
                        else if (msg[2] == "M")
-                               this->user->WriteNumeric(908, "%s :are available SASL mechanisms", msg[3].c_str());
+                               this->user->WriteNumeric(908, msg[3], "are available SASL mechanisms");
                        else
                                ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, "Services sent an unknown SASL message \"%s\" \"%s\"", msg[2].c_str(), msg[3].c_str());
 
@@ -194,13 +194,13 @@ class SaslAuthenticator
                switch (this->result)
                {
                 case SASL_OK:
-                       this->user->WriteNumeric(903, ":SASL authentication successful");
+                       this->user->WriteNumeric(903, "SASL authentication successful");
                        break;
                 case SASL_ABORT:
-                       this->user->WriteNumeric(906, ":SASL authentication aborted");
+                       this->user->WriteNumeric(906, "SASL authentication aborted");
                        break;
                 case SASL_FAIL:
-                       this->user->WriteNumeric(904, ":SASL authentication failed");
+                       this->user->WriteNumeric(904, "SASL authentication failed");
                        break;
                 default:
                        break;
index 4a6f855369276dba2b3fb6fd865571e0454a9713..040d86b9a46b68cf1e9bf09b79d4d7043e7457c2 100644 (file)
@@ -46,7 +46,7 @@ class CommandSATopic : public Command
                }
                else
                {
-                       user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", parameters[0].c_str());
+                       user->WriteNumeric(Numerics::NoSuchNick(parameters[0]));
                        return CMD_FAILURE;
                }
        }
index f4042b8f6299cbdfec0d51a9773b6e43a0c3b84d..b6c6ce174f046570fd34e634b6ea3bf105f0b63d 100644 (file)
@@ -66,8 +66,8 @@ class ModuleSecureList : public Module
                        /* Some crap clients (read: mIRC, various java chat applets) muck up if they don't
                         * receive these numerics whenever they send LIST, so give them an empty LIST to mull over.
                         */
-                       user->WriteNumeric(RPL_LISTSTART, "Channel :Users Name");
-                       user->WriteNumeric(RPL_LISTEND, ":End of channel list.");
+                       user->WriteNumeric(RPL_LISTSTART, "Channel", "Users Name");
+                       user->WriteNumeric(RPL_LISTEND, "End of channel list.");
                        return MOD_RES_DENY;
                }
                return MOD_RES_PASSTHRU;
index 48ab511f08c8a557cccbd1af4892ea425c488e26..048e04a5a332ae7fbd8159b9017b3810e274acd2 100644 (file)
@@ -46,7 +46,7 @@ class Channel_r : public ModeHandler
                }
                else
                {
-                       source->WriteNumeric(500, ":Only a server may modify the +r channel mode");
+                       source->WriteNumeric(500, "Only a server may modify the +r channel mode");
                }
                return MODEACTION_DENY;
        }
@@ -72,7 +72,7 @@ class User_r : public ModeHandler
                }
                else
                {
-                       source->WriteNumeric(500, ":Only a server may modify the +r user mode");
+                       source->WriteNumeric(500, "Only a server may modify the +r user mode");
                }
                return MODEACTION_DENY;
        }
@@ -128,8 +128,7 @@ class AccountExtItemImpl : public AccountExtItem
                        // Logged in
                        if (IS_LOCAL(user))
                        {
-                               user->WriteNumeric(900, "%s %s :You are now logged in as %s",
-                                       user->GetFullHost().c_str(), value.c_str(), value.c_str());
+                               user->WriteNumeric(900, user->GetFullHost(), value, InspIRCd::Format("You are now logged in as %s", value.c_str()));
                        }
                }
                // If value is empty then logged out
@@ -202,7 +201,7 @@ class ModuleServicesAccount : public Module, public Whois::EventListener
                        if (c->IsModeSet(m2) && !is_registered && res != MOD_RES_ALLOW)
                        {
                                // user messaging a +M channel and is not registered
-                               user->WriteNumeric(477, c->name+" :You need to be identified to a registered account to message this channel");
+                               user->WriteNumeric(477, c->name, "You need to be identified to a registered account to message this channel");
                                return MOD_RES_DENY;
                        }
                }
@@ -213,7 +212,7 @@ class ModuleServicesAccount : public Module, public Whois::EventListener
                        if (u->IsModeSet(m3) && !is_registered)
                        {
                                // user messaging a +R user and is not registered
-                               user->WriteNumeric(477, u->nick +" :You need to be identified to a registered account to message this user");
+                               user->WriteNumeric(477, u->nick, "You need to be identified to a registered account to message this user");
                                return MOD_RES_DENY;
                        }
                }
@@ -268,7 +267,7 @@ class ModuleServicesAccount : public Module, public Whois::EventListener
                                if (!is_registered)
                                {
                                        // joining a +R channel and not identified
-                                       user->WriteNumeric(477, chan->name + " :You need to be identified to a registered account to join this channel");
+                                       user->WriteNumeric(477, chan->name, "You need to be identified to a registered account to join this channel");
                                        return MOD_RES_DENY;
                                }
                        }
index 0445235dc795f6821de7853ee98c0fae38b5fc89..34f730c629ce162e7470e4885e4862204b51850a 100644 (file)
@@ -86,7 +86,7 @@ class ModuleServProtectMode : public Module, public Whois::EventListener, public
                                if (u->IsModeSet(bm) && memb && memb->hasMode(mh->GetModeChar()))
                                {
                                        /* BZZZT, Denied! */
-                                       user->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s :You are not permitted to remove privileges from %s services", chan->name.c_str(), ServerInstance->Config->Network.c_str());
+                                       user->WriteNumeric(ERR_CHANOPRIVSNEEDED, chan->name, InspIRCd::Format("You are not permitted to remove privileges from %s services", ServerInstance->Config->Network.c_str()));
                                        return MOD_RES_DENY;
                                }
                        }
@@ -102,7 +102,7 @@ class ModuleServProtectMode : public Module, public Whois::EventListener, public
 
                if (dst->IsModeSet(bm))
                {
-                       src->WriteNumeric(485, ":You are not permitted to kill %s services!", ServerInstance->Config->Network.c_str());
+                       src->WriteNumeric(485, InspIRCd::Format("You are not permitted to kill %s services!", ServerInstance->Config->Network.c_str()));
                        ServerInstance->SNO->WriteGlobalSno('a', src->nick+" tried to kill service "+dst->nick+" ("+reason+")");
                        return MOD_RES_DENY;
                }
@@ -113,8 +113,7 @@ class ModuleServProtectMode : public Module, public Whois::EventListener, public
        {
                if (memb->user->IsModeSet(bm))
                {
-                       src->WriteNumeric(ERR_RESTRICTED, "%s :You are not permitted to kick services",
-                               memb->chan->name.c_str());
+                       src->WriteNumeric(ERR_RESTRICTED, memb->chan->name, "You are not permitted to kick services");
                        return MOD_RES_DENY;
                }
 
index dd82aef29ebf33f19247ebad525b5bf6138225d4..4a15fd0d5a050fff9c33f6694ae94d7909aba858 100644 (file)
@@ -36,7 +36,7 @@ class CommandSetidle : public SplitCommand
                int idle = InspIRCd::Duration(parameters[0]);
                if (idle < 1)
                {
-                       user->WriteNumeric(948, ":Invalid idle time.");
+                       user->WriteNumeric(948, "Invalid idle time.");
                        return CMD_FAILURE;
                }
                user->idle_lastmsg = (ServerInstance->Time() - idle);
@@ -44,7 +44,7 @@ class CommandSetidle : public SplitCommand
                if (user->signon > user->idle_lastmsg)
                        user->signon = user->idle_lastmsg;
                ServerInstance->SNO->WriteToSnoMask('a', user->nick+" used SETIDLE to set their idle time to "+ConvToStr(idle)+" seconds");
-               user->WriteNumeric(944, ":Idle time set.");
+               user->WriteNumeric(944, "Idle time set.");
 
                return CMD_SUCCESS;
        }
index f2ac26fb3692a8617cdb5fc19590b1903b5eee57..7d3b3f90ce091d20b2d07713a5664ad6c9fdc27d 100644 (file)
@@ -125,10 +125,10 @@ class CommandSilence : public Command
                                for (silencelist::const_iterator c = sl->begin(); c != sl->end(); c++)
                                {
                                        std::string decomppattern = DecompPattern(c->second);
-                                       user->WriteNumeric(271, "%s %s %s", user->nick.c_str(),c->first.c_str(), decomppattern.c_str());
+                                       user->WriteNumeric(271, user->nick, c->first, decomppattern);
                                }
                        }
-                       user->WriteNumeric(272, ":End of Silence List");
+                       user->WriteNumeric(272, "End of Silence List");
 
                        return CMD_SUCCESS;
                }
@@ -174,7 +174,7 @@ class CommandSilence : public Command
                                                if (listitem == mask && i->second == pattern)
                                                {
                                                        sl->erase(i);
-                                                       user->WriteNumeric(950, "%s :Removed %s %s from silence list", user->nick.c_str(), mask.c_str(), decomppattern.c_str());
+                                                       user->WriteNumeric(950, user->nick, InspIRCd::Format("Removed %s %s from silence list", mask.c_str(), decomppattern.c_str()));
                                                        if (!sl->size())
                                                        {
                                                                ext.unset(user);
@@ -183,7 +183,7 @@ class CommandSilence : public Command
                                                }
                                        }
                                }
-                               user->WriteNumeric(952, "%s :%s %s does not exist on your silence list", user->nick.c_str(), mask.c_str(), decomppattern.c_str());
+                               user->WriteNumeric(952, user->nick, InspIRCd::Format("%s %s does not exist on your silence list", mask.c_str(), decomppattern.c_str()));
                        }
                        else if (action == '+')
                        {
@@ -196,7 +196,7 @@ class CommandSilence : public Command
                                }
                                if (sl->size() > maxsilence)
                                {
-                                       user->WriteNumeric(952, "%s :Your silence list is full",user->nick.c_str());
+                                       user->WriteNumeric(952, user->nick, "Your silence list is full");
                                        return CMD_FAILURE;
                                }
 
@@ -206,7 +206,7 @@ class CommandSilence : public Command
                                        irc::string listitem = n->first.c_str();
                                        if (listitem == mask && n->second == pattern)
                                        {
-                                               user->WriteNumeric(952, "%s :%s %s is already on your silence list", user->nick.c_str(), mask.c_str(), decomppattern.c_str());
+                                               user->WriteNumeric(952, user->nick, InspIRCd::Format("%s %s is already on your silence list", mask.c_str(), decomppattern.c_str()));
                                                return CMD_FAILURE;
                                        }
                                }
@@ -218,7 +218,7 @@ class CommandSilence : public Command
                                {
                                        sl->push_back(silenceset(mask,pattern));
                                }
-                               user->WriteNumeric(951, "%s :Added %s %s to silence list", user->nick.c_str(), mask.c_str(), decomppattern.c_str());
+                               user->WriteNumeric(951, user->nick, InspIRCd::Format("Added %s %s to silence list", mask.c_str(), decomppattern.c_str()));
                                return CMD_SUCCESS;
                        }
                }
index 7263768443a4f7ab52fa2d9dbf6f6acdd931c360..ade8359ba4a85463ad714e1e7c40243544f553bc 100644 (file)
@@ -127,16 +127,15 @@ void ModuleSpanningTree::ShowLinks(TreeServer* Current, User* user, int hops)
        else if ((Current->Hidden) && (!user->IsOper()))
                return;
 
-       user->WriteNumeric(RPL_LINKS, "%s %s :%d %s",   Current->GetName().c_str(),
-                       (Utils->FlatLinks && (!user->IsOper())) ? ServerInstance->Config->ServerName.c_str() : Parent.c_str(),
-                       (Utils->FlatLinks && (!user->IsOper())) ? 0 : hops,
-                       Current->GetDesc().c_str());
+       user->WriteNumeric(RPL_LINKS, Current->GetName(),
+                       (((Utils->FlatLinks) && (!user->IsOper())) ? ServerInstance->Config->ServerName : Parent),
+                       InspIRCd::Format("%d %s", (((Utils->FlatLinks) && (!user->IsOper())) ? 0 : hops), Current->GetDesc().c_str()));
 }
 
 void ModuleSpanningTree::HandleLinks(const std::vector<std::string>& parameters, User* user)
 {
        ShowLinks(Utils->TreeRoot,user,0);
-       user->WriteNumeric(RPL_ENDOFLINKS, "* :End of /LINKS list.");
+       user->WriteNumeric(RPL_ENDOFLINKS, '*', "End of /LINKS list.");
 }
 
 std::string ModuleSpanningTree::TimeToStr(time_t secs)
@@ -304,11 +303,11 @@ ModResult ModuleSpanningTree::HandleVersion(const std::vector<std::string>& para
                // or the server is a 2.0 server and does not send a full version.
                bool showfull = ((user->IsOper()) && (!found->GetFullVersion().empty()));
                const std::string& Version = (showfull ? found->GetFullVersion() : found->GetVersion());
-               user->WriteNumeric(RPL_VERSION, ":%s", Version.c_str());
+               user->WriteNumeric(RPL_VERSION, Version);
        }
        else
        {
-               user->WriteNumeric(ERR_NOSUCHSERVER, "%s :No such server", parameters[0].c_str());
+               user->WriteNumeric(ERR_NOSUCHSERVER, parameters[0], "No such server");
        }
        return MOD_RES_DENY;
 }
index 612df80f3ef0802b9e8ee04f1d8c83ddf084893f..7ae6c6b4a0203a4ef34be878a0c578e88760cdd3 100644 (file)
@@ -172,7 +172,7 @@ CmdResult CommandMap::Handle(const std::vector<std::string>& parameters, User* u
                TreeServer* s = Utils->FindServerMask(parameters[0]);
                if (!s)
                {
-                       user->WriteNumeric(ERR_NOSUCHSERVER, "%s :No such server", parameters[0].c_str());
+                       user->WriteNumeric(ERR_NOSUCHSERVER, parameters[0], "No such server");
                        return CMD_FAILURE;
                }
 
index 430467dc73319ad810978c2b4841e55d74ab85a5..7f718985436c5ff5af1b3e06da01f811cf5948c2 100644 (file)
@@ -31,8 +31,8 @@ ModResult ModuleSpanningTree::HandleRemoteWhois(const std::vector<std::string>&
        }
        else if (!remote)
        {
-               user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", parameters[1].c_str());
-               user->WriteNumeric(RPL_ENDOFWHOIS, "%s :End of /WHOIS list.", parameters[1].c_str());
+               user->WriteNumeric(Numerics::NoSuchNick(parameters[0]));
+               user->WriteNumeric(RPL_ENDOFWHOIS, parameters[0], "End of /WHOIS list.");
                return MOD_RES_DENY;
        }
        return MOD_RES_PASSTHRU;
index a3b80457927b5aacd6bce3e416328d34f4a9e5c0..01465670a4c1efc6b22ab175f9e8dc18ac3eb9d3 100644 (file)
@@ -50,7 +50,7 @@ CmdResult CommandUID::HandleServer(TreeServer* remoteserver, std::vector<std::st
                // User that the incoming user is colliding with is not fully registered, we force nick change the
                // unregistered user to their uuid and tell them what happened
                collideswith->WriteFrom(collideswith, "NICK %s", collideswith->uuid.c_str());
-               collideswith->WriteNumeric(ERR_NICKNAMEINUSE, "%s :Nickname overruled.", collideswith->nick.c_str());
+               collideswith->WriteNumeric(ERR_NICKNAMEINUSE, collideswith->nick, "Nickname overruled.");
 
                // Clear the bit before calling User::ChangeNick() to make it NOT run the OnUserPostNick() hook
                collideswith->registered &= ~REG_NICK;
index 523d52abbc9cf21a3d2cde83c3f13deace7cc028..ac02908c4e5d887e3bb7907a0da4700dc138beee 100644 (file)
@@ -95,7 +95,7 @@ class CommandSSLInfo : public Command
 
                if ((!target) || (target->registered != REG_ALL))
                {
-                       user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nickname", parameters[0].c_str());
+                       user->WriteNumeric(Numerics::NoSuchNick(parameters[0]));
                        return CMD_FAILURE;
                }
                bool operonlyfp = ServerInstance->Config->ConfValue("sslinfo")->getBool("operonly");
@@ -181,7 +181,7 @@ class ModuleSSLInfo : public Module, public Whois::EventListener
 
                                if (ifo->oper_block->getBool("sslonly") && !cert)
                                {
-                                       user->WriteNumeric(491, ":This oper login requires an SSL connection.");
+                                       user->WriteNumeric(491, "This oper login requires an SSL connection.");
                                        user->CommandFloodPenalty += 10000;
                                        return MOD_RES_DENY;
                                }
@@ -189,7 +189,7 @@ class ModuleSSLInfo : public Module, public Whois::EventListener
                                std::string fingerprint;
                                if (ifo->oper_block->readString("fingerprint", fingerprint) && (!cert || cert->GetFingerprint() != fingerprint))
                                {
-                                       user->WriteNumeric(491, ":This oper login requires a matching SSL certificate fingerprint.");
+                                       user->WriteNumeric(491, "This oper login requires a matching SSL certificate fingerprint.");
                                        user->CommandFloodPenalty += 10000;
                                        return MOD_RES_DENY;
                                }
index 1a596f5e0424b0332b344566e965ef9011132425..e499082ff81f5c821745597ca25744ec5961f573 100644 (file)
@@ -54,7 +54,7 @@ class SSLMode : public ModeHandler
                                                ssl_cert* cert = API->GetCertificate(i->first);
                                                if (!cert && !i->first->server->IsULine())
                                                {
-                                                       source->WriteNumeric(ERR_ALLMUSTSSL, "%s :all members of the channel must be connected via SSL", channel->name.c_str());
+                                                       source->WriteNumeric(ERR_ALLMUSTSSL, channel->name, "all members of the channel must be connected via SSL");
                                                        return MODEACTION_DENY;
                                                }
                                        }
@@ -107,7 +107,7 @@ class ModuleSSLModes : public Module
                        else
                        {
                                // Deny
-                               user->WriteNumeric(489, "%s :Cannot join channel; SSL users only (+z)", cname.c_str());
+                               user->WriteNumeric(489, cname, "Cannot join channel; SSL users only (+z)");
                                return MOD_RES_DENY;
                        }
                }
index 054f9c3344e7ffe46d739bbdf1a8ac88ef9d2327..b3cf5a26319d4772baa645921c0676417340aeeb 100644 (file)
@@ -44,23 +44,23 @@ class CommandStartTLS : public SplitCommand
        {
                if (!ssl)
                {
-                       user->WriteNumeric(ERR_STARTTLS, ":STARTTLS is not enabled");
+                       user->WriteNumeric(ERR_STARTTLS, "STARTTLS is not enabled");
                        return CMD_FAILURE;
                }
 
                if (user->registered == REG_ALL)
                {
-                       user->WriteNumeric(ERR_STARTTLS, ":STARTTLS is not permitted after client registration is complete");
+                       user->WriteNumeric(ERR_STARTTLS, "STARTTLS is not permitted after client registration is complete");
                        return CMD_FAILURE;
                }
 
                if (user->eh.GetIOHook())
                {
-                       user->WriteNumeric(ERR_STARTTLS, ":STARTTLS failure");
+                       user->WriteNumeric(ERR_STARTTLS, "STARTTLS failure");
                        return CMD_FAILURE;
                }
 
-               user->WriteNumeric(RPL_STARTTLS, ":STARTTLS successful, go ahead with TLS handshake");
+               user->WriteNumeric(RPL_STARTTLS, "STARTTLS successful, go ahead with TLS handshake");
                /* We need to flush the write buffer prior to adding the IOHook,
                 * otherwise we'll be sending this line inside the SSL session - which
                 * won't start its handshake until the client gets this line. Currently,
index a623e1553746021fdd53fac731e71140897287ce..b95a847a5cbbd9c99997ea1869decb01dab3f526 100644 (file)
@@ -198,7 +198,7 @@ class ModuleSVSHold : public Module
 
                if (rl)
                {
-                       user->WriteNumeric(ERR_ERRONEUSNICKNAME, "%s :Services reserved nickname: %s", newnick.c_str(), rl->reason.c_str());
+                       user->WriteNumeric(ERR_ERRONEUSNICKNAME, newnick, InspIRCd::Format("Services reserved nickname: %s", rl->reason.c_str()));
                        return MOD_RES_DENY;
                }
 
index 80c7ddd3b13d8054dc5ddc587890c6d02b572489..46d96a9521d60d67446f425a21ef98eff79cda35 100644 (file)
@@ -45,7 +45,7 @@ class CommandSwhois : public Command
 
                if (!dest) // allow setting swhois using SWHOIS before reg
                {
-                       user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", parameters[0].c_str());
+                       user->WriteNumeric(Numerics::NoSuchNick(parameters[0]));
                        return CMD_FAILURE;
                }
 
index 8196d37ba6299a01f509c9ed70279a2a99fcec9c..8a627b9a6c1d9fcd02bae06b23e8dda4b2a6eb72 100644 (file)
@@ -72,14 +72,13 @@ class CommandTban : public Command
                Channel* channel = ServerInstance->FindChan(parameters[0]);
                if (!channel)
                {
-                       user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such channel", parameters[0].c_str());
+                       user->WriteNumeric(Numerics::NoSuchNick(parameters[0]));
                        return CMD_FAILURE;
                }
                int cm = channel->GetPrefixValue(user);
                if (cm < HALFOP_VALUE)
                {
-                       user->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s :You do not have permission to set bans on this channel",
-                               channel->name.c_str());
+                       user->WriteNumeric(ERR_CHANOPRIVSNEEDED, channel->name, "You do not have permission to set bans on this channel");
                        return CMD_FAILURE;
                }
 
index 6053bc849cca9c6ad1c011dca25c9d5801c62653..eba2b33f0760088ce6197b8f256d40b47fcdd402 100644 (file)
@@ -150,7 +150,7 @@ class ModuleTopicLock : public Module
                // Only fired for local users currently, but added a check anyway
                if ((IS_LOCAL(user)) && (topiclock.get(chan)))
                {
-                       user->WriteNumeric(744, "%s :TOPIC cannot be changed due to topic lock being active on the channel", chan->name.c_str());
+                       user->WriteNumeric(744, chan->name, "TOPIC cannot be changed due to topic lock being active on the channel");
                        return MOD_RES_DENY;
                }
 
index e92688d1ddfff17171c06c64b2ce5d54f8ad25c3..94f71d9c180fb0a52a73156b14a4cc708d608d92 100644 (file)
@@ -51,11 +51,11 @@ class CommandUninvite : public Command
                {
                        if (!c)
                        {
-                               user->WriteNumeric(401, "%s :No such nick/channel", parameters[1].c_str());
+                               user->WriteNumeric(Numerics::NoSuchNick(parameters[1]));
                        }
                        else
                        {
-                               user->WriteNumeric(401, "%s :No such nick/channel", parameters[0].c_str());
+                               user->WriteNumeric(Numerics::NoSuchNick(parameters[0]));
                        }
 
                        return CMD_FAILURE;
@@ -65,7 +65,7 @@ class CommandUninvite : public Command
                {
                        if (c->GetPrefixValue(user) < HALFOP_VALUE)
                        {
-                               user->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s :You must be a channel %soperator", c->name.c_str(), c->GetPrefixValue(u) == HALFOP_VALUE ? "" : "half-");
+                               user->WriteNumeric(ERR_CHANOPRIVSNEEDED, c->name, InspIRCd::Format("You must be a channel %soperator", c->GetPrefixValue(u) == HALFOP_VALUE ? "" : "half-"));
                                return CMD_FAILURE;
                        }
                }
@@ -84,7 +84,7 @@ class CommandUninvite : public Command
                        }
 
                        user->SendText(":%s 494 %s %s %s :Uninvited", user->server->GetName().c_str(), user->nick.c_str(), c->name.c_str(), u->nick.c_str());
-                       lu->WriteNumeric(493, ":You were uninvited from %s by %s", c->name.c_str(), user->nick.c_str());
+                       lu->WriteNumeric(493, InspIRCd::Format("You were uninvited from %s by %s", c->name.c_str(), user->nick.c_str()));
 
                        std::string msg = "*** " + user->nick + " uninvited " + u->nick + ".";
                        c->WriteChannelWithServ(ServerInstance->Config->ServerName, "NOTICE " + c->name + " :" + msg);
index 04396739340c2dda7e680d48b06ae45e781ecafe..1b2ce9b1382e4f7580b005f572375331cd8da932 100644 (file)
@@ -52,7 +52,7 @@ class CommandUserip : public Command
                                                checked_privs = true;
                                                has_privs = user->HasPrivPermission("users/auspex");
                                                if (!has_privs)
-                                                       user->WriteNumeric(ERR_NOPRIVILEGES, ":Permission Denied - You do not have the required operator privileges");
+                                                       user->WriteNumeric(ERR_NOPRIVILEGES, "Permission Denied - You do not have the required operator privileges");
                                        }
 
                                        if (!has_privs)
index bdd4b2b15414797720e20ac17fb94f24e73e787b..6e9a6f9ed716be97ee34dcf1953e8214bccce1f1 100644 (file)
@@ -53,12 +53,12 @@ class CommandWatch : public SplitCommand
                {
                        // The away state should only be sent if the client requests away notifications for a nick but 2.0 always sends them so we do that too
                        if (target->IsAway())
-                               user->WriteNumeric(RPL_NOWISAWAY, "%s %s %s %lu :is away", target->nick.c_str(), target->ident.c_str(), target->dhost.c_str(), (unsigned long)target->awaytime);
+                               user->WriteNumeric(RPL_NOWISAWAY, target->nick, target->ident, target->dhost, (unsigned long)target->awaytime, "is away");
                        else
-                               user->WriteNumeric(RPL_NOWON, "%s %s %s %lu :is online", target->nick.c_str(), target->ident.c_str(), target->dhost.c_str(), (unsigned long)target->age);
+                               user->WriteNumeric(RPL_NOWON, target->nick, target->ident, target->dhost, (unsigned long)target->age, "is online");
                }
                else if (show_offline)
-                       user->WriteNumeric(RPL_NOWOFF, "%s * * 0 :is offline", nick.c_str());
+                       user->WriteNumeric(RPL_NOWOFF, nick, "*", "*", "0", "is offline");
        }
 
        void HandlePlus(LocalUser* user, const std::string& nick)
@@ -67,12 +67,12 @@ class CommandWatch : public SplitCommand
                if (result == IRCv3::Monitor::Manager::WR_TOOMANY)
                {
                        // List is full, send error numeric
-                       user->WriteNumeric(ERR_TOOMANYWATCH, "%s :Too many WATCH entries", nick.c_str());
+                       user->WriteNumeric(ERR_TOOMANYWATCH, nick, "Too many WATCH entries");
                        return;
                }
                else if (result == IRCv3::Monitor::Manager::WR_INVALIDNICK)
                {
-                       user->WriteNumeric(942, "%s :Invalid nickname", nick.c_str());
+                       user->WriteNumeric(942, nick, "Invalid nickname");
                        return;
                }
                else if (result != IRCv3::Monitor::Manager::WR_OK)
@@ -88,9 +88,9 @@ class CommandWatch : public SplitCommand
 
                User* target = IRCv3::Monitor::Manager::FindNick(nick);
                if (target)
-                       user->WriteNumeric(RPL_WATCHOFF, "%s %s %s %lu :stopped watching", target->nick.c_str(), target->ident.c_str(), target->dhost.c_str(), (unsigned long)target->age);
+                       user->WriteNumeric(RPL_WATCHOFF, target->nick, target->ident, target->dhost, (unsigned long)target->age, "stopped watching");
                else
-                       user->WriteNumeric(RPL_WATCHOFF, "%s * * 0 :stopped watching", nick.c_str());
+                       user->WriteNumeric(RPL_WATCHOFF, nick, "*", "*", "0", "stopped watching");
        }
 
        void HandleList(LocalUser* user, bool show_offline)
@@ -102,7 +102,7 @@ class CommandWatch : public SplitCommand
                        const IRCv3::Monitor::Entry* entry = *i;
                        SendOnlineOffline(user, entry->GetNick(), show_offline);
                }
-               user->WriteNumeric(RPL_ENDOFWATCHLIST, ":End of WATCH list");
+               user->WriteNumeric(RPL_ENDOFWATCHLIST, "End of WATCH list");
        }
 
        void HandleStats(LocalUser* user)
@@ -111,7 +111,7 @@ class CommandWatch : public SplitCommand
 
                // Do not show how many clients are watching this nick, it's pointless
                const IRCv3::Monitor::WatchedList& list = manager.GetWatched(user);
-               user->WriteNumeric(RPL_WATCHSTAT, ":You have %lu and are on 0 WATCH entries", (unsigned long)list.size());
+               user->WriteNumeric(RPL_WATCHSTAT, InspIRCd::Format("You have %lu and are on 0 WATCH entries", (unsigned long)list.size()));
 
                Numeric::Builder<' '> out(user, RPL_WATCHLIST);
                for (IRCv3::Monitor::WatchedList::const_iterator i = list.begin(); i != list.end(); ++i)
@@ -120,7 +120,7 @@ class CommandWatch : public SplitCommand
                        out.Add(entry->GetNick());
                }
                out.Flush();
-               user->WriteNumeric(RPL_ENDOFWATCHLIST, ":End of WATCH S");
+               user->WriteNumeric(RPL_ENDOFWATCHLIST, "End of WATCH S");
        }
 
  public:
@@ -189,11 +189,12 @@ class ModuleWatch : public Module
                if (!list)
                        return;
 
-               std::string text = InspIRCd::Format("%s %s %s %lu :%s", nick.c_str(), user->ident.c_str(), user->dhost.c_str(), (unsigned long) shownts, numerictext);
+               Numeric::Numeric num(numeric);
+               num.push(nick).push(user->ident).push(user->dhost).push(ConvToStr(shownts)).push(numerictext);
                for (IRCv3::Monitor::WatcherList::const_iterator i = list->begin(); i != list->end(); ++i)
                {
                        LocalUser* curr = *i;
-                       curr->WriteNumeric(numeric, text);
+                       curr->WriteNumeric(num);
                }
        }
 
index 191a3d30ffd21812a8a0e596ac3399ddd34ea4df..f22cf1ad4a168f275a9c1d5e96a6debaea771616 100644 (file)
@@ -194,35 +194,34 @@ void ISupportManager::Build()
        }
 
        // Transform the map into a list of lines, ready to be sent to clients
-       std::string line;
+       Numeric::Numeric numeric(RPL_ISUPPORT);
        unsigned int token_count = 0;
        cachedlines.clear();
 
        for (std::map<std::string, std::string>::const_iterator it = tokens.begin(); it != tokens.end(); ++it)
        {
-               line.append(it->first);
+               numeric.push(it->first);
+               std::string& token = numeric.GetParams().back();
 
                // If this token has a value then append a '=' char after the name and then the value itself
                if (!it->second.empty())
-                       line.append(1, '=').append(it->second);
+                       token.append(1, '=').append(it->second);
 
-               // Always append a space, even if it's the last token because all lines will be suffixed
-               line.push_back(' ');
                token_count++;
 
                if (token_count % 13 == 12 || it == --tokens.end())
                {
                        // Reached maximum number of tokens for this line or the current token
                        // is the last one; finalize the line and store it for later use
-                       line.append(":are supported by this server");
-                       cachedlines.push_back(line);
-                       line.clear();
+                       numeric.push("are supported by this server");
+                       cachedlines.push_back(numeric);
+                       numeric.GetParams().clear();
                }
        }
 }
 
 void ISupportManager::SendTo(LocalUser* user)
 {
-       for (std::vector<std::string>::const_iterator i = cachedlines.begin(); i != cachedlines.end(); ++i)
-               user->WriteNumeric(RPL_ISUPPORT, *i);
+       for (std::vector<Numeric::Numeric>::const_iterator i = cachedlines.begin(); i != cachedlines.end(); ++i)
+               user->WriteNumeric(*i);
 }
index ba6bbf36bb8e6a96bd1a2a3c6bd82211df21bf9d..fe052fcfc90f517c477772e8849f8aa15b8acb37 100644 (file)
@@ -127,7 +127,7 @@ void UserManager::AddUser(int socket, ListenSocket* via, irc::sockets::sockaddrs
                        /* user banned */
                        ServerInstance->Logs->Log("BANCACHE", LOG_DEBUG, "BanCache: Positive hit for " + New->GetIPString());
                        if (!ServerInstance->Config->XLineMessage.empty())
-                               New->WriteNumeric(ERR_YOUREBANNEDCREEP, ":" + ServerInstance->Config->XLineMessage);
+                               New->WriteNumeric(ERR_YOUREBANNEDCREEP, ServerInstance->Config->XLineMessage);
                        this->QuitUser(New, b->Reason);
                        return;
                }
index 915afd8b8157becaeaec827590d1e5c9b3682f7b..b6fbc38a0927700c2d91b799026af0a9834fc3a6 100644 (file)
@@ -348,7 +348,7 @@ void User::Oper(OperInfo* info)
 
        ServerInstance->SNO->WriteToSnoMask('o',"%s (%s@%s) is now an IRC operator of type %s (using oper '%s')",
                nick.c_str(), ident.c_str(), host.c_str(), oper->name.c_str(), opername.c_str());
-       this->WriteNumeric(RPL_YOUAREOPER, ":You are now %s %s", strchr("aeiouAEIOU", oper->name[0]) ? "an" : "a", oper->name.c_str());
+       this->WriteNumeric(RPL_YOUAREOPER, InspIRCd::Format("You are now %s %s", strchr("aeiouAEIOU", oper->name[0]) ? "an" : "a", oper->name.c_str()));
 
        ServerInstance->Logs->Log("OPER", LOG_DEFAULT, "%s opered as type: %s", GetFullRealHost().c_str(), oper->name.c_str());
        ServerInstance->Users->all_opers.push_back(this);
@@ -524,12 +524,12 @@ void LocalUser::FullConnect()
        if (quitting)
                return;
 
-       this->WriteNumeric(RPL_WELCOME, ":Welcome to the %s IRC Network %s", ServerInstance->Config->Network.c_str(), GetFullRealHost().c_str());
-       this->WriteNumeric(RPL_YOURHOSTIS, ":Your host is %s, running version %s", ServerInstance->Config->ServerName.c_str(), INSPIRCD_BRANCH);
-       this->WriteNumeric(RPL_SERVERCREATED, ":This server was created %s %s", __TIME__, __DATE__);
+       this->WriteNumeric(RPL_WELCOME, InspIRCd::Format("Welcome to the %s IRC Network %s", ServerInstance->Config->Network.c_str(), GetFullRealHost().c_str()));
+       this->WriteNumeric(RPL_YOURHOSTIS, InspIRCd::Format("Your host is %s, running version %s", ServerInstance->Config->ServerName.c_str(), INSPIRCD_BRANCH));
+       this->WriteNumeric(RPL_SERVERCREATED, InspIRCd::Format("This server was created %s %s", __TIME__, __DATE__));
 
        const std::string& modelist = ServerInstance->Modes->GetModeListFor004Numeric();
-       this->WriteNumeric(RPL_SERVERVERSION, "%s %s %s", ServerInstance->Config->ServerName.c_str(), INSPIRCD_BRANCH, modelist.c_str());
+       this->WriteNumeric(RPL_SERVERVERSION, ServerInstance->Config->ServerName, INSPIRCD_BRANCH, modelist);
 
        ServerInstance->ISupport.SendTo(this);
 
@@ -615,7 +615,7 @@ bool User::ChangeNick(const std::string& newnick, time_t newts)
                        {
                                /* force the camper to their UUID, and ask them to re-send a NICK. */
                                InUse->WriteFrom(InUse, "NICK %s", InUse->uuid.c_str());
-                               InUse->WriteNumeric(ERR_NICKNAMEINUSE, "%s :Nickname overruled.", InUse->nick.c_str());
+                               InUse->WriteNumeric(ERR_NICKNAMEINUSE, InUse->nick, "Nickname overruled.");
 
                                InUse->registered &= ~REG_NICK;
                                InUse->ChangeNick(InUse->uuid);
@@ -623,7 +623,7 @@ bool User::ChangeNick(const std::string& newnick, time_t newts)
                        else
                        {
                                /* No camping, tell the incoming user  to stop trying to change nick ;p */
-                               this->WriteNumeric(ERR_NICKNAMEINUSE, "%s :Nickname is already in use.", newnick.c_str());
+                               this->WriteNumeric(ERR_NICKNAMEINUSE, newnick, "Nickname is already in use.");
                                return false;
                        }
                }
@@ -802,25 +802,16 @@ namespace
        }
 }
 
-void User::WriteNumeric(unsigned int numeric, const char* text, ...)
-{
-       std::string textbuffer;
-       VAFORMAT(textbuffer, text, text);
-       this->WriteNumeric(numeric, textbuffer);
-}
-
-void User::WriteNumeric(unsigned int numeric, const std::string &text)
+void User::WriteNumeric(const Numeric::Numeric& numeric)
 {
        ModResult MOD_RESULT;
 
-       FIRST_MOD_RESULT(OnNumeric, MOD_RESULT, (this, numeric, text));
+       FIRST_MOD_RESULT(OnNumeric, MOD_RESULT, (this, numeric));
 
        if (MOD_RESULT == MOD_RES_DENY)
                return;
 
-       const std::string message = InspIRCd::Format(":%s %03u %s %s", ServerInstance->Config->ServerName.c_str(),
-               numeric, this->registered & REG_NICK ? this->nick.c_str() : "*", text.c_str());
-       this->Write(message);
+       this->Write(BuildNumeric(ServerInstance->Config->ServerName, this, numeric.GetNumeric(), numeric.GetParams()));
 }
 
 void User::WriteFrom(User *user, const std::string &text)
@@ -1026,7 +1017,7 @@ bool User::ChangeDisplayedHost(const std::string& shost)
        this->InvalidateCache();
 
        if (IS_LOCAL(this))
-               this->WriteNumeric(RPL_YOURDISPLAYEDHOST, "%s :is now your displayed host", this->dhost.c_str());
+               this->WriteNumeric(RPL_YOURDISPLAYEDHOST, this->dhost, "is now your displayed host");
 
        return true;
 }
index dedf8c7a9c917a4c838ee31acce445d0eab3a57a..003d77e80ef4facc76d73b42c6b25c3d5e15c417 100644 (file)
@@ -531,7 +531,7 @@ void XLine::DefaultApply(User* u, const std::string &line, bool bancache)
        const std::string banReason = line + "-Lined: " + reason;
 
        if (!ServerInstance->Config->XLineMessage.empty())
-               u->WriteNumeric(ERR_YOUREBANNEDCREEP, ":" + ServerInstance->Config->XLineMessage);
+               u->WriteNumeric(ERR_YOUREBANNEDCREEP, ServerInstance->Config->XLineMessage);
 
        if (ServerInstance->Config->HideBans)
                ServerInstance->Users->QuitUser(u, line + "-Lined", &banReason);