]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - docs/man/man3/chanrec.3
New documentation!
[user/henk/code/inspircd.git] / docs / man / man3 / chanrec.3
1 .TH "chanrec" 3 "26 Apr 2005" "InspIRCd" \" -*- nroff -*-
2 .ad l
3 .nh
4 .SH NAME
5 chanrec \- Holds all relevent information for a channel.  
6
7 .PP
8 .SH SYNOPSIS
9 .br
10 .PP
11 \fC#include <channels.h>\fP
12 .PP
13 Inherits \fBExtensible\fP.
14 .PP
15 .SS "Public Member Functions"
16
17 .in +1c
18 .ti -1c
19 .RI "void \fBSetCustomMode\fP (char mode, bool mode_on)"
20 .br
21 .RI "\fISets or unsets a custom mode in the channels info. \fP"
22 .ti -1c
23 .RI "void \fBSetCustomModeParam\fP (char mode, char *parameter, bool mode_on)"
24 .br
25 .RI "\fISets or unsets the parameters for a custom mode in a channels info. \fP"
26 .ti -1c
27 .RI "bool \fBIsCustomModeSet\fP (char mode)"
28 .br
29 .RI "\fIReturns true if a custom mode is set on a channel. \fP"
30 .ti -1c
31 .RI "std::string \fBGetModeParameter\fP (char mode)"
32 .br
33 .RI "\fIReturns the parameter for a custom mode on a channel. \fP"
34 .ti -1c
35 .RI "void \fBIncUserCounter\fP ()"
36 .br
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"
38 .ti -1c
39 .RI "void \fBDecUserCounter\fP ()"
40 .br
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"
42 .ti -1c
43 .RI "long \fBGetUserCounter\fP ()"
44 .br
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"
46 .ti -1c
47 .RI "void \fBAddUser\fP (char *castuser)"
48 .br
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"
50 .ti -1c
51 .RI "void \fBDelUser\fP (char *castuser)"
52 .br
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"
54 .ti -1c
55 .RI "std::vector< char * > * \fBGetUsers\fP ()"
56 .br
57 .RI "\fIObrain the internal reference list The internal reference list contains a list of userrec* cast to char*. \fP"
58 .ti -1c
59 .RI "\fBchanrec\fP ()"
60 .br
61 .RI "\fICreates a channel record and initialises it with default values. \fP"
62 .ti -1c
63 .RI "virtual \fB~chanrec\fP ()"
64 .br
65 .in -1c
66 .SS "Public Attributes"
67
68 .in +1c
69 .ti -1c
70 .RI "char \fBname\fP [CHANMAX]"
71 .br
72 .RI "\fIThe channels name. \fP"
73 .ti -1c
74 .RI "char \fBcustom_modes\fP [MAXMODES]"
75 .br
76 .RI "\fICustom modes for the channel. \fP"
77 .ti -1c
78 .RI "long \fBusers\fP"
79 .br
80 .RI "\fICount of users on the channel used for fast user counting. \fP"
81 .ti -1c
82 .RI "std::vector< char * > \fBinternal_userlist\fP"
83 .br
84 .RI "\fIUser list (casted to char*'s to stop forward declaration stuff) (chicken and egg scenario!). \fP"
85 .ti -1c
86 .RI "char \fBtopic\fP [MAXBUF]"
87 .br
88 .RI "\fIChannel topic. \fP"
89 .ti -1c
90 .RI "time_t \fBcreated\fP"
91 .br
92 .RI "\fICreation time. \fP"
93 .ti -1c
94 .RI "time_t \fBtopicset\fP"
95 .br
96 .RI "\fITime topic was set. \fP"
97 .ti -1c
98 .RI "char \fBsetby\fP [NICKMAX]"
99 .br
100 .RI "\fIThe last user to set the topic. \fP"
101 .ti -1c
102 .RI "long \fBlimit\fP"
103 .br
104 .RI "\fIContains the channel user limit. \fP"
105 .ti -1c
106 .RI "char \fBkey\fP [32]"
107 .br
108 .RI "\fIContains the channel key. \fP"
109 .ti -1c
110 .RI "short int \fBtopiclock\fP"
111 .br
112 .RI "\fINonzero if the mode +t is set. \fP"
113 .ti -1c
114 .RI "short int \fBnoexternal\fP"
115 .br
116 .RI "\fINonzero if the mode +n is set. \fP"
117 .ti -1c
118 .RI "short int \fBinviteonly\fP"
119 .br
120 .RI "\fINonzero if the mode +i is set. \fP"
121 .ti -1c
122 .RI "short int \fBmoderated\fP"
123 .br
124 .RI "\fINonzero if the mode +m is set. \fP"
125 .ti -1c
126 .RI "short int \fBsecret\fP"
127 .br
128 .RI "\fINonzero if the mode +s is set. \fP"
129 .ti -1c
130 .RI "short int \fBc_private\fP"
131 .br
132 .RI "\fINonzero if the mode +p is set. \fP"
133 .ti -1c
134 .RI "\fBBanList\fP \fBbans\fP"
135 .br
136 .RI "\fIThe list of all bans set on the channel. \fP"
137 .in -1c
138 .SH "Detailed Description"
139 .PP 
140 Holds all relevent information for a channel. 
141
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. 
143 .PP
144 Definition at line 94 of file channels.h.
145 .SH "Constructor & Destructor Documentation"
146 .PP 
147 .SS "chanrec::chanrec ()"
148 .PP
149 Creates a channel record and initialises it with default values. Definition at line 113 of file channels.cpp.
150 .PP
151 References c_private, created, custom_modes, internal_userlist, inviteonly, key, limit, moderated, name, noexternal, secret, setby, topic, topiclock, topicset, and users.
152 .PP
153 .nf
154 114 {
155 115         strcpy(name,'');
156 116         strcpy(custom_modes,'');
157 117         strcpy(topic,'');
158 118         strcpy(setby,'');
159 119         strcpy(key,'');
160 120         created = topicset = limit = users = 0;
161 121         topiclock = noexternal = inviteonly = moderated = secret = c_private = false;
162 122         internal_userlist.clear();
163 123 }
164 .fi
165 .SS "virtual chanrec::~\fBchanrec\fP ()\fC [inline, virtual]\fP"
166 .PP
167 Definition at line 240 of file channels.h.
168 .PP
169 .nf
170 240 { /* stub */ }
171 .fi
172 .SH "Member Function Documentation"
173 .PP 
174 .SS "void chanrec::AddUser (char * castuser)"
175 .PP
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.
177 .PP
178 References DEBUG, and internal_userlist.
179 .PP
180 .nf
181 221 {
182 222         internal_userlist.push_back(castuser);
183 223         log(DEBUG,'Added casted user to channel's internal list');
184 224 }
185 .fi
186 .SS "void chanrec::DecUserCounter ()"
187 .PP
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.
189 .PP
190 References DEBUG, name, and users.
191 .PP
192 .nf
193 209 {
194 210         if (this->users > 0)
195 211                 this->users--;
196 212         log(DEBUG,'Decremented channel user count for %s to %lu',name,(unsigned long)users);
197 213 }
198 .fi
199 .SS "void chanrec::DelUser (char * castuser)"
200 .PP
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.
202 .PP
203 References DEBUG, internal_userlist, and name.
204 .PP
205 .nf
206 227 {
207 228         for (std::vector<char*>::iterator a = internal_userlist.begin(); a < internal_userlist.end(); a++)
208 229         {
209 230                 if (*a == castuser)
210 231                 {
211 232                         log(DEBUG,'Removed casted user from channel's internal list');
212 233                         internal_userlist.erase(a);
213 234                         return;
214 235                 }
215 236         }
216 237         log(DEBUG,'BUG BUG BUG! Attempt to remove an uncasted user from the internal list of %s!',name);
217 238 }
218 .fi
219 .SS "std::string chanrec::GetModeParameter (char mode)"
220 .PP
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.
222 .PP
223 References custom_mode_params.
224 .PP
225 .nf
226 188 {
227 189         if (custom_mode_params.size())
228 190         {
229 191                 for (vector<ModeParameter>::iterator i = custom_mode_params.begin(); i < custom_mode_params.end(); i++)
230 192                 {
231 193                         if ((i->mode == mode) && (!strcasecmp(this->name,i->channel)))
232 194                         {
233 195                                 return std::string(i->parameter);
234 196                         }
235 197                 }
236 198         }
237 199         return std::string('');
238 200 }
239 .fi
240 .SS "long chanrec::GetUserCounter ()"
241 .PP
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.
243 .PP
244 References users.
245 .PP
246 .nf
247 216 {
248 217         return (this->users);
249 218 }
250 .fi
251 .SS "std::vector< char * > * chanrec::GetUsers ()"
252 .PP
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.
254 .PP
255 References internal_userlist.
256 .PP
257 .nf
258 241 {
259 242         return &internal_userlist;
260 243 }
261 .fi
262 .SS "void chanrec::IncUserCounter ()"
263 .PP
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.
265 .PP
266 References DEBUG, name, and users.
267 .PP
268 .nf
269 203 {
270 204         this->users++;
271 205         log(DEBUG,'Incremented channel user count for %s to %lu',name,(unsigned long)users);
272 206 }
273 .fi
274 .SS "bool chanrec::IsCustomModeSet (char mode)"
275 .PP
276 Returns true if a custom mode is set on a channel. Definition at line 181 of file channels.cpp.
277 .PP
278 References DEBUG.
279 .PP
280 .nf
281 182 {
282 183         log(DEBUG,'Checking ISCustomModeSet: %c %s',mode,this->custom_modes);
283 184         return (strchr(this->custom_modes,mode) != 0);
284 185 }
285 .fi
286 .SS "void chanrec::SetCustomMode (char mode, bool mode_on)"
287 .PP
288 Sets or unsets a custom mode in the channels info. Definition at line 125 of file channels.cpp.
289 .PP
290 References custom_modes, DEBUG, and SetCustomModeParam().
291 .PP
292 .nf
293 126 {
294 127         if (mode_on) {
295 128                 char m[3];
296 129                 m[0] = mode;
297 130                 m[1] = '\0';
298 131                 if (!strchr(this->custom_modes,mode))
299 132                 {
300 133                         strlcat(custom_modes,m,MAXMODES);
301 134                 }
302 135                 log(DEBUG,'Custom mode %c set',mode);
303 136         }
304 137         else {
305 138 
306 139                 std::string a = this->custom_modes;
307 140                 int pos = a.find(mode);
308 141                 a.erase(pos,1);
309 142                 strncpy(this->custom_modes,a.c_str(),MAXMODES);
310 143 
311 144                 log(DEBUG,'Custom mode %c removed: modelist='%s'',mode,this->custom_modes);
312 145                 this->SetCustomModeParam(mode,'',false);
313 146         }
314 147 }
315 .fi
316 .SS "void chanrec::SetCustomModeParam (char mode, char * parameter, bool mode_on)"
317 .PP
318 Sets or unsets the parameters for a custom mode in a channels info. Definition at line 150 of file channels.cpp.
319 .PP
320 References ModeParameter::channel, custom_mode_params, DEBUG, ModeParameter::mode, and ModeParameter::parameter.
321 .PP
322 Referenced by SetCustomMode().
323 .PP
324 .nf
325 151 {
326 152 
327 153         log(DEBUG,'SetCustomModeParam called');
328 154         ModeParameter M;
329 155         M.mode = mode;
330 156         strlcpy(M.channel,this->name,CHANMAX);
331 157         strlcpy(M.parameter,parameter,MAXBUF);
332 158         if (mode_on)
333 159         {
334 160                 log(DEBUG,'Custom mode parameter %c %s added',mode,parameter);
335 161                 custom_mode_params.push_back(M);
336 162         }
337 163         else
338 164         {
339 165                 if (custom_mode_params.size())
340 166                 {
341 167                         for (vector<ModeParameter>::iterator i = custom_mode_params.begin(); i < custom_mode_params.end(); i++)
342 168                         {
343 169                                 if ((i->mode == mode) && (!strcasecmp(this->name,i->channel)))
344 170                                 {
345 171                                         log(DEBUG,'Custom mode parameter %c %s removed',mode,parameter);
346 172                                         custom_mode_params.erase(i);
347 173                                         return;
348 174                                 }
349 175                         }
350 176                 }
351 177                 log(DEBUG,'*** BUG *** Attempt to remove non-existent mode parameter!');
352 178         }
353 179 }
354 .fi
355 .SH "Member Data Documentation"
356 .PP 
357 .SS "\fBBanList\fP \fBchanrec::bans\fP"
358 .PP
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"
361 .PP
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.
363 .PP
364 Referenced by chanrec().
365 .SS "time_t \fBchanrec::created\fP"
366 .PP
367 Creation time. Definition at line 120 of file channels.h.
368 .PP
369 Referenced by chanrec().
370 .SS "char \fBchanrec::custom_modes\fP[MAXMODES]"
371 .PP
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.
373 .PP
374 Referenced by chanrec(), and SetCustomMode().
375 .SS "std::vector<char*> \fBchanrec::internal_userlist\fP"
376 .PP
377 User list (casted to char*'s to stop forward declaration stuff) (chicken and egg scenario!). Definition at line 112 of file channels.h.
378 .PP
379 Referenced by AddUser(), chanrec(), DelUser(), and GetUsers().
380 .SS "short int \fBchanrec::inviteonly\fP"
381 .PP
382 Nonzero if the mode +i is set. Definition at line 150 of file channels.h.
383 .PP
384 Referenced by chanrec().
385 .SS "char \fBchanrec::key\fP[32]"
386 .PP
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.
388 .PP
389 Referenced by chanrec().
390 .SS "long \fBchanrec::limit\fP"
391 .PP
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.
393 .PP
394 Referenced by chanrec().
395 .SS "short int \fBchanrec::moderated\fP"
396 .PP
397 Nonzero if the mode +m is set. Definition at line 154 of file channels.h.
398 .PP
399 Referenced by chanrec().
400 .SS "char \fBchanrec::name\fP[CHANMAX]"
401 .PP
402 The channels name. Definition at line 99 of file channels.h.
403 .PP
404 Referenced by chanrec(), DecUserCounter(), DelUser(), IncUserCounter(), and Server::PseudoToUser().
405 .SS "short int \fBchanrec::noexternal\fP"
406 .PP
407 Nonzero if the mode +n is set. Definition at line 146 of file channels.h.
408 .PP
409 Referenced by chanrec().
410 .SS "short int \fBchanrec::secret\fP"
411 .PP
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.
413 .PP
414 Referenced by chanrec().
415 .SS "char \fBchanrec::setby\fP[NICKMAX]"
416 .PP
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.
418 .PP
419 Referenced by chanrec(), and Server::PseudoToUser().
420 .SS "char \fBchanrec::topic\fP[MAXBUF]"
421 .PP
422 Channel topic. If this is an empty string, no channel topic is set.Definition at line 117 of file channels.h.
423 .PP
424 Referenced by chanrec(), and Server::PseudoToUser().
425 .SS "short int \fBchanrec::topiclock\fP"
426 .PP
427 Nonzero if the mode +t is set. Definition at line 142 of file channels.h.
428 .PP
429 Referenced by chanrec().
430 .SS "time_t \fBchanrec::topicset\fP"
431 .PP
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.
433 .PP
434 Referenced by chanrec(), and Server::PseudoToUser().
435 .SS "long \fBchanrec::users\fP"
436 .PP
437 Count of users on the channel used for fast user counting. Definition at line 107 of file channels.h.
438 .PP
439 Referenced by chanrec(), DecUserCounter(), GetUserCounter(), and IncUserCounter().
440
441 .SH "Author"
442 .PP 
443 Generated automatically by Doxygen for InspIRCd from the source code.