summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/actions.c2
-rw-r--r--src/bots.cpp97
-rw-r--r--src/botserv.c23
-rw-r--r--src/channels.c28
-rw-r--r--src/chanserv.c22
-rw-r--r--src/commands.c14
-rw-r--r--src/core/bs_assign.c6
-rw-r--r--src/core/bs_bot.c42
-rw-r--r--src/core/bs_botlist.c4
-rw-r--r--src/core/bs_info.c8
-rw-r--r--src/core/bs_set.c4
-rw-r--r--src/core/cs_akick.c16
-rw-r--r--src/core/db_plain.cpp4
-rw-r--r--src/core/os_defcon.c8
-rw-r--r--src/core/ss_main.c2
-rw-r--r--src/init.c9
-rw-r--r--src/messages.c46
-rw-r--r--src/misc.c7
-rw-r--r--src/nickserv.c2
-rw-r--r--src/protocol/bahamut.c10
-rw-r--r--src/protocol/inspircd11.c11
-rw-r--r--src/protocol/inspircd12.cpp10
-rw-r--r--src/protocol/ratbox.c10
-rw-r--r--src/protocol/unreal32.c14
-rw-r--r--src/send.c2
-rw-r--r--src/servers.c2
-rw-r--r--src/users.c4
27 files changed, 176 insertions, 231 deletions
diff --git a/src/actions.c b/src/actions.c
index 0e15f2cf4..1d2b7d2e4 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -158,7 +158,7 @@ void common_unban(ChannelInfo *ci, const std::string &nick)
for (ban = ci->c->bans->entries; ban; ban = next)
{
next = ban->next;
- if (entry_match(ban, u->nick.c_str(), u->GetIdent().c_str(), u->host, ip) || entry_match(ban, u->nick.c_str(), u->GetIdent().c_str(), u->GetDisplayedHost().c_str(), ip))
+ if (entry_match(ban, u->nick, u->GetIdent(), u->host, ip) || entry_match(ban, u->nick, u->GetIdent().c_str(), u->GetDisplayedHost().c_str(), ip))
ci->c->RemoveMode(NULL, CMODE_BAN, ban->mask);
}
}
diff --git a/src/bots.cpp b/src/bots.cpp
index ddd517b77..bb8b8a06f 100644
--- a/src/bots.cpp
+++ b/src/bots.cpp
@@ -12,75 +12,42 @@
#include "services.h"
#include "modules.h"
-BotInfo::BotInfo(const char *nnick)
+BotInfo::BotInfo(const std::string &nnick, const std::string &nuser, const std::string &nhost, const std::string &nreal)
{
- this->nick = sstrdup(nnick);
+ this->nick = nnick;
+ this->user = nuser;
+ this->host = nhost;
+ this->real = nreal;
this->lastmsg = this->created = time(NULL);
this->uid = ts6_uid_retrieve(); // XXX is this safe? has ts6 been setup yet?
- nbots++;
+ ++nbots;
this->cmdTable = NULL;
this->chancount = 0;
- if (Config.s_ChanServ && !stricmp(Config.s_ChanServ, nnick))
+ ci::string ci_nick(nnick.c_str());
+ if (Config.s_ChanServ && ci_nick == Config.s_ChanServ)
this->SetFlag(BI_CHANSERV);
- else if (Config.s_BotServ && !stricmp(Config.s_BotServ, nnick))
+ else if (Config.s_BotServ && ci_nick == Config.s_BotServ)
this->SetFlag(BI_BOTSERV);
- else if (Config.s_HostServ && !stricmp(Config.s_HostServ, nnick))
+ else if (Config.s_HostServ && ci_nick == Config.s_HostServ)
this->SetFlag(BI_HOSTSERV);
- else if (Config.s_OperServ && !stricmp(Config.s_OperServ, nnick))
+ else if (Config.s_OperServ && ci_nick == Config.s_OperServ)
this->SetFlag(BI_OPERSERV);
- else if (Config.s_MemoServ && !stricmp(Config.s_MemoServ, nnick))
+ else if (Config.s_MemoServ && ci_nick == Config.s_MemoServ)
this->SetFlag(BI_MEMOSERV);
- else if (Config.s_NickServ && !stricmp(Config.s_NickServ, nnick))
+ else if (Config.s_NickServ && ci_nick == Config.s_NickServ)
this->SetFlag(BI_NICKSERV);
- else if (Config.s_GlobalNoticer && !stricmp(Config.s_GlobalNoticer, nnick))
+ else if (Config.s_GlobalNoticer && ci_nick == Config.s_GlobalNoticer)
this->SetFlag(BI_GLOBAL);
-
- FOREACH_MOD(I_OnBotPreLoad, OnBotPreLoad(this));
-
- insert_bot(this); // XXX, this is ugly, but it needs to stay until hashing of bots is redone in STL.
-
- // If we're synchronised with the uplink already, call introduce_user() for this bot.
- alog("serv_uplink is %p and status is %d", static_cast<void *>(serv_uplink), serv_uplink ? serv_uplink->sync == SSYNC_DONE : 0);
- if (serv_uplink && serv_uplink->sync == SSYNC_DONE)
- ircdproto->SendClientIntroduction(this->nick, this->user, this->host, this->real, ircd->pseudoclient_mode, this->uid.c_str());
-}
-BotInfo::BotInfo(const char *nnick, const char *nuser, const char *nhost, const char *nreal)
-{
- this->nick = sstrdup(nnick);
- this->user = sstrdup(nuser);
- this->host = sstrdup(nhost);
- this->real = sstrdup(nreal);
- this->lastmsg = this->created = time(NULL);
- this->uid = ts6_uid_retrieve(); // XXX is this safe? has ts6 been setup yet?
- nbots++;
- this->cmdTable = NULL;
- this->chancount = 0;
-
- if (Config.s_ChanServ && !stricmp(Config.s_ChanServ, nnick))
- this->SetFlag(BI_CHANSERV);
- else if (Config.s_BotServ && !stricmp(Config.s_BotServ, nnick))
- this->SetFlag(BI_BOTSERV);
- else if (Config.s_HostServ && !stricmp(Config.s_HostServ, nnick))
- this->SetFlag(BI_HOSTSERV);
- else if (Config.s_OperServ && !stricmp(Config.s_OperServ, nnick))
- this->SetFlag(BI_OPERSERV);
- else if (Config.s_MemoServ && !stricmp(Config.s_MemoServ, nnick))
- this->SetFlag(BI_MEMOSERV);
- else if (Config.s_NickServ && !stricmp(Config.s_NickServ, nnick))
- this->SetFlag(BI_NICKSERV);
- else if (Config.s_GlobalNoticer && !stricmp(Config.s_GlobalNoticer, nnick))
- this->SetFlag(BI_GLOBAL);
-
FOREACH_MOD(I_OnBotPreLoad, OnBotPreLoad(this));
-
+
insert_bot(this); // XXX, this is ugly, but it needs to stay until hashing of bots is redone in STL.
// If we're synchronised with the uplink already, call introduce_user() for this bot.
alog("serv_uplink is %p and status is %d", static_cast<void *>(serv_uplink), serv_uplink ? serv_uplink->sync == SSYNC_DONE : 0);
if (serv_uplink && serv_uplink->sync == SSYNC_DONE)
- ircdproto->SendClientIntroduction(this->nick, this->user, this->host, this->real, ircd->pseudoclient_mode, this->uid.c_str());
+ ircdproto->SendClientIntroduction(this->nick, this->user, this->host, this->real, ircd->pseudoclient_mode, this->uid);
}
BotInfo::~BotInfo()
@@ -88,7 +55,7 @@ BotInfo::~BotInfo()
int i;
ChannelInfo *ci;
- for (i = 0; i < 256; i++)
+ for (i = 0; i < 256; ++i)
for (ci = chanlists[i]; ci; ci = ci->next)
if (ci->bi == this)
ci->bi = NULL;
@@ -98,14 +65,9 @@ BotInfo::~BotInfo()
if (this->prev)
this->prev->next = this->next;
else
- botlists[tolower(*this->nick)] = this->next;
+ botlists[tolower(this->nick[0])] = this->next;
- nbots--;
-
- delete [] this->nick;
- delete [] this->user;
- delete [] this->host;
- delete [] this->real;
+ --nbots;
}
@@ -116,11 +78,9 @@ void BotInfo::ChangeNick(const char *newnick)
if (this->prev)
this->prev->next = this->next;
else
- botlists[tolower(*this->nick)] = this->next;
+ botlists[tolower(this->nick[0])] = this->next;
- if (this->nick)
- delete [] this->nick;
- this->nick = sstrdup(newnick);
+ this->nick = newnick;
insert_bot(this);
}
@@ -130,7 +90,7 @@ void BotInfo::RejoinAll()
int i;
ChannelInfo *ci;
- for (i = 0; i < 256; i++)
+ for (i = 0; i < 256; ++i)
for (ci = chanlists[i]; ci; ci = ci->next)
if (ci->bi == this && ci->c && (ci->c->usercount >= Config.BSMinUsers))
bot_join(ci);
@@ -144,15 +104,10 @@ void BotInfo::Assign(User *u, ChannelInfo *ci)
return;
if (ci->bi)
- {
- if (u)
- ci->bi->UnAssign(u, ci);
- else
- ci->bi->UnAssign(NULL, ci);
- }
+ ci->bi->UnAssign(u, ci);
ci->bi = this;
- this->chancount++;
+ ++this->chancount;
if (ci->c && ci->c->usercount >= Config.BSMinUsers)
bot_join(ci);
}
@@ -172,8 +127,6 @@ void BotInfo::UnAssign(User *u, ChannelInfo *ci)
ircdproto->SendPart(ci->bi, ci->c, "");
}
- ci->bi->chancount--;
+ --ci->bi->chancount;
ci->bi = NULL;
}
-
-
diff --git a/src/botserv.c b/src/botserv.c
index f145e7028..148d71b97 100644
--- a/src/botserv.c
+++ b/src/botserv.c
@@ -52,10 +52,10 @@ void get_botserv_stats(long *nrec, long *memuse)
for (bi = botlists[i]; bi; bi = bi->next) {
count++;
mem += sizeof(*bi);
- mem += strlen(bi->nick) + 1;
- mem += strlen(bi->user) + 1;
- mem += strlen(bi->host) + 1;
- mem += strlen(bi->real) + 1;
+ mem += bi->nick.size() + 1;
+ mem += bi->user.size() + 1;
+ mem += bi->host.size() + 1;
+ mem += bi->real.size() + 1;
}
}
@@ -463,17 +463,18 @@ void botchanmsgs(User * u, ChannelInfo * ci, char *buf)
/* Inserts a bot in the bot list. I can't be much explicit mh? */
-void insert_bot(BotInfo * bi)
+void insert_bot(BotInfo *bi)
{
BotInfo *ptr, *prev;
- for (prev = NULL, ptr = botlists[tolower(*bi->nick)];
- ptr != NULL && stricmp(ptr->nick, bi->nick) < 0;
+ ci::string ci_bi_nick(bi->nick.c_str());
+ for (prev = NULL, ptr = botlists[tolower(bi->nick[0])];
+ ptr != NULL && ci_bi_nick > ptr->nick.c_str();
prev = ptr, ptr = ptr->next);
bi->prev = prev;
bi->next = ptr;
if (!prev)
- botlists[tolower(*bi->nick)] = bi;
+ botlists[tolower(bi->nick[0])] = bi;
else
prev->next = bi;
if (ptr)
@@ -648,7 +649,7 @@ void bot_join(ChannelInfo * ci)
|| (limit && ci->c->usercount >= limit))
ircdproto->SendNoticeChanops(ci->bi, ci->c,
"%s invited %s into the channel.",
- ci->bi->nick, ci->bi->nick);
+ ci->bi->nick.c_str(), ci->bi->nick.c_str());
}
ircdproto->SendJoin(ci->bi, ci->c->name.c_str(), ci->c->creation_time);
ci->c->SetMode(NULL, CMODE_PROTECT, ci->bi->nick);
@@ -756,7 +757,7 @@ void bot_raw_ban(User * requester, ChannelInfo * ci, char *nick,
kav[1] = nick;
if (!reason) {
- kav[2] = ci->bi->nick;
+ kav[2] = ci->bi->nick.c_str();
} else {
if (strlen(reason) > 200)
(*const_cast<char **>(&reason))[200] = '\0'; // Unsafe cast -- will review later -- CyberBotX
@@ -801,7 +802,7 @@ void bot_raw_kick(User * requester, ChannelInfo * ci, char *nick,
av[1] = nick;
if (!reason) {
- av[2] = ci->bi->nick;
+ av[2] = ci->bi->nick.c_str();
} else {
if (strlen(reason) > 200)
(*const_cast<char **>(&reason))[200] = '\0'; // Unsafe cast -- will review later -- CyberBotX
diff --git a/src/channels.c b/src/channels.c
index 5e9ca98de..85b026b40 100644
--- a/src/channels.c
+++ b/src/channels.c
@@ -50,7 +50,7 @@ Channel::Channel(const std::string &name, time_t ts)
this->server_modetime = this->chanserv_modetime = 0;
this->server_modecount = this->chanserv_modecount = this->bouncy_modes = this->topic_sync = 0;
- this->ci = cs_findchan(this->name.c_str());
+ this->ci = cs_findchan(this->name);
if (this->ci)
{
this->ci->c = this;
@@ -1139,7 +1139,7 @@ void do_join(const char *source, int ac, const char **av)
* av[2] = reason
*/
-void do_kick(const char *source, int ac, const char **av)
+void do_kick(const std::string &source, int ac, const char **av)
{
BotInfo *bi;
ChannelInfo *ci;
@@ -2309,32 +2309,26 @@ EList *list_create()
* @param ip IP to match against, set to 0 to not match this
* @return 1 for a match, 0 for no match
*/
-int entry_match(Entry * e, const char *nick, const char *user, const char *host, uint32 ip)
+int entry_match(Entry *e, const std::string &nick, const std::string &user, const std::string &host, uint32 ip)
{
/* If we don't get an entry, or it s an invalid one, no match ~ Viper */
if (!e || !e->FlagCount())
return 0;
- if (ircd->cidrchanbei && (e->HasFlag(ENTRYTYPE_CIDR4)) &&
- (!ip || (ip && ((ip & e->cidr_mask) != e->cidr_ip))))
+ ci::string ci_nick(nick.c_str()), ci_user(user.c_str()), ci_host(host.c_str());
+ if (ircd->cidrchanbei && e->HasFlag(ENTRYTYPE_CIDR4) && (!ip || (ip && (ip & e->cidr_mask) != e->cidr_ip)))
return 0;
- if ((e->HasFlag(ENTRYTYPE_NICK))
- && (!nick || stricmp(e->nick, nick) != 0))
+ if (e->HasFlag(ENTRYTYPE_NICK) && (nick.empty() || nick != e->nick))
return 0;
- if ((e->HasFlag(ENTRYTYPE_USER))
- && (!user || stricmp(e->user, user) != 0))
+ if (e->HasFlag(ENTRYTYPE_USER) && (user.empty() || user != e->user))
return 0;
- if ((e->HasFlag(ENTRYTYPE_HOST))
- && (!user || stricmp(e->host, host) != 0))
+ if (e->HasFlag(ENTRYTYPE_HOST) && (host.empty() || host != e->host))
return 0;
- if ((e->HasFlag(ENTRYTYPE_NICK_WILD))
- && !Anope::Match(nick, e->nick, false))
+ if (e->HasFlag(ENTRYTYPE_NICK_WILD) && !Anope::Match(nick, e->nick, false))
return 0;
- if ((e->HasFlag(ENTRYTYPE_USER_WILD))
- && !Anope::Match(user, e->user, false))
+ if (e->HasFlag(ENTRYTYPE_USER_WILD) && !Anope::Match(user, e->user, false))
return 0;
- if ((e->HasFlag(ENTRYTYPE_HOST_WILD))
- && !Anope::Match(host, e->host, false))
+ if (e->HasFlag(ENTRYTYPE_HOST_WILD) && !Anope::Match(host, e->host, false))
return 0;
return 1;
diff --git a/src/chanserv.c b/src/chanserv.c
index a9ab953fc..5fcfee37f 100644
--- a/src/chanserv.c
+++ b/src/chanserv.c
@@ -131,7 +131,7 @@ class ChanServTimer : public Timer
void Tick(time_t ctime)
{
- ChannelInfo *ci = cs_findchan(channel.c_str());
+ ChannelInfo *ci = cs_findchan(channel);
if (ci)
ci->UnsetFlag(CI_INHABIT);
@@ -472,7 +472,7 @@ int check_valid_op(User * user, Channel * chan, int servermode)
chan->RemoveMode(NULL, CMODE_OP, user->nick);
if (halfop && !check_access(user, chan->ci, CA_AUTOHALFOP))
chan->RemoveMode(NULL, CMODE_HALFOP, user->nick);
-
+
return 0;
}
@@ -511,7 +511,7 @@ int check_should_op(User * user, char *chan)
if (check_access(user, ci, CA_AUTOOP))
{
- ci->c->SetMode(NULL, CMODE_OP, user->nick);
+ ci->c->SetMode(NULL, CMODE_OP, user->nick);
return 1;
}
@@ -968,11 +968,11 @@ void cs_remove_nick(const NickCore * nc)
/* Return the ChannelInfo structure for the given channel, or NULL if the
* channel isn't registered. */
-ChannelInfo *cs_findchan(const char *chan)
+ChannelInfo *cs_findchan(const std::string &chan)
{
ChannelInfo *ci;
- if (!chan || !*chan) {
+ if (chan.empty()) {
if (debug) {
alog("debug: cs_findchan() called with NULL values");
}
@@ -981,7 +981,7 @@ ChannelInfo *cs_findchan(const char *chan)
for (ci = chanlists[static_cast<unsigned char>(tolower(chan[1]))]; ci;
ci = ci->next) {
- if (stricmp(ci->name.c_str(), chan) == 0)
+ if (ci::string(ci->name.c_str()) == chan)
return ci;
}
return NULL;
@@ -1094,7 +1094,7 @@ bool IsFounder(User *user, ChannelInfo *ci)
if (IsRealFounder(user, ci))
return true;
-
+
if (user->nc)
access = ci->GetAccess(user->nc);
else
@@ -1103,7 +1103,7 @@ bool IsFounder(User *user, ChannelInfo *ci)
if (na)
access = ci->GetAccess(na->nc);
}
-
+
/* If they're QOP+ and theyre identified or theyre recognized and the channel isn't secure */
if (access && access->level >= ACCESS_QOP && (user->nc || (user->IsRecognized() && !(ci->HasFlag(CI_SECURE)))))
return true;
@@ -1148,10 +1148,10 @@ int get_access(User *user, ChannelInfo *ci)
/* SuperAdmin always has highest level */
if (user->isSuperAdmin)
return ACCESS_SUPERADMIN;
-
+
if (IsFounder(user, ci))
return ACCESS_FOUNDER;
-
+
if (nick_identified(user))
{
access = ci->GetAccess(user->nc);
@@ -1292,7 +1292,7 @@ AutoKick *is_stuck(ChannelInfo * ci, const char *mask)
{
if (!ci)
return NULL;
-
+
for (unsigned i = 0; i < ci->GetAkickCount(); ++i)
{
AutoKick *akick = ci->GetAkick(i);
diff --git a/src/commands.c b/src/commands.c
index 553bc2442..f8a1bba62 100644
--- a/src/commands.c
+++ b/src/commands.c
@@ -48,7 +48,7 @@ Command *lookup_cmd(Command * list, char *cmd)
* @param cmd Command
* @return void
*/
-void mod_run_cmd(char *service, User * u, CommandHash * cmdTable[], const char *cmd)
+void mod_run_cmd(const std::string &service, User * u, CommandHash * cmdTable[], const char *cmd)
{
Command *c = findCommand(cmdTable, cmd);
int retVal = MOD_CONT;
@@ -58,10 +58,10 @@ void mod_run_cmd(char *service, User * u, CommandHash * cmdTable[], const char *
FOREACH_RESULT(I_OnPreCommandRun, OnPreCommandRun(service, u, cmd, c));
if (MOD_RESULT == EVENT_STOP)
return;
-
+
if (!c)
{
- notice_lang(service, u, UNKNOWN_COMMAND_HELP, cmd, service);
+ notice_lang(service, u, UNKNOWN_COMMAND_HELP, cmd, service.c_str());
return;
}
@@ -71,7 +71,7 @@ void mod_run_cmd(char *service, User * u, CommandHash * cmdTable[], const char *
if (!nick_identified(u))
{
notice_lang(service, u, NICK_IDENTIFY_REQUIRED, Config.s_NickServ);
- alog("Access denied for unregistered user %s with service %s and command %s", u->nick.c_str(), service, cmd);
+ alog("Access denied for unregistered user %s with service %s and command %s", u->nick.c_str(), service.c_str(), cmd);
return;
}
}
@@ -122,14 +122,14 @@ void mod_run_cmd(char *service, User * u, CommandHash * cmdTable[], const char *
{
notice_lang(service, u, CHAN_X_FORBIDDEN, ci->name.c_str());
alog("Access denied for user %s with service %s and command %s because of FORBIDDEN channel %s",
- u->nick.c_str(), service, cmd, ci->name.c_str());
+ u->nick.c_str(), service.c_str(), cmd, ci->name.c_str());
return;
}
else if ((ci->HasFlag(CI_SUSPENDED)) && (!c->HasFlag(CFLAG_ALLOW_SUSPENDED)))
{
notice_lang(service, u, CHAN_X_FORBIDDEN, ci->name.c_str());
alog("Access denied for user %s with service %s and command %s because of SUSPENDED channel %s",
- u->nick.c_str(), service, cmd, ci->name.c_str());
+ u->nick.c_str(), service.c_str(), cmd, ci->name.c_str());
return;
}
}
@@ -153,7 +153,7 @@ void mod_run_cmd(char *service, User * u, CommandHash * cmdTable[], const char *
if (!u->nc->HasCommand(c->permission))
{
notice_lang(service, u, ACCESS_DENIED);
- alog("Access denied for user %s with service %s and command %s", u->nick.c_str(), service, cmd);
+ alog("Access denied for user %s with service %s and command %s", u->nick.c_str(), service.c_str(), cmd);
return;
}
diff --git a/src/core/bs_assign.c b/src/core/bs_assign.c
index 56912559e..bf9fdc5b2 100644
--- a/src/core/bs_assign.c
+++ b/src/core/bs_assign.c
@@ -55,14 +55,14 @@ class CommandBSAssign : public Command
return MOD_CONT;
}
- if ((ci->bi) && (stricmp(ci->bi->nick, nick) == 0))
+ if (ci->bi && ci::string(ci->bi->nick.c_str()) == nick)
{
- notice_lang(Config.s_BotServ, u, BOT_ASSIGN_ALREADY, ci->bi->nick, chan);
+ notice_lang(Config.s_BotServ, u, BOT_ASSIGN_ALREADY, ci->bi->nick.c_str(), chan);
return MOD_CONT;
}
bi->Assign(u, ci);
- notice_lang(Config.s_BotServ, u, BOT_ASSIGN_ASSIGNED, bi->nick, ci->name.c_str());
+ notice_lang(Config.s_BotServ, u, BOT_ASSIGN_ASSIGNED, bi->nick.c_str(), ci->name.c_str());
return MOD_CONT;
}
diff --git a/src/core/bs_bot.c b/src/core/bs_bot.c
index 0d057849e..3692840bd 100644
--- a/src/core/bs_bot.c
+++ b/src/core/bs_bot.c
@@ -110,8 +110,7 @@ class CommandBSBot : public Command
/* We check whether user with this nick is online, and kill it if so */
EnforceQlinedNick(nick, Config.s_BotServ);
- notice_lang(Config.s_BotServ, u, BOT_BOT_ADDED, bi->nick, bi->user,
- bi->host, bi->real);
+ notice_lang(Config.s_BotServ, u, BOT_BOT_ADDED, bi->nick.c_str(), bi->user.c_str(), bi->host.c_str(), bi->real.c_str());
FOREACH_MOD(I_OnBotCreate, OnBotCreate(bi));
return MOD_CONT;
@@ -174,10 +173,7 @@ class CommandBSBot : public Command
* And we must finally check that the nick is not already
* taken by another bot.
*/
- if (!strcmp(bi->nick, nick)
- && ((user) ? !strcmp(bi->user, user) : 1)
- && ((host) ? !strcmp(bi->host, host) : 1)
- && ((real) ? !strcmp(bi->real, real) : 1))
+ if (bi->nick == nick && (user ? bi->user == user : 1) && (host ? bi->host == host : 1) && (real ? bi->real == real : 1))
{
notice_lang(Config.s_BotServ, u, BOT_BOT_ANY_CHANGES);
return MOD_CONT;
@@ -224,13 +220,14 @@ class CommandBSBot : public Command
}
}
- if (stricmp(bi->nick, nick) && findbot(nick))
+ ci::string ci_bi_nick(bi->nick.c_str());
+ if (ci_bi_nick != nick && findbot(nick))
{
notice_lang(Config.s_BotServ, u, BOT_BOT_ALREADY_EXISTS, nick);
return MOD_CONT;
}
- if (stricmp(bi->nick, nick))
+ if (ci_bi_nick != nick)
{
/* We check whether the nick is registered, and inform the user
* if so. You need to drop the nick manually before you can use
@@ -260,24 +257,15 @@ class CommandBSBot : public Command
ircdproto->SendSQLine(bi->nick, "Reserved for services");
}
- if (strcmp(nick, bi->nick))
+ if (bi->nick != nick)
bi->ChangeNick(nick);
- if (user && strcmp(user, bi->user))
- {
- delete [] bi->user;
- bi->user = sstrdup(user);
- }
- if (host && strcmp(host, bi->host))
- {
- delete [] bi->host;
- bi->host = sstrdup(host);
- }
- if (real && strcmp(real, bi->real))
- {
- delete [] bi->real;
- bi->real = sstrdup(real);
- }
+ if (user && bi->user != user)
+ bi->user = user;
+ if (host && bi->host != host)
+ bi->host = host;
+ if (real && bi->real != real)
+ bi->real = real;
if (user)
{
@@ -285,13 +273,11 @@ class CommandBSBot : public Command
// This isn't the nicest way to do this, unfortunately.
bi->uid = ts6_uid_retrieve();
}
- ircdproto->SendClientIntroduction(bi->nick, bi->user, bi->host, bi->real,
- ircd->pseudoclient_mode, bi->uid.c_str());
+ ircdproto->SendClientIntroduction(bi->nick, bi->user, bi->host, bi->real, ircd->pseudoclient_mode, bi->uid);
bi->RejoinAll();
}
- notice_lang(Config.s_BotServ, u, BOT_BOT_CHANGED,
- oldnick, bi->nick, bi->user, bi->host, bi->real);
+ notice_lang(Config.s_BotServ, u, BOT_BOT_CHANGED, oldnick, bi->nick.c_str(), bi->user.c_str(), bi->host.c_str(), bi->real.c_str());
FOREACH_MOD(I_OnBotChange, OnBotChange(bi));
return MOD_CONT;
diff --git a/src/core/bs_botlist.c b/src/core/bs_botlist.c
index afc0ba996..e43224e69 100644
--- a/src/core/bs_botlist.c
+++ b/src/core/bs_botlist.c
@@ -38,7 +38,7 @@ class CommandBSBotList : public Command
if (!count)
notice_lang(Config.s_BotServ, u, BOT_BOTLIST_HEADER);
count++;
- u->SendMessage(Config.s_BotServ, " %-15s (%s@%s)", bi->nick, bi->user, bi->host);
+ u->SendMessage(Config.s_BotServ, " %-15s (%s@%s)", bi->nick.c_str(), bi->user.c_str(), bi->host.c_str());
}
}
}
@@ -49,7 +49,7 @@ class CommandBSBotList : public Command
for (i = 0; i < 256; i++) {
for (bi = botlists[i]; bi; bi = bi->next) {
if (bi->HasFlag(BI_PRIVATE)) {
- u->SendMessage(Config.s_BotServ, " %-15s (%s@%s)", bi->nick, bi->user, bi->host);
+ u->SendMessage(Config.s_BotServ, " %-15s (%s@%s)", bi->nick.c_str(), bi->user.c_str(), bi->host.c_str());
count++;
}
}
diff --git a/src/core/bs_info.c b/src/core/bs_info.c
index 5cb89c673..073773cee 100644
--- a/src/core/bs_info.c
+++ b/src/core/bs_info.c
@@ -66,9 +66,9 @@ class CommandBSInfo : public Command
{
struct tm *tm;
- notice_lang(Config.s_BotServ, u, BOT_INFO_BOT_HEADER, bi->nick);
- notice_lang(Config.s_BotServ, u, BOT_INFO_BOT_MASK, bi->user, bi->host);
- notice_lang(Config.s_BotServ, u, BOT_INFO_BOT_REALNAME, bi->real);
+ notice_lang(Config.s_BotServ, u, BOT_INFO_BOT_HEADER, bi->nick.c_str());
+ notice_lang(Config.s_BotServ, u, BOT_INFO_BOT_MASK, bi->user.c_str(), bi->host.c_str());
+ notice_lang(Config.s_BotServ, u, BOT_INFO_BOT_REALNAME, bi->real.c_str());
tm = localtime(&bi->created);
strftime_lang(buf, sizeof(buf), u, STRFTIME_DATE_TIME_FORMAT, tm);
notice_lang(Config.s_BotServ, u, BOT_INFO_BOT_CREATED, buf);
@@ -88,7 +88,7 @@ class CommandBSInfo : public Command
notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_HEADER, ci->name.c_str());
if (ci->bi)
- notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_BOT, ci->bi->nick);
+ notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_BOT, ci->bi->nick.c_str());
else
notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_BOT_NONE);
diff --git a/src/core/bs_set.c b/src/core/bs_set.c
index deffc5833..28094653b 100644
--- a/src/core/bs_set.c
+++ b/src/core/bs_set.c
@@ -49,12 +49,12 @@ class CommandBSSet : public Command
if (value == "ON")
{
bi->SetFlag(BI_PRIVATE);
- notice_lang(Config.s_BotServ, u, BOT_SET_PRIVATE_ON, bi->nick);
+ notice_lang(Config.s_BotServ, u, BOT_SET_PRIVATE_ON, bi->nick.c_str());
}
else if (value == "OFF")
{
bi->UnsetFlag(BI_PRIVATE);
- notice_lang(Config.s_BotServ, u, BOT_SET_PRIVATE_OFF, bi->nick);
+ notice_lang(Config.s_BotServ, u, BOT_SET_PRIVATE_OFF, bi->nick.c_str());
}
else
{
diff --git a/src/core/cs_akick.c b/src/core/cs_akick.c
index 625e226c6..881cd01ec 100644
--- a/src/core/cs_akick.c
+++ b/src/core/cs_akick.c
@@ -387,16 +387,16 @@ class CommandCSAKick : public Command
&& akick->mask == mask))
break;
}
-
+
if (i == ci->GetAkickCount())
{
- notice_lang(Config.s_ChanServ, u, CHAN_AKICK_NOT_FOUND, mask.c_str(), ci->name.c_str());
- return;
- }
-
+ notice_lang(Config.s_ChanServ, u, CHAN_AKICK_NOT_FOUND, mask.c_str(), ci->name.c_str());
+ return;
+ }
+
ci->EraseAkick(akick);
-
- notice_lang(Config.s_ChanServ, u, CHAN_AKICK_DELETED, mask.c_str(), ci->name.c_str());
+
+ notice_lang(Config.s_ChanServ, u, CHAN_AKICK_DELETED, mask.c_str(), ci->name.c_str());
}
}
@@ -543,7 +543,7 @@ class CommandCSAKick : public Command
this->DoAdd(u, ci, params);
else if (cmd == "STICK")
this->DoStick(u, ci, params);
- else if (cmd == "UNSTICK")
+ else if (cmd == "UNSTICK")
this->DoUnStick(u, ci, params);
else if (cmd == "DEL")
this->DoDel(u, ci, params);
diff --git a/src/core/db_plain.cpp b/src/core/db_plain.cpp
index 0f4d6ccb5..5cc6ab42b 100644
--- a/src/core/db_plain.cpp
+++ b/src/core/db_plain.cpp
@@ -105,7 +105,7 @@ static void ReadDatabase(Module *m = NULL)
}
else if (params[0] == "CH")
{
- ci = cs_findchan(params[1].c_str());
+ ci = cs_findchan(params[1]);
Type = MD_CH;
}
else if (params[0] == "MD")
@@ -435,7 +435,7 @@ static void LoadBotInfo(const std::vector<std::string> &params)
bi->real = sstrdup(params[6].c_str());
if (debug > 1)
- alog("[db_plain]: Loaded botinfo for %s", bi->nick);
+ alog("[db_plain]: Loaded botinfo for %s", bi->nick.c_str());
}
static void LoadChanInfo(const std::vector<std::string> &params)
diff --git a/src/core/os_defcon.c b/src/core/os_defcon.c
index 46aa64131..42320b8d5 100644
--- a/src/core/os_defcon.c
+++ b/src/core/os_defcon.c
@@ -187,7 +187,7 @@ class OSDEFCON : public Module
if (CheckDefCon(DEFCON_FORCE_CHAN_MODES) && cm && DefConModesOff.HasFlag(Name))
{
c->RemoveMode(findbot(Config.s_OperServ), Name);
-
+
return EVENT_STOP;
}
@@ -201,7 +201,7 @@ class OSDEFCON : public Module
if (CheckDefCon(DEFCON_FORCE_CHAN_MODES) && cm && DefConModesOn.HasFlag(Name))
{
std::string param;
-
+
if (GetDefConParam(Name, &param))
{
c->SetMode(findbot(Config.s_OperServ), Name, param);
@@ -216,7 +216,7 @@ class OSDEFCON : public Module
return EVENT_CONTINUE;
}
- EventReturn OnPreCommandRun(const char *service, User *u, const char *cmd, Command *c)
+ EventReturn OnPreCommandRun(const std::string &service, User *u, const char *cmd, Command *c)
{
if (!c)
{
@@ -302,7 +302,7 @@ class OSDEFCON : public Module
kill_user(Config.s_OperServ, u->nick, "Session limit exceeded");
session->hits++;
- if (Config.MaxSessionKill && session->hits >= Config.MaxSessionKill)
+ if (Config.MaxSessionKill && session->hits >= Config.MaxSessionKill)
{
char akillmask[BUFSIZE];
snprintf(akillmask, sizeof(akillmask), "*@%s", u->host);
diff --git a/src/core/ss_main.c b/src/core/ss_main.c
index 258effa18..f3957a3bc 100644
--- a/src/core/ss_main.c
+++ b/src/core/ss_main.c
@@ -75,7 +75,7 @@ class SSMain : public Module
void OnBotPreLoad(BotInfo *bi)
{
- if (!strcmp(bi->nick, "StatServ"))
+ if (bi->nick == "StatServ")
{
delete statserv;
statserv = bi;
diff --git a/src/init.c b/src/init.c
index bde426578..cd53e67bf 100644
--- a/src/init.c
+++ b/src/init.c
@@ -21,7 +21,7 @@ extern void moduleAddIRCDMsgs();
/*************************************************************************/
-void introduce_user(const char *user)
+void introduce_user(const std::string &user)
{
/* Watch out for infinite loops... */
@@ -37,12 +37,13 @@ void introduce_user(const char *user)
int i;
/* XXX: it might be nice to have this inside BotInfo's constructor, or something? */
- for (i = 0; i < 256; i++)
+ for (i = 0; i < 256; ++i)
{
for (bi = botlists[i]; bi; bi = bi->next)
{
- if (!user || !stricmp(user, bi->nick))
- ircdproto->SendClientIntroduction(bi->nick, bi->user, bi->host, bi->real, ircd->pseudoclient_mode, bi->uid.c_str());
+ ci::string ci_bi_nick(bi->nick.c_str());
+ if (user.empty() || ci_bi_nick == user)
+ ircdproto->SendClientIntroduction(bi->nick, bi->user, bi->host, bi->real, ircd->pseudoclient_mode, bi->uid);
}
}
}
diff --git a/src/messages.c b/src/messages.c
index f0df5fb6c..ae0d078a5 100644
--- a/src/message