1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2008 InspIRCd Development Team
6 * See: http://www.inspircd.org/wiki/index.php/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
14 /* $Core: libIRCDchannels */
21 Channel::Channel(InspIRCd* Instance, const std::string &cname, time_t ts) : ServerInstance(Instance)
23 chan_hash::iterator findchan = ServerInstance->chanlist->find(cname);
24 if (findchan != Instance->chanlist->end())
25 throw CoreException("Cannot create duplicate channel " + cname);
27 (*(ServerInstance->chanlist))[cname.c_str()] = this;
28 strlcpy(this->name, cname.c_str(), CHANMAX);
29 this->created = ts ? ts : ServerInstance->Time();
30 this->age = this->created;
35 *topic = *setby = *key = 0;
36 maxbans = topicset = limit = 0;
40 void Channel::SetMode(char mode,bool mode_on)
42 modes[mode-65] = mode_on;
44 this->SetModeParam(mode,"",false);
48 void Channel::SetModeParam(char mode,const char* parameter,bool mode_on)
50 CustomModeList::iterator n = custom_mode_params.find(mode);
54 if (n == custom_mode_params.end())
55 custom_mode_params[mode] = strdup(parameter);
59 if (n != custom_mode_params.end())
62 custom_mode_params.erase(n);
67 bool Channel::IsModeSet(char mode)
69 return modes[mode-65];
72 std::string Channel::GetModeParameter(char mode)
79 return ConvToStr(this->limit);
81 CustomModeList::iterator n = custom_mode_params.find(mode);
82 if (n != custom_mode_params.end())
89 long Channel::GetUserCounter()
91 return (this->internal_userlist.size());
94 void Channel::AddUser(User* user)
96 internal_userlist[user] = user->nick;
99 unsigned long Channel::DelUser(User* user)
101 CUListIter a = internal_userlist.find(user);
103 if (a != internal_userlist.end())
105 internal_userlist.erase(a);
106 /* And tidy any others... */
108 DelHalfoppedUser(user);
112 return internal_userlist.size();
115 bool Channel::HasUser(User* user)
117 return (internal_userlist.find(user) != internal_userlist.end());
120 void Channel::AddOppedUser(User* user)
122 internal_op_userlist[user] = user->nick;
125 void Channel::DelOppedUser(User* user)
127 CUListIter a = internal_op_userlist.find(user);
128 if (a != internal_op_userlist.end())
130 internal_op_userlist.erase(a);
135 void Channel::AddHalfoppedUser(User* user)
137 internal_halfop_userlist[user] = user->nick;
140 void Channel::DelHalfoppedUser(User* user)
142 CUListIter a = internal_halfop_userlist.find(user);
144 if (a != internal_halfop_userlist.end())
146 internal_halfop_userlist.erase(a);
150 void Channel::AddVoicedUser(User* user)
152 internal_voice_userlist[user] = user->nick;
155 void Channel::DelVoicedUser(User* user)
157 CUListIter a = internal_voice_userlist.find(user);
159 if (a != internal_voice_userlist.end())
161 internal_voice_userlist.erase(a);
165 CUList* Channel::GetUsers()
167 return &internal_userlist;
170 CUList* Channel::GetOppedUsers()
172 return &internal_op_userlist;
175 CUList* Channel::GetHalfoppedUsers()
177 return &internal_halfop_userlist;
180 CUList* Channel::GetVoicedUsers()
182 return &internal_voice_userlist;
185 void Channel::SetDefaultModes()
187 ServerInstance->Logs->Log("CHANNELS", DEBUG, "SetDefaultModes %s", ServerInstance->Config->DefaultModes);
188 irc::spacesepstream list(ServerInstance->Config->DefaultModes);
190 std::string parameter;
192 list.GetToken(modeseq);
194 for (std::string::iterator n = modeseq.begin(); n != modeseq.end(); ++n)
196 ModeHandler* mode = ServerInstance->Modes->FindMode(*n, MODETYPE_CHANNEL);
199 if (mode->GetNumParams(true))
200 list.GetToken(parameter);
204 mode->OnModeChange(ServerInstance->FakeClient, ServerInstance->FakeClient, this, parameter, true);
210 * add a channel to a user, creating the record for it if needed and linking
211 * it to the user record
213 Channel* Channel::JoinUser(InspIRCd* Instance, User *user, const char* cn, bool override, const char* key, bool bursting, time_t TS)
224 * We don't restrict the number of channels that remote users or users that are override-joining may be in.
225 * We restrict local users to MaxChans channels.
226 * We restrict local operators to OperMaxChans channels.
227 * This is a lot more logical than how it was formerly. -- w00t
229 if (IS_LOCAL(user) && !override)
231 if (user->GetMaxChans())
233 if (user->chans.size() >= user->GetMaxChans())
235 user->WriteNumeric(405, "%s %s :You are on too many channels",user->nick, cn);
243 if (user->chans.size() >= Instance->Config->OperMaxChans)
245 user->WriteNumeric(405, "%s %s :You are on too many channels",user->nick, cn);
251 if (user->chans.size() >= Instance->Config->MaxChans)
253 user->WriteNumeric(405, "%s %s :You are on too many channels",user->nick, cn);
260 strlcpy(cname, cn, CHANMAX);
261 Ptr = Instance->FindChan(cname);
266 * Fix: desync bug was here, don't set @ on remote users - spanningtree handles their permissions. bug #358. -- w00t
271 Instance->Logs->Log("CHANNEL",DEBUG,"*** BUG *** Channel::JoinUser called for REMOTE user '%s' on channel '%s' but no TS given!", user->nick, cn);
278 if (IS_LOCAL(user) && override == false)
281 FOREACH_RESULT_I(Instance,I_OnUserPreJoin,OnUserPreJoin(user,NULL,cname,privs));
286 Ptr = new Channel(Instance, cname, TS);
290 /* Already on the channel */
291 if (Ptr->HasUser(user))
295 * remote users are allowed us to bypass channel modes
296 * and bans (used by servers)
298 if (IS_LOCAL(user) && override == false)
301 FOREACH_RESULT_I(Instance,I_OnUserPreJoin,OnUserPreJoin(user,Ptr,cname,privs));
306 else if (MOD_RESULT == 0)
311 FOREACH_RESULT_I(Instance,I_OnCheckKey,OnCheckKey(user, Ptr, key ? key : ""));
314 if ((!key) || strcmp(key,Ptr->key))
316 user->WriteNumeric(475, "%s %s :Cannot join channel (Incorrect channel key)",user->nick, Ptr->name);
321 if (Ptr->IsModeSet('i'))
324 FOREACH_RESULT_I(Instance,I_OnCheckInvite,OnCheckInvite(user, Ptr));
327 if (!user->IsInvited(Ptr->name))
329 user->WriteNumeric(473, "%s %s :Cannot join channel (Invite only)",user->nick, Ptr->name);
333 user->RemoveInvite(Ptr->name);
338 FOREACH_RESULT_I(Instance,I_OnCheckLimit,OnCheckLimit(user, Ptr));
341 if (Ptr->GetUserCounter() >= Ptr->limit)
343 user->WriteNumeric(471, "%s %s :Cannot join channel (Channel is full)",user->nick, Ptr->name);
348 if (Ptr->bans.size())
350 if (Ptr->IsBanned(user))
352 user->WriteNumeric(474, "%s %s :Cannot join channel (You're banned)",user->nick, Ptr->name);
360 /* As spotted by jilles, dont bother to set this on remote users */
361 if (IS_LOCAL(user) && Ptr->GetUserCounter() == 0)
362 Ptr->SetDefaultModes();
364 return Channel::ForceChan(Instance, Ptr, user, privs, bursting);
367 Channel* Channel::ForceChan(InspIRCd* Instance, Channel* Ptr, User* user, const std::string &privs, bool bursting)
369 std::string nick = user->nick;
374 /* Just in case they have no permissions */
375 user->chans[Ptr] = 0;
377 for (std::string::const_iterator x = privs.begin(); x != privs.end(); x++)
379 const char status = *x;
380 ModeHandler* mh = Instance->Modes->FindPrefix(status);
383 /* Set, and make sure that the mode handler knows this mode was now set */
384 Ptr->SetPrefix(user, status, mh->GetPrefixRank(), true);
385 mh->OnModeChange(Instance->FakeClient, Instance->FakeClient, Ptr, nick, true);
387 switch (mh->GetPrefix())
389 /* These logic ops are SAFE IN THIS CASE because if the entry doesnt exist,
390 * addressing operator[] creates it. If they do exist, it points to it.
391 * At all other times where we dont want to create an item if it doesnt exist, we
392 * must stick to ::find().
395 user->chans[Ptr] |= UCMODE_OP;
398 user->chans[Ptr] |= UCMODE_HOP;
401 user->chans[Ptr] |= UCMODE_VOICE;
407 FOREACH_MOD_I(Instance,I_OnUserJoin,OnUserJoin(user, Ptr, bursting, silent));
410 Ptr->WriteChannel(user,"JOIN :%s",Ptr->name);
412 /* Theyre not the first ones in here, make sure everyone else sees the modes we gave the user */
413 std::string ms = Instance->Modes->ModeString(user, Ptr);
414 if ((Ptr->GetUserCounter() > 1) && (ms.length()))
415 Ptr->WriteAllExceptSender(user, true, 0, "MODE %s +%s", Ptr->name, ms.c_str());
417 /* Major improvement by Brain - we dont need to be calculating all this pointlessly for remote users */
422 user->WriteNumeric(332, "%s %s :%s", user->nick, Ptr->name, Ptr->topic);
423 user->WriteNumeric(333, "%s %s %s %lu", user->nick, Ptr->name, Ptr->setby, (unsigned long)Ptr->topicset);
427 FOREACH_MOD_I(Instance,I_OnPostJoin,OnPostJoin(user, Ptr));
431 bool Channel::IsBanned(User* user)
435 FOREACH_RESULT(I_OnCheckBan,OnCheckBan(user, this));
437 if (MOD_RESULT == -1)
439 else if (MOD_RESULT == 0)
441 snprintf(mask, MAXBUF, "%s!%s@%s", user->nick, user->ident, user->GetIPString());
442 for (BanList::iterator i = this->bans.begin(); i != this->bans.end(); i++)
444 /* This allows CIDR ban matching
446 * Full masked host Full unmasked host IP with/without CIDR
448 if ((match(user->GetFullHost(),i->data)) || (match(user->GetFullRealHost(),i->data)) || (match(mask, i->data, true)))
457 bool Channel::IsExtBanned(User *user, char type)
459 // XXX. do we need events?
463 snprintf(mask, MAXBUF, "%s!%s@%s", user->nick, user->ident, user->GetIPString());
465 for (BanList::iterator i = this->bans.begin(); i != this->bans.end(); i++)
467 if (i->data[0] != type || i->data[1] != ':')
470 // Iterate past char and : to get to the mask without doing a data copy(!)
472 maskptr++; // past the char
473 maskptr++; // past the :
475 /* This allows CIDR ban matching
477 * Full masked host Full unmasked host IP with/without CIDR
479 if ((match(user->GetFullHost(), maskptr)) || (match(user->GetFullRealHost(), maskptr)) || (match(mask, maskptr, true)))
489 * remove a channel from a users record, and return the number of users left.
490 * Therefore, if this function returns 0 the caller should delete the Channel.
492 long Channel::PartUser(User *user, const char* reason)
497 return this->GetUserCounter();
499 UCListIter i = user->chans.find(this);
500 if (i != user->chans.end())
502 FOREACH_MOD(I_OnUserPart,OnUserPart(user, this, reason ? reason : "", silent));
505 this->WriteChannel(user, "PART %s%s%s", this->name, reason ? " :" : "", reason ? reason : "");
507 user->chans.erase(i);
508 this->RemoveAllPrefixes(user);
511 if (!this->DelUser(user)) /* if there are no users left on the channel... */
513 chan_hash::iterator iter = ServerInstance->chanlist->find(this->name);
514 /* kill the record */
515 if (iter != ServerInstance->chanlist->end())
518 FOREACH_RESULT_I(ServerInstance,I_OnChannelPreDelete, OnChannelPreDelete(this));
520 return 1; // delete halted by module
521 FOREACH_MOD(I_OnChannelDelete, OnChannelDelete(this));
522 ServerInstance->chanlist->erase(iter);
527 return this->GetUserCounter();
530 long Channel::ServerKickUser(User* user, const char* reason, bool triggerevents, const char* servername)
534 if (!user || !reason)
535 return this->GetUserCounter();
539 if (!this->HasUser(user))
542 return this->GetUserCounter();
546 if (servername == NULL || *ServerInstance->Config->HideWhoisServer)
547 servername = ServerInstance->Config->ServerName;
551 FOREACH_MOD(I_OnUserKick,OnUserKick(NULL, user, this, reason, silent));
554 UCListIter i = user->chans.find(this);
555 if (i != user->chans.end())
558 this->WriteChannelWithServ(servername, "KICK %s %s :%s", this->name, user->nick, reason);
560 user->chans.erase(i);
561 this->RemoveAllPrefixes(user);
564 if (!this->DelUser(user))
566 chan_hash::iterator iter = ServerInstance->chanlist->find(this->name);
567 /* kill the record */
568 if (iter != ServerInstance->chanlist->end())
571 FOREACH_RESULT_I(ServerInstance,I_OnChannelPreDelete, OnChannelPreDelete(this));
573 return 1; // delete halted by module
574 FOREACH_MOD(I_OnChannelDelete, OnChannelDelete(this));
575 ServerInstance->chanlist->erase(iter);
580 return this->GetUserCounter();
583 long Channel::KickUser(User *src, User *user, const char* reason)
587 if (!src || !user || !reason)
588 return this->GetUserCounter();
592 if (!this->HasUser(user))
594 src->WriteNumeric(441, "%s %s %s :They are not on that channel",src->nick, user->nick, this->name);
595 return this->GetUserCounter();
597 if ((ServerInstance->ULine(user->server)) && (!ServerInstance->ULine(src->server)))
599 src->WriteNumeric(482, "%s %s :Only a u-line may kick a u-line from a channel.",src->nick, this->name);
600 return this->GetUserCounter();
604 if (!ServerInstance->ULine(src->server))
607 FOREACH_RESULT(I_OnUserPreKick,OnUserPreKick(src,user,this,reason));
609 return this->GetUserCounter();
611 /* Set to -1 by OnUserPreKick if explicit allow was set */
612 if (MOD_RESULT != -1)
614 FOREACH_RESULT(I_OnAccessCheck,OnAccessCheck(src,user,this,AC_KICK));
615 if ((MOD_RESULT == ACR_DENY) && (!ServerInstance->ULine(src->server)))
616 return this->GetUserCounter();
618 if ((MOD_RESULT == ACR_DEFAULT) || (!ServerInstance->ULine(src->server)))
620 int them = this->GetStatus(src);
621 int us = this->GetStatus(user);
622 if ((them < STATUS_HOP) || (them < us))
624 src->WriteNumeric(482, "%s %s :You must be a channel %soperator",src->nick, this->name, them == STATUS_HOP ? "" : "half-");
625 return this->GetUserCounter();
631 FOREACH_MOD(I_OnUserKick,OnUserKick(src, user, this, reason, silent));
633 UCListIter i = user->chans.find(this);
634 if (i != user->chans.end())
636 /* zap it from the channel list of the user */
638 this->WriteChannel(src, "KICK %s %s :%s", this->name, user->nick, reason);
640 user->chans.erase(i);
641 this->RemoveAllPrefixes(user);
644 if (!this->DelUser(user))
645 /* if there are no users left on the channel */
647 chan_hash::iterator iter = ServerInstance->chanlist->find(this->name);
649 /* kill the record */
650 if (iter != ServerInstance->chanlist->end())
653 FOREACH_RESULT_I(ServerInstance,I_OnChannelPreDelete, OnChannelPreDelete(this));
655 return 1; // delete halted by module
656 FOREACH_MOD(I_OnChannelDelete, OnChannelDelete(this));
657 ServerInstance->chanlist->erase(iter);
662 return this->GetUserCounter();
665 void Channel::WriteChannel(User* user, const char* text, ...)
667 char textbuffer[MAXBUF];
673 va_start(argsPtr, text);
674 vsnprintf(textbuffer, MAXBUF, text, argsPtr);
677 this->WriteChannel(user, std::string(textbuffer));
680 void Channel::WriteChannel(User* user, const std::string &text)
682 CUList *ulist = this->GetUsers();
688 snprintf(tb,MAXBUF,":%s %s",user->GetFullHost(),text.c_str());
689 std::string out = tb;
691 for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
693 if (IS_LOCAL(i->first))
694 i->first->Write(out);
698 void Channel::WriteChannelWithServ(const char* ServName, const char* text, ...)
700 char textbuffer[MAXBUF];
706 va_start(argsPtr, text);
707 vsnprintf(textbuffer, MAXBUF, text, argsPtr);
710 this->WriteChannelWithServ(ServName, std::string(textbuffer));
713 void Channel::WriteChannelWithServ(const char* ServName, const std::string &text)
715 CUList *ulist = this->GetUsers();
718 snprintf(tb,MAXBUF,":%s %s",ServName ? ServName : ServerInstance->Config->ServerName, text.c_str());
719 std::string out = tb;
721 for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
723 if (IS_LOCAL(i->first))
724 i->first->Write(out);
728 /* write formatted text from a source user to all users on a channel except
729 * for the sender (for privmsg etc) */
730 void Channel::WriteAllExceptSender(User* user, bool serversource, char status, const char* text, ...)
732 char textbuffer[MAXBUF];
738 va_start(argsPtr, text);
739 vsnprintf(textbuffer, MAXBUF, text, argsPtr);
742 this->WriteAllExceptSender(user, serversource, status, std::string(textbuffer));
745 void Channel::WriteAllExcept(User* user, bool serversource, char status, CUList &except_list, const char* text, ...)
747 char textbuffer[MAXBUF];
753 va_start(argsPtr, text);
754 vsnprintf(textbuffer, MAXBUF, text, argsPtr);
757 this->WriteAllExcept(user, serversource, status, except_list, std::string(textbuffer));
760 void Channel::WriteAllExcept(User* user, bool serversource, char status, CUList &except_list, const std::string &text)
762 CUList *ulist = this->GetUsers();
765 snprintf(tb,MAXBUF,":%s %s",user->GetFullHost(),text.c_str());
766 std::string out = tb;
768 for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
770 if ((IS_LOCAL(i->first)) && (except_list.find(i->first) == except_list.end()))
772 /* User doesnt have the status we're after */
773 if (status && !strchr(this->GetAllPrefixChars(i->first), status))
777 i->first->WriteServ(text);
779 i->first->Write(out);
784 void Channel::WriteAllExceptSender(User* user, bool serversource, char status, const std::string& text)
787 except_list[user] = user->nick;
788 this->WriteAllExcept(user, serversource, status, except_list, std::string(text));
792 * return a count of the users on a specific channel accounting for
793 * invisible users who won't increase the count. e.g. for /LIST
795 int Channel::CountInvisible()
798 CUList *ulist= this->GetUsers();
799 for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
801 if (!(i->first->IsModeSet('i')))
808 char* Channel::ChanModes(bool showkey)
810 static char scratch[MAXBUF];
811 static char sparam[MAXBUF];
812 char* offset = scratch;
813 std::string extparam;
818 /* This was still iterating up to 190, Channel::modes is only 64 elements -- Om */
819 for(int n = 0; n < 64; n++)
828 extparam = (showkey ? this->key : "<key>");
831 extparam = ConvToStr(this->limit);
839 /* We know these have no parameters */
842 extparam = this->GetModeParameter(n + 65);
845 if (!extparam.empty())
847 charlcat(sparam,' ',MAXBUF);
848 strlcat(sparam,extparam.c_str(),MAXBUF);
853 /* Null terminate scratch */
855 strlcat(scratch,sparam,MAXBUF);
859 /* compile a userlist of a channel into a string, each nick seperated by
860 * spaces and op, voice etc status shown as @ and +, and send it to 'user'
862 void Channel::UserList(User *user, CUList *ulist)
867 bool call_modules = true;
872 FOREACH_RESULT(I_OnUserList,OnUserList(user, this, ulist));
874 call_modules = false;
876 if (MOD_RESULT != -1)
878 if ((this->IsModeSet('s')) && (!this->HasUser(user)))
880 user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick, this->name);
885 dlen = curlen = snprintf(list,MAXBUF,"%s %c %s :", user->nick, this->IsModeSet('s') ? '@' : this->IsModeSet('p') ? '*' : '=', this->name);
888 char* ptr = list + dlen;
891 ulist = this->GetUsers();
893 /* Improvement by Brain - this doesnt change in value, so why was it inside
896 bool has_user = this->HasUser(user);
898 for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
900 if ((!has_user) && (i->first->IsModeSet('i')))
903 * user is +i, and source not on the channel, does not show
909 if (i->first->Visibility && !i->first->Visibility->VisibleTo(user))
912 std::string prefixlist = this->GetPrefixChar(i->first);
913 std::string nick = i->first->nick;
917 FOREACH_MOD(I_OnNamesListItem, OnNamesListItem(user, i->first, this, prefixlist, nick));
919 /* Nick was nuked, a module wants us to skip it */
926 if (curlen > (480-NICKMAX))
928 /* list overflowed into multiple numerics */
929 user->WriteServ(std::string(list));
931 /* reset our lengths */
932 dlen = curlen = snprintf(list,MAXBUF,"%s %c %s :", user->nick, this->IsModeSet('s') ? '@' : this->IsModeSet('p') ? '*' : '=', this->name);
939 ptrlen = snprintf(ptr, MAXBUF, "%s%s ", prefixlist.c_str(), nick.c_str());
947 /* if whats left in the list isnt empty, send it */
950 user->WriteNumeric(353,std::string(list));
953 user->WriteNumeric(366, "%s %s :End of /NAMES list.", user->nick, this->name);
956 long Channel::GetMaxBans()
958 /* Return the cached value if there is one */
960 return this->maxbans;
962 /* If there isnt one, we have to do some O(n) hax to find it the first time. (ick) */
963 for (std::map<std::string,int>::iterator n = ServerInstance->Config->maxbans.begin(); n != ServerInstance->Config->maxbans.end(); n++)
965 if (match(this->name,n->first.c_str()))
967 this->maxbans = n->second;
972 /* Screw it, just return the default of 64 */
974 return this->maxbans;
977 void Channel::ResetMaxBans()
982 /* returns the status character for a given user on a channel, e.g. @ for op,
983 * % for halfop etc. If the user has several modes set, the highest mode
984 * the user has must be returned.
986 const char* Channel::GetPrefixChar(User *user)
988 static char pf[2] = {0, 0};
990 prefixlist::iterator n = prefixes.find(user);
991 if (n != prefixes.end())
993 if (n->second.size())
995 /* If the user has any prefixes, their highest prefix
996 * will always be at the head of the list, as the list is
997 * sorted in rank order highest first (see SetPrefix()
1000 *pf = n->second.begin()->first;
1010 const char* Channel::GetAllPrefixChars(User* user)
1012 static char prefix[MAXBUF];
1016 prefixlist::iterator n = prefixes.find(user);
1017 if (n != prefixes.end())
1019 for (std::vector<prefixtype>::iterator x = n->second.begin(); x != n->second.end(); x++)
1021 prefix[ctr++] = x->first;
1030 unsigned int Channel::GetPrefixValue(User* user)
1032 prefixlist::iterator n = prefixes.find(user);
1033 if (n != prefixes.end())
1035 if (n->second.size())
1036 return n->second.begin()->second;
1041 int Channel::GetStatusFlags(User *user)
1043 UCListIter i = user->chans.find(this);
1044 if (i != user->chans.end())
1051 int Channel::GetStatus(User *user)
1053 if (ServerInstance->ULine(user->server))
1056 UCListIter i = user->chans.find(this);
1057 if (i != user->chans.end())
1059 if ((i->second & UCMODE_OP) > 0)
1063 if ((i->second & UCMODE_HOP) > 0)
1067 if ((i->second & UCMODE_VOICE) > 0)
1069 return STATUS_VOICE;
1071 return STATUS_NORMAL;
1073 return STATUS_NORMAL;
1076 void Channel::SetPrefix(User* user, char prefix, unsigned int prefix_value, bool adding)
1078 prefixlist::iterator n = prefixes.find(user);
1079 prefixtype pfx = std::make_pair(prefix,prefix_value);
1082 if (n != prefixes.end())
1084 if (std::find(n->second.begin(), n->second.end(), pfx) == n->second.end())
1086 n->second.push_back(pfx);
1087 /* We must keep prefixes in rank order, largest first.
1088 * This is for two reasons, firstly because x-chat *ass-u-me's* this
1089 * state, and secondly it turns out to be a benefit to us later.
1090 * See above in GetPrefix().
1092 std::sort(n->second.begin(), n->second.end(), ModeParser::PrefixComparison);
1099 prefixes.insert(std::make_pair<User*,pfxcontainer>(user, one));
1104 if (n != prefixes.end())
1106 pfxcontainer::iterator x = std::find(n->second.begin(), n->second.end(), pfx);
1107 if (x != n->second.end())
1113 void Channel::RemoveAllPrefixes(User* user)
1115 prefixlist::iterator n = prefixes.find(user);
1116 if (n != prefixes.end())