+ std::map<char,char*>::iterator n = custom_mode_params.find(mode);
+ if (n != custom_mode_params.end())
+ {
+ return n->second;
+ }
+ return "";
+}
+
+long chanrec::GetUserCounter()
+{
+ return (this->internal_userlist.size());
+}
+
+void chanrec::AddUser(userrec* user)
+{
+ internal_userlist[user] = user;
+}
+
+unsigned long chanrec::DelUser(userrec* user)
+{
+ CUList::iterator a = internal_userlist.find(user);
+ if (a != internal_userlist.end())
+ {
+ internal_userlist.erase(a);
+ /* And tidy any others... */
+ DelOppedUser(user);
+ DelHalfoppedUser(user);
+ DelVoicedUser(user);
+ return internal_userlist.size();
+ }
+ return internal_userlist.size();
+}
+
+bool chanrec::HasUser(userrec* user)
+{
+ return (internal_userlist.find(user) != internal_userlist.end());
+}
+
+void chanrec::AddOppedUser(userrec* user)
+{
+ internal_op_userlist[user] = user;
+}
+
+void chanrec::DelOppedUser(userrec* user)
+{
+ CUList::iterator a = internal_op_userlist.find(user);
+ if (a != internal_op_userlist.end())
+ {
+ internal_op_userlist.erase(a);
+ return;
+ }
+}
+
+void chanrec::AddHalfoppedUser(userrec* user)
+{
+ internal_halfop_userlist[user] = user;
+}
+
+void chanrec::DelHalfoppedUser(userrec* user)
+{
+ CUList::iterator a = internal_halfop_userlist.find(user);
+ if (a != internal_halfop_userlist.end())
+ {
+ internal_halfop_userlist.erase(a);
+ return;
+ }
+}
+
+void chanrec::AddVoicedUser(userrec* user)
+{
+ internal_voice_userlist[user] = user;
+}
+
+void chanrec::DelVoicedUser(userrec* user)
+{
+ CUList::iterator a = internal_voice_userlist.find(user);
+ if (a != internal_voice_userlist.end())
+ {
+ internal_voice_userlist.erase(a);
+ return;
+ }
+}
+
+CUList* chanrec::GetUsers()
+{
+ return &internal_userlist;
+}
+
+CUList* chanrec::GetOppedUsers()
+{
+ return &internal_op_userlist;
+}
+
+CUList* chanrec::GetHalfoppedUsers()
+{
+ return &internal_halfop_userlist;
+}
+
+CUList* chanrec::GetVoicedUsers()
+{
+ return &internal_voice_userlist;
+}
+
+/*
+ * add a channel to a user, creating the record for it if needed and linking
+ * it to the user record
+ */
+
+chanrec* add_channel(userrec *user, const char* cn, const char* key, bool override)
+{
+ if ((!user) || (!cn))
+ {
+ log(DEFAULT,"*** BUG *** add_channel was given an invalid parameter");
+ return 0;
+ }
+
+ int created = 0;
+ char cname[MAXBUF];
+ int MOD_RESULT = 0;
+ strlcpy(cname,cn,CHANMAX);
+ log(DEBUG,"cname='%s' cn='%s'",cname,cn);
+
+ log(DEBUG,"add_channel: %s %s",user->nick,cname);
+
+ chanrec* Ptr = FindChan(cname);
+
+ if (!Ptr)
+ {
+ if (user->fd > -1)
+ {
+ MOD_RESULT = 0;
+ FOREACH_RESULT(I_OnUserPreJoin,OnUserPreJoin(user,NULL,cname));
+ if (MOD_RESULT == 1)
+ return NULL;
+ }
+
+ /* create a new one */
+ chanlist[cname] = new chanrec();
+ strlcpy(chanlist[cname]->name, cname,CHANMAX);
+ chanlist[cname]->binarymodes = CM_TOPICLOCK | CM_NOEXTERNAL;
+ chanlist[cname]->created = TIME;
+ *chanlist[cname]->topic = 0;
+ strlcpy(chanlist[cname]->setby, user->nick,NICKMAX-1);
+ chanlist[cname]->topicset = 0;
+ Ptr = chanlist[cname];
+ log(DEBUG,"add_channel: created: %s",cname);
+ /*
+ * set created to 2 to indicate user
+ * is the first in the channel
+ * and should be given ops
+ */
+ created = 2;
+ }
+ else