diff --git a/include/protocol.h b/include/protocol.h index 73373f881..4c9f5afd0 100644 --- a/include/protocol.h +++ b/include/protocol.h @@ -30,13 +30,8 @@ public: virtual ~IRCDProto(); - virtual void SendSVSKillInternal(const MessageSource &, User *, const Anope::string &); - virtual void SendKickInternal(const MessageSource &, const Channel *, User *, const Anope::string &); virtual void SendNoticeInternal(const MessageSource &, const Anope::string &dest, const Anope::string &msg, const Anope::map &tags = {}); virtual void SendPrivmsgInternal(const MessageSource &, const Anope::string &dest, const Anope::string &msg, const Anope::map &tags = {}); - virtual void SendQuitInternal(User *, const Anope::string &buf); - virtual void SendPartInternal(User *, const Channel *chan, const Anope::string &buf); - virtual void SendGlobopsInternal(const MessageSource &, const Anope::string &buf); virtual void SendCTCPInternal(const MessageSource &, const Anope::string &dest, const Anope::string &buf); /** Parses an incoming message from the IRC server. @@ -158,9 +153,9 @@ public: /** Kills a user * @param source Who is doing the kill * @param user The user to be killed - * @param fmt Kill reason + * @param msg Kill reason */ - virtual void SendSVSKill(const MessageSource &source, User *user, const char *fmt, ...) ATTR_FORMAT(4, 5); + virtual void SendSVSKill(const MessageSource &source, User *user, const Anope::string &msg); virtual void SendModeInternal(const MessageSource &source, Channel *chan, const Anope::string &modes, const std::vector &values); template @@ -181,7 +176,7 @@ public: */ virtual void SendClientIntroduction(User *u) = 0; - virtual void SendKick(const MessageSource &source, const Channel *chan, User *user, const char *fmt, ...) ATTR_FORMAT(5, 6); + virtual void SendKick(const MessageSource &source, const Channel *chan, User *user, const Anope::string &msg); virtual void SendNotice(const MessageSource &source, const Anope::string &dest, const char *fmt, ...) ATTR_FORMAT(4, 5); virtual void SendPrivmsg(const MessageSource &source, const Anope::string &dest, const char *fmt, ...) ATTR_FORMAT(4, 5); @@ -194,7 +189,7 @@ public: virtual void SendContextNotice(BotInfo *bi, User *target, Channel *context, const Anope::string &msg); virtual void SendContextPrivmsg(BotInfo *bi, User *target, Channel *context, const Anope::string &msg); - virtual void SendQuit(User *u, const char *fmt, ...) ATTR_FORMAT(3, 4); + virtual void SendQuit(User *u, const Anope::string &msg); virtual void SendPing(const Anope::string &servname, const Anope::string &who); virtual void SendPong(const Anope::string &servname, const Anope::string &who); @@ -206,7 +201,7 @@ public: * stacker to be set "soon". */ virtual void SendJoin(User *u, Channel *c, const ChannelStatus *status) = 0; - virtual void SendPart(User *u, const Channel *chan, const char *fmt, ...) ATTR_FORMAT(4, 5); + virtual void SendPart(User *u, const Channel *chan, const Anope::string &msg); /** Force joins a user that isn't ours to a channel. * @param bi The source of the message @@ -225,7 +220,7 @@ public: virtual void SendSVSPart(const MessageSource &source, User *u, const Anope::string &chan, const Anope::string ¶m) { } virtual void SendInvite(const MessageSource &source, const Channel *c, User *u); - virtual void SendGlobops(const MessageSource &source, const char *fmt, ...) ATTR_FORMAT(3, 4); + virtual void SendGlobops(const MessageSource &source, const Anope::string &msg); /** Sends a nick change of one of our clients. */ diff --git a/modules/protocol/bahamut.cpp b/modules/protocol/bahamut.cpp index e9a5ac163..f8d7f3dc4 100644 --- a/modules/protocol/bahamut.cpp +++ b/modules/protocol/bahamut.cpp @@ -235,7 +235,7 @@ public: /* Note: if the stamp is null 0, the below usage is correct of Bahamut */ - void SendSVSKillInternal(const MessageSource &source, User *user, const Anope::string &buf) override + void SendSVSKill(const MessageSource &source, User *user, const Anope::string &buf) override { Uplink::Send(source, "SVSKILL", user->nick, buf); } diff --git a/modules/protocol/hybrid.cpp b/modules/protocol/hybrid.cpp index c859ae98f..ed86b29f7 100644 --- a/modules/protocol/hybrid.cpp +++ b/modules/protocol/hybrid.cpp @@ -18,9 +18,9 @@ static bool UseSVSAccount = false; // Temporary backwards compatibility hack un class HybridProto final : public IRCDProto { - void SendSVSKillInternal(const MessageSource &source, User *u, const Anope::string &buf) override + void SendSVSKill(const MessageSource &source, User *u, const Anope::string &buf) override { - IRCDProto::SendSVSKillInternal(source, u, buf); + IRCDProto::SendSVSKill(source, u, buf); u->KillInternal(source, buf); } diff --git a/modules/protocol/inspircd.cpp b/modules/protocol/inspircd.cpp index 2bb88ae8e..af6968048 100644 --- a/modules/protocol/inspircd.cpp +++ b/modules/protocol/inspircd.cpp @@ -173,9 +173,9 @@ public: Uplink::Send("METADATA", "*", "saslmechlist", mechanisms.empty() ? "" : mechlist.substr(1)); } - void SendSVSKillInternal(const MessageSource &source, User *user, const Anope::string &buf) override + void SendSVSKill(const MessageSource &source, User *user, const Anope::string &buf) override { - IRCDProto::SendSVSKillInternal(source, user, buf); + IRCDProto::SendSVSKill(source, user, buf); user->KillInternal(source, buf); } @@ -495,7 +495,7 @@ public: Uplink::Send("ENDBURST"); } - void SendGlobopsInternal(const MessageSource &source, const Anope::string &buf) override + void SendGlobops(const MessageSource &source, const Anope::string &buf) override { if (Servers::Capab.count("GLOBOPS")) Uplink::Send(source, "SNONOTICE", 'g', buf); diff --git a/modules/protocol/ngircd.cpp b/modules/protocol/ngircd.cpp index dacf68d57..5d65f49ab 100644 --- a/modules/protocol/ngircd.cpp +++ b/modules/protocol/ngircd.cpp @@ -19,9 +19,9 @@ namespace class ngIRCdProto final : public IRCDProto { - void SendSVSKillInternal(const MessageSource &source, User *user, const Anope::string &buf) override + void SendSVSKill(const MessageSource &source, User *user, const Anope::string &buf) override { - IRCDProto::SendSVSKillInternal(source, user, buf); + IRCDProto::SendSVSKill(source, user, buf); user->KillInternal(source, buf); } @@ -90,7 +90,7 @@ public: Uplink::Send(bi, "PRIVMSG", "$" + dest->GetName(), msg); } - void SendGlobopsInternal(const MessageSource &source, const Anope::string &buf) override + void SendGlobops(const MessageSource &source, const Anope::string &buf) override { Uplink::Send(source, "WALLOPS", buf); } diff --git a/modules/protocol/plexus.cpp b/modules/protocol/plexus.cpp index fe0d37e22..7e3a7a2e6 100644 --- a/modules/protocol/plexus.cpp +++ b/modules/protocol/plexus.cpp @@ -36,7 +36,7 @@ public: MaxModes = 4; } - void SendSVSKillInternal(const MessageSource &source, User *targ, const Anope::string &reason) override { hybrid->SendSVSKillInternal(source, targ, reason); } + void SendSVSKill(const MessageSource &source, User *targ, const Anope::string &reason) override { hybrid->SendSVSKill(source, targ, reason); } void SendGlobalNotice(BotInfo *bi, const Server *dest, const Anope::string &msg) override { hybrid->SendGlobalNotice(bi, dest, msg); } void SendGlobalPrivmsg(BotInfo *bi, const Server *dest, const Anope::string &msg) override { hybrid->SendGlobalPrivmsg(bi, dest, msg); } void SendSQLine(User *u, const XLine *x) override { hybrid->SendSQLine(u, x); } @@ -50,7 +50,7 @@ public: void SendSVSHold(const Anope::string &nick, time_t t) override { hybrid->SendSVSHold(nick, t); } void SendSVSHoldDel(const Anope::string &nick) override { hybrid->SendSVSHoldDel(nick); } - void SendGlobopsInternal(const MessageSource &source, const Anope::string &buf) override + void SendGlobops(const MessageSource &source, const Anope::string &buf) override { Uplink::Send(source, "OPERWALL", buf); } diff --git a/modules/protocol/ratbox.cpp b/modules/protocol/ratbox.cpp index c720c07cc..dc2da1161 100644 --- a/modules/protocol/ratbox.cpp +++ b/modules/protocol/ratbox.cpp @@ -44,7 +44,7 @@ public: MaxModes = 4; } - void SendSVSKillInternal(const MessageSource &source, User *targ, const Anope::string &reason) override { hybrid->SendSVSKillInternal(source, targ, reason); } + void SendSVSKill(const MessageSource &source, User *targ, const Anope::string &reason) override { hybrid->SendSVSKill(source, targ, reason); } void SendGlobalNotice(BotInfo *bi, const Server *dest, const Anope::string &msg) override { hybrid->SendGlobalNotice(bi, dest, msg); } void SendGlobalPrivmsg(BotInfo *bi, const Server *dest, const Anope::string &msg) override { hybrid->SendGlobalPrivmsg(bi, dest, msg); } void SendSGLine(User *u, const XLine *x) override { hybrid->SendSGLine(u, x); } @@ -57,7 +57,7 @@ public: void SendChannel(Channel *c) override { hybrid->SendChannel(c); } bool IsIdentValid(const Anope::string &ident) override { return hybrid->IsIdentValid(ident); } - void SendGlobopsInternal(const MessageSource &source, const Anope::string &buf) override + void SendGlobops(const MessageSource &source, const Anope::string &buf) override { Uplink::Send(source, "OPERWALL", buf); } diff --git a/modules/protocol/solanum.cpp b/modules/protocol/solanum.cpp index ac0ebd8fa..4b70965f2 100644 --- a/modules/protocol/solanum.cpp +++ b/modules/protocol/solanum.cpp @@ -51,10 +51,10 @@ public: MaxModes = 4; } - void SendSVSKillInternal(const MessageSource &source, User *targ, const Anope::string &reason) override { ratbox->SendSVSKillInternal(source, targ, reason); } + void SendSVSKill(const MessageSource &source, User *targ, const Anope::string &reason) override { ratbox->SendSVSKill(source, targ, reason); } void SendGlobalNotice(BotInfo *bi, const Server *dest, const Anope::string &msg) override { ratbox->SendGlobalNotice(bi, dest, msg); } void SendGlobalPrivmsg(BotInfo *bi, const Server *dest, const Anope::string &msg) override { ratbox->SendGlobalPrivmsg(bi, dest, msg); } - void SendGlobopsInternal(const MessageSource &source, const Anope::string &buf) override { ratbox->SendGlobopsInternal(source, buf); } + void SendGlobops(const MessageSource &source, const Anope::string &buf) override { ratbox->SendGlobops(source, buf); } void SendSGLine(User *u, const XLine *x) override { ratbox->SendSGLine(u, x); } void SendSGLineDel(const XLine *x) override { ratbox->SendSGLineDel(x); } void SendAkill(User *u, XLine *x) override { ratbox->SendAkill(u, x); } diff --git a/modules/protocol/unrealircd.cpp b/modules/protocol/unrealircd.cpp index 22c1d4734..c75cd3b2f 100644 --- a/modules/protocol/unrealircd.cpp +++ b/modules/protocol/unrealircd.cpp @@ -128,7 +128,7 @@ private: Uplink::Send("TKL", '+', 'G', x->GetUser(), x->GetHost(), x->by, x->expires, x->created, x->GetReason()); } - void SendSVSKillInternal(const MessageSource &source, User *user, const Anope::string &buf) override + void SendSVSKill(const MessageSource &source, User *user, const Anope::string &buf) override { Uplink::Send(source, "SVSKILL", user->GetUID(), buf); user->KillInternal(source, buf); @@ -313,7 +313,7 @@ private: Uplink::Send("SVSPART", user->GetUID(), chan); } - void SendGlobopsInternal(const MessageSource &source, const Anope::string &buf) override + void SendGlobops(const MessageSource &source, const Anope::string &buf) override { Uplink::Send("SENDUMODE", 'o', "From " + source.GetName() + ": " < buf); } diff --git a/src/bots.cpp b/src/bots.cpp index ecccafe16..32b0546e6 100644 --- a/src/bots.cpp +++ b/src/bots.cpp @@ -216,7 +216,7 @@ void BotInfo::Part(Channel *c, const Anope::string &reason) FOREACH_MOD(OnPrePartChannel, (this, c)); - IRCD->SendPart(this, c, "%s", !reason.empty() ? reason.c_str() : ""); + IRCD->SendPart(this, c, reason); c->DeleteUser(this); diff --git a/src/channels.cpp b/src/channels.cpp index 8a3248183..babe5c69c 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -799,7 +799,7 @@ bool Channel::Kick(BotInfo *bi, User *u, const Anope::string &reason) FOREACH_RESULT(OnBotKick, MOD_RESULT, (bi, this, u, reason)); if (MOD_RESULT == EVENT_STOP) return false; - IRCD->SendKick(bi, this, u, "%s", reason.c_str()); + IRCD->SendKick(bi, this, u, reason); this->KickInternal(bi, u->nick, reason); return true; } diff --git a/src/logger.cpp b/src/logger.cpp index ebd14c0eb..1b8fe04f4 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -380,7 +380,7 @@ void LogInfo::ProcessMessage(const Log *l) if (!bi) bi = this->bot; if (bi) - IRCD->SendGlobops(bi, "%s", buffer.c_str()); + IRCD->SendGlobops(bi, buffer); } } } diff --git a/src/protocol.cpp b/src/protocol.cpp index 920e0662b..091157d8e 100644 --- a/src/protocol.cpp +++ b/src/protocol.cpp @@ -90,7 +90,7 @@ void IRCDProto::SendKill(const MessageSource &source, const Anope::string &targe Uplink::Send(source, "KILL", target, reason); } -void IRCDProto::SendSVSKillInternal(const MessageSource &source, User *user, const Anope::string &buf) +void IRCDProto::SendSVSKill(const MessageSource &source, User *user, const Anope::string &buf) { Uplink::Send(source, "KILL", user->GetUID(), buf); } @@ -109,7 +109,7 @@ void IRCDProto::SendModeInternal(const MessageSource &source, User *dest, const Uplink::SendInternal({}, source, "MODE", params); } -void IRCDProto::SendKickInternal(const MessageSource &source, const Channel *c, User *u, const Anope::string &r) +void IRCDProto::SendKick(const MessageSource &source, const Channel *c, User *u, const Anope::string &r) { if (!r.empty()) Uplink::Send(source, "KICK", c->name, u->GetUID(), r); @@ -127,7 +127,7 @@ void IRCDProto::SendPrivmsgInternal(const MessageSource &source, const Anope::st Uplink::Send(tags, source, "PRIVMSG", dest, msg); } -void IRCDProto::SendQuitInternal(User *u, const Anope::string &buf) +void IRCDProto::SendQuit(User *u, const Anope::string &buf) { if (!buf.empty()) Uplink::Send(u, "QUIT", buf); @@ -135,7 +135,7 @@ void IRCDProto::SendQuitInternal(User *u, const Anope::string &buf) Uplink::Send(u, "QUIT"); } -void IRCDProto::SendPartInternal(User *u, const Channel *chan, const Anope::string &buf) +void IRCDProto::SendPart(User *u, const Channel *chan, const Anope::string &buf) { if (!buf.empty()) Uplink::Send(u, "PART", chan->name, buf); @@ -143,7 +143,7 @@ void IRCDProto::SendPartInternal(User *u, const Channel *chan, const Anope::stri Uplink::Send(u, "PART", chan->name); } -void IRCDProto::SendGlobopsInternal(const MessageSource &source, const Anope::string &message) +void IRCDProto::SendGlobops(const MessageSource &source, const Anope::string &message) { Uplink::Send(source, "GLOBOPS", message); } @@ -172,32 +172,6 @@ void IRCDProto::SendTopic(const MessageSource &source, Channel *c) Uplink::Send(source, "TOPIC", c->name, c->topic); } -void IRCDProto::SendSVSKill(const MessageSource &source, User *user, const char *fmt, ...) -{ - if (!user || !fmt) - return; - - va_list args; - char buf[BUFSIZE] = ""; - va_start(args, fmt); - vsnprintf(buf, BUFSIZE - 1, fmt, args); - va_end(args); - SendSVSKillInternal(source, user, buf); -} - -void IRCDProto::SendKick(const MessageSource &source, const Channel *chan, User *user, const char *fmt, ...) -{ - if (!chan || !user) - return; - - va_list args; - char buf[BUFSIZE] = ""; - va_start(args, fmt); - vsnprintf(buf, BUFSIZE - 1, fmt, args); - va_end(args); - SendKickInternal(source, chan, user, buf); -} - void IRCDProto::SendNotice(const MessageSource &source, const Anope::string &dest, const char *fmt, ...) { va_list args; @@ -229,16 +203,6 @@ void IRCDProto::SendPrivmsg(const MessageSource &source, const Anope::string &de SendPrivmsgInternal(source, dest, buf); } -void IRCDProto::SendQuit(User *u, const char *fmt, ...) -{ - va_list args; - char buf[BUFSIZE] = ""; - va_start(args, fmt); - vsnprintf(buf, BUFSIZE - 1, fmt, args); - va_end(args); - SendQuitInternal(u, buf); -} - void IRCDProto::SendPing(const Anope::string &servname, const Anope::string &who) { if (servname.empty()) @@ -266,31 +230,6 @@ void IRCDProto::SendInvite(const MessageSource &source, const Channel *c, User * Uplink::Send(source, "INVITE", u->GetUID(), c->name); } -void IRCDProto::SendPart(User *user, const Channel *chan, const char *fmt, ...) -{ - if (fmt) - { - va_list args; - char buf[BUFSIZE] = ""; - va_start(args, fmt); - vsnprintf(buf, BUFSIZE - 1, fmt, args); - va_end(args); - SendPartInternal(user, chan, buf); - } - else - SendPartInternal(user, chan, ""); -} - -void IRCDProto::SendGlobops(const MessageSource &source, const char *fmt, ...) -{ - va_list args; - char buf[BUFSIZE] = ""; - va_start(args, fmt); - vsnprintf(buf, BUFSIZE - 1, fmt, args); - va_end(args); - SendGlobopsInternal(source, buf); -} - void IRCDProto::SendSquit(Server *s, const Anope::string &message) { Uplink::Send("SQUIT", s->GetSID(), message); diff --git a/src/users.cpp b/src/users.cpp index f2bf55e88..7761cb5c7 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -93,7 +93,7 @@ static void CollideKill(User *target, const Anope::string &reason) else { // Be sure my user is really dead - IRCD->SendQuit(target, "%s", reason.c_str()); + IRCD->SendQuit(target, reason); // Reintroduce my client if (BotInfo *bi = dynamic_cast(target)) @@ -770,7 +770,7 @@ void User::Kill(const MessageSource &source, const Anope::string &reason) { Anope::string real_reason = source.GetName() + " (" + reason + ")"; - IRCD->SendSVSKill(source, this, "%s", real_reason.c_str()); + IRCD->SendSVSKill(source, this, real_reason); } void User::KillInternal(const MessageSource &source, const Anope::string &reason)