diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2008-05-19 21:16:42 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2008-05-19 21:16:42 +0000 |
commit | 31f1e7ad092f8bf16ee653cc105eea4a769650ca (patch) | |
tree | dced0411d5fbe803fe92ea54cb03d36c0a817563 /src/commands | |
parent | 869bd02318d94a38369a125726b8edeb54ba0706 (diff) |
Convert channel::name to std::string, this was a beastie!
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@9770 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/commands')
-rw-r--r-- | src/commands/cmd_invite.cpp | 20 | ||||
-rw-r--r-- | src/commands/cmd_list.cpp | 2 | ||||
-rw-r--r-- | src/commands/cmd_names.cpp | 2 | ||||
-rw-r--r-- | src/commands/cmd_notice.cpp | 10 | ||||
-rw-r--r-- | src/commands/cmd_privmsg.cpp | 14 | ||||
-rw-r--r-- | src/commands/cmd_topic.cpp | 27 | ||||
-rw-r--r-- | src/commands/cmd_who.cpp | 8 |
7 files changed, 42 insertions, 41 deletions
diff --git a/src/commands/cmd_invite.cpp b/src/commands/cmd_invite.cpp index 1455e94e7..116198d73 100644 --- a/src/commands/cmd_invite.cpp +++ b/src/commands/cmd_invite.cpp @@ -45,20 +45,20 @@ CmdResult CommandInvite::Handle (const std::vector<std::string>& parameters, Use { if (c->GetStatus(user) < STATUS_HOP) { - user->WriteNumeric(482, "%s %s :You must be a channel %soperator", user->nick.c_str(), c->name, c->GetStatus(u) == STATUS_HOP ? "" : "half-"); + user->WriteNumeric(482, "%s %s :You must be a channel %soperator", user->nick.c_str(), c->name.c_str(), c->GetStatus(u) == STATUS_HOP ? "" : "half-"); return CMD_FAILURE; } } if (c->HasUser(u)) { - user->WriteNumeric(443, "%s %s %s :is already on channel",user->nick.c_str(),u->nick.c_str(),c->name); + user->WriteNumeric(443, "%s %s %s :is already on channel",user->nick.c_str(),u->nick.c_str(),c->name.c_str()); return CMD_FAILURE; } if ((IS_LOCAL(user)) && (!c->HasUser(user))) { - user->WriteNumeric(442, "%s %s :You're not on that channel!",user->nick.c_str(), c->name); + user->WriteNumeric(442, "%s %s :You're not on that channel!",user->nick.c_str(), c->name.c_str()); return CMD_FAILURE; } @@ -69,22 +69,22 @@ CmdResult CommandInvite::Handle (const std::vector<std::string>& parameters, Use return CMD_FAILURE; } - u->InviteTo(c->name, timeout); - u->WriteFrom(user,"INVITE %s :%s",u->nick.c_str(),c->name); - user->WriteNumeric(341, "%s %s %s",user->nick.c_str(),u->nick.c_str(),c->name); + u->InviteTo(c->name.c_str(), timeout); + u->WriteFrom(user,"INVITE %s :%s",u->nick.c_str(),c->name.c_str()); + user->WriteNumeric(341, "%s %s %s",user->nick.c_str(),u->nick.c_str(),c->name.c_str()); switch (ServerInstance->Config->AnnounceInvites) { case ServerConfig::INVITE_ANNOUNCE_ALL: - c->WriteChannelWithServ(ServerInstance->Config->ServerName, "NOTICE %s :*** %s invited %s into the channel", c->name, user->nick.c_str(), u->nick.c_str()); + c->WriteChannelWithServ(ServerInstance->Config->ServerName, "NOTICE %s :*** %s invited %s into the channel", c->name.c_str(), user->nick.c_str(), u->nick.c_str()); break; case ServerConfig::INVITE_ANNOUNCE_OPS: - c->WriteAllExceptSender(user, true, '@', "NOTICE %s :*** %s invited %s into the channel", c->name, user->nick.c_str(), u->nick.c_str()); + c->WriteAllExceptSender(user, true, '@', "NOTICE %s :*** %s invited %s into the channel", c->name.c_str(), user->nick.c_str(), u->nick.c_str()); break; case ServerConfig::INVITE_ANNOUNCE_DYNAMIC: if (c->IsModeSet('i')) - c->WriteAllExceptSender(user, true, '@', "NOTICE %s :*** %s invited %s into the channel", c->name, user->nick.c_str(), u->nick.c_str()); + c->WriteAllExceptSender(user, true, '@', "NOTICE %s :*** %s invited %s into the channel", c->name.c_str(), user->nick.c_str(), u->nick.c_str()); else - c->WriteChannelWithServ(ServerInstance->Config->ServerName, "NOTICE %s :*** %s invited %s into the channel", c->name, user->nick.c_str(), u->nick.c_str()); + c->WriteChannelWithServ(ServerInstance->Config->ServerName, "NOTICE %s :*** %s invited %s into the channel", c->name.c_str(), user->nick.c_str(), u->nick.c_str()); break; default: /* Nobody */ diff --git a/src/commands/cmd_list.cpp b/src/commands/cmd_list.cpp index 62bf8d628..b2ec1941b 100644 --- a/src/commands/cmd_list.cpp +++ b/src/commands/cmd_list.cpp @@ -68,7 +68,7 @@ CmdResult CommandList::Handle (const std::vector<std::string>& parameters, User { if (IS_OPER(user) || (((!(i->second->IsModeSet('p'))) && (!(i->second->IsModeSet('s')))) || (n))) { - user->WriteNumeric(322, "%s %s %ld :[+%s] %s",user->nick.c_str(),i->second->name,users,i->second->ChanModes(n),i->second->topic); + user->WriteNumeric(322, "%s %s %ld :[+%s] %s",user->nick.c_str(),i->second->name.c_str(),users,i->second->ChanModes(n),i->second->topic.c_str()); } } } diff --git a/src/commands/cmd_names.cpp b/src/commands/cmd_names.cpp index acf516e86..a48cd2560 100644 --- a/src/commands/cmd_names.cpp +++ b/src/commands/cmd_names.cpp @@ -39,7 +39,7 @@ CmdResult CommandNames::Handle (const std::vector<std::string>& parameters, User { if ((c->IsModeSet('s')) && (!c->HasUser(user))) { - user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick.c_str(), c->name); + user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick.c_str(), c->name.c_str()); return CMD_FAILURE; } c->UserList(user); diff --git a/src/commands/cmd_notice.cpp b/src/commands/cmd_notice.cpp index 6c8762a30..5086f3f4f 100644 --- a/src/commands/cmd_notice.cpp +++ b/src/commands/cmd_notice.cpp @@ -69,12 +69,12 @@ CmdResult CommandNotice::Handle (const std::vector<std::string>& parameters, Use { if ((chan->IsModeSet('n')) && (!chan->HasUser(user))) { - user->WriteNumeric(404, "%s %s :Cannot send to channel (no external messages)", user->nick.c_str(), chan->name); + user->WriteNumeric(404, "%s %s :Cannot send to channel (no external messages)", user->nick.c_str(), chan->name.c_str()); return CMD_FAILURE; } if ((chan->IsModeSet('m')) && (chan->GetStatus(user) < STATUS_VOICE)) { - user->WriteNumeric(404, "%s %s :Cannot send to channel (+m)", user->nick.c_str(), chan->name); + user->WriteNumeric(404, "%s %s :Cannot send to channel (+m)", user->nick.c_str(), chan->name.c_str()); return CMD_FAILURE; } } @@ -99,16 +99,16 @@ CmdResult CommandNotice::Handle (const std::vector<std::string>& parameters, Use { if (ServerInstance->Config->UndernetMsgPrefix) { - chan->WriteAllExcept(user, false, status, exempt_list, "NOTICE %c%s :%c %s", status, chan->name, status, text); + chan->WriteAllExcept(user, false, status, exempt_list, "NOTICE %c%s :%c %s", status, chan->name.c_str(), status, text); } else { - chan->WriteAllExcept(user, false, status, exempt_list, "NOTICE %c%s :%s", status, chan->name, text); + chan->WriteAllExcept(user, false, status, exempt_list, "NOTICE %c%s :%s", status, chan->name.c_str(), text); } } else { - chan->WriteAllExcept(user, false, status, exempt_list, "NOTICE %s :%s", chan->name, text); + chan->WriteAllExcept(user, false, status, exempt_list, "NOTICE %s :%s", chan->name.c_str(), text); } FOREACH_MOD(I_OnUserNotice,OnUserNotice(user,chan,TYPE_CHANNEL,text,status,exempt_list)); diff --git a/src/commands/cmd_privmsg.cpp b/src/commands/cmd_privmsg.cpp index c4d604959..842635ae2 100644 --- a/src/commands/cmd_privmsg.cpp +++ b/src/commands/cmd_privmsg.cpp @@ -70,12 +70,12 @@ CmdResult CommandPrivmsg::Handle (const std::vector<std::string>& parameters, Us { if ((chan->IsModeSet('n')) && (!chan->HasUser(user))) { - user->WriteNumeric(404, "%s %s :Cannot send to channel (no external messages)", user->nick.c_str(), chan->name); + user->WriteNumeric(404, "%s %s :Cannot send to channel (no external messages)", user->nick.c_str(), chan->name.c_str()); return CMD_FAILURE; } if ((chan->IsModeSet('m')) && (chan->GetStatus(user) < STATUS_VOICE)) { - user->WriteNumeric(404, "%s %s :Cannot send to channel (+m)", user->nick.c_str(), chan->name); + user->WriteNumeric(404, "%s %s :Cannot send to channel (+m)", user->nick.c_str(), chan->name.c_str()); return CMD_FAILURE; } } @@ -101,16 +101,16 @@ CmdResult CommandPrivmsg::Handle (const std::vector<std::string>& parameters, Us { if (ServerInstance->Config->UndernetMsgPrefix) { - chan->WriteAllExcept(user, false, status, except_list, "PRIVMSG %c%s :%c %s", status, chan->name, status, text); + chan->WriteAllExcept(user, false, status, except_list, "PRIVMSG %c%s :%c %s", status, chan->name.c_str(), status, text); } else { - chan->WriteAllExcept(user, false, status, except_list, "PRIVMSG %c%s :%s", status, chan->name, text); + chan->WriteAllExcept(user, false, status, except_list, "PRIVMSG %c%s :%s", status, chan->name.c_str(), text); } } else { - chan->WriteAllExcept(user, false, status, except_list, "PRIVMSG %s :%s", chan->name, text); + chan->WriteAllExcept(user, false, status, except_list, "PRIVMSG %s :%s", chan->name.c_str(), text); } FOREACH_MOD(I_OnUserMessage,OnUserMessage(user,chan,TYPE_CHANNEL,text,status,except_list)); @@ -118,7 +118,7 @@ CmdResult CommandPrivmsg::Handle (const std::vector<std::string>& parameters, Us else { /* no such nick/channel */ - user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick.c_str(), target); + user->WriteNumeric(401, "%s %s :No such nick/channel", user->nick.c_str(), target); return CMD_FAILURE; } return CMD_SUCCESS; @@ -159,7 +159,7 @@ CmdResult CommandPrivmsg::Handle (const std::vector<std::string>& parameters, Us if (IS_AWAY(dest)) { /* auto respond with aweh msg */ - user->WriteNumeric(301, "%s %s :%s",user->nick.c_str(),dest->nick.c_str(),dest->awaymsg.c_str()); + user->WriteNumeric(301, "%s %s :%s", user->nick.c_str(), dest->nick.c_str(), dest->awaymsg.c_str()); } int MOD_RESULT = 0; diff --git a/src/commands/cmd_topic.cpp b/src/commands/cmd_topic.cpp index f228243bd..e723a50c9 100644 --- a/src/commands/cmd_topic.cpp +++ b/src/commands/cmd_topic.cpp @@ -31,17 +31,17 @@ CmdResult CommandTopic::Handle (const std::vector<std::string>& parameters, User { if ((Ptr->IsModeSet('s')) && (!Ptr->HasUser(user))) { - user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick.c_str(), Ptr->name); + user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick.c_str(), Ptr->name.c_str()); return CMD_FAILURE; } if (Ptr->topicset) { - user->WriteNumeric(332, "%s %s :%s", user->nick.c_str(), Ptr->name, Ptr->topic); - user->WriteNumeric(333, "%s %s %s %lu", user->nick.c_str(), Ptr->name, Ptr->setby, (unsigned long)Ptr->topicset); + user->WriteNumeric(332, "%s %s :%s", user->nick.c_str(), Ptr->name.c_str(), Ptr->topic.c_str()); + user->WriteNumeric(333, "%s %s %s %lu", user->nick.c_str(), Ptr->name.c_str(), Ptr->setby.c_str(), (unsigned long)Ptr->topicset); } else { - user->WriteNumeric(331, "%s %s :No topic is set.", user->nick.c_str(), Ptr->name); + user->WriteNumeric(331, "%s %s :No topic is set.", user->nick.c_str(), Ptr->name.c_str()); } } else @@ -60,12 +60,12 @@ CmdResult CommandTopic::Handle (const std::vector<std::string>& parameters, User { if (!Ptr->HasUser(user)) { - user->WriteNumeric(442, "%s %s :You're not on that channel!",user->nick.c_str(), Ptr->name); + user->WriteNumeric(442, "%s %s :You're not on that channel!",user->nick.c_str(), Ptr->name.c_str()); return CMD_FAILURE; } if ((Ptr->IsModeSet('t')) && (Ptr->GetStatus(user) < STATUS_HOP)) { - user->WriteNumeric(482, "%s %s :You must be at least a half-operator to change the topic on this channel", user->nick.c_str(), Ptr->name); + user->WriteNumeric(482, "%s %s :You must be at least a half-operator to change the topic on this channel", user->nick.c_str(), Ptr->name.c_str()); return CMD_FAILURE; } } @@ -79,26 +79,25 @@ CmdResult CommandTopic::Handle (const std::vector<std::string>& parameters, User */ int MOD_RESULT = 0; - strlcpy(topic, parameters[1].c_str(), MAXTOPIC-1); + strlcpy(topic, parameters[1].c_str(), MAXTOPIC); FOREACH_RESULT(I_OnLocalTopicChange,OnLocalTopicChange(user,Ptr,topic)); if (MOD_RESULT) return CMD_FAILURE; - strlcpy(Ptr->topic, topic, MAXTOPIC-1); + Ptr->topic.assign(topic, 0, MAXTOPIC); } else { /* Sneaky shortcut, one string copy for a remote topic */ - strlcpy(Ptr->topic, parameters[1].c_str(), MAXTOPIC-1); + Ptr->topic.assign(parameters[1], 0, MAXTOPIC); } - if (ServerInstance->Config->FullHostInTopic) - strlcpy(Ptr->setby,user->GetFullHost().c_str(),127); - else - strlcpy(Ptr->setby,user->nick.c_str(),127); + Ptr->setby.assign(ServerInstance->Config->FullHostInTopic ? + user->GetFullHost() : user->nick, + 0, 128); Ptr->topicset = ServerInstance->Time(); - Ptr->WriteChannel(user, "TOPIC %s :%s", Ptr->name, Ptr->topic); + Ptr->WriteChannel(user, "TOPIC %s :%s", Ptr->name.c_str(), Ptr->topic.c_str()); if (IS_LOCAL(user)) /* We know 'topic' will contain valid data here */ diff --git a/src/commands/cmd_who.cpp b/src/commands/cmd_who.cpp index 7f4365204..a9f27de83 100644 --- a/src/commands/cmd_who.cpp +++ b/src/commands/cmd_who.cpp @@ -15,7 +15,9 @@ #include "wildcard.h" #include "commands/cmd_who.h" -static const char *get_first_visible_channel(User *u) +static const std::string star = "*"; + +static const std::string& get_first_visible_channel(User *u) { UCListIter i = u->chans.begin(); if (i != u->chans.end()) @@ -24,7 +26,7 @@ static const char *get_first_visible_channel(User *u) return i->first->name; } - return "*"; + return star; } bool CommandWho::whomatch(User* user, const char* matchtext) @@ -138,7 +140,7 @@ void CommandWho::SendWhoLine(User* user, const std::string &initial, Channel* ch if (u->Visibility && !u->Visibility->VisibleTo(user)) return; - std::string lcn = get_first_visible_channel(u); + const std::string& lcn = get_first_visible_channel(u); Channel* chlast = ServerInstance->FindChan(lcn); std::string wholine = initial + (ch ? ch->name : lcn) + " " + u->ident + " " + (opt_showrealhost ? u->host : u->dhost) + " " + |