summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2016-12-06 21:02:48 -0500
committerAdam <Adam@anope.org>2016-12-06 21:02:48 -0500
commit87ec095a89bbc73a4dd16858bea499f466066212 (patch)
tree776129c883242ae6b6c27884b128a336b801999b /src
parent1ff4719ea70cfead41bd91d7b78cfdcb5b84b8cc (diff)
Remove many more old C style format strings in the protocol functions
Diffstat (limited to 'src')
-rw-r--r--src/bots.cpp2
-rw-r--r--src/channels.cpp2
-rw-r--r--src/init.cpp6
-rw-r--r--src/logger.cpp4
-rw-r--r--src/misc.cpp28
-rw-r--r--src/modes.cpp6
-rw-r--r--src/process.cpp2
-rw-r--r--src/protocol.cpp190
-rw-r--r--src/users.cpp12
9 files changed, 60 insertions, 192 deletions
diff --git a/src/bots.cpp b/src/bots.cpp
index 2ba7bda67..091caa12f 100644
--- a/src/bots.cpp
+++ b/src/bots.cpp
@@ -178,7 +178,7 @@ void ServiceBot::Part(Channel *c, const Anope::string &reason)
EventManager::Get()->Dispatch(&Event::PrePartChannel::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 98ecfe127..53c5ae81b 100644
--- a/src/channels.cpp
+++ b/src/channels.cpp
@@ -773,7 +773,7 @@ bool Channel::Kick(User *source, User *u, const char *reason, ...)
if (!this->KickInternal(source, u->nick, buf))
return false;
- IRCD->SendKick(source, this, u, "%s", buf);
+ IRCD->SendKick(source, this, u, buf);
return true;
}
diff --git a/src/init.cpp b/src/init.cpp
index 0967baa33..8bd6683b9 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -303,13 +303,13 @@ void Anope::Init(int ac, char **av)
if (GetCommandLineArgument("version", 'v'))
{
- Log(LOG_TERMINAL) << "Anope-" << Anope::Version() << " -- " << Anope::VersionBuildString();
+ Log(LOG_TERMINAL) << "Anope-" << Anope::Version() << " -- Built: " << Anope::VersionBuildTime() << " -- Flags: " << Anope::VersionFlags();
throw CoreException();
}
if (GetCommandLineArgument("help", 'h'))
{
- Log(LOG_TERMINAL) << "Anope-" << Anope::Version() << " -- " << Anope::VersionBuildString();
+ Log(LOG_TERMINAL) << "Anope-" << Anope::Version();
Log(LOG_TERMINAL) << "Anope IRC Services (http://www.anope.org)";
Log(LOG_TERMINAL) << "Usage ./" << Anope::ServicesBin << " [options] ...";
Log(LOG_TERMINAL) << "-c, --config=filename.conf";
@@ -417,7 +417,7 @@ void Anope::Init(int ac, char **av)
throw CoreException("Unable to chdir to " + Anope::ServicesDir + ": " + Anope::LastError());
}
- Log(LOG_TERMINAL) << "Anope " << Anope::Version() << ", " << Anope::VersionBuildString();
+ Log(LOG_TERMINAL) << "Anope-" << Anope::Version() << " -- Built: " << Anope::VersionBuildTime() << " -- Flags: " << Anope::VersionFlags();
#ifdef _WIN32
if (!SupportedWindowsVersion())
diff --git a/src/logger.cpp b/src/logger.cpp
index 0d379e568..4949860a3 100644
--- a/src/logger.cpp
+++ b/src/logger.cpp
@@ -383,14 +383,14 @@ void LogInfo::ProcessMessage(const Log *l)
if (!bi)
bi = c->ci->WhoSends();
if (bi)
- IRCD->SendPrivmsg(bi, c->name, "%s", buffer.c_str());
+ IRCD->SendPrivmsg(bi, c->name, buffer);
}
}
else if (target == "globops")
{
if (UplinkSock && l->bi && l->type <= LOG_NORMAL && Me && Me->IsSynced())
{
- IRCD->SendGlobops(l->bi, "%s", buffer.c_str());
+ IRCD->SendGlobops(l->bi, buffer);
}
}
}
diff --git a/src/misc.cpp b/src/misc.cpp
index 3b044d9fa..863bca2b7 100644
--- a/src/misc.cpp
+++ b/src/misc.cpp
@@ -579,40 +579,44 @@ const Anope::string Anope::LastError()
Anope::string Anope::Version()
{
#ifdef VERSION_GIT
- return stringify(VERSION_MAJOR) + "." + stringify(VERSION_MINOR) + "." + stringify(VERSION_PATCH) + VERSION_EXTRA + " (" + VERSION_GIT + ")";
+ return Anope::Format("{0}.{1}.{2}{3}-{4}", VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH, VERSION_EXTRA, VERSION_GIT);
#else
- return stringify(VERSION_MAJOR) + "." + stringify(VERSION_MINOR) + "." + stringify(VERSION_PATCH) + VERSION_EXTRA;
+ return Anope::Format("{0}.{1}.{2}{3}", VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH, VERSION_EXTRA);
#endif
}
Anope::string Anope::VersionShort()
{
- return stringify(VERSION_MAJOR) + "." + stringify(VERSION_MINOR) + "." + stringify(VERSION_PATCH);
+ return Anope::Format("{0}.{1}.{2}", VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH);
}
-Anope::string Anope::VersionBuildString()
+Anope::string Anope::VersionBuildTime()
{
#ifdef REPRODUCIBLE_BUILD
- Anope::string s = "build #" + stringify(BUILD);
+ return "unknown";
#else
- Anope::string s = "build #" + stringify(BUILD) + ", compiled " + Anope::compiled;
+ return Anope::COMPILED;
#endif
+}
+
+Anope::string Anope::VersionFlags()
+{
Anope::string flags;
#ifdef DEBUG_BUILD
- flags += "D";
+ flags.append('D');
#endif
#ifdef VERSION_GIT
- flags += "G";
+ flags.append('G');
#endif
#ifdef _WIN32
- flags += "W";
+ flags.append('W');
#endif
- if (!flags.empty())
- s += ", flags " + flags;
+ if (flags.empty())
+ flags = "none";
- return s;
+ return flags;
}
int Anope::VersionMajor() { return VERSION_MAJOR; }
diff --git a/src/modes.cpp b/src/modes.cpp
index b41bece1d..348ec4542 100644
--- a/src/modes.cpp
+++ b/src/modes.cpp
@@ -629,7 +629,7 @@ void ModeManager::ProcessModes()
std::list<Anope::string> ModeStrings = BuildModeStrings(s);
for (std::list<Anope::string>::iterator lit = ModeStrings.begin(), lit_end = ModeStrings.end(); lit != lit_end; ++lit)
- IRCD->SendMode(s->bi, u, lit->c_str());
+ IRCD->SendMode(s->bi, u, *lit);
delete it->second;
}
UserStackerObjects.clear();
@@ -644,7 +644,7 @@ void ModeManager::ProcessModes()
std::list<Anope::string> ModeStrings = BuildModeStrings(s);
for (std::list<Anope::string>::iterator lit = ModeStrings.begin(), lit_end = ModeStrings.end(); lit != lit_end; ++lit)
- IRCD->SendMode(s->bi, c, lit->c_str());
+ IRCD->SendMode(s->bi, c, *lit);
delete it->second;
}
ChannelStackerObjects.clear();
@@ -660,7 +660,7 @@ static void StackerDel(std::map<T *, StackerInfo *> &map, T *obj)
StackerInfo *si = it->second;
std::list<Anope::string> ModeStrings = BuildModeStrings(si);
for (std::list<Anope::string>::iterator lit = ModeStrings.begin(), lit_end = ModeStrings.end(); lit != lit_end; ++lit)
- IRCD->SendMode(si->bi, obj, lit->c_str());
+ IRCD->SendMode(si->bi, obj, *lit);
delete si;
map.erase(it);
diff --git a/src/process.cpp b/src/process.cpp
index 0d463b8d1..8512a188f 100644
--- a/src/process.cpp
+++ b/src/process.cpp
@@ -86,7 +86,7 @@ void Anope::ProcessCommand(MessageSource &src, const Anope::string &command, con
else if (m->HasFlag(IRCDMESSAGE_REQUIRE_USER) && !src.GetUser())
Log(LOG_DEBUG) << "unexpected non-user source " << src.GetSource() << " for " << command;
else if (m->HasFlag(IRCDMESSAGE_REQUIRE_SERVER) && !src.GetServer())
- Log(LOG_DEBUG) << "unexpected non-server source " << src.GetSource() << " for " << command;
+ Log(LOG_DEBUG) << "unexpected non-server source " << (src.GetSource().empty() ? "(no source)" : src.GetSource()) << " for " << command;
else
m->Run(src, params);
}
diff --git a/src/protocol.cpp b/src/protocol.cpp
index f23117952..5bf474a21 100644
--- a/src/protocol.cpp
+++ b/src/protocol.cpp
@@ -26,17 +26,12 @@
#include "uplink.h"
#include "bots.h"
#include "channels.h"
+#include "numeric.h"
IRCDProto *IRCD = NULL;
IRCDProto::IRCDProto(Module *creator, const Anope::string &p) : Service(creator, "IRCDProto", creator->name), proto_name(p)
{
- DefaultPseudoclientModes = "+io";
- CanSVSNick = CanSVSJoin = CanSetVHost = CanSetVIdent = CanSNLine = CanSQLine = CanSQLineChannel
- = CanSZLine = CanSVSHold = CanCertFP = RequiresID = AmbiguousID = false;
- MaxModes = 3;
- MaxLine = 512;
-
if (IRCD == NULL)
IRCD = this;
}
@@ -47,7 +42,7 @@ IRCDProto::~IRCDProto()
IRCD = NULL;
}
-const Anope::string &IRCDProto::GetProtocolName()
+const Anope::string &IRCDProto::GetProtocolName() const
{
return this->proto_name;
}
@@ -107,26 +102,26 @@ 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);
}
-void IRCDProto::SendModeInternal(const MessageSource &source, const Channel *dest, const Anope::string &buf)
+void IRCDProto::SendMode(const MessageSource &source, Channel *dest, const Anope::string &buf)
{
IRCMessage message(source, "MODE", dest->name);
message.TokenizeAndPush(buf);
Uplink::SendMessage(message);
}
-void IRCDProto::SendModeInternal(const MessageSource &source, User *dest, const Anope::string &buf)
+void IRCDProto::SendMode(const MessageSource &source, User *dest, const Anope::string &buf)
{
IRCMessage message(source, "MODE", dest->GetUID());
message.TokenizeAndPush(buf);
Uplink::SendMessage(message);
}
-void IRCDProto::SendKickInternal(const MessageSource &source, const Channel *c, User *u, const Anope::string &r)
+void IRCDProto::SendKick(const MessageSource &source, Channel *c, User *u, const Anope::string &r)
{
if (!r.empty())
Uplink::Send(source, "KICK", c->name, u->GetUID(), r);
@@ -134,17 +129,17 @@ void IRCDProto::SendKickInternal(const MessageSource &source, const Channel *c,
Uplink::Send(source, "KICK", c->name, u->GetUID());
}
-void IRCDProto::SendNoticeInternal(const MessageSource &source, const Anope::string &dest, const Anope::string &msg)
+void IRCDProto::SendNotice(const MessageSource &source, const Anope::string &dest, const Anope::string &msg)
{
Uplink::Send(source, "NOTICE", dest, msg);
}
-void IRCDProto::SendPrivmsgInternal(const MessageSource &source, const Anope::string &dest, const Anope::string &buf)
+void IRCDProto::SendPrivmsg(const MessageSource &source, const Anope::string &dest, const Anope::string &buf)
{
Uplink::Send(source, "PRIVMSG", dest, buf);
}
-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);
@@ -152,7 +147,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, Channel *chan, const Anope::string &buf)
{
if (!buf.empty())
Uplink::Send(u, "PART", chan->name, buf);
@@ -160,27 +155,19 @@ 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 &buf)
+void IRCDProto::SendGlobops(const MessageSource &source, const Anope::string &buf)
{
Uplink::Send(source, "GLOBOPS", buf);
}
-void IRCDProto::SendCTCPInternal(const MessageSource &source, const Anope::string &dest, const Anope::string &buf)
+void IRCDProto::SendCTCPReply(const MessageSource &source, const Anope::string &dest, const Anope::string &buf)
{
Anope::string s = Anope::NormalizeBuffer(buf);
- this->SendNoticeInternal(source, dest, "\1" + s + "\1");
+ this->SendNotice(source, dest, "\1" + s + "\1");
}
-void IRCDProto::SendNumericInternal(int numeric, const Anope::string &dest, const Anope::string &buf)
+void IRCDProto::SendNumeric(int numeric, User *dest, IRCMessage &message)
{
- Anope::string n = stringify(numeric);
- if (numeric < 10)
- n = "0" + n;
- if (numeric < 100)
- n = "0" + n;
-
- IRCMessage message(Me, n, dest);
- message.TokenizeAndPush(buf);
Uplink::SendMessage(message);
}
@@ -189,91 +176,13 @@ 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::SendMode(const MessageSource &source, const Channel *dest, const char *fmt, ...)
-{
- va_list args;
- char buf[BUFSIZE] = "";
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- SendModeInternal(source, dest, buf);
-}
-
-void IRCDProto::SendMode(const MessageSource &source, User *u, const char *fmt, ...)
-{
- va_list args;
- char buf[BUFSIZE] = "";
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- SendModeInternal(source, u, 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, ...)
+void IRCDProto::SendAction(const MessageSource &source, const Anope::string &dest, const Anope::string &message)
{
- va_list args;
- char buf[BUFSIZE] = "";
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- SendNoticeInternal(source, dest, buf);
-}
+ Anope::string actionbuf = "\1ACTION ";
+ actionbuf.append(message);
+ actionbuf.append('\1');
-void IRCDProto::SendAction(const MessageSource &source, const Anope::string &dest, const char *fmt, ...)
-{
- va_list args;
- char buf[BUFSIZE] = "";
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- Anope::string actionbuf = Anope::string("\1ACTION ") + buf + '\1';
- SendPrivmsgInternal(source, dest, actionbuf);
-}
-
-void IRCDProto::SendPrivmsg(const MessageSource &source, const Anope::string &dest, const char *fmt, ...)
-{
- va_list args;
- char buf[BUFSIZE] = "";
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- 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);
+ SendPrivmsg(source, dest, actionbuf);
}
void IRCDProto::SendPing(const Anope::string &servname, const Anope::string &who)
@@ -292,36 +201,11 @@ void IRCDProto::SendPong(const Anope::string &servname, const Anope::string &who
Uplink::Send(Me, "PONG", servname, who);
}
-void IRCDProto::SendInvite(const MessageSource &source, const Channel *c, User *u)
+void IRCDProto::SendInvite(const MessageSource &source, Channel *c, User *u)
{
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);
@@ -337,26 +221,6 @@ void IRCDProto::SendForceNickChange(User *u, const Anope::string &newnick, time_
Uplink::Send(u, "SVSNICK", u->GetUID(), newnick, when);
}
-void IRCDProto::SendCTCP(const MessageSource &source, const Anope::string &dest, const char *fmt, ...)
-{
- va_list args;
- char buf[BUFSIZE] = "";
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- SendCTCPInternal(source, dest, buf);
-}
-
-void IRCDProto::SendNumeric(int numeric, const Anope::string &dest, const char *fmt, ...)
-{
- va_list args;
- char buf[BUFSIZE] = "";
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- SendNumericInternal(numeric, dest, buf);
-}
-
bool IRCDProto::IsNickValid(const Anope::string &nick)
{
/**
@@ -438,11 +302,11 @@ bool IRCDProto::IsHostValid(const Anope::string &host)
void IRCDProto::SendOper(User *u)
{
- SendNumericInternal(381, u->GetUID(), ":You are now an IRC operator (set by services)");
+ SendNumeric(RPL_YOUREOPER, u, "You are now an IRC operator (set by services)");
u->SetMode(NULL, "OPER");
}
-unsigned IRCDProto::GetMaxListFor(Channel *c)
+unsigned int IRCDProto::GetMaxListFor(Channel *c)
{
return c->HasMode("LBAN") ? 0 : Config->GetBlock("networkinfo")->Get<int>("modelistsize");
}
@@ -454,7 +318,7 @@ Anope::string IRCDProto::NormalizeMask(const Anope::string &mask)
return Entry("", mask).GetNUHMask();
}
-MessageSource::MessageSource(const Anope::string &src) : source(src), u(NULL), s(NULL)
+MessageSource::MessageSource(const Anope::string &src) : source(src)
{
/* no source for incoming message is our uplink */
if (src.empty())
@@ -465,11 +329,11 @@ MessageSource::MessageSource(const Anope::string &src) : source(src), u(NULL), s
this->u = User::Find(src);
}
-MessageSource::MessageSource(User *_u) : source(_u ? _u->nick : ""), u(_u), s(NULL)
+MessageSource::MessageSource(User *_u) : source(_u ? _u->nick : ""), u(_u)
{
}
-MessageSource::MessageSource(Server *_s) : source(_s ? _s->GetName() : ""), u(NULL), s(_s)
+MessageSource::MessageSource(Server *_s) : source(_s ? _s->GetName() : ""), s(_s)
{
}
@@ -512,11 +376,11 @@ Server *MessageSource::GetServer() const
return this->s;
}
-IRCDMessage::IRCDMessage(Module *o, const Anope::string &n, unsigned p) : Service(o, "IRCDMessage", o->name + "/" + n.lower()), name(n), param_count(p)
+IRCDMessage::IRCDMessage(Module *o, const Anope::string &n, unsigned int p) : Service(o, "IRCDMessage", o->name + "/" + n.lower()), name(n), param_count(p)
{
}
-unsigned IRCDMessage::GetParamCount() const
+unsigned int IRCDMessage::GetParamCount() const
{
return this->param_count;
}
diff --git a/src/users.cpp b/src/users.cpp
index 4afe7d4a9..33a4cdaf6 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -92,7 +92,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 (ServiceBot *bi = dynamic_cast<ServiceBot *>(target))
@@ -352,9 +352,9 @@ void User::SendMessage(const MessageSource &source, const Anope::string &msg)
if (buf.length() + add.length() > Config->LineWrap)
{
if (send_privmsg)
- IRCD->SendPrivmsg(source, this->GetUID(), "%s", buf.c_str());
+ IRCD->SendPrivmsg(source, this->GetUID(), buf);
else
- IRCD->SendNotice(source, this->GetUID(), "%s", buf.c_str());
+ IRCD->SendNotice(source, this->GetUID(), buf);
buf.clear();
add = word;
@@ -366,9 +366,9 @@ void User::SendMessage(const MessageSource &source, const Anope::string &msg)
if (!buf.empty())
{
if (send_privmsg)
- IRCD->SendPrivmsg(source, this->GetUID(), "%s", buf.c_str());
+ IRCD->SendPrivmsg(source, this->GetUID(), buf);
else
- IRCD->SendNotice(source, this->GetUID(), "%s", buf.c_str());
+ IRCD->SendNotice(source, this->GetUID(), buf);
}
}
}
@@ -769,7 +769,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)