summaryrefslogtreecommitdiff
path: root/modules/protocol
diff options
context:
space:
mode:
Diffstat (limited to 'modules/protocol')
-rw-r--r--modules/protocol/bahamut.cpp202
-rw-r--r--modules/protocol/inspircd11.cpp297
-rw-r--r--modules/protocol/inspircd12.cpp349
-rw-r--r--modules/protocol/inspircd20.cpp509
-rw-r--r--modules/protocol/ratbox.cpp300
-rw-r--r--modules/protocol/unreal32.cpp372
6 files changed, 897 insertions, 1132 deletions
diff --git a/modules/protocol/bahamut.cpp b/modules/protocol/bahamut.cpp
index d7849c940..1f8b70ef7 100644
--- a/modules/protocol/bahamut.cpp
+++ b/modules/protocol/bahamut.cpp
@@ -7,8 +7,6 @@
*
* Based on the original code of Epona by Lara.
* Based on the original code of Services by Andy Church.
- *
- *
*/
/*************************************************************************/
@@ -45,7 +43,6 @@ IRCDVar myIrcd[] = {
0, /* Change RealName */
1, /* No Knock requires +i */
0, /* We support TOKENS */
- 0, /* TIME STAMPS are BASE64 */
0, /* Can remove User Channel Modes with SVSMODE */
0, /* Sglines are not enforced until user reconnects */
0, /* ts6 */
@@ -60,7 +57,7 @@ IRCDVar myIrcd[] = {
void bahamut_cmd_burst()
{
- send_cmd(NULL, "BURST");
+ send_cmd("", "BURST");
}
/*
@@ -73,138 +70,131 @@ void bahamut_cmd_burst()
*/
void bahamut_cmd_svinfo()
{
- send_cmd(NULL, "SVINFO 3 1 0 :%ld", static_cast<long>(time(NULL)));
+ send_cmd("", "SVINFO 3 1 0 :%ld", static_cast<long>(time(NULL)));
}
/* PASS */
-void bahamut_cmd_pass(const char *pass)
+void bahamut_cmd_pass(const Anope::string &pass)
{
- send_cmd(NULL, "PASS %s :TS", pass);
+ send_cmd("", "PASS %s :TS", pass.c_str());
}
/* CAPAB */
void bahamut_cmd_capab()
{
- send_cmd(NULL, "CAPAB SSJOIN NOQUIT BURST UNCONNECT NICKIP TSMODE TS3");
-}
-
-/* this avoids "undefined symbol" messages of those whom try to load mods that
- call on this function */
-void bahamut_cmd_chghost(const char *nick, const char *vhost)
-{
- Alog(LOG_DEBUG) << "This IRCD does not support vhosting";
+ send_cmd("", "CAPAB SSJOIN NOQUIT BURST UNCONNECT NICKIP TSMODE TS3");
}
class BahamutIRCdProto : public IRCDProto
{
- void SendModeInternal(BotInfo *source, Channel *dest, const char *buf)
+ void SendModeInternal(BotInfo *source, Channel *dest, const Anope::string &buf)
{
- if (!buf)
+ if (buf.empty())
return;
if (Capab.HasFlag(CAPAB_TSMODE))
- send_cmd(source->nick, "MODE %s 0 %s", dest->name.c_str(), buf);
+ send_cmd(source->nick, "MODE %s 0 %s", dest->name.c_str(), buf.c_str());
else
- send_cmd(source->nick, "MODE %s %s", dest->name.c_str(), buf);
+ send_cmd(source->nick, "MODE %s %s", dest->name.c_str(), buf.c_str());
}
- void SendModeInternal(BotInfo *bi, User *u, const char *buf)
+ void SendModeInternal(BotInfo *bi, User *u, const Anope::string &buf)
{
- if (!buf)
+ if (buf.empty())
return;
- send_cmd(bi ? bi->nick : Config.ServerName, "SVSMODE %s %ld %s", u->nick.c_str(), static_cast<long>(u->timestamp), buf);
+ send_cmd(bi ? bi->nick : Config.ServerName, "SVSMODE %s %ld %s", u->nick.c_str(), static_cast<long>(u->timestamp), buf.c_str());
}
/* SVSHOLD - set */
- void SendSVSHold(const char *nick)
+ void SendSVSHold(const Anope::string &nick)
{
- send_cmd(Config.ServerName, "SVSHOLD %s %u :%s", nick, static_cast<unsigned>(Config.NSReleaseTimeout), "Being held for registered user");
+ send_cmd(Config.ServerName, "SVSHOLD %s %u :Being held for registered user", nick.c_str(), static_cast<unsigned>(Config.NSReleaseTimeout));
}
/* SVSHOLD - release */
- void SendSVSHoldDel(const char *nick)
+ void SendSVSHoldDel(const Anope::string &nick)
{
- send_cmd(Config.ServerName, "SVSHOLD %s 0", nick);
+ send_cmd(Config.ServerName, "SVSHOLD %s 0", nick.c_str());
}
/* SVSMODE -b */
- void SendBanDel(Channel *c, const std::string &nick)
+ void SendBanDel(Channel *c, const Anope::string &nick)
{
- SendSVSModeChan(c, "-b", nick.empty() ? NULL : nick.c_str());
+ SendSVSModeChan(c, "-b", nick);
}
/* SVSMODE channel modes */
- void SendSVSModeChan(Channel *c, const char *mode, const char *nick)
+ void SendSVSModeChan(Channel *c, const Anope::string &mode, const Anope::string &nick)
{
- if (nick)
- send_cmd(Config.ServerName, "SVSMODE %s %s %s", c->name.c_str(), mode, nick);
+ if (!nick.empty())
+ send_cmd(Config.ServerName, "SVSMODE %s %s %s", c->name.c_str(), mode.c_str(), nick.c_str());
else
- send_cmd(Config.ServerName, "SVSMODE %s %s", c->name.c_str(), mode);
+ send_cmd(Config.ServerName, "SVSMODE %s %s", c->name.c_str(), mode.c_str());
}
/* SQLINE */
void SendSQLine(XLine *x)
{
- send_cmd(NULL, "SQLINE %s :%s", x->Mask.c_str(), x->Reason.c_str());
+ send_cmd("", "SQLINE %s :%s", x->Mask.c_str(), x->Reason.c_str());
}
/* UNSLINE */
void SendSGLineDel(XLine *x)
{
- send_cmd(NULL, "UNSGLINE 0 :%s", x->Mask.c_str());
+ send_cmd("", "UNSGLINE 0 :%s", x->Mask.c_str());
}
/* UNSZLINE */
void SendSZLineDel(XLine *x)
{
/* this will likely fail so its only here for legacy */
- send_cmd(NULL, "UNSZLINE 0 %s", x->Mask.c_str());
+ send_cmd("", "UNSZLINE 0 %s", x->Mask.c_str());
/* this is how we are supposed to deal with it */
- send_cmd(NULL, "RAKILL %s *", x->Mask.c_str());
+ send_cmd("", "RAKILL %s *", x->Mask.c_str());
}
/* SZLINE */
void SendSZLine(XLine *x)
{
/* this will likely fail so its only here for legacy */
- send_cmd(NULL, "SZLINE %s :%s", x->Mask.c_str(), x->Reason.c_str());
+ send_cmd("", "SZLINE %s :%s", x->Mask.c_str(), x->Reason.c_str());
/* this is how we are supposed to deal with it */
- send_cmd(NULL, "AKILL %s * %d %s %ld :%s", x->Mask.c_str(), 172800, x->By.c_str(), static_cast<long>(time(NULL)), x->Reason.c_str());
+ send_cmd("", "AKILL %s * %d %s %ld :%s", x->Mask.c_str(), 172800, x->By.c_str(), static_cast<long>(time(NULL)), x->Reason.c_str());
}
/* SVSNOOP */
- void SendSVSNOOP(const char *server, int set)
+ void SendSVSNOOP(const Anope::string &server, int set)
{
- send_cmd(NULL, "SVSNOOP %s %s", server, set ? "+" : "-");
+ send_cmd("", "SVSNOOP %s %s", server.c_str(), set ? "+" : "-");
}
/* SGLINE */
void SendSGLine(XLine *x)
{
- send_cmd(NULL, "SGLINE %d :%s:%s", static_cast<int>(x->Mask.length()), x->Mask.c_str(), x->Reason.c_str());
+ send_cmd("", "SGLINE %d :%s:%s", static_cast<int>(x->Mask.length()), x->Mask.c_str(), x->Reason.c_str());
}
/* RAKILL */
void SendAkillDel(XLine *x)
{
- send_cmd(NULL, "RAKILL %s %s", x->GetHost().c_str(), x->GetUser().c_str());
+ send_cmd("", "RAKILL %s %s", x->GetHost().c_str(), x->GetUser().c_str());
}
/* TOPIC */
- void SendTopic(BotInfo *whosets, Channel *c, const char *whosetit, const char *topic)
+ void SendTopic(BotInfo *whosets, Channel *c, const Anope::string &whosetit, const Anope::string &topic)
{
- send_cmd(whosets->nick, "TOPIC %s %s %lu :%s", c->name.c_str(), whosetit, static_cast<unsigned long>(c->topic_time), topic);
+ send_cmd(whosets->nick, "TOPIC %s %s %lu :%s", c->name.c_str(), whosetit.c_str(), static_cast<unsigned long>(c->topic_time), topic.c_str());
}
/* UNSQLINE */
void SendSQLineDel(XLine *x)
{
- send_cmd(NULL, "UNSQLINE %s", x->Mask.c_str());
+ send_cmd("", "UNSQLINE %s", x->Mask.c_str());
}
/* JOIN - SJOIN */
- void SendJoin(BotInfo *user, const char *channel, time_t chantime)
+ void SendJoin(BotInfo *user, const Anope::string &channel, time_t chantime)
{
- send_cmd(user->nick, "SJOIN %ld %s", static_cast<long>(chantime), channel);
+ send_cmd(user->nick, "SJOIN %ld %s", static_cast<long>(chantime), channel.c_str());
}
void SendAkill(XLine *x)
@@ -213,15 +203,15 @@ class BahamutIRCdProto : public IRCDProto
time_t timeleft = x->Expires - time(NULL);
if (timeleft > 172800)
timeleft = 172800;
- send_cmd(NULL, "AKILL %s %s %d %s %ld :%s", x->GetHost().c_str(), x->GetUser().c_str(), static_cast<int>(timeleft), x->By.c_str(), static_cast<long>(time(NULL)), x->Reason.c_str());
+ send_cmd("", "AKILL %s %s %d %s %ld :%s", x->GetHost().c_str(), x->GetUser().c_str(), static_cast<int>(timeleft), x->By.c_str(), static_cast<long>(time(NULL)), x->Reason.c_str());
}
/*
Note: if the stamp is null 0, the below usage is correct of Bahamut
*/
- void SendSVSKillInternal(BotInfo *source, User *user, const char *buf)
+ void SendSVSKillInternal(BotInfo *source, User *user, const Anope::string &buf)
{
- send_cmd(source ? source->nick : NULL, "SVSKILL %s :%s", user->nick.c_str(), buf);
+ send_cmd(source ? source->nick : "", "SVSKILL %s :%s", user->nick.c_str(), buf.c_str());
}
/* SVSMODE */
@@ -238,28 +228,28 @@ class BahamutIRCdProto : public IRCDProto
void SendEOB()
{
- send_cmd(NULL, "BURST 0");
+ send_cmd("", "BURST 0");
}
- void SendNoticeChanopsInternal(BotInfo *source, Channel *dest, const char *buf)
+ void SendNoticeChanopsInternal(BotInfo *source, Channel *dest, const Anope::string &buf)
{
- if (!buf)
+ if (buf.empty())
return;
- send_cmd(NULL, "NOTICE @%s :%s", dest->name.c_str(), buf);
+ send_cmd("", "NOTICE @%s :%s", dest->name.c_str(), buf.c_str());
}
- void SendKickInternal(BotInfo *source, Channel *chan, User *user, const char *buf)
+ void SendKickInternal(BotInfo *source, Channel *chan, User *user, const Anope::string &buf)
{
- if (buf)
- send_cmd(source->nick, "KICK %s %s :%s", chan->name.c_str(), user->nick.c_str(), buf);
+ if (!buf.empty())
+ send_cmd(source->nick, "KICK %s %s :%s", chan->name.c_str(), user->nick.c_str(), buf.c_str());
else
send_cmd(source->nick, "KICK %s %s", chan->name.c_str(), user->nick.c_str());
}
- void SendClientIntroduction(const std::string &nick, const std::string &user, const std::string &host, const std::string &real, const char *modes, const std::string &uid)
+ void SendClientIntroduction(const Anope::string &nick, const Anope::string &user, const Anope::string &host, const Anope::string &real, const Anope::string &modes, const Anope::string &)
{
EnforceQlinedNick(nick, Config.s_BotServ);
- send_cmd(NULL, "NICK %s 1 %ld %s %s %s %s 0 0 :%s", nick.c_str(), static_cast<long>(time(NULL)), modes, user.c_str(), host.c_str(), Config.ServerName, real.c_str());
+ send_cmd("", "NICK %s 1 %ld %s %s %s %s 0 0 :%s", nick.c_str(), static_cast<long>(time(NULL)), modes.c_str(), user.c_str(), host.c_str(), Config.ServerName.c_str(), real.c_str());
}
/* SVSMODE +d */
@@ -274,7 +264,7 @@ class BahamutIRCdProto : public IRCDProto
/* SERVER */
void SendServer(Server *server)
{
- send_cmd(NULL, "SERVER %s %d :%s", server->GetName().c_str(), server->GetHops(), server->GetDescription().c_str());
+ send_cmd("", "SERVER %s %d :%s", server->GetName().c_str(), server->GetHops(), server->GetDescription().c_str());
}
void SendConnect()
@@ -288,28 +278,26 @@ class BahamutIRCdProto : public IRCDProto
void SetAutoIdentificationToken(User *u)
{
- char svidbuf[15];
-
if (!u->Account())
return;
srand(time(NULL));
- snprintf(svidbuf, sizeof(svidbuf), "%d", rand());
+ Anope::string svidbuf = stringify(rand());
u->Account()->Shrink("authenticationtoken");
- u->Account()->Extend("authenticationtoken", new ExtensibleItemPointerArray<char>(sstrdup(svidbuf)));
+ u->Account()->Extend("authenticationtoken", new ExtensibleItemRegular<Anope::string>(svidbuf));
BotInfo *bi = NickServ;
u->SetMode(bi, UMODE_REGISTERED);
- ircdproto->SendMode(bi, u, "+d %s", svidbuf);
+ ircdproto->SendMode(bi, u, "+d %s", svidbuf.c_str());
}
} ircd_proto;
/* EVENT: SJOIN */
-int anope_event_sjoin(const char *source, int ac, const char **av)
+int anope_event_sjoin(const Anope::string &source, int ac, const char **av)
{
Channel *c = findchan(av[1]);
- time_t ts = atol(av[0]);
+ time_t ts = Anope::string(av[0]).is_number_only() ? convertTo<time_t>(av[0]) : 0;
bool was_created = false;
bool keep_their_modes = false;
@@ -399,11 +387,10 @@ int anope_event_sjoin(const char *source, int ac, const char **av)
else
{
spacesepstream sep(av[ac - 1]);
- std::string buf;
+ Anope::string buf;
while (sep.GetToken(buf))
{
std::list<ChannelMode *> Status;
- Status.clear();
char ch;
/* Get prefixes from the nick */
@@ -488,13 +475,13 @@ int anope_event_sjoin(const char *source, int ac, const char **av)
** parv[0] = new nickname
** parv[1] = hopcount
*/
-int anope_event_nick(const char *source, int ac, const char **av)
+int anope_event_nick(const Anope::string &source, int ac, const char **av)
{
User *user;
if (ac != 2)
{
- user = do_nick(source, av[0], av[4], av[5], av[6], av[9], strtoul(av[2], NULL, 10), strtoul(av[8], NULL, 0), NULL, NULL);
+ user = do_nick(source, av[0], av[4], av[5], av[6], av[9], Anope::string(av[2]).is_number_only() ? convertTo<time_t>(av[2]) : 0, Anope::string(av[8]).is_number_only() ? convertTo<uint32>(av[8]) : 0, "", "");
if (user)
{
/* Check to see if the user should be identified because their
@@ -506,19 +493,19 @@ int anope_event_nick(const char *source, int ac, const char **av)
}
}
else
- do_nick(source, av[0], NULL, NULL, NULL, NULL, strtoul(av[1], NULL, 10), 0, NULL, NULL);
+ do_nick(source, av[0], "", "", "", "", Anope::string(av[1]).is_number_only() ? convertTo<time_t>(av[1]) : 0, 0, "", "");
return MOD_CONT;
}
/* EVENT : CAPAB */
-int anope_event_capab(const char *source, int ac, const char **av)
+int anope_event_capab(const Anope::string &source, int ac, const char **av)
{
CapabParse(ac, av);
return MOD_CONT;
}
/* EVENT : OS */
-int anope_event_os(const char *source, int ac, const char **av)
+int anope_event_os(const Anope::string &source, int ac, const char **av)
{
if (ac < 1)
return MOD_CONT;
@@ -527,7 +514,7 @@ int anope_event_os(const char *source, int ac, const char **av)
}
/* EVENT : NS */
-int anope_event_ns(const char *source, int ac, const char **av)
+int anope_event_ns(const Anope::string &source, int ac, const char **av)
{
if (ac < 1)
return MOD_CONT;
@@ -536,7 +523,7 @@ int anope_event_ns(const char *source, int ac, const char **av)
}
/* EVENT : MS */
-int anope_event_ms(const char *source, int ac, const char **av)
+int anope_event_ms(const Anope::string &source, int ac, const char **av)
{
if (ac < 1)
return MOD_CONT;
@@ -545,7 +532,7 @@ int anope_event_ms(const char *source, int ac, const char **av)
}
/* EVENT : HS */
-int anope_event_hs(const char *source, int ac, const char **av)
+int anope_event_hs(const Anope::string &source, int ac, const char **av)
{
if (ac < 1)
return MOD_CONT;
@@ -554,7 +541,7 @@ int anope_event_hs(const char *source, int ac, const char **av)
}
/* EVENT : CS */
-int anope_event_cs(const char *source, int ac, const char **av)
+int anope_event_cs(const Anope::string &source, int ac, const char **av)
{
if (ac < 1)
return MOD_CONT;
@@ -562,7 +549,7 @@ int anope_event_cs(const char *source, int ac, const char **av)
return MOD_CONT;
}
-int anope_event_436(const char *source, int ac, const char **av)
+int anope_event_436(const Anope::string &source, int ac, const char **av)
{
if (ac < 1)
return MOD_CONT;
@@ -572,14 +559,14 @@ int anope_event_436(const char *source, int ac, const char **av)
}
/* EVENT : SERVER */
-int anope_event_server(const char *source, int ac, const char **av)
+int anope_event_server(const Anope::string &source, int ac, const char **av)
{
- do_server(source, av[0], atoi(av[1]), av[2], "");
+ do_server(source, av[0], Anope::string(av[1]).is_number_only() ? convertTo<unsigned>(av[1]) : 0, av[2], "");
return MOD_CONT;
}
/* EVENT : PRIVMSG */
-int anope_event_privmsg(const char *source, int ac, const char **av)
+int anope_event_privmsg(const Anope::string &source, int ac, const char **av)
{
if (ac != 2)
return MOD_CONT;
@@ -587,7 +574,7 @@ int anope_event_privmsg(const char *source, int ac, const char **av)
return MOD_CONT;
}
-int anope_event_part(const char *source, int ac, const char **av)
+int anope_event_part(const Anope::string &source, int ac, const char **av)
{
if (ac < 1 || ac > 2)
return MOD_CONT;
@@ -595,14 +582,14 @@ int anope_event_part(const char *source, int ac, const char **av)
return MOD_CONT;
}
-int anope_event_whois(const char *source, int ac, const char **av)
+int anope_event_whois(const Anope::string &source, int ac, const char **av)
{
- if (source && ac >= 1)
+ if (!source.empty() && ac >= 1)
m_whois(source, av[0]);
return MOD_CONT;
}
-int anope_event_topic(const char *source, int ac, const char **av)
+int anope_event_topic(const Anope::string &source, int ac, const char **av)
{
if (ac != 4)
return MOD_CONT;
@@ -610,7 +597,7 @@ int anope_event_topic(const char *source, int ac, const char **av)
return MOD_CONT;
}
-int anope_event_squit(const char *source, int ac, const char **av)
+int anope_event_squit(const Anope::string &source, int ac, const char **av)
{
if (ac != 2)
return MOD_CONT;
@@ -618,7 +605,7 @@ int anope_event_squit(const char *source, int ac, const char **av)
return MOD_CONT;
}
-int anope_event_quit(const char *source, int ac, const char **av)
+int anope_event_quit(const Anope::string &source, int ac, const char **av)
{
if (ac != 1)
return MOD_CONT;
@@ -627,7 +614,7 @@ int anope_event_quit(const char *source, int ac, const char **av)
}
/* EVENT: MODE */
-int anope_event_mode(const char *source, int ac, const char **av)
+int anope_event_mode(const Anope::string &source, int ac, const char **av)
{
if (ac < 2)
return MOD_CONT;
@@ -640,7 +627,7 @@ int anope_event_mode(const char *source, int ac, const char **av)
}
/* EVENT: KILL */
-int anope_event_kill(const char *source, int ac, const char **av)
+int anope_event_kill(const Anope::string &source, int ac, const char **av)
{
if (ac != 2)
return MOD_CONT;
@@ -650,7 +637,7 @@ int anope_event_kill(const char *source, int ac, const char **av)
}
/* EVENT: KICK */
-int anope_event_kick(const char *source, int ac, const char **av)
+int anope_event_kick(const Anope::string &source, int ac, const char **av)
{
if (ac != 3)
return MOD_CONT;
@@ -659,7 +646,7 @@ int anope_event_kick(const char *source, int ac, const char **av)
}
/* EVENT: JOIN */
-int anope_event_join(const char *source, int ac, const char **av)
+int anope_event_join(const Anope::string &source, int ac, const char **av)
{
if (ac != 1)
return MOD_CONT;
@@ -668,24 +655,24 @@ int anope_event_join(const char *source, int ac, const char **av)
}
/* EVENT: MOTD */
-int anope_event_motd(const char *source, int ac, const char **av)
+int anope_event_motd(const Anope::string &source, int ac, const char **av)
{
- if (!source)
+ if (source.empty())
return MOD_CONT;
m_motd(source);
return MOD_CONT;
}
-int anope_event_away(const char *source, int ac, const char **av)
+int anope_event_away(const Anope::string &source, int ac, const char **av)
{
- if (!source)
+ if (source.empty())
return MOD_CONT;
- m_away(source, (ac ? av[0] : NULL));
+ m_away(source, ac ? av[0] : "");
return MOD_CONT;
}
-int anope_event_ping(const char *source, int ac, const char **av)
+int anope_event_ping(const Anope::string &source, int ac, const char **av)
{
if (ac < 1)
return MOD_CONT;
@@ -693,16 +680,16 @@ int anope_event_ping(const char *source, int ac, const char **av)
return MOD_CONT;
}
-int anope_event_error(const char *source, int ac, const char **av)
+int anope_event_error(const Anope::string &source, int ac, const char **av)
{
if (ac >= 1)
Alog(LOG_DEBUG) << av[0];
return MOD_CONT;
}
-int anope_event_burst(const char *source, int ac, const char **av)
+int anope_event_burst(const Anope::string &source, int ac, const char **av)
{
- Server *s = Server::Find(source ? source : "");
+ Server *s = Server::Find(source);
if (!ac)
{
@@ -722,11 +709,10 @@ int anope_event_burst(const char *source, int ac, const char **av)
return MOD_CONT;
}
-bool ChannelModeFlood::IsValid(const std::string &value)
+bool ChannelModeFlood::IsValid(const Anope::string &value)
{
- char *dp, *end;
-
- if (!value.empty() && value[0] != ':' && strtoul((value[0] == '*' ? value.c_str() + 1 : value.c_str()), &dp, 10) > 0 && *dp == ':' && *(++dp) && strtoul(dp, &end, 10) > 0 && !*end)
+ Anope::string rest;
+ if (!value.empty() && value[0] != ':' && convertTo<int>(value[0] == '*' ? value.substr(1) : value, rest, false) > 0 && rest[0] == ':' && rest.length() > 1 && convertTo<int>(rest.substr(1), rest, false) > 0 && rest.empty())
return true;
return false;
@@ -769,7 +755,7 @@ static void AddModes()
ModeManager::AddUserMode(new UserMode(UMODE_REGPRIV, "UMODE_REGPRIV", 'R'));
ModeManager::AddUserMode(new UserMode(UMODE_ADMIN, "UMODE_ADMIN", 'a'));
ModeManager::AddUserMode(new UserMode(UMODE_INVIS, "UMODE_INVIS", 'i'));
- ModeManager::AddUserMode(new UserMode(UMODE_OPER,"UMODE_OPER", 'o'));
+ ModeManager::AddUserMode(new UserMode(UMODE_OPER, "UMODE_OPER", 'o'));
ModeManager::AddUserMode(new UserMode(UMODE_REGISTERED, "UMODE_REGISTERED", 'r'));
ModeManager::AddUserMode(new UserMode(UMODE_SNOMASK, "UMODE_SNOMASK", 's'));
ModeManager::AddUserMode(new UserMode(UMODE_WALLOPS, "UMODE_WALLOPS", 'w'));
@@ -802,7 +788,7 @@ static void AddModes()
class ProtoBahamut : public Module
{
public:
- ProtoBahamut(const std::string &modname, const std::string &creator) : Module(modname, creator)
+ ProtoBahamut(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator)
{
this->SetAuthor("Anope");
this->SetType(PROTOCOL);
@@ -823,7 +809,7 @@ class ProtoBahamut : public Module
ModuleManager::Attach(I_OnUserNickChange, this);
}
- void OnUserNickChange(User *u, const std::string &)
+ void OnUserNickChange(User *u, const Anope::string &)
{
u->RemoveModeInternal(ModeManager::FindUserModeByName(UMODE_REGISTERED));
}
diff --git a/modules/protocol/inspircd11.cpp b/modules/protocol/inspircd11.cpp
index ac50f64b9..9e21516e6 100644
--- a/modules/protocol/inspircd11.cpp
+++ b/modules/protocol/inspircd11.cpp
@@ -15,22 +15,6 @@
#include "modules.h"
#include "hashcomp.h"
-#ifndef _WIN32
-# include <sys/socket.h>
-# include <netinet/in.h>
-# include <arpa/inet.h>
-#endif
-
-#ifdef _WIN32
-# include <winsock.h>
-int inet_aton(const char *name, struct in_addr *addr)
-{
- uint32 a = inet_addr(name);
- addr->s_addr = a;
- return a != (uint32) - 1;
-}
-#endif
-
IRCDVar myIrcd[] = {
{"InspIRCd 1.1", /* ircd name */
"+I", /* Modes used by pseudoclients */
@@ -60,7 +44,6 @@ IRCDVar myIrcd[] = {
0, /* Change RealName */
1, /* No Knock requires +i */
0, /* We support inspircd TOKENS */
- 0, /* TIME STAMPS are BASE64 */
0, /* Can remove User Channel Modes with SVSMODE */
0, /* Sglines are not enforced until user reconnects */
0, /* ts6 */
@@ -81,31 +64,31 @@ static bool has_chgidentmod = false;
static bool has_hidechansmod = false;
/* CHGHOST */
-void inspircd_cmd_chghost(const char *nick, const char *vhost)
+void inspircd_cmd_chghost(const Anope::string &nick, const Anope::string &vhost)
{
if (has_chghostmod)
{
- if (!nick || !vhost)
+ if (nick.empty() || vhost.empty())
return;
- send_cmd(Config.s_OperServ, "CHGHOST %s %s", nick, vhost);
+ send_cmd(Config.s_OperServ, "CHGHOST %s %s", nick.c_str(), vhost.c_str());
}
else
ircdproto->SendGlobops(OperServ, "CHGHOST not loaded!");
}
-int anope_event_idle(const char *source, int ac, const char **av)
+int anope_event_idle(const Anope::string &source, int ac, const char **av)
{
if (ac == 1)
- send_cmd(av[0], "IDLE %s %ld 0", source, static_cast<long>(time(NULL)));
+ send_cmd(av[0], "IDLE %s %ld 0", source.c_str(), static_cast<long>(time(NULL)));
return MOD_CONT;
}
-static char currentpass[1024];
+static Anope::string currentpass;
/* PASS */
-void inspircd_cmd_pass(const char *pass)
+void inspircd_cmd_pass(const Anope::string &pass)
{
- strlcpy(currentpass, pass, sizeof(currentpass));
+ currentpass = pass;
}
class InspIRCdProto : public IRCDProto
@@ -115,20 +98,20 @@ class InspIRCdProto : public IRCDProto
send_cmd(Config.s_OperServ, "GLINE %s", x->Mask.c_str());
}
- void SendTopic(BotInfo *whosets, Channel *c, const char *whosetit, const char *topic)
+ void SendTopic(BotInfo *whosets, Channel *c, const Anope::string &whosetit, const Anope::string &topic)
{
- send_cmd(whosets->nick, "FTOPIC %s %lu %s :%s", c->name.c_str(), static_cast<unsigned long>(c->topic_time), whosetit, topic);
+ send_cmd(whosets->nick, "FTOPIC %s %lu %s :%s", c->name.c_str(), static_cast<unsigned long>(c->topic_time), whosetit.c_str(), topic.c_str());
}
void SendVhostDel(User *u)
{
if (u->HasMode(UMODE_CLOAK))
- inspircd_cmd_chghost(u->nick.c_str(), u->chost.c_str());
+ inspircd_cmd_chghost(u->nick, u->chost);
else
- inspircd_cmd_chghost(u->nick.c_str(), u->host);
+ inspircd_cmd_chghost(u->nick, u->host);
if (has_chgidentmod && u->GetIdent() != u->GetVIdent())
- inspircd_cmd_chgident(u->nick.c_str(), u->GetIdent().c_str());
+ inspircd_cmd_chgident(u->nick, u->GetIdent());
}
void SendAkill(XLine *x)
@@ -140,9 +123,9 @@ class InspIRCdProto : public IRCDProto
send_cmd(Config.ServerName, "ADDLINE G %s %s %ld %ld :%s", x->Mask.c_str(), x->By.c_str(), static_cast<long>(time(NULL)), static_cast<long>(timeleft), x->Reason.c_str());
}
- void SendSVSKillInternal(BotInfo *source, User *user, const char *buf)
+ void SendSVSKillInternal(BotInfo *source, User *user, const Anope::string &buf)
{
- send_cmd(source ? source->nick : Config.ServerName, "KILL %s :%s", user->nick.c_str(), buf);
+ send_cmd(source ? source->nick : Config.ServerName, "KILL %s :%s", user->nick.c_str(), buf.c_str());
}
void SendSVSMode(User *u, int ac, const char **av)
@@ -150,61 +133,56 @@ class InspIRCdProto : public IRCDProto
this->SendModeInternal(NULL, u, merge_args(ac, av));
}
- void SendNumericInternal(const char *source, int numeric, const char *dest, const char *buf)
- {
- send_cmd(source, "PUSH %s ::%s %03d %s %s", dest, source, numeric, dest, buf);
- }
-
- void SendGuestNick(const char *nick, const char *user, const char *host, const char *real, const char *modes)
+ void SendNumericInternal(const Anope::string &source, int numeric, const Anope::string &dest, const Anope::string &buf)
{
- send_cmd(Config.ServerName, "NICK %ld %s %s %s %s +%s 0.0.0.0 :%s", static_cast<long>(time(NULL)), nick, host, host, user, modes, real);
+ send_cmd(source, "PUSH %s ::%s %03d %s %s", dest.c_str(), source.c_str(), numeric, dest.c_str(), buf.c_str());
}
- void SendModeInternal(BotInfo *source, Channel *dest, const char *buf)
+ void SendModeInternal(BotInfo *source, Channel *dest, const Anope::string &buf)
{
- if (!buf)
+ if (buf.empty())
return;
- send_cmd(source ? source->nick : Config.s_OperServ, "FMODE %s %u %s", dest->name.c_str(), static_cast<unsigned>(dest->creation_time), buf);
+ send_cmd(source ? source->nick : Config.s_OperServ, "FMODE %s %u %s", dest->name.c_str(), static_cast<unsigned>(dest->creation_time), buf.c_str());
}
- void SendModeInternal(BotInfo *bi, User *u, const char *buf)
+ void SendModeInternal(BotInfo *bi, User *u, const Anope::string &buf)
{
- if (!buf)
+ if (buf.empty())
return;
- send_cmd(bi ? bi->nick : Config.ServerName, "MODE %s %s", u->nick.c_str(), buf);
+ send_cmd(bi ? bi->nick : Config.ServerName, "MODE %s %s", u->nick.c_str(), buf.c_str());
}
- void SendClientIntroduction(const std::string &nick, const std::string &user, const std::string &host, const std::string &real, const char *modes, const std::string &uid)
+ void SendClientIntroduction(const Anope::string &nick, const Anope::string &user, const Anope::string &host, const Anope::string &real, const Anope::string &modes, const Anope::string &)
{
- send_cmd(Config.ServerName, "NICK %ld %s %s %s %s %s 0.0.0.0 :%s", static_cast<long>(time(NULL)), nick.c_str(), host.c_str(), host.c_str(), user.c_str(), modes, real.c_str());
+ send_cmd(Config.ServerName, "NICK %ld %s %s %s %s %s 0.0.0.0 :%s", static_cast<long>(time(NULL)), nick.c_str(), host.c_str(), host.c_str(), user.c_str(), modes.c_str(), real.c_str());
send_cmd(nick, "OPERTYPE Service");
}
- void SendKickInternal(BotInfo *source, Channel *chan, User *user, const char *buf)
+ void SendKickInternal(BotInfo *source, Channel *chan, User *user, const Anope::string &buf)
{
- if (buf)
- send_cmd(source->nick, "KICK %s %s :%s", chan->name.c_str(), user->nick.c_str(), buf);
+ if (!buf.empty())
+ send_cmd(source->nick, "KICK %s %s :%s", chan->name.c_str(), user->nick.c_str(), buf.c_str());
else
send_cmd(source->nick, "KICK %s %s :%s", chan->name.c_str(), user->nick.c_str(), user->nick.c_str());
}
- void SendNoticeChanopsInternal(BotInfo *source, Channel *dest, const char *buf)
+ void SendNoticeChanopsInternal(BotInfo *source, Channel *dest, const Anope::string &buf)
{
- if (!buf)
+ if (buf.empty())
return;
- send_cmd(Config.ServerName, "NOTICE @%s :%s", dest->name.c_str(), buf);
+ send_cmd(Config.ServerName, "NOTICE @%s :%s", dest->name.c_str(), buf.c_str());
}
/* SERVER services-dev.chatspike.net password 0 :Description here */
void SendServer(Server *server)
{
- send_cmd(Config.ServerName, "SERVER %s %s %d :%s", server->GetName().c_str(), currentpass, server->GetHops(), server->GetDescription().c_str());
+ send_cmd(Config.ServerName, "SERVER %s %s %d :%s", server->GetName().c_str(), currentpass.c_str(), server->GetHops(), server->GetDescription().c_str());
}
/* JOIN */
- void SendJoin(BotInfo *user, const char *channel, time_t chantime)
+ void SendJoin(BotInfo *user, const Anope::string &channel, time_t chantime)
{
- send_cmd(user->nick, "JOIN %s %ld", channel, static_cast<long>(chantime));
+ send_cmd(user->nick, "JOIN %s %ld", channel.c_str(), static_cast<long>(chantime));
}
/* UNSQLINE */
@@ -216,58 +194,58 @@ class InspIRCdProto : public IRCDProto
/* SQLINE */
void SendSQLine(XLine *x)
{
- send_cmd(Config.ServerName, "ADDLINE Q %s %s %ld 0 :%s", x->Mask.c_str(), Config.s_OperServ, static_cast<long>(time(NULL)), x->Reason.c_str());
+ send_cmd(Config.ServerName, "ADDLINE Q %s %s %ld 0 :%s", x->Mask.c_str(), Config.s_OperServ.c_str(), static_cast<long>(time(NULL)), x->Reason.c_str());
}
/* SQUIT */
- void SendSquit(const char *servname, const char *message)
+ void SendSquit(const Anope::string &servname, const Anope::string &message)
{
- if (!servname || !message)
+ if (servname.empty() || message.empty())
return;
- send_cmd(Config.ServerName, "SQUIT %s :%s", servname, message);
+ send_cmd(Config.ServerName, "SQUIT %s :%s", servname.c_str(), message.c_str());
}
/* Functions that use serval cmd functions */
- void SendVhost(User *u, const std::string &vIdent, const std::string &vhost)
+ void SendVhost(User *u, const Anope::string &vIdent, const Anope::string &vhost)
{
if (!vIdent.empty())
- inspircd_cmd_chgident(u->nick.c_str(), vIdent.c_str());
+ inspircd_cmd_chgident(u->nick, vIdent);
if (!vhost.empty())
- inspircd_cmd_chghost(u->nick.c_str(), vhost.c_str());
+ inspircd_cmd_chghost(u->nick, vhost);
}
void SendConnect()
{
inspircd_cmd_pass(uplink_server->password);
SendServer(Me);
- send_cmd(NULL, "BURST");
- send_cmd(Config.ServerName, "VERSION :Anope-%s %s :%s - (%s) -- %s", Anope::Version().c_str(), Config.ServerName, ircd->name, Config.EncModuleList.begin()->c_str(), Anope::Build().c_str());
+ send_cmd("", "BURST");
+ send_cmd(Config.ServerName, "VERSION :Anope-%s %s :%s - (%s) -- %s", Anope::Version().c_str(), Config.ServerName.c_str(), ircd->name, Config.EncModuleList.begin()->c_str(), Anope::Build().c_str());
}
/* CHGIDENT */
- void inspircd_cmd_chgident(const char *nick, const char *vIdent)
+ void inspircd_cmd_chgident(const Anope::string &nick, const Anope::string &vIdent)
{
if (has_chgidentmod)
{
- if (!nick || !vIdent || !*vIdent)
+ if (nick.empty() || vIdent.empty())
return;
- send_cmd(Config.s_OperServ, "CHGIDENT %s %s", nick, vIdent);
+ send_cmd(Config.s_OperServ, "CHGIDENT %s %s", nick.c_str(), vIdent.c_str());
}
else
ircdproto->SendGlobops(OperServ, "CHGIDENT not loaded!");
}
/* SVSHOLD - set */
- void SendSVSHold(const char *nick)
+ void SendSVSHold(const Anope::string &nick)
{
- send_cmd(Config.s_OperServ, "SVSHOLD %s %ds :%s", nick, static_cast<int>(Config.NSReleaseTimeout), "Being held for registered user");
+ send_cmd(Config.s_OperServ, "SVSHOLD %s %ds :Being held for registered user", nick.c_str(), static_cast<int>(Config.NSReleaseTimeout));
}
/* SVSHOLD - release */
- void SendSVSHoldDel(const char *nick)
+ void SendSVSHoldDel(const Anope::string &nick)
{
- send_cmd(Config.s_OperServ, "SVSHOLD %s", nick);
+ send_cmd(Config.s_OperServ, "SVSHOLD %s", nick.c_str());
}
/* UNSZLINE */
@@ -288,38 +266,37 @@ class InspIRCdProto : public IRCDProto
u->RemoveMode(NickServ, UMODE_REGISTERED);
}
- void SendSVSJoin(const char *source, const char *nick, const char *chan, const char *param)
+ void SendSVSJoin(const Anope::string &source, const Anope::string &nick, const Anope::string &chan, const Anope::string &)
{
- send_cmd(source, "SVSJOIN %s %s", nick, chan);
+ send_cmd(source, "SVSJOIN %s %s", nick.c_str(), chan.c_str());
}
- void SendSVSPart(const char *source, const char *nick, const char *chan)
+ void SendSVSPart(const Anope::string &source, const Anope::string &nick, const Anope::string &chan)
{
- send_cmd(source, "SVSPART %s %s", nick, chan);
+ send_cmd(source, "SVSPART %s %s", nick.c_str(), chan.c_str());
}
void SendEOB()
{
- send_cmd(NULL, "ENDBURST");
+ send_cmd("", "ENDBURST");
}
void SetAutoIdentificationToken(User *u)
{
- char svidbuf[15];
if (!u->Account())
return;
- snprintf(svidbuf, sizeof(svidbuf), "%ld", static_cast<long>(u->timestamp));
+ Anope::string svidbuf = stringify(u->timestamp);
u->Account()->Shrink("authenticationtoken");
- u->Account()->Extend("authenticationtoken", new ExtensibleItemPointerArray<char>(sstrdup(svidbuf)));
+ u->Account()->Extend("authenticationtoken", new ExtensibleItemRegular<Anope::string>(svidbuf));
u->SetMode(NickServ, UMODE_REGISTERED);
}
} ircd_proto;
-int anope_event_ftopic(const char *source, int ac, const char **av)
+int anope_event_ftopic(const Anope::string &source, int ac, const char **av)
{
/* :source FTOPIC channel ts setby :topic */
const char *temp;
@@ -332,7 +309,7 @@ int anope_event_ftopic(const char *source, int ac, const char **av)
return MOD_CONT;
}
-int anope_event_mode(const char *source, int ac, const char **av)
+int anope_event_mode(const Anope::string &source, int ac, const char **av)
{
if (ac < 2)
return MOD_CONT;
@@ -345,7 +322,7 @@ int anope_event_mode(const char *source, int ac, const char **av)
users modes, we have to kludge this
as it slightly breaks RFC1459
*/
- if (!strcasecmp(source, av[0]))
+ if (source.equals_ci(av[0]))
do_umode(source, ac, av);
else
do_umode(av[0], ac, av);
@@ -353,7 +330,7 @@ int anope_event_mode(const char *source, int ac, const char **av)
return MOD_CONT;
}
-int anope_event_opertype(const char *source, int ac, const char **av)
+int anope_event_opertype(const Anope::string &source, int ac, const char **av)
{
/* opertype is equivalent to mode +o because servers
dont do this directly */
@@ -362,7 +339,7 @@ int anope_event_opertype(const char *source, int ac, const char **av)
if (u && !is_oper(u))
{
const char *newav[2];
- newav[0] = source;
+ newav[0] = source.c_str();
newav[1] = "+o";
return anope_event_mode(source, 2, newav);
}
@@ -370,7 +347,7 @@ int anope_event_opertype(const char *source, int ac, const char **av)
return MOD_CONT;