diff options
| author | cyberbotx <cyberbotx@5417fbe8-f217-4b02-8779-1006273d7864> | 2010-01-04 06:40:24 +0000 |
|---|---|---|
| committer | cyberbotx <cyberbotx@5417fbe8-f217-4b02-8779-1006273d7864> | 2010-01-04 06:40:24 +0000 |
| commit | b462814760cb7c0830072275acc97291a9fb905b (patch) | |
| tree | 56cfe6caee408eb852f728cd8aaa2d18e4365228 /src/core | |
| parent | 2708eea5d13c249143b83fbaa8b552992f0ac8b6 (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/core')
| -rw-r--r-- | src/core/bs_assign.c | 6 | ||||
| -rw-r--r-- | src/core/bs_bot.c | 42 | ||||
| -rw-r--r-- | src/core/bs_botlist.c | 4 | ||||
| -rw-r--r-- | src/core/bs_info.c | 8 | ||||
| -rw-r--r-- | src/core/bs_set.c | 4 | ||||
| -rw-r--r-- | src/core/cs_akick.c | 16 | ||||
| -rw-r--r-- | src/core/db_plain.cpp | 4 | ||||
| -rw-r--r-- | src/core/os_defcon.c | 8 | ||||
| -rw-r--r-- | src/core/ss_main.c | 2 |
9 files changed, 40 insertions, 54 deletions
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> ¶ms) 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> ¶ms) 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, ¶m)) { 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; |
