1 .TH "chanrec" 3 "26 Apr 2005" "InspIRCd" \" -*- nroff -*-
5 chanrec \- Holds all relevent information for a channel.
11 \fC#include <channels.h>\fP
13 Inherits \fBExtensible\fP.
15 .SS "Public Member Functions"
19 .RI "void \fBSetCustomMode\fP (char mode, bool mode_on)"
21 .RI "\fISets or unsets a custom mode in the channels info. \fP"
23 .RI "void \fBSetCustomModeParam\fP (char mode, char *parameter, bool mode_on)"
25 .RI "\fISets or unsets the parameters for a custom mode in a channels info. \fP"
27 .RI "bool \fBIsCustomModeSet\fP (char mode)"
29 .RI "\fIReturns true if a custom mode is set on a channel. \fP"
31 .RI "std::string \fBGetModeParameter\fP (char mode)"
33 .RI "\fIReturns the parameter for a custom mode on a channel. \fP"
35 .RI "void \fBIncUserCounter\fP ()"
37 .RI "\fIIncrement the channel 'user counter' The channel user counter is a reference counter which holds the number of users on the channel. \fP"
39 .RI "void \fBDecUserCounter\fP ()"
41 .RI "\fIDecrement the channel 'user counter' The channel user counter is a reference counter which holds the number of users on the channel. \fP"
43 .RI "long \fBGetUserCounter\fP ()"
45 .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"
47 .RI "void \fBAddUser\fP (char *castuser)"
49 .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"
51 .RI "void \fBDelUser\fP (char *castuser)"
53 .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"
55 .RI "std::vector< char * > * \fBGetUsers\fP ()"
57 .RI "\fIObrain the internal reference list The internal reference list contains a list of userrec* cast to char*. \fP"
59 .RI "\fBchanrec\fP ()"
61 .RI "\fICreates a channel record and initialises it with default values. \fP"
63 .RI "virtual \fB~chanrec\fP ()"
66 .SS "Public Attributes"
70 .RI "char \fBname\fP [CHANMAX]"
72 .RI "\fIThe channels name. \fP"
74 .RI "char \fBcustom_modes\fP [MAXMODES]"
76 .RI "\fICustom modes for the channel. \fP"
78 .RI "long \fBusers\fP"
80 .RI "\fICount of users on the channel used for fast user counting. \fP"
82 .RI "std::vector< char * > \fBinternal_userlist\fP"
84 .RI "\fIUser list (casted to char*'s to stop forward declaration stuff) (chicken and egg scenario!). \fP"
86 .RI "char \fBtopic\fP [MAXBUF]"
88 .RI "\fIChannel topic. \fP"
90 .RI "time_t \fBcreated\fP"
92 .RI "\fICreation time. \fP"
94 .RI "time_t \fBtopicset\fP"
96 .RI "\fITime topic was set. \fP"
98 .RI "char \fBsetby\fP [NICKMAX]"
100 .RI "\fIThe last user to set the topic. \fP"
102 .RI "long \fBlimit\fP"
104 .RI "\fIContains the channel user limit. \fP"
106 .RI "char \fBkey\fP [32]"
108 .RI "\fIContains the channel key. \fP"
110 .RI "short int \fBtopiclock\fP"
112 .RI "\fINonzero if the mode +t is set. \fP"
114 .RI "short int \fBnoexternal\fP"
116 .RI "\fINonzero if the mode +n is set. \fP"
118 .RI "short int \fBinviteonly\fP"
120 .RI "\fINonzero if the mode +i is set. \fP"
122 .RI "short int \fBmoderated\fP"
124 .RI "\fINonzero if the mode +m is set. \fP"
126 .RI "short int \fBsecret\fP"
128 .RI "\fINonzero if the mode +s is set. \fP"
130 .RI "short int \fBc_private\fP"
132 .RI "\fINonzero if the mode +p is set. \fP"
134 .RI "\fBBanList\fP \fBbans\fP"
136 .RI "\fIThe list of all bans set on the channel. \fP"
138 .SH "Detailed Description"
140 Holds all relevent information for a channel.
142 This class represents a channel, and contains its name, modes, time created, topic, topic set time, etc, and an instance of the BanList type.
144 Definition at line 94 of file channels.h.
145 .SH "Constructor & Destructor Documentation"
147 .SS "chanrec::chanrec ()"
149 Creates a channel record and initialises it with default values. Definition at line 113 of file channels.cpp.
151 References c_private, created, custom_modes, internal_userlist, inviteonly, key, limit, moderated, name, noexternal, secret, setby, topic, topiclock, topicset, and users.
156 116 strcpy(custom_modes,'');
157 117 strcpy(topic,'');
158 118 strcpy(setby,'');
160 120 created = topicset = limit = users = 0;
161 121 topiclock = noexternal = inviteonly = moderated = secret = c_private = false;
162 122 internal_userlist.clear();
165 .SS "virtual chanrec::~\fBchanrec\fP ()\fC [inline, virtual]\fP"
167 Definition at line 240 of file channels.h.
172 .SH "Member Function Documentation"
174 .SS "void chanrec::AddUser (char * castuser)"
176 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.
178 References DEBUG, and internal_userlist.
182 222 internal_userlist.push_back(castuser);
183 223 log(DEBUG,'Added casted user to channel's internal list');
186 .SS "void chanrec::DecUserCounter ()"
188 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.
190 References DEBUG, name, and users.
194 210 if (this->users > 0)
196 212 log(DEBUG,'Decremented channel user count for %s to %lu',name,(unsigned long)users);
199 .SS "void chanrec::DelUser (char * castuser)"
201 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.
203 References DEBUG, internal_userlist, and name.
207 228 for (std::vector<char*>::iterator a = internal_userlist.begin(); a < internal_userlist.end(); a++)
209 230 if (*a == castuser)
211 232 log(DEBUG,'Removed casted user from channel's internal list');
212 233 internal_userlist.erase(a);
216 237 log(DEBUG,'BUG BUG BUG! Attempt to remove an uncasted user from the internal list of %s!',name);
219 .SS "std::string chanrec::GetModeParameter (char mode)"
221 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.
223 References custom_mode_params.
227 189 if (custom_mode_params.size())
229 191 for (vector<ModeParameter>::iterator i = custom_mode_params.begin(); i < custom_mode_params.end(); i++)
231 193 if ((i->mode == mode) && (!strcasecmp(this->name,i->channel)))
233 195 return std::string(i->parameter);
237 199 return std::string('');
240 .SS "long chanrec::GetUserCounter ()"
242 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.
248 217 return (this->users);
251 .SS "std::vector< char * > * chanrec::GetUsers ()"
253 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.
255 References internal_userlist.
259 242 return &internal_userlist;
262 .SS "void chanrec::IncUserCounter ()"
264 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.
266 References DEBUG, name, and users.
271 205 log(DEBUG,'Incremented channel user count for %s to %lu',name,(unsigned long)users);
274 .SS "bool chanrec::IsCustomModeSet (char mode)"
276 Returns true if a custom mode is set on a channel. Definition at line 181 of file channels.cpp.
282 183 log(DEBUG,'Checking ISCustomModeSet: %c %s',mode,this->custom_modes);
283 184 return (strchr(this->custom_modes,mode) != 0);
286 .SS "void chanrec::SetCustomMode (char mode, bool mode_on)"
288 Sets or unsets a custom mode in the channels info. Definition at line 125 of file channels.cpp.
290 References custom_modes, DEBUG, and SetCustomModeParam().
298 131 if (!strchr(this->custom_modes,mode))
300 133 strlcat(custom_modes,m,MAXMODES);
302 135 log(DEBUG,'Custom mode %c set',mode);
306 139 std::string a = this->custom_modes;
307 140 int pos = a.find(mode);
309 142 strncpy(this->custom_modes,a.c_str(),MAXMODES);
311 144 log(DEBUG,'Custom mode %c removed: modelist='%s'',mode,this->custom_modes);
312 145 this->SetCustomModeParam(mode,'',false);
316 .SS "void chanrec::SetCustomModeParam (char mode, char * parameter, bool mode_on)"
318 Sets or unsets the parameters for a custom mode in a channels info. Definition at line 150 of file channels.cpp.
320 References ModeParameter::channel, custom_mode_params, DEBUG, ModeParameter::mode, and ModeParameter::parameter.
322 Referenced by SetCustomMode().
327 153 log(DEBUG,'SetCustomModeParam called');
330 156 strlcpy(M.channel,this->name,CHANMAX);
331 157 strlcpy(M.parameter,parameter,MAXBUF);
334 160 log(DEBUG,'Custom mode parameter %c %s added',mode,parameter);
335 161 custom_mode_params.push_back(M);
339 165 if (custom_mode_params.size())
341 167 for (vector<ModeParameter>::iterator i = custom_mode_params.begin(); i < custom_mode_params.end(); i++)
343 169 if ((i->mode == mode) && (!strcasecmp(this->name,i->channel)))
345 171 log(DEBUG,'Custom mode parameter %c %s removed',mode,parameter);
346 172 custom_mode_params.erase(i);
351 177 log(DEBUG,'*** BUG *** Attempt to remove non-existent mode parameter!');
355 .SH "Member Data Documentation"
357 .SS "\fBBanList\fP \fBchanrec::bans\fP"
359 The list of all bans set on the channel. Definition at line 168 of file channels.h.
360 .SS "short int \fBchanrec::c_private\fP"
362 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.
364 Referenced by chanrec().
365 .SS "time_t \fBchanrec::created\fP"
367 Creation time. Definition at line 120 of file channels.h.
369 Referenced by chanrec().
370 .SS "char \fBchanrec::custom_modes\fP[MAXMODES]"
372 Custom modes for the channel. Plugins may use this field in any way they see fit.Definition at line 103 of file channels.h.
374 Referenced by chanrec(), and SetCustomMode().
375 .SS "std::vector<char*> \fBchanrec::internal_userlist\fP"
377 User list (casted to char*'s to stop forward declaration stuff) (chicken and egg scenario!). Definition at line 112 of file channels.h.
379 Referenced by AddUser(), chanrec(), DelUser(), and GetUsers().
380 .SS "short int \fBchanrec::inviteonly\fP"
382 Nonzero if the mode +i is set. Definition at line 150 of file channels.h.
384 Referenced by chanrec().
385 .SS "char \fBchanrec::key\fP[32]"
387 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.
389 Referenced by chanrec().
390 .SS "long \fBchanrec::limit\fP"
392 Contains the channel user limit. If this value is zero, there is no limit in place.Definition at line 133 of file channels.h.
394 Referenced by chanrec().
395 .SS "short int \fBchanrec::moderated\fP"
397 Nonzero if the mode +m is set. Definition at line 154 of file channels.h.
399 Referenced by chanrec().
400 .SS "char \fBchanrec::name\fP[CHANMAX]"
402 The channels name. Definition at line 99 of file channels.h.
404 Referenced by chanrec(), DecUserCounter(), DelUser(), IncUserCounter(), and Server::PseudoToUser().
405 .SS "short int \fBchanrec::noexternal\fP"
407 Nonzero if the mode +n is set. Definition at line 146 of file channels.h.
409 Referenced by chanrec().
410 .SS "short int \fBchanrec::secret\fP"
412 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.
414 Referenced by chanrec().
415 .SS "char \fBchanrec::setby\fP[NICKMAX]"
417 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.
419 Referenced by chanrec(), and Server::PseudoToUser().
420 .SS "char \fBchanrec::topic\fP[MAXBUF]"
422 Channel topic. If this is an empty string, no channel topic is set.Definition at line 117 of file channels.h.
424 Referenced by chanrec(), and Server::PseudoToUser().
425 .SS "short int \fBchanrec::topiclock\fP"
427 Nonzero if the mode +t is set. Definition at line 142 of file channels.h.
429 Referenced by chanrec().
430 .SS "time_t \fBchanrec::topicset\fP"
432 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.
434 Referenced by chanrec(), and Server::PseudoToUser().
435 .SS "long \fBchanrec::users\fP"
437 Count of users on the channel used for fast user counting. Definition at line 107 of file channels.h.
439 Referenced by chanrec(), DecUserCounter(), GetUserCounter(), and IncUserCounter().
443 Generated automatically by Doxygen for InspIRCd from the source code.