]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - docs/man/man3/chanrec.3
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@2578 e03df62e-2008...
[user/henk/code/inspircd.git] / docs / man / man3 / chanrec.3
1 .TH "chanrec" 3 "19 Dec 2005" "Version 1.0Betareleases" "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 "\fBstd::string\fP \fBGetModeParameter\fP (char mode)"
32 .br
33 .RI "\fIReturns the parameter for a custom mode on a channel. \fP"
34 .ti -1c
35 .RI "long \fBGetUserCounter\fP ()"
36 .br
37 .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"
38 .ti -1c
39 .RI "void \fBAddUser\fP (char *castuser)"
40 .br
41 .RI "\fIAdd a user pointer to the internal reference list. \fP"
42 .ti -1c
43 .RI "void \fBDelUser\fP (char *castuser)"
44 .br
45 .RI "\fIDelete a user pointer to the internal reference list. \fP"
46 .ti -1c
47 .RI "std::vector< char * > * \fBGetUsers\fP ()"
48 .br
49 .RI "\fIObrain the internal reference list The internal reference list contains a list of userrec* cast to char*. \fP"
50 .ti -1c
51 .RI "\fBchanrec\fP ()"
52 .br
53 .RI "\fICreates a channel record and initialises it with default values. \fP"
54 .ti -1c
55 .RI "virtual \fB~chanrec\fP ()"
56 .br
57 .in -1c
58 .SS "Public Attributes"
59
60 .in +1c
61 .ti -1c
62 .RI "char \fBname\fP [CHANMAX]"
63 .br
64 .RI "\fIThe channels name. \fP"
65 .ti -1c
66 .RI "char \fBcustom_modes\fP [MAXMODES]"
67 .br
68 .RI "\fICustom modes for the channel. \fP"
69 .ti -1c
70 .RI "std::vector< char * > \fBinternal_userlist\fP"
71 .br
72 .RI "\fIUser list (casted to char*'s to stop forward declaration stuff) (chicken and egg scenario!). \fP"
73 .ti -1c
74 .RI "char \fBtopic\fP [MAXBUF]"
75 .br
76 .RI "\fIChannel topic. \fP"
77 .ti -1c
78 .RI "time_t \fBcreated\fP"
79 .br
80 .RI "\fICreation time. \fP"
81 .ti -1c
82 .RI "time_t \fBtopicset\fP"
83 .br
84 .RI "\fITime topic was set. \fP"
85 .ti -1c
86 .RI "char \fBsetby\fP [NICKMAX]"
87 .br
88 .RI "\fIThe last user to set the topic. \fP"
89 .ti -1c
90 .RI "short int \fBlimit\fP"
91 .br
92 .RI "\fIContains the channel user limit. \fP"
93 .ti -1c
94 .RI "char \fBkey\fP [32]"
95 .br
96 .RI "\fIContains the channel key. \fP"
97 .ti -1c
98 .RI "char \fBbinarymodes\fP"
99 .br
100 .RI "\fIContains a bitmask of the CM_* builtin (RFC) binary mode symbols. \fP"
101 .ti -1c
102 .RI "\fBBanList\fP \fBbans\fP"
103 .br
104 .RI "\fIThe list of all bans set on the channel. \fP"
105 .in -1c
106 .SH "Detailed Description"
107 .PP 
108 Holds all relevent information for a channel. 
109
110 This class represents a channel, and contains its name, modes, time created, topic, topic set time, etc, and an instance of the BanList type.
111 .PP
112 Definition at line 103 of file channels.h.
113 .SH "Constructor & Destructor Documentation"
114 .PP 
115 .SS "chanrec::chanrec ()"
116 .PP
117 Creates a channel record and initialises it with default values. 
118 .PP
119 Definition at line 73 of file channels.cpp.
120 .PP
121 References binarymodes, created, custom_modes, internal_userlist, key, limit, name, setby, topic, and topicset.
122 .PP
123 .nf
124 74 {
125 75         strcpy(name,'');
126 76         strcpy(custom_modes,'');
127 77         strcpy(topic,'');
128 78         strcpy(setby,'');
129 79         strcpy(key,'');
130 80         created = topicset = limit = 0;
131 81         binarymodes = 0;
132 82         internal_userlist.clear();
133 83 }
134 .fi
135 .PP
136 .SS "virtual chanrec::~chanrec ()\fC [inline, virtual]\fP"
137 .PP
138 Definition at line 226 of file channels.h.
139 .PP
140 .nf
141 226 { /* stub */ }
142 .fi
143 .PP
144 .SH "Member Function Documentation"
145 .PP 
146 .SS "void chanrec::AddUser (char * castuser)"
147 .PP
148 Add a user pointer to the internal reference list. 
149 .PP
150 \fBParameters:\fP
151 .RS 4
152 \fIcastuser\fP This should be a pointer to a userrec, casted to char*
153 .RE
154 .PP
155 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.
156 .PP
157 Definition at line 166 of file channels.cpp.
158 .PP
159 References DEBUG, internal_userlist, and log().
160 .PP
161 Referenced by ForceChan().
162 .PP
163 .nf
164 167 {
165 168         internal_userlist.push_back(castuser);
166 169         log(DEBUG,'Added casted user to channel's internal list');
167 170 }
168 .fi
169 .PP
170 .SS "void chanrec::DelUser (char * castuser)"
171 .PP
172 Delete a user pointer to the internal reference list. 
173 .PP
174 \fBParameters:\fP
175 .RS 4
176 \fIcastuser\fP This should be a pointer to a userrec, casted to char*
177 .RE
178 .PP
179 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.
180 .PP
181 Definition at line 172 of file channels.cpp.
182 .PP
183 References DEBUG, internal_userlist, log(), and name.
184 .PP
185 Referenced by del_channel(), and kick_channel().
186 .PP
187 .nf
188 173 {
189 174         for (std::vector<char*>::iterator a = internal_userlist.begin(); a < internal_userlist.end(); a++)
190 175         {
191 176                 if (*a == castuser)
192 177                 {
193 178                         log(DEBUG,'Removed casted user from channel's internal list');
194 179                         internal_userlist.erase(a);
195 180                         return;
196 181                 }
197 182         }
198 183         log(DEBUG,'BUG BUG BUG! Attempt to remove an uncasted user from the internal list of %s!',name);
199 184 }
200 .fi
201 .PP
202 .SS "\fBstd::string\fP chanrec::GetModeParameter (char mode)"
203 .PP
204 Returns the parameter for a custom mode on a channel. 
205 .PP
206 \fBParameters:\fP
207 .RS 4
208 \fImode\fP The mode character you wish to query
209 .RE
210 .PP
211 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.
212 .PP
213 \fBReturns:\fP
214 .RS 4
215 The parameter for this mode is returned, or an empty string
216 .RE
217 .PP
218
219 .PP
220 Definition at line 146 of file channels.cpp.
221 .PP
222 References custom_mode_params.
223 .PP
224 .nf
225 147 {
226 148         if (custom_mode_params.size())
227 149         {
228 150                 for (vector<ModeParameter>::iterator i = custom_mode_params.begin(); i < custom_mode_params.end(); i++)
229 151                 {
230 152                         if ((i->mode == mode) && (!strcasecmp(this->name,i->channel)))
231 153                         {
232 154                                 return i->parameter;
233 155                         }
234 156                 }
235 157         }
236 158         return '';
237 159 }
238 .fi
239 .PP
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. 
243 .PP
244 \fBReturns:\fP
245 .RS 4
246 The number of users on this channel
247 .RE
248 .PP
249
250 .PP
251 Definition at line 161 of file channels.cpp.
252 .PP
253 .nf
254 162 {
255 163         return (this->internal_userlist.size());
256 164 }
257 .fi
258 .PP
259 .SS "std::vector< char * > * chanrec::GetUsers ()"
260 .PP
261 Obrain the internal reference list The internal reference list contains a list of userrec* cast to char*. 
262 .PP
263 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.
264 .PP
265 \fBReturns:\fP
266 .RS 4
267 This function returns a vector of userrec pointers, each of which has been casted to char* to prevent circular references
268 .RE
269 .PP
270
271 .PP
272 Definition at line 186 of file channels.cpp.
273 .PP
274 References internal_userlist.
275 .PP
276 Referenced by Server::GetUsers().
277 .PP
278 .nf
279 187 {
280 188         return &internal_userlist;
281 189 }
282 .fi
283 .PP
284 .SS "bool chanrec::IsCustomModeSet (char mode)"
285 .PP
286 Returns true if a custom mode is set on a channel. 
287 .PP
288 \fBParameters:\fP
289 .RS 4
290 \fImode\fP The mode character you wish to query 
291 .RE
292 .PP
293 \fBReturns:\fP
294 .RS 4
295 True if the custom mode is set, false if otherwise
296 .RE
297 .PP
298
299 .PP
300 Definition at line 141 of file channels.cpp.
301 .PP
302 .nf
303 142 {
304 143         return (strchr(this->custom_modes,mode));
305 144 }
306 .fi
307 .PP
308 .SS "void chanrec::SetCustomMode (char mode, bool mode_on)"
309 .PP
310 Sets or unsets a custom mode in the channels info. 
311 .PP
312 \fBParameters:\fP
313 .RS 4
314 \fImode\fP The mode character to set or unset 
315 .br
316 \fImode_on\fP True if you want to set the mode or false if you want to remove it
317 .RE
318 .PP
319
320 .PP
321 Definition at line 85 of file channels.cpp.
322 .PP
323 References custom_modes, DEBUG, log(), and SetCustomModeParam().
324 .PP
325 .nf
326 86 {
327 87         if (mode_on) {
328 88                 static char m[3];
329 89                 m[0] = mode;
330 90                 m[1] = '\0';
331 91                 if (!strchr(this->custom_modes,mode))
332 92                 {
333 93                         strlcat(custom_modes,m,MAXMODES);
334 94                 }
335 95                 log(DEBUG,'Custom mode %c set',mode);
336 96         }
337 97         else {
338 98 
339 99                 std::string a = this->custom_modes;
340 100                 int pos = a.find(mode);
341 101                 a.erase(pos,1);
342 102                 strncpy(this->custom_modes,a.c_str(),MAXMODES);
343 103 
344 104                 log(DEBUG,'Custom mode %c removed: modelist='%s'',mode,this->custom_modes);
345 105                 this->SetCustomModeParam(mode,'',false);
346 106         }
347 107 }
348 .fi
349 .PP
350 .SS "void chanrec::SetCustomModeParam (char mode, char * parameter, bool mode_on)"
351 .PP
352 Sets or unsets the parameters for a custom mode in a channels info. 
353 .PP
354 \fBParameters:\fP
355 .RS 4
356 \fImode\fP The mode character to set or unset 
357 .br
358 \fIparameter\fP The parameter string to associate with this mode character 
359 .br
360 \fImode_on\fP True if you want to set the mode or false if you want to remove it
361 .RE
362 .PP
363
364 .PP
365 Definition at line 110 of file channels.cpp.
366 .PP
367 References ModeParameter::channel, custom_mode_params, DEBUG, log(), ModeParameter::mode, and ModeParameter::parameter.
368 .PP
369 Referenced by SetCustomMode().
370 .PP
371 .nf
372 111 {
373 112 
374 113         log(DEBUG,'SetCustomModeParam called');
375 114         ModeParameter M;
376 115         M.mode = mode;
377 116         strlcpy(M.channel,this->name,CHANMAX);
378 117         strlcpy(M.parameter,parameter,MAXBUF);
379 118         if (mode_on)
380 119         {
381 120                 log(DEBUG,'Custom mode parameter %c %s added',mode,parameter);
382 121                 custom_mode_params.push_back(M);
383 122         }
384 123         else
385 124         {
386 125                 if (custom_mode_params.size())
387 126                 {
388 127                         for (vector<ModeParameter>::iterator i = custom_mode_params.begin(); i < custom_mode_params.end(); i++)
389 128                         {
390 129                                 if ((i->mode == mode) && (!strcasecmp(this->name,i->channel)))
391 130                                 {
392 131                                         log(DEBUG,'Custom mode parameter %c %s removed',mode,parameter);
393 132                                         custom_mode_params.erase(i);
394 133                                         return;
395 134                                 }
396 135                         }
397 136                 }
398 137                 log(DEBUG,'*** BUG *** Attempt to remove non-existent mode parameter!');
399 138         }
400 139 }
401 .fi
402 .PP
403 .SH "Member Data Documentation"
404 .PP 
405 .SS "\fBBanList\fP \fBchanrec::bans\fP"
406 .PP
407 The list of all bans set on the channel. 
408 .PP
409 Definition at line 151 of file channels.h.
410 .PP
411 Referenced by add_channel().
412 .SS "char \fBchanrec::binarymodes\fP"
413 .PP
414 Contains a bitmask of the CM_* builtin (RFC) binary mode symbols. 
415 .PP
416 Definition at line 147 of file channels.h.
417 .PP
418 Referenced by add_channel(), and chanrec().
419 .SS "time_t \fBchanrec::created\fP"
420 .PP
421 Creation time. 
422 .PP
423 Definition at line 125 of file channels.h.
424 .PP
425 Referenced by chanrec().
426 .SS "char \fBchanrec::custom_modes\fP[MAXMODES]"
427 .PP
428 Custom modes for the channel. 
429 .PP
430 Plugins may use this field in any way they see fit.
431 .PP
432 Definition at line 112 of file channels.h.
433 .PP
434 Referenced by chanrec(), and SetCustomMode().
435 .SS "std::vector<char*> \fBchanrec::internal_userlist\fP"
436 .PP
437 User list (casted to char*'s to stop forward declaration stuff) (chicken and egg scenario!). 
438 .PP
439 Definition at line 117 of file channels.h.
440 .PP
441 Referenced by AddUser(), chanrec(), DelUser(), and GetUsers().
442 .SS "char \fBchanrec::key\fP[32]"
443 .PP
444 Contains the channel key. 
445 .PP
446 If this value is an empty string, there is no channel key in place.
447 .PP
448 Definition at line 143 of file channels.h.
449 .PP
450 Referenced by add_channel(), and chanrec().
451 .SS "short int \fBchanrec::limit\fP"
452 .PP
453 Contains the channel user limit. 
454 .PP
455 If this value is zero, there is no limit in place.
456 .PP
457 Definition at line 138 of file channels.h.
458 .PP
459 Referenced by add_channel(), and chanrec().
460 .SS "char \fBchanrec::name\fP[CHANMAX]"
461 .PP
462 The channels name. 
463 .PP
464 Definition at line 108 of file channels.h.
465 .PP
466 Referenced by add_channel(), chanrec(), del_channel(), DelUser(), ForceChan(), kick_channel(), and Server::PseudoToUser().
467 .SS "char \fBchanrec::setby\fP[NICKMAX]"
468 .PP
469 The last user to set the topic. 
470 .PP
471 If this member is an empty string, no topic was ever set.
472 .PP
473 Definition at line 133 of file channels.h.
474 .PP
475 Referenced by chanrec(), ForceChan(), and Server::PseudoToUser().
476 .SS "char \fBchanrec::topic\fP[MAXBUF]"
477 .PP
478 Channel topic. 
479 .PP
480 If this is an empty string, no channel topic is set.
481 .PP
482 Definition at line 122 of file channels.h.
483 .PP
484 Referenced by chanrec(), ForceChan(), and Server::PseudoToUser().
485 .SS "time_t \fBchanrec::topicset\fP"
486 .PP
487 Time topic was set. 
488 .PP
489 If no topic was ever set, this will be equal to \fBchanrec::created\fP
490 .PP
491 Definition at line 129 of file channels.h.
492 .PP
493 Referenced by chanrec(), ForceChan(), and Server::PseudoToUser().
494
495 .SH "Author"
496 .PP 
497 Generated automatically by Doxygen for InspIRCd from the source code.