summaryrefslogtreecommitdiff
path: root/docs/man/man3/chanrec.3
diff options
context:
space:
mode:
Diffstat (limited to 'docs/man/man3/chanrec.3')
-rw-r--r--docs/man/man3/chanrec.3306
1 files changed, 214 insertions, 92 deletions
diff --git a/docs/man/man3/chanrec.3 b/docs/man/man3/chanrec.3
index 5c9d0d9c4..80b5db18d 100644
--- a/docs/man/man3/chanrec.3
+++ b/docs/man/man3/chanrec.3
@@ -1,4 +1,4 @@
-.TH "chanrec" 3 "20 Apr 2005" "InspIRCd" \" -*- nroff -*-
+.TH "chanrec" 3 "26 Apr 2005" "InspIRCd" \" -*- nroff -*-
.ad l
.nh
.SH NAME
@@ -32,6 +32,30 @@ Inherits \fBExtensible\fP.
.br
.RI "\fIReturns the parameter for a custom mode on a channel. \fP"
.ti -1c
+.RI "void \fBIncUserCounter\fP ()"
+.br
+.RI "\fIIncrement the channel 'user counter' The channel user counter is a reference counter which holds the number of users on the channel. \fP"
+.ti -1c
+.RI "void \fBDecUserCounter\fP ()"
+.br
+.RI "\fIDecrement the channel 'user counter' The channel user counter is a reference counter which holds the number of users on the channel. \fP"
+.ti -1c
+.RI "long \fBGetUserCounter\fP ()"
+.br
+.RI "\fIObtain the channel 'user counter' This returns the channel reference counter, which is initialized to 0 when the channel is created and incremented/decremented upon joins, parts quits and kicks. \fP"
+.ti -1c
+.RI "void \fBAddUser\fP (char *castuser)"
+.br
+.RI "\fIAdd a user pointer to the internal reference list The data inserted into the reference list is a table as it is an arbitary pointer compared to other users by its memory address, as this is a very fast 32 or 64 bit integer comparison. \fP"
+.ti -1c
+.RI "void \fBDelUser\fP (char *castuser)"
+.br
+.RI "\fIDelete a user pointer to the internal reference list The data removed from the reference list is a table as it is an arbitary pointer compared to other users by its memory address, as this is a very fast 32 or 64 bit integer comparison. \fP"
+.ti -1c
+.RI "std::vector< char * > * \fBGetUsers\fP ()"
+.br
+.RI "\fIObrain the internal reference list The internal reference list contains a list of userrec* cast to char*. \fP"
+.ti -1c
.RI "\fBchanrec\fP ()"
.br
.RI "\fICreates a channel record and initialises it with default values. \fP"
@@ -51,6 +75,14 @@ Inherits \fBExtensible\fP.
.br
.RI "\fICustom modes for the channel. \fP"
.ti -1c
+.RI "long \fBusers\fP"
+.br
+.RI "\fICount of users on the channel used for fast user counting. \fP"
+.ti -1c
+.RI "std::vector< char * > \fBinternal_userlist\fP"
+.br
+.RI "\fIUser list (casted to char*'s to stop forward declaration stuff) (chicken and egg scenario!). \fP"
+.ti -1c
.RI "char \fBtopic\fP [MAXBUF]"
.br
.RI "\fIChannel topic. \fP"
@@ -116,7 +148,7 @@ Definition at line 94 of file channels.h.
.PP
Creates a channel record and initialises it with default values. Definition at line 113 of file channels.cpp.
.PP
-References c_private, created, custom_modes, inviteonly, key, limit, moderated, name, noexternal, secret, setby, topic, topiclock, and topicset.
+References c_private, created, custom_modes, internal_userlist, inviteonly, key, limit, moderated, name, noexternal, secret, setby, topic, topiclock, topicset, and users.
.PP
.nf
114 {
@@ -125,134 +157,214 @@ References c_private, created, custom_modes, inviteonly, key, limit, moderated,
117 strcpy(topic,'');
118 strcpy(setby,'');
119 strcpy(key,'');
-120 created = topicset = limit = 0;
+120 created = topicset = limit = users = 0;
121 topiclock = noexternal = inviteonly = moderated = secret = c_private = false;
-122 }
+122 internal_userlist.clear();
+123 }
.fi
.SS "virtual chanrec::~\fBchanrec\fP ()\fC [inline, virtual]\fP"
.PP
-Definition at line 185 of file channels.h.
+Definition at line 240 of file channels.h.
.PP
.nf
-185 { /* stub */ }
+240 { /* stub */ }
.fi
.SH "Member Function Documentation"
.PP
+.SS "void chanrec::AddUser (char * castuser)"
+.PP
+Add a user pointer to the internal reference list The data inserted into the reference list is a table as it is an arbitary pointer compared to other users by its memory address, as this is a very fast 32 or 64 bit integer comparison. Definition at line 220 of file channels.cpp.
+.PP
+References DEBUG, and internal_userlist.
+.PP
+.nf
+221 {
+222 internal_userlist.push_back(castuser);
+223 log(DEBUG,'Added casted user to channel's internal list');
+224 }
+.fi
+.SS "void chanrec::DecUserCounter ()"
+.PP
+Decrement the channel 'user counter' The channel user counter is a reference counter which holds the number of users on the channel. If it decremented to 0 then the channel is removed from the system. Modules may alter the reference count to hold channels open which have no users and would normally be deleted once empty.Definition at line 208 of file channels.cpp.
+.PP
+References DEBUG, name, and users.
+.PP
+.nf
+209 {
+210 if (this->users > 0)
+211 this->users--;
+212 log(DEBUG,'Decremented channel user count for %s to %lu',name,(unsigned long)users);
+213 }
+.fi
+.SS "void chanrec::DelUser (char * castuser)"
+.PP
+Delete a user pointer to the internal reference list The data removed from the reference list is a table as it is an arbitary pointer compared to other users by its memory address, as this is a very fast 32 or 64 bit integer comparison. Definition at line 226 of file channels.cpp.
+.PP
+References DEBUG, internal_userlist, and name.
+.PP
+.nf
+227 {
+228 for (std::vector<char*>::iterator a = internal_userlist.begin(); a < internal_userlist.end(); a++)
+229 {
+230 if (*a == castuser)
+231 {
+232 log(DEBUG,'Removed casted user from channel's internal list');
+233 internal_userlist.erase(a);
+234 return;
+235 }
+236 }
+237 log(DEBUG,'BUG BUG BUG! Attempt to remove an uncasted user from the internal list of %s!',name);
+238 }
+.fi
.SS "std::string chanrec::GetModeParameter (char mode)"
.PP
-Returns the parameter for a custom mode on a channel. For example if '+L #foo' is set, and you pass this method 'L', it will return '#foo'. If the mode is not set on the channel, or the mode has no parameters associated with it, it will return an empty string.Definition at line 186 of file channels.cpp.
+Returns the parameter for a custom mode on a channel. For example if '+L #foo' is set, and you pass this method 'L', it will return '#foo'. If the mode is not set on the channel, or the mode has no parameters associated with it, it will return an empty string.Definition at line 187 of file channels.cpp.
.PP
References custom_mode_params.
.PP
.nf
-187 {
-188 if (custom_mode_params.size())
-189 {
-190 for (vector<ModeParameter>::iterator i = custom_mode_params.begin(); i < custom_mode_params.end(); i++)
-191 {
-192 if ((i->mode == mode) && (!strcasecmp(this->name,i->channel)))
-193 {
-194 return std::string(i->parameter);
-195 }
-196 }
-197 }
-198 return std::string('');
-199 }
+188 {
+189 if (custom_mode_params.size())
+190 {
+191 for (vector<ModeParameter>::iterator i = custom_mode_params.begin(); i < custom_mode_params.end(); i++)
+192 {
+193 if ((i->mode == mode) && (!strcasecmp(this->name,i->channel)))
+194 {
+195 return std::string(i->parameter);
+196 }
+197 }
+198 }
+199 return std::string('');
+200 }
+.fi
+.SS "long chanrec::GetUserCounter ()"
+.PP
+Obtain the channel 'user counter' This returns the channel reference counter, which is initialized to 0 when the channel is created and incremented/decremented upon joins, parts quits and kicks. Definition at line 215 of file channels.cpp.
+.PP
+References users.
+.PP
+.nf
+216 {
+217 return (this->users);
+218 }
+.fi
+.SS "std::vector< char * > * chanrec::GetUsers ()"
+.PP
+Obrain the internal reference list The internal reference list contains a list of userrec* cast to char*. These are used for rapid comparison to determine channel membership for PRIVMSG, NOTICE, QUIT, PART etc. The resulting pointer to the vector should be considered readonly and only modified via AddUser and DelUser.Definition at line 240 of file channels.cpp.
+.PP
+References internal_userlist.
+.PP
+.nf
+241 {
+242 return &internal_userlist;
+243 }
+.fi
+.SS "void chanrec::IncUserCounter ()"
+.PP
+Increment the channel 'user counter' The channel user counter is a reference counter which holds the number of users on the channel. If it decremented to 0 then the channel is removed from the system.Definition at line 202 of file channels.cpp.
+.PP
+References DEBUG, name, and users.
+.PP
+.nf
+203 {
+204 this->users++;
+205 log(DEBUG,'Incremented channel user count for %s to %lu',name,(unsigned long)users);
+206 }
.fi
.SS "bool chanrec::IsCustomModeSet (char mode)"
.PP
-Returns true if a custom mode is set on a channel. Definition at line 180 of file channels.cpp.
+Returns true if a custom mode is set on a channel. Definition at line 181 of file channels.cpp.
.PP
References DEBUG.
.PP
.nf
-181 {
-182 log(DEBUG,'Checking ISCustomModeSet: %c %s',mode,this->custom_modes);
-183 return (strchr(this->custom_modes,mode) != 0);
-184 }
+182 {
+183 log(DEBUG,'Checking ISCustomModeSet: %c %s',mode,this->custom_modes);
+184 return (strchr(this->custom_modes,mode) != 0);
+185 }
.fi
.SS "void chanrec::SetCustomMode (char mode, bool mode_on)"
.PP
-Sets or unsets a custom mode in the channels info. Definition at line 124 of file channels.cpp.
+Sets or unsets a custom mode in the channels info. Definition at line 125 of file channels.cpp.
.PP
References custom_modes, DEBUG, and SetCustomModeParam().
.PP
.nf
-125 {
-126 if (mode_on) {
-127 char m[3];
-128 m[0] = mode;
-129 m[1] = '\0';
-130 if (!strchr(this->custom_modes,mode))
-131 {
-132 strlcat(custom_modes,m,MAXMODES);
-133 }
-134 log(DEBUG,'Custom mode %c set',mode);
-135 }
-136 else {
-137
-138 std::string a = this->custom_modes;
-139 int pos = a.find(mode);
-140 a.erase(pos,1);
-141 strncpy(this->custom_modes,a.c_str(),MAXMODES);
-142
-143 log(DEBUG,'Custom mode %c removed: modelist='%s'',mode,this->custom_modes);
-144 this->SetCustomModeParam(mode,'',false);
-145 }
-146 }
+126 {
+127 if (mode_on) {
+128 char m[3];
+129 m[0] = mode;
+130 m[1] = '\0';
+131 if (!strchr(this->custom_modes,mode))
+132 {
+133 strlcat(custom_modes,m,MAXMODES);
+134 }
+135 log(DEBUG,'Custom mode %c set',mode);
+136 }
+137 else {
+138
+139 std::string a = this->custom_modes;
+140 int pos = a.find(mode);
+141 a.erase(pos,1);
+142 strncpy(this->custom_modes,a.c_str(),MAXMODES);
+143
+144 log(DEBUG,'Custom mode %c removed: modelist='%s'',mode,this->custom_modes);
+145 this->SetCustomModeParam(mode,'',false);
+146 }
+147 }
.fi
.SS "void chanrec::SetCustomModeParam (char mode, char * parameter, bool mode_on)"
.PP
-Sets or unsets the parameters for a custom mode in a channels info. Definition at line 149 of file channels.cpp.
+Sets or unsets the parameters for a custom mode in a channels info. Definition at line 150 of file channels.cpp.
.PP
References ModeParameter::channel, custom_mode_params, DEBUG, ModeParameter::mode, and ModeParameter::parameter.
.PP
Referenced by SetCustomMode().
.PP
.nf
-150 {
-151
-152 log(DEBUG,'SetCustomModeParam called');
-153 ModeParameter M;
-154 M.mode = mode;
-155 strlcpy(M.channel,this->name,CHANMAX);
-156 strlcpy(M.parameter,parameter,MAXBUF);
-157 if (mode_on)
-158 {
-159 log(DEBUG,'Custom mode parameter %c %s added',mode,parameter);
-160 custom_mode_params.push_back(M);
-161 }
-162 else
-163 {
-164 if (custom_mode_params.size())
-165 {
-166 for (vector<ModeParameter>::iterator i = custom_mode_params.begin(); i < custom_mode_params.end(); i++)
-167 {
-168 if ((i->mode == mode) && (!strcasecmp(this->name,i->channel)))
-169 {
-170 log(DEBUG,'Custom mode parameter %c %s removed',mode,parameter);
-171 custom_mode_params.erase(i);
-172 return;
-173 }
-174 }
-175 }
-176 log(DEBUG,'*** BUG *** Attempt to remove non-existent mode parameter!');
-177 }
-178 }
+151 {
+152
+153 log(DEBUG,'SetCustomModeParam called');
+154 ModeParameter M;
+155 M.mode = mode;
+156 strlcpy(M.channel,this->name,CHANMAX);
+157 strlcpy(M.parameter,parameter,MAXBUF);
+158 if (mode_on)
+159 {
+160 log(DEBUG,'Custom mode parameter %c %s added',mode,parameter);
+161 custom_mode_params.push_back(M);
+162 }
+163 else
+164 {
+165 if (custom_mode_params.size())
+166 {
+167 for (vector<ModeParameter>::iterator i = custom_mode_params.begin(); i < custom_mode_params.end(); i++)
+168 {
+169 if ((i->mode == mode) && (!strcasecmp(this->name,i->channel)))
+170 {
+171 log(DEBUG,'Custom mode parameter %c %s removed',mode,parameter);
+172 custom_mode_params.erase(i);
+173 return;
+174 }
+175 }
+176 }
+177 log(DEBUG,'*** BUG *** Attempt to remove non-existent mode parameter!');
+178 }
+179 }
.fi
.SH "Member Data Documentation"
.PP
.SS "\fBBanList\fP \fBchanrec::bans\fP"
.PP
-The list of all bans set on the channel. Definition at line 159 of file channels.h.
+The list of all bans set on the channel. Definition at line 168 of file channels.h.
.SS "short int \fBchanrec::c_private\fP"
.PP
-Nonzero if the mode +p is set. This value cannot be set at the same time as \fBchanrec::secret\fPDefinition at line 155 of file channels.h.
+Nonzero if the mode +p is set. This value cannot be set at the same time as \fBchanrec::secret\fPDefinition at line 164 of file channels.h.
.PP
Referenced by chanrec().
.SS "time_t \fBchanrec::created\fP"
.PP
-Creation time. Definition at line 111 of file channels.h.
+Creation time. Definition at line 120 of file channels.h.
.PP
Referenced by chanrec().
.SS "char \fBchanrec::custom_modes\fP[MAXMODES]"
@@ -260,61 +372,71 @@ Referenced by chanrec().
Custom modes for the channel. Plugins may use this field in any way they see fit.Definition at line 103 of file channels.h.
.PP
Referenced by chanrec(), and SetCustomMode().
+.SS "std::vector<char*> \fBchanrec::internal_userlist\fP"
+.PP
+User list (casted to char*'s to stop forward declaration stuff) (chicken and egg scenario!). Definition at line 112 of file channels.h.
+.PP
+Referenced by AddUser(), chanrec(), DelUser(), and GetUsers().
.SS "short int \fBchanrec::inviteonly\fP"
.PP
-Nonzero if the mode +i is set. Definition at line 141 of file channels.h.
+Nonzero if the mode +i is set. Definition at line 150 of file channels.h.
.PP
Referenced by chanrec().
.SS "char \fBchanrec::key\fP[32]"
.PP
-Contains the channel key. If this value is an empty string, there is no channel key in place.Definition at line 129 of file channels.h.
+Contains the channel key. If this value is an empty string, there is no channel key in place.Definition at line 138 of file channels.h.
.PP
Referenced by chanrec().
.SS "long \fBchanrec::limit\fP"
.PP
-Contains the channel user limit. If this value is zero, there is no limit in place.Definition at line 124 of file channels.h.
+Contains the channel user limit. If this value is zero, there is no limit in place.Definition at line 133 of file channels.h.
.PP
Referenced by chanrec().
.SS "short int \fBchanrec::moderated\fP"
.PP
-Nonzero if the mode +m is set. Definition at line 145 of file channels.h.
+Nonzero if the mode +m is set. Definition at line 154 of file channels.h.
.PP
Referenced by chanrec().
.SS "char \fBchanrec::name\fP[CHANMAX]"
.PP
The channels name. Definition at line 99 of file channels.h.
.PP
-Referenced by chanrec(), and Server::PseudoToUser().
+Referenced by chanrec(), DecUserCounter(), DelUser(), IncUserCounter(), and Server::PseudoToUser().
.SS "short int \fBchanrec::noexternal\fP"
.PP
-Nonzero if the mode +n is set. Definition at line 137 of file channels.h.
+Nonzero if the mode +n is set. Definition at line 146 of file channels.h.
.PP
Referenced by chanrec().
.SS "short int \fBchanrec::secret\fP"
.PP
-Nonzero if the mode +s is set. This value cannot be set at the same time as \fBchanrec::c_private\fPDefinition at line 150 of file channels.h.
+Nonzero if the mode +s is set. This value cannot be set at the same time as \fBchanrec::c_private\fPDefinition at line 159 of file channels.h.
.PP
Referenced by chanrec().
.SS "char \fBchanrec::setby\fP[NICKMAX]"
.PP
-The last user to set the topic. If this member is an empty string, no topic was ever set.Definition at line 119 of file channels.h.
+The last user to set the topic. If this member is an empty string, no topic was ever set.Definition at line 128 of file channels.h.
.PP
Referenced by chanrec(), and Server::PseudoToUser().
.SS "char \fBchanrec::topic\fP[MAXBUF]"
.PP
-Channel topic. If this is an empty string, no channel topic is set.Definition at line 108 of file channels.h.
+Channel topic. If this is an empty string, no channel topic is set.Definition at line 117 of file channels.h.
.PP
Referenced by chanrec(), and Server::PseudoToUser().
.SS "short int \fBchanrec::topiclock\fP"
.PP
-Nonzero if the mode +t is set. Definition at line 133 of file channels.h.
+Nonzero if the mode +t is set. Definition at line 142 of file channels.h.
.PP
Referenced by chanrec().
.SS "time_t \fBchanrec::topicset\fP"
.PP
-Time topic was set. If no topic was ever set, this will be equal to \fBchanrec::created\fPDefinition at line 115 of file channels.h.
+Time topic was set. If no topic was ever set, this will be equal to \fBchanrec::created\fPDefinition at line 124 of file channels.h.
.PP
Referenced by chanrec(), and Server::PseudoToUser().
+.SS "long \fBchanrec::users\fP"
+.PP
+Count of users on the channel used for fast user counting. Definition at line 107 of file channels.h.
+.PP
+Referenced by chanrec(), DecUserCounter(), GetUserCounter(), and IncUserCounter().
.SH "Author"
.PP