]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - docs/man/man3/chanrec.3
Added final documentation for inspircd Beta 4
[user/henk/code/inspircd.git] / docs / man / man3 / chanrec.3
1 .TH "chanrec" 3 "7 May 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 Referenced by Server::GetUsers().
258 .PP
259 .nf
260 241 {
261 242         return &internal_userlist;
262 243 }
263 .fi
264 .SS "void chanrec::IncUserCounter ()"
265 .PP
266 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.
267 .PP
268 References DEBUG, name, and users.
269 .PP
270 .nf
271 203 {
272 204         this->users++;
273 205         log(DEBUG,'Incremented channel user count for %s to %lu',name,(unsigned long)users);
274 206 }
275 .fi
276 .SS "bool chanrec::IsCustomModeSet (char mode)"
277 .PP
278 Returns true if a custom mode is set on a channel. Definition at line 181 of file channels.cpp.
279 .PP
280 References DEBUG.
281 .PP
282 .nf
283 182 {
284 183         log(DEBUG,'Checking ISCustomModeSet: %c %s',mode,this->custom_modes);
285 184         return (strchr(this->custom_modes,mode) != 0);
286 185 }
287 .fi
288 .SS "void chanrec::SetCustomMode (char mode, bool mode_on)"
289 .PP
290 Sets or unsets a custom mode in the channels info. Definition at line 125 of file channels.cpp.
291 .PP
292 References custom_modes, DEBUG, and SetCustomModeParam().
293 .PP
294 .nf
295 126 {
296 127         if (mode_on) {
297 128                 static char m[3];
298 129                 m[0] = mode;
299 130                 m[1] = '\0';
300 131                 if (!strchr(this->custom_modes,mode))
301 132                 {
302 133                         strlcat(custom_modes,m,MAXMODES);
303 134                 }
304 135                 log(DEBUG,'Custom mode %c set',mode);
305 136         }
306 137         else {
307 138 
308 139                 std::string a = this->custom_modes;
309 140                 int pos = a.find(mode);
310 141                 a.erase(pos,1);
311 142                 strncpy(this->custom_modes,a.c_str(),MAXMODES);
312 143 
313 144                 log(DEBUG,'Custom mode %c removed: modelist='%s'',mode,this->custom_modes);
314 145                 this->SetCustomModeParam(mode,'',false);
315 146         }
316 147 }
317 .fi
318 .SS "void chanrec::SetCustomModeParam (char mode, char * parameter, bool mode_on)"
319 .PP
320 Sets or unsets the parameters for a custom mode in a channels info. Definition at line 150 of file channels.cpp.
321 .PP
322 References ModeParameter::channel, custom_mode_params, DEBUG, ModeParameter::mode, and ModeParameter::parameter.
323 .PP
324 Referenced by SetCustomMode().
325 .PP
326 .nf
327 151 {
328 152 
329 153         log(DEBUG,'SetCustomModeParam called');
330 154         ModeParameter M;
331 155         M.mode = mode;
332 156         strlcpy(M.channel,this->name,CHANMAX);
333 157         strlcpy(M.parameter,parameter,MAXBUF);
334 158         if (mode_on)
335 159         {
336 160                 log(DEBUG,'Custom mode parameter %c %s added',mode,parameter);
337 161                 custom_mode_params.push_back(M);
338 162         }
339 163         else
340 164         {
341 165                 if (custom_mode_params.size())
342 166                 {
343 167                         for (vector<ModeParameter>::iterator i = custom_mode_params.begin(); i < custom_mode_params.end(); i++)
344 168                         {
345 169                                 if ((i->mode == mode) && (!strcasecmp(this->name,i->channel)))
346 170                                 {
347 171                                         log(DEBUG,'Custom mode parameter %c %s removed',mode,parameter);
348 172                                         custom_mode_params.erase(i);
349 173                                         return;
350 174                                 }
351 175                         }
352 176                 }
353 177                 log(DEBUG,'*** BUG *** Attempt to remove non-existent mode parameter!');
354 178         }
355 179 }
356 .fi
357 .SH "Member Data Documentation"
358 .PP 
359 .SS "\fBBanList\fP \fBchanrec::bans\fP"
360 .PP
361 The list of all bans set on the channel. Definition at line 168 of file channels.h.
362 .SS "short int \fBchanrec::c_private\fP"
363 .PP
364 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.
365 .PP
366 Referenced by chanrec().
367 .SS "time_t \fBchanrec::created\fP"
368 .PP
369 Creation time. Definition at line 120 of file channels.h.
370 .PP
371 Referenced by chanrec().
372 .SS "char \fBchanrec::custom_modes\fP[MAXMODES]"
373 .PP
374 Custom modes for the channel. Plugins may use this field in any way they see fit.Definition at line 103 of file channels.h.
375 .PP
376 Referenced by chanrec(), and SetCustomMode().
377 .SS "std::vector<char*> \fBchanrec::internal_userlist\fP"
378 .PP
379 User list (casted to char*'s to stop forward declaration stuff) (chicken and egg scenario!). Definition at line 112 of file channels.h.
380 .PP
381 Referenced by AddUser(), chanrec(), DelUser(), and GetUsers().
382 .SS "short int \fBchanrec::inviteonly\fP"
383 .PP
384 Nonzero if the mode +i is set. Definition at line 150 of file channels.h.
385 .PP
386 Referenced by chanrec().
387 .SS "char \fBchanrec::key\fP[32]"
388 .PP
389 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.
390 .PP
391 Referenced by chanrec().
392 .SS "long \fBchanrec::limit\fP"
393 .PP
394 Contains the channel user limit. If this value is zero, there is no limit in place.Definition at line 133 of file channels.h.
395 .PP
396 Referenced by chanrec().
397 .SS "short int \fBchanrec::moderated\fP"
398 .PP
399 Nonzero if the mode +m is set. Definition at line 154 of file channels.h.
400 .PP
401 Referenced by chanrec().
402 .SS "char \fBchanrec::name\fP[CHANMAX]"
403 .PP
404 The channels name. Definition at line 99 of file channels.h.
405 .PP
406 Referenced by chanrec(), DecUserCounter(), DelUser(), IncUserCounter(), and Server::PseudoToUser().
407 .SS "short int \fBchanrec::noexternal\fP"
408 .PP
409 Nonzero if the mode +n is set. Definition at line 146 of file channels.h.
410 .PP
411 Referenced by chanrec().
412 .SS "short int \fBchanrec::secret\fP"
413 .PP
414 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.
415 .PP
416 Referenced by chanrec().
417 .SS "char \fBchanrec::setby\fP[NICKMAX]"
418 .PP
419 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.
420 .PP
421 Referenced by chanrec(), and Server::PseudoToUser().
422 .SS "char \fBchanrec::topic\fP[MAXBUF]"
423 .PP
424 Channel topic. If this is an empty string, no channel topic is set.Definition at line 117 of file channels.h.
425 .PP
426 Referenced by chanrec(), and Server::PseudoToUser().
427 .SS "short int \fBchanrec::topiclock\fP"
428 .PP
429 Nonzero if the mode +t is set. Definition at line 142 of file channels.h.
430 .PP
431 Referenced by chanrec().
432 .SS "time_t \fBchanrec::topicset\fP"
433 .PP
434 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.
435 .PP
436 Referenced by chanrec(), and Server::PseudoToUser().
437 .SS "long \fBchanrec::users\fP"
438 .PP
439 Count of users on the channel used for fast user counting. Definition at line 107 of file channels.h.
440 .PP
441 Referenced by chanrec(), DecUserCounter(), GetUserCounter(), and IncUserCounter().
442
443 .SH "Author"
444 .PP 
445 Generated automatically by Doxygen for InspIRCd from the source code.