*/
Channel* FindChan(const std::string &chan);
+ /** Get a hash map containing all channels, keyed by their name
+ * @return A hash map mapping channel names to Channel pointers
+ */
+ chan_hash& GetChans() { return *chanlist; }
+
/** Return true if a channel name is valid
* @param chname A channel name to verify
* @return True if the name is valid
static const char* Format(const char* formatString, ...) CUSTOM_PRINTF(1, 2);
static const char* Format(va_list &vaList, const char* formatString) CUSTOM_PRINTF(2, 0);
- /** Return a count of channels on the network
- * @return The number of channels
- */
- long ChannelCount() const { return chanlist->size(); }
-
/** Send an error notice to all local users, opered and unopered
* @param s The error string to send
*/
}
}
- for (chan_hash::const_iterator i = ServerInstance->chanlist->begin(); i != ServerInstance->chanlist->end(); i++)
+ const chan_hash& chans = ServerInstance->GetChans();
+ for (chan_hash::const_iterator i = chans.begin(); i != chans.end(); ++i)
{
// attempt to match a glob pattern
long users = i->second->GetUserCounter();
if (ServerInstance->Users->UnregisteredUserCount())
user->WriteNumeric(RPL_LUSERUNKNOWN, "%d :unknown connections", ServerInstance->Users->UnregisteredUserCount());
- user->WriteNumeric(RPL_LUSERCHANNELS, "%ld :channels formed", ServerInstance->ChannelCount());
+ user->WriteNumeric(RPL_LUSERCHANNELS, "%lu :channels formed", (unsigned long)ServerInstance->GetChans().size());
user->WriteNumeric(RPL_LUSERME, ":I have %d clients and %d servers", ServerInstance->Users->LocalUserCount(),n_local_servs);
user->WriteNumeric(RPL_LOCALUSERS, ":Current Local Users: %d Max: %d", ServerInstance->Users->LocalUserCount(), counters.max_local);
user->WriteNumeric(RPL_GLOBALUSERS, ":Current Global Users: %d Max: %d", n_users, counters.max_global);
case 'z':
{
results.push_back("249 "+user->nick+" :Users: "+ConvToStr(ServerInstance->Users->clientlist->size()));
- results.push_back("249 "+user->nick+" :Channels: "+ConvToStr(ServerInstance->chanlist->size()));
+ results.push_back("249 "+user->nick+" :Channels: "+ConvToStr(ServerInstance->GetChans().size()));
results.push_back("249 "+user->nick+" :Commands: "+ConvToStr(ServerInstance->Parser->cmdlist.size()));
float kbitpersec_in, kbitpersec_out, kbitpersec_total;
if (oldlimits == chanlimits)
return;
- for (chan_hash::const_iterator i = ServerInstance->chanlist->begin(); i != ServerInstance->chanlist->end(); ++i)
+ const chan_hash& chans = ServerInstance->GetChans();
+ for (chan_hash::const_iterator i = chans.begin(); i != chans.end(); ++i)
{
ChanData* cd = extItem.get(i->second);
if (cd)
}
break;
case MODETYPE_CHANNEL:
- for (chan_hash::iterator i = ServerInstance->chanlist->begin(); i != ServerInstance->chanlist->end(); )
+ {
+ const chan_hash& chans = ServerInstance->GetChans();
+ for (chan_hash::const_iterator i = chans.begin(); i != chans.end(); )
{
// The channel may not be in the hash after RemoveMode(), see m_permchannels
Channel* chan = i->second;
stackresult.erase(stackresult.begin() + 1, stackresult.end());
}
}
+ }
break;
}
std::vector<reference<ExtensionItem> > items;
ServerInstance->Extensions.BeginUnregister(modfind->second, items);
/* Give the module a chance to tidy out all its metadata */
- for (chan_hash::iterator c = ServerInstance->chanlist->begin(); c != ServerInstance->chanlist->end(); )
+ const chan_hash& chans = ServerInstance->GetChans();
+ for (chan_hash::const_iterator c = chans.begin(); c != chans.end(); )
{
Channel* chan = c->second;
++c;
{
badchan = true;
std::vector<Channel*> chanvec;
- for (chan_hash::const_iterator i = ServerInstance->chanlist->begin(); i != ServerInstance->chanlist->end(); ++i)
+ const chan_hash& chans = ServerInstance->GetChans();
+ for (chan_hash::const_iterator i = chans.begin(); i != chans.end(); ++i)
{
if (!ServerInstance->IsChannel(i->second->name))
chanvec.push_back(i->second);
data << "<general>";
data << "<usercount>" << ServerInstance->Users->clientlist->size() << "</usercount>";
- data << "<channelcount>" << ServerInstance->chanlist->size() << "</channelcount>";
+ data << "<channelcount>" << ServerInstance->GetChans().size() << "</channelcount>";
data << "<opercount>" << ServerInstance->Users->all_opers.size() << "</opercount>";
data << "<socketcount>" << (SocketEngine::GetUsedFds()) << "</socketcount><socketmax>" << SocketEngine::GetMaxFds() << "</socketmax><socketengine>" INSPIRCD_SOCKETENGINE_NAME "</socketengine>";
}
data << "</modulelist><channellist>";
- for (chan_hash::const_iterator a = ServerInstance->chanlist->begin(); a != ServerInstance->chanlist->end(); ++a)
+ const chan_hash& chans = ServerInstance->GetChans();
+ for (chan_hash::const_iterator i = chans.begin(); i != chans.end(); ++i)
{
- Channel* c = a->second;
+ Channel* c = i->second;
data << "<channel>";
data << "<usercount>" << c->GetUsers()->size() << "</usercount><channelname>" << Sanitize(c->name) << "</channelname>";
stream << "# This file is automatically generated by m_permchannels. Any changes will be overwritten." << std::endl
<< "<config format=\"xml\">" << std::endl;
- for (chan_hash::const_iterator i = ServerInstance->chanlist->begin(); i != ServerInstance->chanlist->end(); i++)
+ const chan_hash& chans = ServerInstance->GetChans();
+ for (chan_hash::const_iterator i = chans.begin(); i != chans.end(); ++i)
{
Channel* chan = i->second;
if (!chan->IsModeSet(permchanmode))
/* Send users and their oper status */
this->SendUsers(bs);
- for (chan_hash::const_iterator i = ServerInstance->chanlist->begin(); i != ServerInstance->chanlist->end(); ++i)
+ const chan_hash& chans = ServerInstance->GetChans();
+ for (chan_hash::const_iterator i = chans.begin(); i != chans.end(); ++i)
SyncChannel(i->second, bs);
this->SendXLines();