summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorcyberbotx <cyberbotx@5417fbe8-f217-4b02-8779-1006273d7864>2010-01-04 06:40:24 +0000
committercyberbotx <cyberbotx@5417fbe8-f217-4b02-8779-1006273d7864>2010-01-04 06:40:24 +0000
commitb462814760cb7c0830072275acc97291a9fb905b (patch)
tree56cfe6caee408eb852f728cd8aaa2d18e4365228 /src
parent2708eea5d13c249143b83fbaa8b552992f0ac8b6 (diff)
Changed 'char *' fields in BotInfo to 'std::string', cleanup of bots.cpp, changed many other functions to use 'const std::string &' arguments as a chain reaction.
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2733 5417fbe8-f217-4b02-8779-1006273d7864
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/messages.c
+++ b/src/messages.c
@@ -39,7 +39,7 @@ int m_away(const char *source, const char *msg)
/*************************************************************************/
-int m_kill(const char *nick, const char *msg)
+int m_kill(const std::string &nick, const char *msg)
{
BotInfo *bi;
@@ -102,16 +102,16 @@ int m_motd(const char *source)
/*************************************************************************/
-int m_privmsg(const char *source, const char *receiver, const char *msg)
+int m_privmsg(const char *source, const std::string &receiver, const char *msg)
{
- char *s, *target;
+ char *target;
time_t starttime, stoptime; /* When processing started and finished */
BotInfo *bi;
ChannelInfo *ci;
User *u;
- if (!source || !*source || !*receiver || !receiver || !msg) {
+ if (!source || !*source || receiver.empty() || !msg) {
return MOD_CONT;
}
@@ -127,7 +127,7 @@ int m_privmsg(const char *source, const char *receiver, const char *msg)
return MOD_CONT;
}
- if (*receiver == '#') {
+ if (receiver[0] == '#') {
if (Config.s_BotServ && (ci = cs_findchan(receiver))) {
/* Some paranoia checks */
if (!ci->HasFlag(CI_FORBIDDEN) && ci->c && ci->bi) {
@@ -140,7 +140,7 @@ int m_privmsg(const char *source, const char *receiver, const char *msg)
IgnoreData *ign = get_ignore(source);
if (ign) {
target = myStrGetToken(msg, ' ', 0);
- alog("Ignored message from %s to %s using command %s", source, receiver, target);
+ alog("Ignored message from %s to %s using command %s", source, receiver.c_str(), target);
delete [] target;
return MOD_CONT;
}
@@ -148,17 +148,18 @@ int m_privmsg(const char *source, const char *receiver, const char *msg)
/* If a server is specified (nick@server format), make sure it matches
* us, and strip it off. */
- s = const_cast<char *>(strchr(receiver, '@'));
- if (s) {
- *s++ = 0;
- if (stricmp(s, Config.ServerName) != 0)
+ unsigned s = receiver.find('@');
+ if (s != std::string::npos)
+ {
+ ci::string servername(receiver.begin() + s, receiver.end());
+ if (servername != Config.ServerName)
return MOD_CONT;
} else if (Config.UseStrictPrivMsg) {
if (debug) {
alog("Ignored PRIVMSG without @ from %s", source);
}
- notice_lang(receiver, u, INVALID_TARGET, receiver, receiver,
- Config.ServerName, receiver);
+ notice_lang(receiver, u, INVALID_TARGET, receiver.c_str(), receiver.c_str(),
+ Config.ServerName, receiver.c_str());
return MOD_CONT;
}
@@ -168,7 +169,8 @@ int m_privmsg(const char *source, const char *receiver, const char *msg)
if (bi)
{
- if (!stricmp(bi->nick, Config.s_OperServ))
+ ci::string ci_bi_nick(bi->nick.c_str());
+ if (ci_bi_nick == Config.s_OperServ)
{
if (!is_oper(u) && Config.OSOpersOnly)
{
@@ -179,22 +181,22 @@ int m_privmsg(const char *source, const char *receiver, const char *msg)
else
operserv(u, const_cast<char *>(msg)); // XXX Unsafe cast, this needs reviewing -- CyberBotX
}
- else if (!stricmp(bi->nick, Config.s_NickServ))
+ else if (ci_bi_nick == Config.s_NickServ)
nickserv(u, const_cast<char *>(msg)); // XXX Unsafe cast, this needs reviewing -- CyberBotX
- else if (!stricmp(bi->nick, Config.s_ChanServ))
+ else if (ci_bi_nick== Config.s_ChanServ)
{
if (!is_oper(u) && Config.CSOpersOnly)
notice_lang(Config.s_ChanServ, u, ACCESS_DENIED);
else
chanserv(u, const_cast<char *>(msg)); // XXX Unsafe cast, this needs reviewing -- CyberBotX
}
- else if (!stricmp(bi->nick, Config.s_MemoServ))
+ else if (ci_bi_nick == Config.s_MemoServ)
memoserv(u, const_cast<char *>(msg)); // XXX Unsafe cast, this needs reviewing -- CyberBotX
- else if (Config.s_HostServ && !stricmp(bi->nick, Config.s_HostServ))
+ else if (Config.s_HostServ && ci_bi_nick == Config.s_HostServ)
hostserv(u, const_cast<char *>(msg)); // XXX Unsafe cast, this needs reviewing -- CyberBotX
else if (Config.s_BotServ)
{
- if (!stricmp(bi->nick, Config.s_BotServ))
+ if (ci_bi_nick == Config.s_BotServ)
botserv(u, const_cast<char *>(msg)); // XXX Unsafe cast, this needs reviewing -- CyberBotX
else
botmsgs(u, bi, const_cast<char *>(msg)); // XXX Unsafe cast, this needs reviewing -- CyberBotX
@@ -307,10 +309,10 @@ int m_whois(const char *source, const char *who)
clientdesc = Config.desc_GlobalNoticer;
else if (Config.s_BotServ && (bi = findbot(who))) {
/* Bots are handled separately */
- ircdproto->SendNumeric(Config.ServerName, 311, source, "%s %s %s * :%s", bi->nick, bi->user, bi->host, bi->real);
- ircdproto->SendNumeric(Config.ServerName, 307, source, "%s :is a registered nick", bi->nick);
- ircdproto->SendNumeric(Config.ServerName, 312, source, "%s %s :%s", bi->nick, Config.ServerName, Config.ServerDesc);
- ircdproto->SendNumeric(Config.ServerName, 317, source, "%s %ld %ld :seconds idle, signon time", bi->nick, time(NULL) - bi->lastmsg, start_time);
+ ircdproto->SendNumeric(Config.ServerName, 311, source, "%s %s %s * :%s", bi->nick.c_str(), bi->user.c_str(), bi->host.c_str(), bi->real.c_str());
+ ircdproto->SendNumeric(Config.ServerName, 307, source, "%s :is a registered nick", bi->nick.c_str());
+ ircdproto->SendNumeric(Config.ServerName, 312, source, "%s %s :%s", bi->nick.c_str(), Config.ServerName, Config.ServerDesc);
+ ircdproto->SendNumeric(Config.ServerName, 317, source, "%s %ld %ld :seconds idle, signon time", bi->nick.c_str(), time(NULL) - bi->lastmsg, start_time);
ircdproto->SendNumeric(Config.ServerName, 318, source, "%s :End of /WHOIS list.", who);
return MOD_CONT;
} else if (!ircd->svshold && (na = findnick(who)) && na->HasFlag(NS_KILL_HELD)) {
diff --git a/src/misc.c b/src/misc.c
index 7f0c090c0..92dd28a36 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -753,7 +753,7 @@ void doCleanBuffer(char *str)
* @param killer whom is doing the killing
* @return void
*/
-void EnforceQlinedNick(const char *nick, const char *killer)
+void EnforceQlinedNick(const std::string &nick, const char *killer)
{
User *u2;
@@ -812,7 +812,8 @@ int nickIsServices(const char *tempnick, int bot)
int i;
for (i = 0; i < 256; i++) {
for (bi = botlists[i]; bi; bi = bi->next) {
- if (stricmp(nick, bi->nick) == 0) {
+ ci::string ci_bi_nick(bi->nick.c_str());
+ if (ci_bi_nick == nick) {
found++;
continue;
}
@@ -1043,7 +1044,7 @@ std::list<std::string> BuildStringList(const std::string &src)
while (tokens.GetToken(token))
Ret.push_back(token);
-
+
return Ret;
}
diff --git a/src/nickserv.c b/src/nickserv.c
index 7e3219fae..ee68f7fe1 100644
--- a/src/nickserv.c
+++ b/src/nickserv.c
@@ -361,7 +361,7 @@ void cancel_user(User * u)
else if (ircd->svsnick)
{
uid = ts6_uid_retrieve();
- ircdproto->SendClientIntroduction(u->nick.c_str(), Config.NSEnforcerUser, Config.NSEnforcerHost, "Services Enforcer", "+", uid.c_str());
+ ircdproto->SendClientIntroduction(u->nick, Config.NSEnforcerUser, Config.NSEnforcerHost, "Services Enforcer", "+", uid);
t = new NickServRelease(na, Config.NSReleaseTimeout);
t->uid = uid;
}
diff --git a/src/protocol/bahamut.c b/src/protocol/bahamut.c
index 5ac0fe006..ced288073 100644
--- a/src/protocol/bahamut.c
+++ b/src/protocol/bahamut.c
@@ -236,9 +236,11 @@ class BahamutIRCdProto : public IRCDProto
}
/* UNSQLINE */
- void SendSQLineDel(const char *user)
+ void SendSQLineDel(const std::string &user)
{
- send_cmd(NULL, "UNSQLINE %s", user);
+ if (user.empty())
+ return;
+ send_cmd(NULL, "UNSQLINE %s", user.c_str());
}
/* JOIN - SJOIN */
@@ -292,10 +294,10 @@ class BahamutIRCdProto : public IRCDProto
else send_cmd(source->nick, "KICK %s %s", chan->name.c_str(), user->nick.c_str());
}
- void SendClientIntroduction(const char *nick, const char *user, const char *host, const char *real, const char *modes, const char *uid)
+ 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)
{
EnforceQlinedNick(nick, Config.s_BotServ);
- send_cmd(NULL, "NICK %s 1 %ld %s %s %s %s 0 0 :%s", nick, static_cast<long>(time(NULL)), modes, user, host, Config.ServerName, real);
+ 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());
SendSQLine(nick, "Reserved for services");
}
diff --git a/src/protocol/inspircd11.c b/src/protocol/inspircd11.c
index 659d1aaa9..da6883f3c 100644
--- a/src/protocol/inspircd11.c
+++ b/src/protocol/inspircd11.c
@@ -222,9 +222,9 @@ class InspIRCdProto : public IRCDProto
send_cmd(bi ? bi->nick : Config.ServerName, "MODE %s %s", u->nick.c_str(), buf);
}
- void SendClientIntroduction(const char *nick, const char *user, const char *host, const char *real, const char *modes, const char *uid)
+ 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)
{
- 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(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(nick, "OPERTYPE Service");
}
@@ -253,10 +253,11 @@ class InspIRCdProto : public IRCDProto
}
/* UNSQLINE */
- void SendSQLineDel(const char *user)
+ void SendSQLineDel(const std::string &user)
{
- if (!user) return;
- send_cmd(Config.s_OperServ, "QLINE %s", user);
+ if (user.empty())
+ return;
+ send_cmd(Config.s_OperServ, "QLINE %s", user.c_str());
}
/* SQLINE */
diff --git a/src/protocol/inspircd12.cpp b/src/protocol/inspircd12.cpp
index b791ca71f..e94d3cd1b 100644
--- a/src/protocol/inspircd12.cpp
+++ b/src/protocol/inspircd12.cpp
@@ -228,9 +228,9 @@ class InspIRCdProto : public IRCDProto
send_cmd(bi ? bi->uid : TS6SID, "MODE %s %s", u->GetUID().c_str(), buf);
}
- void SendClientIntroduction(const char *nick, const char *user, const char *host, const char *real, const char *modes, const char *uid)
+ 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)
{
- send_cmd(TS6SID, "UID %s %ld %s %s %s %s 0.0.0.0 %ld %s :%s", uid, static_cast<long>(time(NULL)), nick, host, host, user, static_cast<long>(time(NULL)), modes, real);
+ send_cmd(TS6SID, "UID %s %ld %s %s %s %s 0.0.0.0 %ld %s :%s", uid.c_str(), static_cast<long>(time(NULL)), nick.c_str(), host.c_str(), host.c_str(), user.c_str(), static_cast<long>(time(NULL)), modes, real.c_str());
}
void SendKickInternal(BotInfo *source, Channel *chan, User *user, const char *buf)
@@ -259,9 +259,11 @@ class InspIRCdProto : public IRCDProto
}
/* UNSQLINE */
- void SendSQLineDel(const char *user)
+ void SendSQLineDel(const std::string &user)
{
- send_cmd(TS6SID, "DELLINE Q %s", user);
+ if (user.empty())
+ return;
+ send_cmd(TS6SID, "DELLINE Q %s", user.c_str());
}
/* SQLINE */
diff --git a/src/protocol/ratbox.c b/src/protocol/ratbox.c
index a9e2c9027..299b9b658 100644
--- a/src/protocol/ratbox.c
+++ b/src/protocol/ratbox.c
@@ -198,9 +198,11 @@ class RatboxProto : public IRCDTS6Proto
send_cmd(bi ? bi->uid : Config.s_OperServ, "UNKLINE * %s %s", ak->user, ak->host);
}
- void SendSQLineDel(const char *user)
+ void SendSQLineDel(const std::string &user)
{
- send_cmd(TS6SID, "UNRESV * %s", user);
+ if (user.empty())
+ return;
+ send_cmd(TS6SID, "UNRESV * %s", user.c_str());
}
void SendJoin(BotInfo *user, const char *channel, time_t chantime)
@@ -240,10 +242,10 @@ class RatboxProto : public IRCDTS6Proto
ratbox_cmd_svinfo();
}
- void SendClientIntroduction(const char *nick, const char *user, const char *host, const char *real, const char *modes, const char *uid)
+ 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)
{
EnforceQlinedNick(nick, NULL);
- send_cmd(TS6SID, "UID %s 1 %ld %s %s %s 0 %s :%s", nick, static_cast<long>(time(NULL)), modes, user, host, uid, real);
+ send_cmd(TS6SID, "UID %s 1 %ld %s %s %s 0 %s :%s", nick.c_str(), static_cast<long>(time(NULL)), modes, user.c_str(), host.c_str(), uid.c_str(), real.c_str());
SendSQLine(nick, "Reserved for services");
}
diff --git a/src/protocol/unreal32.c b/src/protocol/unreal32.c
index 81229930c..00335bbbb 100644
--- a/src/protocol/unreal32.c
+++ b/src/protocol/unreal32.c
@@ -234,11 +234,10 @@ class UnrealIRCdProto : public IRCDProto
send_cmd(bi ? bi->nick : Config.ServerName, "v %s %s", u->nick.c_str(), buf);
}
- void SendClientIntroduction(const char *nick, const char *user, const char *host, const char *real, const char *modes, const char *uid)
+ 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)
{
EnforceQlinedNick(nick, Config.s_BotServ);
- send_cmd(NULL, "& %s 1 %ld %s %s %s 0 %s %s%s :%s", nick, static_cast<long>(time(NULL)), user, host, Config.ServerName, modes, host,
- myIrcd->nickip ? " *" : " ", real);
+ send_cmd(NULL, "& %s 1 %ld %s %s %s 0 %s %s%s :%s", nick.c_str(), static_cast<long>(time(NULL)), user.c_str(), host.c_str(), Config.ServerName, modes, host.c_str(), myIrcd->nickip ? " *" : " ", real.c_str());
SendSQLine(nick, "Reserved for services");
}
@@ -267,17 +266,18 @@ class UnrealIRCdProto : public IRCDProto
/* JOIN */
void SendJoin(BotInfo *user, const char *channel, time_t chantime)
{
- send_cmd(Config.ServerName, "~ !%s %s :%s", base64enc(static_cast<long>(chantime)), channel, user->nick);
+ send_cmd(Config.ServerName, "~ !%s %s :%s", base64enc(static_cast<long>(chantime)), channel, user->nick.c_str());
}
/* unsqline
** parv[0] = sender
** parv[1] = nickmask
*/
- void SendSQLineDel(const char *user)
+ void SendSQLineDel(const std::string &user)
{
- if (!user) return;
- send_cmd(NULL, "d %s", user);
+ if (user.empty())
+ return;
+ send_cmd(NULL, "d %s", user.c_str());
}
diff --git a/src/send.c b/src/send.c
index f79398f6f..18cfa761e 100644
--- a/src/send.c
+++ b/src/send.c
@@ -143,7 +143,7 @@ void notice_list(char *source, char *dest, char **text)
* @param ... any number of parameters
* @return void
*/
-void notice_lang(const char *source, User * dest, int message, ...)
+void notice_lang(const std::string &source, User * dest, int message, ...)
{
va_list args;
char buf[4096]; /* because messages can be really big */
diff --git a/src/servers.c b/src/servers.c
index aeb58a966..0de233c60 100644
--- a/src/servers.c
+++ b/src/servers.c
@@ -163,7 +163,7 @@ Server *new_server(Server * server_uplink, const char *name, const char *desc,
if (serv_uplink != NULL)
{
/* Bring in our pseudo-clients */
- introduce_user(NULL);
+ introduce_user("");
/* And hybrid needs Global joined in the logchan */
if (LogChan && ircd->join2msg) {
diff --git a/src/users.c b/src/users.c
index f49929d7e..54cc6b22b 100644
--- a/src/users.c
+++ b/src/users.c
@@ -300,7 +300,7 @@ User::~User()
alog("debug: User::~User() done");
}
-void User::SendMessage(const char *source, const char *fmt, ...)
+void User::SendMessage(const std::string &source, const char *fmt, ...)
{
va_list args;
char buf[BUFSIZE];
@@ -317,7 +317,7 @@ void User::SendMessage(const char *source, const char *fmt, ...)
}
}
-void User::SendMessage(const char *source, const std::string &msg)
+void User::SendMessage(const std::string &source, const std::string &msg)
{
/* Send privmsg instead of notice if:
* - UsePrivmsg is enabled