- /* Null terminate scratch */
- *offset = '\0';
- strlcat(scratch,sparam,MAXBUF);
- return scratch;
-}
-
-/* compile a userlist of a channel into a string, each nick seperated by
- * spaces and op, voice etc status shown as @ and +, and send it to 'user'
- */
-void Channel::UserList(User *user)
-{
- if (!IS_LOCAL(user))
- return;
-
- bool has_privs = user->HasPrivPermission("channels/auspex");
-
- if (this->IsModeSet('s') && !this->HasUser(user) && !has_privs)
- {
- user->WriteNumeric(ERR_NOSUCHNICK, "%s %s :No such nick/channel",user->nick.c_str(), this->name.c_str());
- return;
- }
-
- std::string list = user->nick;
- list.push_back(' ');
- list.push_back(this->IsModeSet('s') ? '@' : this->IsModeSet('p') ? '*' : '=');
- list.push_back(' ');
- list.append(this->name).append(" :");
- std::string::size_type pos = list.size();
-
- bool has_one = false;
-
- /* Improvement by Brain - this doesnt change in value, so why was it inside
- * the loop?
- */
- bool has_user = this->HasUser(user);
-
- const size_t maxlen = MAXBUF - 10 - ServerInstance->Config->ServerName.size();
- std::string prefixlist;
- std::string nick;
- for (UserMembIter i = userlist.begin(); i != userlist.end(); ++i)
- {
- if (i->first->quitting)
- continue;
- if ((!has_user) && (i->first->IsModeSet('i')) && (!has_privs))
- {
- /*
- * user is +i, and source not on the channel, does not show
- * nick in NAMES list
- */
- continue;
- }
-
- prefixlist = this->GetPrefixChar(i->first);
- nick = i->first->nick;
-
- FOREACH_MOD(I_OnNamesListItem, OnNamesListItem(user, i->second, prefixlist, nick));
-
- /* Nick was nuked, a module wants us to skip it */
- if (nick.empty())
- continue;
-
- if (list.size() + prefixlist.length() + nick.length() + 1 > maxlen)
- {
- /* list overflowed into multiple numerics */
- user->WriteNumeric(RPL_NAMREPLY, list);
-
- // Erase all nicks, keep the constant part
- list.erase(pos);
- has_one = false;
- }
-
- list.append(prefixlist).append(nick).push_back(' ');
-
- has_one = true;
- }
-
- /* if whats left in the list isnt empty, send it */
- if (has_one)
- {
- user->WriteNumeric(RPL_NAMREPLY, list);
- }
-
- user->WriteNumeric(RPL_ENDOFNAMES, "%s %s :End of /NAMES list.", user->nick.c_str(), this->name.c_str());
-}
-
-long Channel::GetMaxBans()
-{
- /* Return the cached value if there is one */
- if (this->maxbans)
- return this->maxbans;
-
- /* If there isnt one, we have to do some O(n) hax to find it the first time. (ick) */
- for (std::map<std::string,int>::iterator n = ServerInstance->Config->maxbans.begin(); n != ServerInstance->Config->maxbans.end(); n++)
- {
- if (InspIRCd::Match(this->name, n->first, NULL))
- {
- this->maxbans = n->second;
- return n->second;
- }
- }
-
- /* Screw it, just return the default of 64 */
- this->maxbans = 64;
- return this->maxbans;
-}
-
-void Channel::ResetMaxBans()
-{
- this->maxbans = 0;