From b2a57b09742da6c2f2011ad41eb470139d88e14f Mon Sep 17 00:00:00 2001 From: cyberbotx Date: Sat, 25 Jul 2009 00:37:43 +0000 Subject: Changed params parameter of Command's Execute() from std::vector to std::vector, seems to have no ill effects but may require some testing to be sure. Also a few minor cleanups here and there. git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2392 5417fbe8-f217-4b02-8779-1006273d7864 --- include/modules.h | 6 +- src/command.cpp | 2 +- src/commands.c | 8 +-- src/core/bs_act.c | 5 +- src/core/bs_assign.c | 2 +- src/core/bs_badwords.c | 26 +++----- src/core/bs_bot.c | 16 ++--- src/core/bs_botlist.c | 2 +- src/core/bs_help.c | 8 +-- src/core/bs_info.c | 2 +- src/core/bs_kick.c | 44 ++++++------ src/core/bs_say.c | 3 +- src/core/bs_set.c | 50 +++++++------- src/core/bs_unassign.c | 2 +- src/core/cs_access.c | 36 +++++----- src/core/cs_akick.c | 29 ++++---- src/core/cs_ban.c | 6 +- src/core/cs_clear.c | 20 +++--- src/core/cs_drop.c | 7 +- src/core/cs_forbid.c | 5 +- src/core/cs_getkey.c | 3 +- src/core/cs_getpass.c | 2 +- src/core/cs_help.c | 8 +-- src/core/cs_identify.c | 3 +- src/core/cs_info.c | 12 +--- src/core/cs_invite.c | 9 +-- src/core/cs_kick.c | 3 +- src/core/cs_list.c | 14 ++-- src/core/cs_logout.c | 3 +- src/core/cs_modes.c | 31 +++------ src/core/cs_register.c | 3 +- src/core/cs_sendpass.c | 2 +- src/core/cs_set.c | 60 ++++++++--------- src/core/cs_status.c | 2 +- src/core/cs_suspend.c | 4 +- src/core/cs_topic.c | 2 +- src/core/cs_xop.c | 30 ++++----- src/core/hs_del.c | 2 +- src/core/hs_delall.c | 2 +- src/core/hs_group.c | 2 +- src/core/hs_help.c | 4 +- src/core/hs_list.c | 2 +- src/core/hs_off.c | 2 +- src/core/hs_on.c | 2 +- src/core/hs_set.c | 2 +- src/core/hs_setall.c | 2 +- src/core/ms_cancel.c | 2 +- src/core/ms_check.c | 2 +- src/core/ms_del.c | 30 ++++----- src/core/ms_help.c | 4 +- src/core/ms_info.c | 2 +- src/core/ms_list.c | 34 +++++----- src/core/ms_read.c | 36 +++++----- src/core/ms_rsend.c | 2 +- src/core/ms_send.c | 2 +- src/core/ms_sendall.c | 2 +- src/core/ms_set.c | 93 +++++++++++++------------- src/core/ms_staff.c | 2 +- src/core/ns_access.c | 26 ++++---- src/core/ns_alist.c | 20 +++--- src/core/ns_drop.c | 2 +- src/core/ns_forbid.c | 2 +- src/core/ns_getemail.c | 12 ++-- src/core/ns_getpass.c | 2 +- src/core/ns_ghost.c | 2 +- src/core/ns_group.c | 4 +- src/core/ns_help.c | 8 +-- src/core/ns_identify.c | 2 +- src/core/ns_info.c | 8 +-- src/core/ns_list.c | 13 ++-- src/core/ns_logout.c | 6 +- src/core/ns_recover.c | 2 +- src/core/ns_register.c | 10 +-- src/core/ns_release.c | 2 +- src/core/ns_saset.c | 155 +++++++++++++++++++++---------------------- src/core/ns_sendpass.c | 2 +- src/core/ns_set.c | 140 +++++++++++++++++++------------------- src/core/ns_status.c | 2 +- src/core/ns_suspend.c | 4 +- src/core/ns_update.c | 4 +- src/core/os_akill.c | 26 ++++---- src/core/os_chankill.c | 2 +- src/core/os_chanlist.c | 6 +- src/core/os_clearmodes.c | 9 ++- src/core/os_defcon.c | 2 +- src/core/os_global.c | 2 +- src/core/os_help.c | 4 +- src/core/os_ignore.c | 24 +++---- src/core/os_jupe.c | 2 +- src/core/os_kick.c | 2 +- src/core/os_mode.c | 4 +- src/core/os_modinfo.c | 2 +- src/core/os_modlist.c | 18 ++--- src/core/os_modload.c | 2 +- src/core/os_modunload.c | 2 +- src/core/os_news.c | 30 ++++----- src/core/os_noop.c | 8 +-- src/core/os_oline.c | 2 +- src/core/os_quit.c | 2 +- src/core/os_reload.c | 2 +- src/core/os_restart.c | 3 +- src/core/os_session.c | 39 ++++++----- src/core/os_set.c | 88 ++++++++++++------------ src/core/os_sgline.c | 26 ++++---- src/core/os_shutdown.c | 2 +- src/core/os_sqline.c | 26 ++++---- src/core/os_staff.c | 2 +- src/core/os_stats.c | 40 +++++------ src/core/os_svsnick.c | 2 +- src/core/os_szline.c | 26 ++++---- src/core/os_umode.c | 2 +- src/core/os_update.c | 2 +- src/core/os_userlist.c | 6 +- src/core/ss_main.c | 4 +- src/modules/cs_appendtopic.c | 2 +- src/modules/cs_enforce.c | 24 +++---- src/modules/cs_tban.c | 2 +- src/modules/hs_request.c | 20 +++--- src/modules/ns_maxemail.c | 6 +- src/modules/os_info.c | 26 ++++---- 120 files changed, 777 insertions(+), 851 deletions(-) diff --git a/include/modules.h b/include/modules.h index 61eab28df..23152df95 100644 --- a/include/modules.h +++ b/include/modules.h @@ -249,7 +249,7 @@ class CoreExport Command /** Execute this command. * @param u The user executing the command. */ - virtual CommandReturn Execute(User *u, std::vector &); + virtual CommandReturn Execute(User *u, std::vector &); /** Requested when the user is requesting help on this command. Help on this command should be sent to the user. * @param u The user requesting help @@ -519,7 +519,7 @@ class CoreExport Module * @param params The parameters the user is sending * @return EVENT_CONTINUE to let other modules decide, EVENT_STOP to halt the command and not process it */ - virtual EventReturn OnPreCommand(User *u, const std::string &service, const std::string &command, const std::vector ¶ms) { return EVENT_CONTINUE; } + virtual EventReturn OnPreCommand(User *u, const std::string &service, const ci::string &command, const std::vector ¶ms) { return EVENT_CONTINUE; } /** Called after a command has been executed. * @param u The user executing the command @@ -527,7 +527,7 @@ class CoreExport Module * @param command The command the user executed * @param params The parameters the user sent */ - virtual void OnPostCommand(User *u, const std::string &service, const std::string &command, const std::vector ¶ms) { } + virtual void OnPostCommand(User *u, const std::string &service, const ci::string &command, const std::vector ¶ms) { } /** Called when anope saves databases. * NOTE: This event is deprecated pending new database handling. diff --git a/src/command.cpp b/src/command.cpp index 26b464483..f3bc7ad1f 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -34,7 +34,7 @@ Command::~Command() } } -CommandReturn Command::Execute(User *u, std::vector &) { return MOD_CONT; } +CommandReturn Command::Execute(User *u, std::vector &) { return MOD_CONT; } bool Command::OnHelp(User *u, const ci::string &subcommand) { return false; } diff --git a/src/commands.c b/src/commands.c index 17f854a99..a564b644e 100644 --- a/src/commands.c +++ b/src/commands.c @@ -88,7 +88,7 @@ void mod_run_cmd(char *service, User * u, CommandHash * cmdTable[], const char * // Check whether or not access string is empty } - std::vector params; + std::vector params; std::string curparam; char *s = NULL; while ((s = strtok(NULL, " "))) @@ -111,7 +111,7 @@ void mod_run_cmd(char *service, User * u, CommandHash * cmdTable[], const char * curparam.erase(curparam.size() - 1, curparam.size()); // Add it - params.push_back(curparam); + params.push_back(curparam.c_str()); } if (params.size() < c->MinParams) @@ -121,7 +121,7 @@ void mod_run_cmd(char *service, User * u, CommandHash * cmdTable[], const char * } EventReturn MOD_RESULT = EVENT_CONTINUE; - FOREACH_RESULT(I_OnPreCommand, OnPreCommand(u, c->service, c->name, params)); + FOREACH_RESULT(I_OnPreCommand, OnPreCommand(u, c->service, c->name.c_str(), params)); if (MOD_RESULT == EVENT_STOP) return; @@ -174,7 +174,7 @@ void mod_run_cmd(char *service, User * u, CommandHash * cmdTable[], const char * retVal = c->Execute(u, params); - FOREACH_MOD(I_OnPostCommand, OnPostCommand(u, c->service, c->name, params)); + FOREACH_MOD(I_OnPostCommand, OnPostCommand(u, c->service, c->name.c_str(), params)); } /*************************************************************************/ diff --git a/src/core/bs_act.c b/src/core/bs_act.c index 21f18063b..b81e43c13 100644 --- a/src/core/bs_act.c +++ b/src/core/bs_act.c @@ -20,10 +20,9 @@ class CommandBSAct : public Command public: CommandBSAct() : Command("ACT", 2, 2) { - } - CommandReturn Execute(User *u, std::vector ¶ms) + CommandReturn Execute(User *u, std::vector ¶ms) { ChannelInfo *ci = cs_findchan(params[0].c_str()); @@ -47,9 +46,7 @@ class CommandBSAct : public Command size_t i = 0; while ((i = params[1].find_first_of("\001"), i) && i != std::string::npos) - { params[1].erase(i, 1); - } ircdproto->SendAction(ci->bi, ci->name, "%s", params[1].c_str()); ci->bi->lastmsg = time(NULL); diff --git a/src/core/bs_assign.c b/src/core/bs_assign.c index 20c5e3bb4..95ee8a9aa 100644 --- a/src/core/bs_assign.c +++ b/src/core/bs_assign.c @@ -22,7 +22,7 @@ class CommandBSAssign : public Command { } - CommandReturn Execute(User *u, std::vector ¶ms) + CommandReturn Execute(User *u, std::vector ¶ms) { const char *chan = params[0].c_str(); const char *nick = params[1].c_str(); diff --git a/src/core/bs_badwords.c b/src/core/bs_badwords.c index bc22c0312..d174574d0 100644 --- a/src/core/bs_badwords.c +++ b/src/core/bs_badwords.c @@ -234,15 +234,15 @@ class CommandBSBadwords : public Command { } - CommandReturn Execute(User *u, std::vector ¶ms) + CommandReturn Execute(User *u, std::vector ¶ms) { const char *chan = params[0].c_str(); - const char *cmd = params[1].c_str(); + ci::string cmd = params[1]; const char *word = params.size() > 2 ? params[2].c_str() : NULL; ChannelInfo *ci; - int need_args = (cmd && (!stricmp(cmd, "LIST") || !stricmp(cmd, "CLEAR"))); + bool need_args = cmd == "LIST" || cmd == "CLEAR"; - if (!cmd || (need_args ? 0 : !word)) + if (need_args ? 0 : !word) { this->OnSyntaxError(u); return MOD_CONT; @@ -262,26 +262,16 @@ class CommandBSBadwords : public Command return MOD_CONT; } - if (stricmp(cmd, "ADD") == 0) - { + if (cmd == "ADD") return this->DoAdd(u, ci, word); - } - else if (stricmp(cmd, "DEL") == 0) - { + else if (cmd == "DEL") return this->DoDelete(u, ci, word); - } - else if (stricmp(cmd, "LIST") == 0) - { + else if (cmd == "LIST") return this->DoList(u, ci, word); - } - else if (stricmp(cmd, "CLEAR") == 0) - { + else if (cmd == "CLEAR") return this->DoClear(u, ci, word); - } else - { this->OnSyntaxError(u); - } return MOD_CONT; } diff --git a/src/core/bs_bot.c b/src/core/bs_bot.c index 787f5b131..fa2d7fab4 100644 --- a/src/core/bs_bot.c +++ b/src/core/bs_bot.c @@ -18,7 +18,7 @@ class CommandBSBot : public Command { private: - CommandReturn DoAdd(User *u, std::vector ¶ms) + CommandReturn DoAdd(User *u, std::vector ¶ms) { const char *nick = params[1].c_str(); const char *user = params.size() > 2 ? params[2].c_str() : NULL; @@ -135,7 +135,7 @@ class CommandBSBot : public Command return MOD_CONT; } - CommandReturn DoChange(User *u, std::vector ¶ms) + CommandReturn DoChange(User *u, std::vector ¶ms) { const char *oldnick = params[1].c_str(); const char *nick = params.size() > 2 ? params[2].c_str() : NULL; @@ -315,7 +315,7 @@ class CommandBSBot : public Command return MOD_CONT; } - CommandReturn DoDel(User *u, std::vector ¶ms) + CommandReturn DoDel(User *u, std::vector ¶ms) { const char *nick = params[1].c_str(); BotInfo *bi; @@ -353,9 +353,9 @@ class CommandBSBot : public Command this->SetFlag(CFLAG_STRIP_CHANNEL); } - CommandReturn Execute(User *u, std::vector ¶ms) + CommandReturn Execute(User *u, std::vector ¶ms) { - const char *cmd = params[0].c_str(); + ci::string cmd = params[0]; if (readonly) { @@ -363,7 +363,7 @@ class CommandBSBot : public Command return MOD_CONT; } - if (!stricmp(cmd, "ADD")) + if (cmd == "ADD") { // ADD nick user host real - 5 if (!u->nc->HasCommand("botserv/bot/add")) @@ -384,7 +384,7 @@ class CommandBSBot : public Command return this->DoAdd(u, params); } - else if (!stricmp(cmd, "CHANGE")) + else if (cmd == "CHANGE") { // CHANGE oldn newn user host real - 6 // but only oldn and newn are required @@ -402,7 +402,7 @@ class CommandBSBot : public Command return this->DoChange(u, params); } - else if (!stricmp(cmd, "DEL")) + else if (cmd == "DEL") { // DEL nick if (!u->nc->HasCommand("botserv/bot/del")) diff --git a/src/core/bs_botlist.c b/src/core/bs_botlist.c index 5064642f6..b3125ec23 100644 --- a/src/core/bs_botlist.c +++ b/src/core/bs_botlist.c @@ -22,7 +22,7 @@ class CommandBSBotList : public Command { } - CommandReturn Execute(User *u, std::vector ¶ms) + CommandReturn Execute(User *u, std::vector ¶ms) { int i, count = 0; BotInfo *bi; diff --git a/src/core/bs_help.c b/src/core/bs_help.c index dde26b081..8d0572b79 100644 --- a/src/core/bs_help.c +++ b/src/core/bs_help.c @@ -6,8 +6,8 @@ * Please read COPYING and README for further details. * * Based on the original code of Epona by Lara. - * Based on the original code of Services by Andy Church. - * + * Based on the original code of Services by Andy Church. + * * $Id$ * */ @@ -23,8 +23,8 @@ class CommandBSHelp : public Command this->SetFlag(CFLAG_ALLOW_UNREGISTERED); this->SetFlag(CFLAG_STRIP_CHANNEL); } - - CommandReturn Execute(User *u, std::vector ¶ms) + + CommandReturn Execute(User *u, std::vector ¶ms) { mod_help_cmd(s_BotServ, u, BOTSERV, params[0].c_str()); return MOD_CONT; diff --git a/src/core/bs_info.c b/src/core/bs_info.c index cad350cb2..de7e3e59e 100644 --- a/src/core/bs_info.c +++ b/src/core/bs_info.c @@ -52,7 +52,7 @@ class CommandBSInfo : public Command this->SetFlag(CFLAG_STRIP_CHANNEL); } - CommandReturn Execute(User *u, std::vector ¶ms) + CommandReturn Execute(User *u, std::vector ¶ms) { BotInfo *bi; ChannelInfo *ci; diff --git a/src/core/bs_kick.c b/src/core/bs_kick.c index 372a4ef7f..26b1d911c 100644 --- a/src/core/bs_kick.c +++ b/src/core/bs_kick.c @@ -24,28 +24,28 @@ class CommandBSKick : public Command { } - CommandReturn Execute(User *u, std::vector ¶ms) + CommandReturn Execute(User *u, std::vector ¶ms) { const char *chan = params[0].c_str(); - const char *option = params[1].c_str(); - const char *value = params[2].c_str(); + ci::string option = params[1]; + ci::string value = params[2]; const char *ttb = params.size() > 3 ? params[3].c_str() : NULL; ChannelInfo *ci = cs_findchan(chan); if (readonly) notice_lang(s_BotServ, u, BOT_KICK_DISABLED); - else if (!chan || !option || !value) + else if (!chan || option.empty() || value.empty()) syntax_error(s_BotServ, u, "KICK", BOT_KICK_SYNTAX); - else if (stricmp(value, "ON") && stricmp(value, "OFF")) + else if (value != "ON" && value != "OFF") syntax_error(s_BotServ, u, "KICK", BOT_KICK_SYNTAX); else if (!check_access(u, ci, CA_SET) && !u->nc->HasPriv("botserv/administration")) notice_lang(s_BotServ, u, ACCESS_DENIED); else if (!ci->bi) notice_help(s_BotServ, u, BOT_NOT_ASSIGNED); else { - if (!stricmp(option, "BADWORDS")) { - if (!stricmp(value, "ON")) { + if (option == "BADWORDS") { + if (value == "ON") { if (ttb) { ci->ttb[TTB_BADWORDS] = strtol(ttb, NULL, 10); @@ -74,8 +74,8 @@ class CommandBSKick : public Command ci->botflags &= ~BS_KICK_BADWORDS; notice_lang(s_BotServ, u, BOT_KICK_BADWORDS_OFF); } - } else if (!stricmp(option, "BOLDS")) { - if (!stricmp(value, "ON")) { + } else if (option == "BOLDS") { + if (value == "ON") { if (ttb) { ci->ttb[TTB_BOLDS] = strtol(ttb, NULL, 10); if (errno == ERANGE || errno == EINVAL @@ -99,8 +99,8 @@ class CommandBSKick : public Command ci->botflags &= ~BS_KICK_BOLDS; notice_lang(s_BotServ, u, BOT_KICK_BOLDS_OFF); } - } else if (!stricmp(option, "CAPS")) { - if (!stricmp(value, "ON")) { + } else if (option == "CAPS") { + if (value == "ON") { char *min = strtok(NULL, " "); char *percent = strtok(NULL, " "); @@ -144,8 +144,8 @@ class CommandBSKick : public Command ci->botflags &= ~BS_KICK_CAPS; notice_lang(s_BotServ, u, BOT_KICK_CAPS_OFF); } - } else if (!stricmp(option, "COLORS")) { - if (!stricmp(value, "ON")) { + } else if (option == "COLORS") { + if (value == "ON") { if (ttb) { ci->ttb[TTB_COLORS] = strtol(ttb, NULL, 10); if (errno == ERANGE || errno == EINVAL @@ -169,8 +169,8 @@ class CommandBSKick : public Command ci->botflags &= ~BS_KICK_COLORS; notice_lang(s_BotServ, u, BOT_KICK_COLORS_OFF); } - } else if (!stricmp(option, "FLOOD")) { - if (!stricmp(value, "ON")) { + } else if (option == "FLOOD") { + if (value == "ON") { char *lines = strtok(NULL, " "); char *secs = strtok(NULL, " "); @@ -214,8 +214,8 @@ class CommandBSKick : public Command ci->botflags &= ~BS_KICK_FLOOD; notice_lang(s_BotServ, u, BOT_KICK_FLOOD_OFF); } - } else if (!stricmp(option, "REPEAT")) { - if (!stricmp(value, "ON")) { + } else if (option == "REPEAT") { + if (value == "ON") { char *times = strtok(NULL, " "); if (ttb) { @@ -250,8 +250,8 @@ class CommandBSKick : public Command ci->botflags &= ~BS_KICK_REPEAT; notice_lang(s_BotServ, u, BOT_KICK_REPEAT_OFF); } - } else if (!stricmp(option, "REVERSES")) { - if (!stricmp(value, "ON")) { + } else if (option == "REVERSES") { + if (value == "ON") { if (ttb) { ci->ttb[TTB_REVERSES] = strtol(ttb, NULL, 10); @@ -276,8 +276,8 @@ class CommandBSKick : public Command ci->botflags &= ~BS_KICK_REVERSES; notice_lang(s_BotServ, u, BOT_KICK_REVERSES_OFF); } - } else if (!stricmp(option, "UNDERLINES")) { - if (!stricmp(value, "ON")) { + } else if (option == "UNDERLINES") { + if (value == "ON") { if (ttb) { ci->ttb[TTB_UNDERLINES] = strtol(ttb, NULL, 10); @@ -303,7 +303,7 @@ class CommandBSKick : public Command notice_lang(s_BotServ, u, BOT_KICK_UNDERLINES_OFF); } } else - notice_help(s_BotServ, u, BOT_KICK_UNKNOWN, option); + notice_help(s_BotServ, u, BOT_KICK_UNKNOWN, option.c_str()); } return MOD_CONT; } diff --git a/src/core/bs_say.c b/src/core/bs_say.c index 6fd8f41c7..8a7f49c73 100644 --- a/src/core/bs_say.c +++ b/src/core/bs_say.c @@ -22,7 +22,7 @@ class CommandBSSay : public Command { } - CommandReturn Execute(User *u, std::vector ¶ms) + CommandReturn Execute(User *u, std::vector ¶ms) { ChannelInfo *ci; @@ -37,7 +37,6 @@ class CommandBSSay : public Command return MOD_CONT; } - if (!ci->bi) { notice_help(s_BotServ, u, BOT_NOT_ASSIGNED); diff --git a/src/core/bs_set.c b/src/core/bs_set.c index c68a11688..c7c67714b 100644 --- a/src/core/bs_set.c +++ b/src/core/bs_set.c @@ -23,11 +23,11 @@ class CommandBSSet : public Command this->SetFlag(CFLAG_STRIP_CHANNEL); } - CommandReturn Execute(User *u, std::vector ¶ms) + CommandReturn Execute(User *u, std::vector ¶ms) { const char *chan = params[0].c_str(); - const char *option = params[1].c_str(); - const char *value = params[2].c_str(); + ci::string option = params[1]; + ci::string value = params[2]; ChannelInfo *ci; if (readonly) @@ -36,7 +36,7 @@ class CommandBSSet : public Command return MOD_CONT; } - if (u->nc->HasCommand("botserv/set/private") && !stricmp(option, "PRIVATE")) + if (u->nc->HasCommand("botserv/set/private") && option == "PRIVATE") { BotInfo *bi; @@ -46,12 +46,12 @@ class CommandBSSet : public Command return MOD_CONT; } - if (!stricmp(value, "ON")) + if (value == "ON") { bi->flags |= BI_PRIVATE; notice_lang(s_BotServ, u, BOT_SET_PRIVATE_ON, bi->nick); } - else if (!stricmp(value, "OFF")) + else if (value == "OFF") { bi->flags &= ~BI_PRIVATE; notice_lang(s_BotServ, u, BOT_SET_PRIVATE_OFF, bi->nick); @@ -66,12 +66,12 @@ class CommandBSSet : public Command else if (!u->nc->HasPriv("botserv/administration") && !check_access(u, ci, CA_SET)) notice_lang(s_BotServ, u, ACCESS_DENIED); else { - if (!stricmp(option, "DONTKICKOPS")) { - if (!stricmp(value, "ON")) { + if (option == "DONTKICKOPS") { + if (value == "ON") { ci->botflags |= BS_DONTKICKOPS; notice_lang(s_BotServ, u, BOT_SET_DONTKICKOPS_ON, ci->name); - } else if (!stricmp(value, "OFF")) { + } else if (value == "OFF") { ci->botflags &= ~BS_DONTKICKOPS; notice_lang(s_BotServ, u, BOT_SET_DONTKICKOPS_OFF, ci->name); @@ -79,12 +79,12 @@ class CommandBSSet : public Command syntax_error(s_BotServ, u, "SET DONTKICKOPS", BOT_SET_DONTKICKOPS_SYNTAX); } - } else if (!stricmp(option, "DONTKICKVOICES")) { - if (!stricmp(value, "ON")) { + } else if (option == "DONTKICKVOICES") { + if (value == "ON") { ci->botflags |= BS_DONTKICKVOICES; notice_lang(s_BotServ, u, BOT_SET_DONTKICKVOICES_ON, ci->name); - } else if (!stricmp(value, "OFF")) { + } else if (value == "OFF") { ci->botflags &= ~BS_DONTKICKVOICES; notice_lang(s_BotServ, u, BOT_SET_DONTKICKVOICES_OFF, ci->name); @@ -92,46 +92,46 @@ class CommandBSSet : public Command syntax_error(s_BotServ, u, "SET DONTKICKVOICES", BOT_SET_DONTKICKVOICES_SYNTAX); } - } else if (!stricmp(option, "FANTASY")) { - if (!stricmp(value, "ON")) { + } else if (option == "FANTASY") { + if (value == "ON") { ci->botflags |= BS_FANTASY; notice_lang(s_BotServ, u, BOT_SET_FANTASY_ON, ci->name); - } else if (!stricmp(value, "OFF")) { + } else if (value == "OFF") { ci->botflags &= ~BS_FANTASY; notice_lang(s_BotServ, u, BOT_SET_FANTASY_OFF, ci->name); } else { syntax_error(s_BotServ, u, "SET FANTASY", BOT_SET_FANTASY_SYNTAX); } - } else if (!stricmp(option, "GREET")) { - if (!stricmp(value, "ON")) { + } else if (option == "GREET") { + if (value == "ON") { ci->botflags |= BS_GREET; notice_lang(s_BotServ, u, BOT_SET_GREET_ON, ci->name); - } else if (!stricmp(value, "OFF")) { + } else if (value == "OFF") { ci->botflags &= ~BS_GREET; notice_lang(s_BotServ, u, BOT_SET_GREET_OFF, ci->name); } else { syntax_error(s_BotServ, u, "SET GREET", BOT_SET_GREET_SYNTAX); } - } else if (u->nc->HasCommand("botserv/set/nobot") && !stricmp(option, "NOBOT")) { - if (!stricmp(value, "ON")) { + } else if (u->nc->HasCommand("botserv/set/nobot") && option == "NOBOT") { + if (value == "ON") { ci->botflags |= BS_NOBOT; if (ci->bi) ci->bi->UnAssign(u, ci); notice_lang(s_BotServ, u, BOT_SET_NOBOT_ON, ci->name); - } else if (!stricmp(value, "OFF")) { + } else if (value == "OFF") { ci->botflags &= ~BS_NOBOT; notice_lang(s_BotServ, u, BOT_SET_NOBOT_OFF, ci->name); } else { syntax_error(s_BotServ, u, "SET NOBOT", BOT_SET_NOBOT_SYNTAX); } - } else if (!stricmp(option, "SYMBIOSIS")) { - if (!stricmp(value, "ON")) { + } else if (option == "SYMBIOSIS") { + if (value == "ON") { ci->botflags |= BS_SYMBIOSIS; notice_lang(s_BotServ, u, BOT_SET_SYMBIOSIS_ON, ci->name); - } else if (!stricmp(value, "OFF")) { + } else if (value == "OFF") { ci->botflags &= ~BS_SYMBIOSIS; notice_lang(s_BotServ, u, BOT_SET_SYMBIOSIS_OFF, ci->name); } else { @@ -139,7 +139,7 @@ class CommandBSSet : public Command BOT_SET_SYMBIOSIS_SYNTAX); } } else { - notice_help(s_BotServ, u, BOT_SET_UNKNOWN, option); + notice_help(s_BotServ, u, BOT_SET_UNKNOWN, option.c_str()); } } return MOD_CONT; diff --git a/src/core/bs_unassign.c b/src/core/bs_unassign.c index 83771fc9d..198a625b6 100644 --- a/src/core/bs_unassign.c +++ b/src/core/bs_unassign.c @@ -24,7 +24,7 @@ class CommandBSUnassign : public Command { } - CommandReturn Execute(User *u, std::vector ¶ms) + CommandReturn Execute(User *u, std::vector ¶ms) { const char *chan = params[0].c_str(); ChannelInfo *ci = cs_findchan(chan); diff --git a/src/core/cs_access.c b/src/core/cs_access.c index c2b5d93f2..40014b558 100644 --- a/src/core/cs_access.c +++ b/src/core/cs_access.c @@ -88,10 +88,10 @@ class CommandCSAccess : public Command { } - CommandReturn Execute(User *u, std::vector ¶ms) + CommandReturn Execute(User *u, std::vector ¶ms) { const char *chan = params[0].c_str(); - const char *cmd = params[1].c_str(); + ci::string cmd = params[1]; const char *nick = params.size() > 2 ? params[2].c_str() : NULL; const char *s = params.size() > 3 ? params[3].c_str() : NULL; @@ -102,12 +102,12 @@ class CommandCSAccess : public Command unsigned i; int level = 0, ulev; - int is_list = (cmd && !stricmp(cmd, "LIST")); + bool is_list = cmd == "LIST"; /* If LIST, we don't *require* any parameters, but we can take any. * If DEL, we require a nick and no level. * Else (ADD), we require a level (which implies a nick). */ - if (!cmd || ((is_list || !stricmp(cmd, "CLEAR")) ? 0 : (!stricmp(cmd, "DEL")) ? (!nick || s) : !s)) + if (is_list || cmd == "CLEAR" ? 0 : (cmd == "DEL" ? (!nick || s) : !s)) this->OnSyntaxError(u); /* We still allow LIST in xOP mode, but not others */ else if ((ci->flags & CI_XOP) && !is_list) @@ -123,7 +123,7 @@ class CommandCSAccess : public Command (!is_list && !check_access(u, ci, CA_ACCESS_CHANGE) && !u->nc->HasPriv("chanserv/access/modify")) )) notice_lang(s_ChanServ, u, ACCESS_DENIED); - else if (!stricmp(cmd, "ADD")) + else if (cmd == "ADD") { if (readonly) { @@ -200,7 +200,7 @@ class CommandCSAccess : public Command alog("%s: %s!%s@%s (level %d) set access level %d to %s (group %s) on channel %s", s_ChanServ, u->nick, u->GetIdent().c_str(), u->host, ulev, level, na->nick, nc->display, ci->name); notice_lang(s_ChanServ, u, CHAN_ACCESS_ADDED, nc->display, ci->name, level); } - else if (!stricmp(cmd, "DEL")) + else if (cmd == "DEL") { int deleted; if (readonly) @@ -281,7 +281,7 @@ class CommandCSAccess : public Command FOREACH_MOD(I_OnAccessDel, OnAccessDel(ci, u, (na->nick ? na->nick : NULL))); } } - else if (!stricmp(cmd, "LIST")) + else if (cmd == "LIST") { int sent_header = 0; @@ -307,7 +307,7 @@ class CommandCSAccess : public Command else notice_lang(s_ChanServ, u, CHAN_ACCESS_LIST_FOOTER, ci->name); } - else if (!stricmp(cmd, "CLEAR")) + else if (cmd == "CLEAR") { if (readonly) { @@ -357,10 +357,10 @@ class CommandCSLevels : public Command { } - CommandReturn Execute(User *u, std::vector ¶ms) + CommandReturn Execute(User *u, std::vector ¶ms) { const char *chan = params[0].c_str(); - const char *cmd = params[1].c_str(); + ci::string cmd = params[1]; const char *what = params.size() > 2 ? params[2].c_str() : NULL; const char *s = params.size() > 3 ? params[3].c_str() : NULL; char *error; @@ -372,15 +372,13 @@ class CommandCSLevels : public Command /* If SET, we want two extra parameters; if DIS[ABLE] or FOUNDER, we want only * one; else, we want none. */ - if (!cmd - || ((stricmp(cmd, "SET") == 0) ? !s - : ((strnicmp(cmd, "DIS", 3) == 0)) ? (!what || s) : !!what)) { + if (cmd == "SET" ? !s : (cmd.substr(0, 3) == "DIS" ? (!what || s) : !!what)) this->OnSyntaxError(u); - } else if (ci->flags & CI_XOP) { + else if (ci->flags & CI_XOP) notice_lang(s_ChanServ, u, CHAN_LEVELS_XOP); - } else if (!is_founder(u, ci) && !u->nc->HasPriv("chanserv/access/modify")) { + else if (!is_founder(u, ci) && !u->nc->HasPriv("chanserv/access/modify")) notice_lang(s_ChanServ, u, ACCESS_DENIED); - } else if (stricmp(cmd, "SET") == 0) { + else if (cmd == "SET") { level = strtol(s, &error, 10); if (*error != '\0') { @@ -409,7 +407,7 @@ class CommandCSLevels : public Command notice_lang(s_ChanServ, u, CHAN_LEVELS_UNKNOWN, what, s_ChanServ); - } else if (stricmp(cmd, "DIS") == 0 || stricmp(cmd, "DISABLE") == 0) { + } else if (cmd == "DIS" || cmd == "DISABLE") { for (i = 0; levelinfo[i].what >= 0; i++) { if (stricmp(levelinfo[i].name, what) == 0) { ci->levels[levelinfo[i].what] = ACCESS_INVALID; @@ -424,7 +422,7 @@ class CommandCSLevels : public Command } notice_lang(s_ChanServ, u, CHAN_LEVELS_UNKNOWN, what, s_ChanServ); - } else if (stricmp(cmd, "LIST") == 0) { + } else if (cmd == "LIST") { notice_lang(s_ChanServ, u, CHAN_LEVELS_LIST_HEADER, chan); if (!levelinfo_maxwidth) { @@ -458,7 +456,7 @@ class CommandCSLevels : public Command } } - } else if (stricmp(cmd, "RESET") == 0) { + } else if (cmd == "RESET") { reset_levels(ci); alog("%s: %s!%s@%s reset levels definitions on channel %s", diff --git a/src/core/cs_akick.c b/src/core/cs_akick.c index d396d0386..4f91beb8d 100644 --- a/src/core/cs_akick.c +++ b/src/core/cs_akick.c @@ -173,10 +173,10 @@ class CommandCSAKick : public Command { } - CommandReturn Execute(User *u, std::vector ¶ms) + CommandReturn Execute(User *u, std::vector ¶ms) { const char *chan = params[0].c_str(); - const char *cmd = params[1].c_str(); + ci::string cmd = params[1]; const char *mask = params.size() > 2 ? params[2].c_str() : NULL; const char *reason = NULL; @@ -196,15 +196,11 @@ class CommandCSAKick : public Command const char *argv[3]; int count = 0; - if (!cmd || (!mask && (!stricmp(cmd, "ADD") || !stricmp(cmd, "STICK") - || !stricmp(cmd, "UNSTICK") - || !stricmp(cmd, "DEL")))) { - + if (!mask && (cmd == "ADD" || cmd == "STICK" || cmd == "UNSTICK" || cmd == "DEL")) syntax_error(s_ChanServ, u, "AKICK", CHAN_AKICK_SYNTAX); - } else if (!check_access(u, ci, CA_AKICK) && !u->nc->HasPriv("chanserv/access/modify")) - { + else if (!check_access(u, ci, CA_AKICK) && !u->nc->HasPriv("chanserv/access/modify")) notice_lang(s_ChanServ, u, ACCESS_DENIED); - } else if (stricmp(cmd, "ADD") == 0) { + else if (cmd == "ADD") { NickAlias *na = findnick(mask), *na2; NickCore *nc = NULL; const char *nick, *user, *host; @@ -363,7 +359,7 @@ class CommandCSAKick : public Command if (freemask) delete [] mask; - } else if (stricmp(cmd, "STICK") == 0) { + } else if (cmd == "STICK") { NickAlias *na; NickCore *nc; @@ -399,7 +395,7 @@ class CommandCSAKick : public Command if (ci->c) stick_mask(ci, akick); - } else if (stricmp(cmd, "UNSTICK") == 0) { + } else if (cmd == "UNSTICK") { NickAlias *na; NickCore *nc; @@ -433,7 +429,7 @@ class CommandCSAKick : public Command notice_lang(s_ChanServ, u, CHAN_AKICK_UNSTUCK, akick->u.mask, ci->name); - } else if (stricmp(cmd, "DEL") == 0) { + } else if (cmd == "DEL") { int deleted, a, b; if (readonly) { @@ -531,7 +527,7 @@ class CommandCSAKick : public Command ci->akick = static_cast(srealloc(ci->akick,sizeof(AutoKick) * ci->akickcount)); } - } else if (stricmp(cmd, "LIST") == 0) { + } else if (cmd == "LIST") { int sent_header = 0; if (ci->akickcount == 0) { @@ -561,7 +557,7 @@ class CommandCSAKick : public Command if (!sent_header) notice_lang(s_ChanServ, u, CHAN_AKICK_NO_MATCH, chan); - } else if (stricmp(cmd, "VIEW") == 0) { + } else if (cmd == "VIEW") { int sent_header = 0; if (ci->akickcount == 0) { notice_lang(s_ChanServ, u, CHAN_AKICK_LIST_EMPTY, chan); @@ -590,7 +586,7 @@ class CommandCSAKick : public Command if (!sent_header) notice_lang(s_ChanServ, u, CHAN_AKICK_NO_MATCH, chan); - } else if (stricmp(cmd, "ENFORCE") == 0) { + } else if (cmd == "ENFORCE") { c = findchan(ci->name); cu = NULL; count = 0; @@ -622,8 +618,7 @@ class CommandCSAKick : public Command notice_lang(s_ChanServ, u, CHAN_AKICK_ENFORCE_DONE, chan, count); - } else if (stricmp(cmd, "CLEAR") == 0) { - + } else if (cmd == "CLEAR") { if (readonly) { notice_lang(s_ChanServ, u, CHAN_AKICK_DISABLED); return MOD_CONT; diff --git a/src/core/cs_ban.c b/src/core/cs_ban.c index d69b0540c..5032680a7 100644 --- a/src/core/cs_ban.c +++ b/src/core/cs_ban.c @@ -20,10 +20,9 @@ class CommandCSBan : public Command public: CommandCSBan() : Command("BAN", 2, 3) { - } - CommandReturn Execute(User *u, std::vector ¶ms) + CommandReturn Execute(User *u, std::vector ¶ms) { const char *chan = params[0].c_str(); const char *target = params[1].c_str(); @@ -33,7 +32,6 @@ class CommandCSBan : public Command { params[2].resize(200); reason = params[2].c_str(); - } Channel *c = findchan(chan); @@ -122,7 +120,7 @@ class CommandCSUnban : public Command } - CommandReturn Execute(User *u, std::vector ¶ms) + CommandReturn Execute(User *u, std::vector ¶ms) { const char *chan = params[0].c_str(); Channel *c; diff --git a/src/core/cs_clear.c b/src/core/cs_clear.c index 6aee7a93d..076a5cd34 100644 --- a/src/core/cs_clear.c +++ b/src/core/cs_clear.c @@ -23,10 +23,10 @@ class CommandCSClear : public Command } - CommandReturn Execute(User *u, std::vector ¶ms) + CommandReturn Execute(User *u, std::vector ¶ms) { const char *chan = params[0].c_str(); - const char *what = params[1].c_str(); + ci::string what = params[1]; Channel *c = findchan(chan); ChannelInfo *ci; @@ -37,7 +37,7 @@ class CommandCSClear : public Command notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, chan); } else if (!u || !check_access(u, ci, CA_CLEAR)) { notice_lang(s_ChanServ, u, ACCESS_DENIED); - } else if (stricmp(what, "bans") == 0) { + } else if (what == "bans") { const char *av[2]; Entry *ban, *bnext; @@ -52,7 +52,7 @@ class CommandCSClear : public Command } notice_lang(s_ChanServ, u, CHAN_CLEARED_BANS, chan); - } else if (ircd->except && stricmp(what, "excepts") == 0) { + } else if (ircd->except && what == "excepts") { const char *av[2]; Entry *except, *bnext; @@ -67,7 +67,7 @@ class CommandCSClear : public Command } notice_lang(s_ChanServ, u, CHAN_CLEARED_EXCEPTS, chan); - } else if (ircd->invitemode && stricmp(what, "invites") == 0) { + } else if (ircd->invitemode && what == "invites") { const char *av[2]; Entry *invite, *bnext; @@ -82,7 +82,7 @@ class CommandCSClear : public Command } notice_lang(s_ChanServ, u, CHAN_CLEARED_INVITES, chan); - } else if (stricmp(what, "modes") == 0) { + } else if (what == "modes") { const char *argv[2]; if (c->mode) { @@ -124,7 +124,7 @@ class CommandCSClear : public Command } notice_lang(s_ChanServ, u, CHAN_CLEARED_MODES, chan); - } else if (stricmp(what, "ops") == 0) { + } else if (what == "ops") { const char *av[6]; /* The max we have to hold: chan, ts, modes(max3), nick, nick, nick */ int ac, isop, isadmin, isown, count, i; char buf[BUFSIZE], tmp[BUFSIZE], tmp2[BUFSIZE]; @@ -212,7 +212,7 @@ class CommandCSClear : public Command } } notice_lang(s_ChanServ, u, CHAN_CLEARED_OPS, chan); - } else if (ircd->halfop && stricmp(what, "hops") == 0) { + } else if (ircd->halfop && what == "hops") { const char *av[4]; int ac; char buf[BUFSIZE]; @@ -256,7 +256,7 @@ class CommandCSClear : public Command do_cmode(s_ChanServ, ac, av); } notice_lang(s_ChanServ, u, CHAN_CLEARED_HOPS, chan); - } else if (stricmp(what, "voices") == 0) { + } else if (what == "voices") { const char *av[4]; int ac; char buf[BUFSIZE]; @@ -301,7 +301,7 @@ class CommandCSClear : public Command do_cmode(s_ChanServ, ac, av); } notice_lang(s_ChanServ, u, CHAN_CLEARED_VOICES, chan); - } else if (stricmp(what, "users") == 0) { + } else if (what == "users") { const char *av[3]; struct c_userlist *cu, *bnext; char buf[256]; diff --git a/src/core/cs_drop.c b/src/core/cs_drop.c index fcf7a9a80..7eb6320c0 100644 --- a/src/core/cs_drop.c +++ b/src/core/cs_drop.c @@ -24,7 +24,7 @@ class CommandCSDrop : public Command this->SetFlag(CFLAG_ALLOW_SUSPENDED); } - CommandReturn Execute(User *u, std::vector ¶ms) + CommandReturn Execute(User *u, std::vector ¶ms) { const char *chan = params[0].c_str(); ChannelInfo *ci; @@ -108,8 +108,6 @@ class CommandCSDrop : public Command } }; - - class CSDrop : public Module { public: @@ -126,7 +124,4 @@ class CSDrop : public Module } }; - - - MODULE_INIT("cs_drop", CSDrop) diff --git a/src/core/cs_forbid.c b/src/core/cs_forbid.c index 5e834462c..6b2796b6c 100644 --- a/src/core/cs_forbid.c +++ b/src/core/cs_forbid.c @@ -20,10 +20,9 @@ class CommandCSForbid : public Command public: CommandCSForbid() : Command("FORBID", 1, 2, "chanserv/forbid") { - } - CommandReturn Execute(User *u, std::vector ¶ms) + CommandReturn Execute(User *u, std::vector ¶ms) { ChannelInfo *ci; const char *chan = params[0].c_str(); @@ -53,7 +52,6 @@ class CommandCSForbid : public Command { notice_lang(s_ChanServ, u, READ_ONLY_MODE); return MOD_CONT; - } if ((ci = cs_findchan(chan)) != NULL) @@ -136,5 +134,4 @@ class CSForbid : public Module } }; - MODULE_INIT("cs_forbid", CSForbid) diff --git a/src/core/cs_getkey.c b/src/core/cs_getkey.c index a5be26419..7fa654858 100644 --- a/src/core/cs_getkey.c +++ b/src/core/cs_getkey.c @@ -20,10 +20,9 @@ class CommandCSGetKey : public Command public: CommandCSGetKey() : Command("GETKEY", 1, 1) { - } - CommandReturn Execute(User *u, std::vector ¶ms) + CommandReturn Execute(User *u, std::vector ¶ms) { const char *chan = params[0].c_str(); ChannelInfo *ci; diff --git a/src/core/cs_getpass.c b/src/core/cs_getpass.c index 5f6cd7652..cc1dfb89f 100644 --- a/src/core/cs_getpass.c +++ b/src/core/cs_getpass.c @@ -23,7 +23,7 @@ class CommandCSGetPass : public Command this->SetFlag(CFLAG_ALLOW_SUSPENDED); } - CommandReturn Execute(User *u, std::vector ¶ms) + CommandReturn Execute(User *u, std::vector ¶ms) { const char *chan = params[0].c_str(); char tmp_pass[PASSMAX]; diff --git a/src/core/cs_help.c b/src/core/cs_help.c index 2cc334f65..dd7c21f84 100644 --- a/src/core/cs_help.c +++ b/src/core/cs_help.c @@ -24,11 +24,11 @@ class CommandCSHelp : public Command this->SetFlag(CFLAG_STRIP_CHANNEL); } - CommandReturn Execute(User *u, std::vector ¶ms) + CommandReturn Execute(User *u, std::vector ¶ms) { - const char *cmd = params[0].c_str(); + ci::string cmd = params[0]; - if (!stricmp(cmd, "LEVELS DESC")) + if (cmd == "LEVELS DESC") { int i; notice_help(s_ChanServ, u, CHAN_HELP_LEVELS_DESC); @@ -47,7 +47,7 @@ class CommandCSHelp : public Command } } else - mod_help_cmd(s_ChanServ, u, CHANSERV, cmd); + mod_help_cmd(s_ChanServ, u, CHANSERV, cmd.c_str()); return MOD_CONT; } diff --git a/src/core/cs_identify.c b/src/core/cs_identify.c index 621446703..63f9ac823 100644 --- a/src/core/cs_identify.c +++ b/src/core/cs_identify.c @@ -20,10 +20,9 @@ class CommandCSIdentify : public Command public: CommandCSIdentify(const std::string &cname) : Command(cname, 2, 2) { - } - CommandReturn Execute(User *u, std::vector ¶ms) + CommandReturn Execute(User *u, std::vector ¶ms) { const char *chan = params[0].c_str(); const char *pass = params[1].c_str(); diff --git a/src/core/cs_info.c b/src/core/cs_info.c index f33e74c79..9a7cc9bcc 100644 --- a/src/core/cs_info.c +++ b/src/core/cs_info.c @@ -37,10 +37,10 @@ class CommandCSInfo : public Command this->SetFlag(CFLAG_ALLOW_FORBIDDEN); } - CommandReturn Execute(User *u, std::vector ¶ms) + CommandReturn Execute(User *u, std::vector ¶ms) { const char *chan = params[0].c_str(); - const char *param = params.size() > 1 ? params[1].c_str() : NULL; + ci::string param = params.size() > 1 ? params[1] : ""; ChannelInfo *ci; char buf[BUFSIZE]; struct tm *tm; @@ -63,9 +63,8 @@ class CommandCSInfo : public Command return MOD_CONT; } - /* Should we show all fields? Only for sadmins and identified users */ - if (param && stricmp(param, "ALL") == 0 && (check_access(u, ci, CA_INFO) || has_auspex)) + if (!param.empty() && param == "ALL" && (check_access(u, ci, CA_INFO) || has_auspex)) show_all = 1; notice_lang(s_ChanServ, u, CHAN_INFO_HEADER, chan); @@ -158,8 +157,6 @@ class CommandCSInfo : public Command } }; - - class CSInfo : public Module { public: @@ -176,7 +173,4 @@ class CSInfo : public Module } }; - - - MODULE_INIT("cs_info", CSInfo) diff --git a/src/core/cs_invite.c b/src/core/cs_invite.c index cfaedd3d8..95ab1e371 100644 --- a/src/core/cs_invite.c +++ b/src/core/cs_invite.c @@ -20,9 +20,9 @@ class CommandCSInvite : public Command public: CommandCSInvite() : Command("INVITE", 1, 1) { - } - CommandReturn Execute(User *u, std::vector ¶ms) + + CommandReturn Execute(User *u, std::vector ¶ms) { const char *chan = params[0].c_str(); Channel *c; @@ -64,9 +64,6 @@ class CommandCSInvite : public Command } }; - - - class CSInvite : public Module { public: @@ -83,6 +80,4 @@ class CSInvite : public Module } }; - - MODULE_INIT("cs_invite", CSInvite) diff --git a/src/core/cs_kick.c b/src/core/cs_kick.c index 5cbe007a0..3006c9b08 100644 --- a/src/core/cs_kick.c +++ b/src/core/cs_kick.c @@ -20,10 +20,9 @@ class CommandCSKick : public Command public: CommandCSKick() : Command("KICK", 2, 3) { - } - CommandReturn Execute(User *u, std::vector ¶ms) + CommandReturn Execute(User *u, std::vector ¶ms) { const char *chan = params[0].c_str(); const char *target = params[1].c_str(); diff --git a/src/core/cs_list.c b/src/core/cs_list.c index dcb2ca1bc..4624bcf4c 100644 --- a/src/core/cs_list.c +++ b/src/core/cs_list.c @@ -19,12 +19,12 @@ class CommandCSList : public Command { public: - CommandCSList() : Command("LIST",1,2) + CommandCSList() : Command("LIST", 1, 2) { this->SetFlag(CFLAG_STRIP_CHANNEL); } - CommandReturn Execute(User *u, std::vector ¶ms) + CommandReturn Execute(User *u, std::vector ¶ms) { const char *pattern = params[0].c_str(); int spattern_size; @@ -93,14 +93,15 @@ public: if (is_servadmin && params.size() > 1) { std::string keyword; - spacesepstream keywords(params[1]); + spacesepstream keywords(params[1].c_str()); while (keywords.GetToken(keyword)) { - if (stricmp(keyword.c_str(), "FORBIDDEN") == 0) + ci::string keyword_ci = keyword.c_str(); + if (keyword_ci == "FORBIDDEN") matchflags |= CI_FORBIDDEN; - if (stricmp(keyword.c_str(), "SUSPENDED") == 0) + if (keyword_ci == "SUSPENDED") matchflags |= CI_SUSPENDED; - if (stricmp(keyword.c_str(), "NOEXPIRE") == 0) + if (keyword_ci == "NOEXPIRE") matchflags |= CI_NO_EXPIRE; } @@ -110,7 +111,6 @@ public: spattern = new char[spattern_size]; snprintf(spattern, spattern_size, "#%s", pattern); - notice_lang(s_ChanServ, u, CHAN_LIST_HEADER, pattern); for (i = 0; i < 256; i++) { diff --git a/src/core/cs_logout.c b/src/core/cs_logout.c index 46483b0f7..0418b8ff5 100644 --- a/src/core/cs_logout.c +++ b/src/core/cs_logout.c @@ -47,10 +47,9 @@ class CommandCSLogout : public Command public: CommandCSLogout() : Command("LOGOUT", 1, 2) { - } - CommandReturn Execute(User *u, std::vector ¶ms) + CommandReturn Execute(User *u, std::vector ¶ms) { const char *chan = params[0].c_str(); const char *nick = params.size() > 1 ? params[1].c_str() : NULL; diff --git a/src/core/cs_modes.c b/src/core/cs_modes.c index e71031d28..3ab2d1528 100644 --- a/src/core/cs_modes.c +++ b/src/core/cs_modes.c @@ -71,10 +71,9 @@ class CommandCSOp : public Command public: CommandCSOp() : Command("OP", 1, 2) { - } - CommandReturn Execute(User *u, std::vector ¶ms) + CommandReturn Execute(User *u, std::vector ¶ms) { return do_util(u, &csmodeutils[MUT_OP], (params.size() > 0 ? params[0].c_str() : NULL), (params.size() > 1 ? params[1].c_str() : NULL)); } @@ -97,10 +96,9 @@ class CommandCSDeOp : public Command public: CommandCSDeOp() : Command("DEOP", 1, 2) { - } - CommandReturn Execute(User *u, std::vector ¶ms) + CommandReturn Execute(User *u, std::vector ¶ms) { return do_util(u, &csmodeutils[MUT_DEOP], (params.size() > 0 ? params[0].c_str() : NULL), (params.size() > 1 ? params[1].c_str() : NULL)); } @@ -123,10 +121,9 @@ class CommandCSVoice : public Command public: CommandCSVoice() : Command("VOICE", 1, 2) { - } - CommandReturn Execute(User *u, std::vector ¶ms) + CommandReturn Execute(User *u, std::vector ¶ms) { return do_util(u, &csmodeutils[MUT_VOICE], (params.size() > 0 ? params[0].c_str() : NULL), (params.size() > 1 ? params[1].c_str() : NULL)); } @@ -149,10 +146,9 @@ class CommandCSDeVoice : public Command public: CommandCSDeVoice() : Command("DEVOICE", 1, 2) { - } - CommandReturn Execute(User *u, std::vector ¶ms) + CommandReturn Execute(User *u, std::vector ¶ms) { return do_util(u, &csmodeutils[MUT_DEVOICE], (params.size() > 0 ? params[0].c_str() : NULL), (params.size() > 1 ? params[1].c_str() : NULL)); } @@ -175,15 +171,13 @@ class CommandCSHalfOp : public Command public: CommandCSHalfOp() : Command("HALFOP", 1, 2) { - } - CommandReturn Execute(User *u, std::vector ¶ms) + CommandReturn Execute(User *u, std::vector ¶ms) { if (!ircd->halfop) { return MOD_CONT; - } return do_util(u, &csmodeutils[MUT_HALFOP], (params.size() > 0 ? params[0].c_str() : NULL), (params.size() > 1 ? params[1].c_str() : NULL)); @@ -207,10 +201,9 @@ class CommandCSDeHalfOp : public Command public: CommandCSDeHalfOp() : Command("DEHALFOP", 1, 2) { - } - CommandReturn Execute(User *u, std::vector ¶ms) + CommandReturn Execute(User *u, std::vector ¶ms) { if (!ircd->halfop) { @@ -238,10 +231,9 @@ class CommandCSProtect : public Command public: CommandCSProtect() : Command("PROTECT", 1, 2) { - } - CommandReturn Execute(User *u, std::vector ¶ms) + CommandReturn Execute(User *u, std::vector ¶ms) { if (!ircd->protect && !ircd->admin) { @@ -270,10 +262,9 @@ class CommandCSDeProtect : public Command public: CommandCSDeProtect() : Command("DEPROTECT", 1, 2) { - } - CommandReturn Execute(User *u, std::vector ¶ms) + CommandReturn Execute(User *u, std::vector ¶ms) { if (!ircd->protect && !ircd->admin) { @@ -302,10 +293,9 @@ class CommandCSOwner : public Command public: CommandCSOwner() : Command("OWNER", 1, 2) { - } - CommandReturn Execute(User *u, std::vector ¶ms) + CommandReturn Execute(User *u, std::vector ¶ms) { return do_util(u, &csmodeutils[MUT_OWNER], (params.size() > 0 ? params[0].c_str() : NULL), NULL); } @@ -329,10 +319,9 @@ class CommandCSDeOwner : public Command public: CommandCSDeOwner() : Command("DEOWNER", 1, 2) { - } - CommandReturn Execute(User *u, std::vector ¶ms) + CommandReturn Execute(User *u, std::vector ¶ms) { return do_util(u, &csmodeutils[MUT_DEOWNER], (params.size() > 0 ? params[0].c_str() : NULL), NULL); } diff --git a/src/core/cs_register.c b/src/core/cs_register.c index 4cb2c0d1e..4949502e2 100644 --- a/src/core/cs_register.c +++ b/src/core/cs_register.c @@ -23,7 +23,7 @@ class CommandCSRegister : public Command this->SetFlag(CFLAG_ALLOW_UNREGISTEREDCHANNEL); } - CommandReturn Execute(User *u, std::vector ¶ms) + CommandReturn Execute(User *u, std::vector ¶ms) { const char *chan = params[0].c_str(); const char *pass = params[1].c_str(); @@ -70,7 +70,6 @@ class CommandCSRegister : public Command { alog("%s: makechan() failed for REGISTER %s", s_ChanServ, chan); notice_lang(s_ChanServ, u, CHAN_REGISTRATION_FAILED); - } else if (strscpy(founderpass, pass, PASSMAX), enc_encrypt_in_place(founderpass, PASSMAX) < 0) { diff --git a/src/core/cs_sendpass.c b/src/core/cs_sendpass.c index 3e75653b2..4ea1da3be 100644 --- a/src/core/cs_sendpass.c +++ b/src/core/cs_sendpass.c @@ -22,7 +22,7 @@ class CommandCSSendPass : public Command { } - CommandReturn Execute(User *u, std::vector ¶ms) + CommandReturn Execute(User *u, std::vector ¶ms) { const char *chan = params[0].c_str(); ChannelInfo *ci = cs_findchan(chan); diff --git a/src/core/cs_set.c b/src/core/cs_set.c index e44bfd7d3..1e36e859e 100644 --- a/src/core/cs_set.c +++ b/src/core/cs_set.c @@ -552,10 +552,10 @@ class CommandCSSet : public Command { } - CommandReturn Execute(User *u, std::vector ¶ms) + CommandReturn Execute(User *u, std::vector ¶ms) { const char *chan = params[0].c_str(); - const char *cmd = params[1].c_str(); + ci::string cmd = params[1]; const char *param = params.size() > 2 ? params[2].c_str() : NULL; ChannelInfo *ci = cs_findchan(chan); bool is_servadmin = u->nc->HasPriv("chanserv/set"); @@ -565,15 +565,11 @@ class CommandCSSet : public Command return MOD_CONT; } - if (!param && (!cmd || (stricmp(cmd, "SUCCESSOR") != 0 && - stricmp(cmd, "URL") != 0 && - stricmp(cmd, "EMAIL") != 0 && - stricmp(cmd, "ENTRYMSG") != 0) && - stricmp(cmd, "MLOCK") != 0)) { + if (!param && cmd != "SUCCESSOR" && cmd != "URL" && cmd != "EMAIL" && cmd != "ENTRYMSG" && cmd != "MLOCK") syntax_error(s_ChanServ, u, "SET", CHAN_SET_SYNTAX); - } else if (!is_servadmin && !check_access(u, ci, CA_SET)) { + else if (!is_servadmin && !check_access(u, ci, CA_SET)) notice_lang(s_ChanServ, u, ACCESS_DENIED); - } else if (stricmp(cmd, "FOUNDER") == 0) { + else if (cmd == "FOUNDER") { if (!is_servadmin && (ci-> flags & CI_SECUREFOUNDER ? !is_real_founder(u, @@ -583,7 +579,7 @@ class CommandCSSet : public Command } else { DoSetFounder(u, ci, param); } - } else if (stricmp(cmd, "SUCCESSOR") == 0) { + } else if (cmd == "SUCCESSOR") { if (!is_servadmin && (ci-> flags & CI_SECUREFOUNDER ? !is_real_founder(u, @@ -593,7 +589,7 @@ class CommandCSSet : public Command } else { DoSetSuccessor(u, ci, param); } - } else if (stricmp(cmd, "PASSWORD") == 0) { + } else if (cmd == "PASSWORD") { if (!is_servadmin && (ci-> flags & CI_SECUREFOUNDER ? !is_real_founder(u, @@ -603,29 +599,29 @@ class CommandCSSet : public Command } else { DoSetPassword(u, ci, param); } - } else if (stricmp(cmd, "DESC") == 0) { + } else if (cmd == "DESC") { DoSetDesc(u, ci, param); - } else if (stricmp(cmd, "URL") == 0) { + } else if (cmd == "URL") { DoSetURL(u, ci, param); - } else if (stricmp(cmd, "EMAIL") == 0) { + } else if (cmd == "EMAIL") { DoSetEMail(u, ci, param); - } else if (stricmp(cmd, "ENTRYMSG") == 0) { + } else if (cmd == "ENTRYMSG") { DoSetEntryMsg(u, ci, param); - } else if (stricmp(cmd, "TOPIC") == 0) { + } else if (cmd == "TOPIC") { notice_lang(s_ChanServ, u, OBSOLETE_COMMAND, "TOPIC"); - } else if (stricmp(cmd, "BANTYPE") == 0) { + } else if (cmd == "BANTYPE") { DoSetBanType(u, ci, param); - } else if (stricmp(cmd, "MLOCK") == 0) { + } else if (cmd == "MLOCK") { DoSetMLock(u, ci, param); - } else if (stricmp(cmd, "KEEPTOPIC") == 0) { + } else if (cmd == "KEEPTOPIC") { DoSetKeepTopic(u, ci, param); - } else if (stricmp(cmd, "TOPICLOCK") == 0) { + } else if (cmd == "TOPICLOCK") { DoSetTopicLock(u, ci, param); - } else if (stricmp(cmd, "PRIVATE") == 0) { + } else if (cmd == "PRIVATE") { DoSetPrivate(u, ci, param); - } else if (stricmp(cmd, "SECUREOPS") == 0) { + } else if (cmd == "SECUREOPS") { DoSetSecureOps(u, ci, param); - } else if (stricmp(cmd, "SECUREFOUNDER") == 0) { + } else if (cmd == "SECUREFOUNDER") { if (!is_servadmin && (ci-> flags & CI_SECUREFOUNDER ? !is_real_founder(u, @@ -635,26 +631,26 @@ class CommandCSSet : public Command } else { DoSetSecureFounder(u, ci, param); } - } else if (stricmp(cmd, "RESTRICTED") == 0) { + } else if (cmd == "RESTRICTED") { DoSetRestricted(u, ci, param); - } else if (stricmp(cmd, "SECURE") == 0) { + } else if (cmd == "SECURE") { DoSetSecure(u, ci, param); - } else if (stricmp(cmd, "SIGNKICK") == 0) { + } else if (cmd == "SIGNKICK") { DoSetSignKick(u, ci, param); - } else if (stricmp(cmd, "OPNOTICE") == 0) { + } else if (cmd == "OPNOTICE") { DoSetOpNotice(u, ci, param); - } else if (stricmp(cmd, "XOP") == 0) { + } else if (cmd == "XOP") { if (!(findModule("cs_xop"))) { - notice_lang(s_ChanServ, u, CHAN_XOP_NOT_AVAILABLE, cmd); + notice_lang(s_ChanServ, u, CHAN_XOP_NOT_AVAILABLE, cmd.c_str()); } else { DoSetXOP(u, ci, param); } - } else if (stricmp(cmd, "PEACE") == 0) { + } else if (cmd == "PEACE") { DoSetPeace(u, ci, param); - } else if (stricmp(cmd, "NOEXPIRE") == 0) { + } else if (cmd == "NOEXPIRE") { DoSetNoExpire(u, ci, param); } else { - notice_lang(s_ChanServ, u, CHAN_SET_UNKNOWN_OPTION, cmd); + notice_lang(s_ChanServ, u, CHAN_SET_UNKNOWN_OPTION, cmd.c_str()); notice_lang(s_ChanServ, u, MORE_INFO, s_ChanServ, "SET"); } return MOD_CONT; diff --git a/src/core/cs_status.c b/src/core/cs_status.c index 80cd223d6..d733d949a 100644 --- a/src/core/cs_status.c +++ b/src/core/cs_status.c @@ -22,7 +22,7 @@ class CommandCSStatus : public Command { } - CommandReturn Execute(User *u, std::vector ¶ms) + CommandReturn Execute(User *u, std::vector ¶ms) { ChannelInfo *ci; User *u2; diff --git a/src/core/cs_suspend.c b/src/core/cs_suspend.c index 8ab2fa077..08b1ecddf 100644 --- a/src/core/cs_suspend.c +++ b/src/core/cs_suspend.c @@ -22,7 +22,7 @@ class CommandCSSuspend : public Command { } - CommandReturn Execute(User *u, std::vector ¶ms) + CommandReturn Execute(User *u, std::vector ¶ms) { const char *chan = params[0].c_str(); const char *reason = params.size() > 1 ? params[1].c_str() : NULL; @@ -116,7 +116,7 @@ class CommandCSUnSuspend : public Command this->SetFlag(CFLAG_ALLOW_SUSPENDED); } - CommandReturn Execute(User *u, std::vector ¶ms) + CommandReturn Execute(User *u, std::vector ¶ms) { const char *chan = params[0].c_str(); ChannelInfo *ci = cs_findchan(chan); diff --git a/src/core/cs_topic.c b/src/core/cs_topic.c index 6f3c05390..844ba12fd 100644 --- a/src/core/cs_topic.c +++ b/src/core/cs_topic.c @@ -22,7 +22,7 @@ class CommandCSTopic : public Command { } - CommandReturn Execute(User *u, std::vector ¶ms) + CommandReturn Execute(User *u, std::vector ¶ms) { const char *chan = params[0].c_str(); const char *topic = params.size() > 1 ? params[1].c_str() : NULL; diff --git a/src/core/cs_xop.c b/src/core/cs_xop.c index 84687d79e..b83c44928 100644 --- a/src/core/cs_xop.c +++ b/src/core/cs_xop.c @@ -104,7 +104,7 @@ int xop_msgs[XOP_TYPES][XOP_MESSAGES] = { class XOPBase : public Command { private: - CommandReturn DoAdd(User *u, std::vector ¶ms, ChannelInfo *ci, int level, int *messages) + CommandReturn DoAdd(User *u, std::vector ¶ms, ChannelInfo *ci, int level, int *messages) { const char *nick = params.size() > 2 ? params[2].c_str() : NULL; ChanAccess *access; @@ -187,7 +187,7 @@ class XOPBase : public Command return MOD_CONT; } - CommandReturn DoDel(User *u, std::vector ¶ms, ChannelInfo *ci, int level, int *messages) + CommandReturn DoDel(User *u, std::vector ¶ms, ChannelInfo *ci, int level, int *messages) { const char *nick = params.size() > 2 ? params[2].c_str() : NULL; ChanAccess *access; @@ -286,7 +286,7 @@ class XOPBase : public Command return MOD_CONT; } - CommandReturn DoList(User *u, std::vector ¶ms, ChannelInfo *ci, int level, int *messages) + CommandReturn DoList(User *u, std::vector ¶ms, ChannelInfo *ci, int level, int *messages) { int sent_header = 0; const char *nick = params.size() > 2 ? params[2].c_str() : NULL; @@ -321,7 +321,7 @@ class XOPBase : public Command return MOD_CONT; } - CommandReturn DoClear(User *u, std::vector ¶ms, ChannelInfo *ci, int level, int *messages) + CommandReturn DoClear(User *u, std::vector ¶ms, ChannelInfo *ci, int level, int *messages) { if (readonly) { @@ -355,22 +355,22 @@ class XOPBase : public Command return MOD_CONT; } protected: - CommandReturn DoXop(User *u, std::vector ¶ms, int level, int *messages) + CommandReturn DoXop(User *u, std::vector ¶ms, int level, int *messages) { const char *chan = params[0].c_str(); - const char *cmd = params[1].c_str(); + ci::string cmd = params[1]; ChannelInfo *ci = cs_findchan(chan); if (!(ci->flags & CI_XOP)) notice_lang(s_ChanServ, u, CHAN_XOP_ACCESS, s_ChanServ); - else if (!stricmp(cmd, "ADD")) + else if (cmd == "ADD") return this->DoAdd(u, params, ci, level, messages); - else if (!stricmp(cmd, "DEL")) + else if (cmd == "DEL") return this->DoDel(u, params, ci, level, messages); - else if (!stricmp(cmd, "LIST")) + else if (cmd == "LIST") return this->DoList(u, params, ci, level, messages); - else if (!stricmp(cmd, "CLEAR")) + else if (cmd == "CLEAR") return this->DoClear(u, params, ci, level, messages); else this->OnSyntaxError(u); @@ -385,7 +385,7 @@ class XOPBase : public Command { } - virtual CommandReturn Execute(User *u, std::vector ¶ms) = 0; + virtual CommandReturn Execute(User *u, std::vector ¶ms) = 0; virtual bool OnHelp(User *u, const ci::string &subcommand) = 0; @@ -399,7 +399,7 @@ class CommandCSAOP : public XOPBase { } - CommandReturn Execute(User *u, std::vector ¶ms) + CommandReturn Execute(User *u, std::vector ¶ms) { return this->DoXop(u, params, ACCESS_AOP, xop_msgs[XOP_AOP]); } @@ -423,7 +423,7 @@ class CommandCSHOP : public XOPBase { } - CommandReturn Execute(User *u, std::vector ¶ms) + CommandReturn Execute(User *u, std::vector ¶ms) { return this->DoXop(u, params, ACCESS_HOP, xop_msgs[XOP_HOP]); } @@ -447,7 +447,7 @@ class CommandCSSOP : public XOPBase { } - CommandReturn Execute(User *u, std::vector ¶ms) + CommandReturn Execute(User *u, std::vector ¶ms) { return this->DoXop(u, params, ACCESS_SOP, xop_msgs[XOP_SOP]); } @@ -471,7 +471,7 @@ class CommandCSVOP : public XOPBase { } - CommandReturn Execute(User *u, std::vector ¶ms) + CommandReturn Execute(User *u, std::vector ¶ms) { return this->DoXop(u, params, ACCESS_VOP, xop_msgs[XOP_VOP]); } diff --git a/src/core/hs_del.c b/src/core/hs_del.c index 75f41b56d..83711335a 100644 --- a/src/core/hs_del.c +++ b/src/core/hs_del.c @@ -22,7 +22,7 @@ class CommandHSDel : public Command { } - CommandReturn Execute(User *u, std::vector ¶ms) + CommandReturn Execute(User *u, std::vector ¶ms) { NickAlias *na; const char *nick = params[0].c_str(); diff --git a/src/core/hs_delall.c b/src/core/hs_delall.c index 8381c686c..05f256f34 100644 --- a/src/core/hs_delall.c +++ b/src/core/hs_delall.c @@ -22,7 +22,7 @@ class CommandHSDelAll : public Command { } - CommandReturn Execute(User *u, std::vector ¶ms) + CommandReturn Execute(User *u, std::vector ¶ms) { int i; const char *nick = params[0].c_str(); diff --git a/src/core/hs_group.c b/src/core/hs_group.c index 202f09d26..c63766e17 100644 --- a/src/core/hs_group.c +++ b/src/core/hs_group.c @@ -24,7 +24,7 @@ class CommandHSGroup : public Command { } - CommandReturn Execute(User *u, std::vector ¶ms) + CommandReturn Execute(User *u, std::vector ¶ms) { NickAlias *na; HostCore *tmp; diff --git a/src/core/hs_help.c b/src/core/hs_help.c index ca1f689ae..13b5e544f 100644 --- a/src/core/hs_help.c +++ b/src/core/hs_help.c @@ -23,9 +23,9 @@ class CommandHSHelp : public Command this->SetFlag(CFLAG_ALLOW_UNREGISTERED); } - CommandReturn Execute(User *u, std::vector ¶ms) + CommandReturn Execute(User *u, std::vector ¶ms) { - mod_help_cmd(s_HostServ, u, HOSTSERV, params.size() > 0 ? params[0].c_str() : NULL); + mod_help_cmd(s_HostServ, u, HOSTSERV, params[0].c_str()); return MOD_CONT; } diff --git a/src/core/hs_list.c b/src/core/hs_list.c index d68477865..69efbd320 100644 --- a/src/core/hs_list.c +++ b/src/core/hs_list.c @@ -22,7 +22,7 @@ class CommandHSList : public Command { } - CommandReturn Execute(User *u, std::vector ¶ms) + CommandReturn Execute(User *u, std::vector ¶ms) { const char *key = params.size() ? params[0].c_str() : NULL; struct tm *tm; diff --git a/src/core/hs_off.c b/src/core/hs_off.c index 6acf9d096..086381fee 100644 --- a/src/core/hs_off.c +++ b/src/core/hs_off.c @@ -22,7 +22,7 @@ class CommandHSOff : public Command { } - CommandReturn Execute(User *u, std::vector ¶ms) + CommandReturn Execute(User *u, std::vector ¶ms) { NickAlias *na; char *vhost; diff --git a/src/core/hs_on.c b/src/core/hs_on.c index e946aba18..d1c2b391f 100644 --- a/src/core/hs_on.c +++ b/src/core/hs_on.c @@ -22,7 +22,7 @@ class CommandHSOn : public Command { } - CommandReturn Execute(User *u, std::vector ¶ms) + CommandReturn Execute(User *u, std::vector ¶ms) { NickAlias *na; char *vHost; diff --git a/src/core/hs_set.c b/src/core/hs_set.c index 025bbc044..eac1cbe3e 100644 --- a/src/core/hs_set.c +++ b/src/core/hs_set.c @@ -22,7 +22,7 @@ class CommandHSSet : public Command { } - CommandReturn Execute(User *u, std::vector ¶ms) + CommandReturn Execute(User *u, std::vector ¶ms) { const char *nick = params[0].c_str(); const char *rawhostmask = params[1].c_str(); diff --git a/src/core/hs_setall.c b/src/core/hs_setall.c index 77c10fb37..3bb04f593 100644 --- a/src/core/hs_setall.c +++ b/src/core/hs_setall.c @@ -24,7 +24,7 @@ class CommandHSSetAll : public Command { } - CommandReturn Execute(User *u, std::vector ¶ms) + CommandReturn Execute(User *u, std::vector ¶ms) { const char *nick = params[0].c_str(); const char *rawhostmask = params[1].c_str(); diff --git a/src/core/ms_