summaryrefslogtreecommitdiff
path: root/docs/man/man3/chanrec.3
blob: 0831e46b350295d56a2ab99c943520653878e6ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
.TH "chanrec" 3 "15 May 2005" "InspIRCd" \" -*- nroff -*-
.ad l
.nh
.SH NAME
chanrec \- Holds all relevent information for a channel.  

.PP
.SH SYNOPSIS
.br
.PP
\fC#include <channels.h>\fP
.PP
Inherits \fBExtensible\fP.
.PP
.SS "Public Member Functions"

.in +1c
.ti -1c
.RI "void \fBSetCustomMode\fP (char mode, bool mode_on)"
.br
.RI "\fISets or unsets a custom mode in the channels info. \fP"
.ti -1c
.RI "void \fBSetCustomModeParam\fP (char mode, char *parameter, bool mode_on)"
.br
.RI "\fISets or unsets the parameters for a custom mode in a channels info. \fP"
.ti -1c
.RI "bool \fBIsCustomModeSet\fP (char mode)"
.br
.RI "\fIReturns true if a custom mode is set on a channel. \fP"
.ti -1c
.RI "std::string \fBGetModeParameter\fP (char mode)"
.br
.RI "\fIReturns the parameter for a custom mode on a 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"
.ti -1c
.RI "virtual \fB~chanrec\fP ()"
.br
.in -1c
.SS "Public Attributes"

.in +1c
.ti -1c
.RI "char \fBname\fP [CHANMAX]"
.br
.RI "\fIThe channels name. \fP"
.ti -1c
.RI "char \fBcustom_modes\fP [MAXMODES]"
.br
.RI "\fICustom modes for the channel. \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"
.ti -1c
.RI "time_t \fBcreated\fP"
.br
.RI "\fICreation time. \fP"
.ti -1c
.RI "time_t \fBtopicset\fP"
.br
.RI "\fITime topic was set. \fP"
.ti -1c
.RI "char \fBsetby\fP [NICKMAX]"
.br
.RI "\fIThe last user to set the topic. \fP"
.ti -1c
.RI "short int \fBlimit\fP"
.br
.RI "\fIContains the channel user limit. \fP"
.ti -1c
.RI "char \fBkey\fP [32]"
.br
.RI "\fIContains the channel key. \fP"
.ti -1c
.RI "char \fBbinarymodes\fP"
.br
.RI "\fIContains a bitmask of the CM_* builtin (RFC) binary mode symbols. \fP"
.ti -1c
.RI "\fBBanList\fP \fBbans\fP"
.br
.RI "\fIThe list of all bans set on the channel. \fP"
.in -1c
.SH "Detailed Description"
.PP 
Holds all relevent information for a channel. 

This class represents a channel, and contains its name, modes, time created, topic, topic set time, etc, and an instance of the BanList type. 
.PP
Definition at line 101 of file channels.h.
.SH "Constructor & Destructor Documentation"
.PP 
.SS "chanrec::chanrec ()"
.PP
Creates a channel record and initialises it with default values. Definition at line 108 of file channels.cpp.
.PP
References binarymodes, created, custom_modes, internal_userlist, key, limit, name, setby, topic, and topicset.
.PP
.nf
109 {
110         strcpy(name,'');
111         strcpy(custom_modes,'');
112         strcpy(topic,'');
113         strcpy(setby,'');
114         strcpy(key,'');
115         created = topicset = limit = 0;
116         binarymodes = 0;
117         internal_userlist.clear();
118 }
.fi
.SS "virtual chanrec::~\fBchanrec\fP ()\fC [inline, virtual]\fP"
.PP
Definition at line 205 of file channels.h.
.PP
.nf
205 { /* 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 202 of file channels.cpp.
.PP
References DEBUG, and internal_userlist.
.PP
.nf
203 {
204         internal_userlist.push_back(castuser);
205         log(DEBUG,'Added casted user to channel's internal list');
206 }
.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 208 of file channels.cpp.
.PP
References DEBUG, internal_userlist, and name.
.PP
.nf
209 {
210         for (std::vector<char*>::iterator a = internal_userlist.begin(); a < internal_userlist.end(); a++)
211         {
212                 if (*a == castuser)
213                 {
214                         log(DEBUG,'Removed casted user from channel's internal list');
215                         internal_userlist.erase(a);
216                         return;
217                 }
218         }
219         log(DEBUG,'BUG BUG BUG! Attempt to remove an uncasted user from the internal list of %s!',name);
220 }
.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 182 of file channels.cpp.
.PP
References custom_mode_params.
.PP
.nf
183 {
184         if (custom_mode_params.size())
185         {
186                 for (vector<ModeParameter>::iterator i = custom_mode_params.begin(); i < custom_mode_params.end(); i++)
187                 {
188                         if ((i->mode == mode) && (!strcasecmp(this->name,i->channel)))
189                         {
190                                 return i->parameter;
191                         }
192                 }
193         }
194         return '';
195 }
.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 197 of file channels.cpp.
.PP
References internal_userlist.
.PP
.nf
198 {
199         return (this->internal_userlist.size());
200 }
.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 222 of file channels.cpp.
.PP
References internal_userlist.
.PP
Referenced by Server::GetUsers().
.PP
.nf
223 {
224         return &internal_userlist;
225 }
.fi
.SS "bool chanrec::IsCustomModeSet (char mode)"
.PP
Returns true if a custom mode is set on a channel. Definition at line 176 of file channels.cpp.
.PP
References DEBUG.
.PP
.nf
177 {
178         log(DEBUG,'Checking ISCustomModeSet: %c %s',mode,this->custom_modes);
179         return (strchr(this->custom_modes,mode) != 0);
180 }
.fi
.SS "void chanrec::SetCustomMode (char mode, bool mode_on)"
.PP
Sets or unsets a custom mode in the channels info. Definition at line 120 of file channels.cpp.
.PP
References custom_modes, DEBUG, and SetCustomModeParam().
.PP
.nf
121 {
122         if (mode_on) {
123                 static char m[3];
124                 m[0] = mode;
125                 m[1] = '\0';
126                 if (!strchr(this->custom_modes,mode))
127                 {
128                         strlcat(custom_modes,m,MAXMODES);
129                 }
130                 log(DEBUG,'Custom mode %c set',mode);
131         }
132         else {
133 
134                 std::string a = this->custom_modes;
135                 int pos = a.find(mode);
136                 a.erase(pos,1);
137                 strncpy(this->custom_modes,a.c_str(),MAXMODES);
138 
139                 log(DEBUG,'Custom mode %c removed: modelist='%s'',mode,this->custom_modes);
140                 this->SetCustomModeParam(mode,'',false);
141         }
142 }
.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 145 of file channels.cpp.
.PP
References ModeParameter::channel, custom_mode_params, DEBUG, ModeParameter::mode, and ModeParameter::parameter.
.PP
Referenced by SetCustomMode().
.PP
.nf
146 {
147 
148         log(DEBUG,'SetCustomModeParam called');
149         ModeParameter M;
150         M.mode = mode;
151         strlcpy(M.channel,this->name,CHANMAX);
152         strlcpy(M.parameter,parameter,MAXBUF);
153         if (mode_on)
154         {
155                 log(DEBUG,'Custom mode parameter %c %s added',mode,parameter);
156                 custom_mode_params.push_back(M);
157         }
158         else
159         {
160                 if (custom_mode_params.size())
161                 {
162                         for (vector<ModeParameter>::iterator i = custom_mode_params.begin(); i < custom_mode_params.end(); i++)
163                         {
164                                 if ((i->mode == mode) && (!strcasecmp(this->name,i->channel)))
165                                 {
166                                         log(DEBUG,'Custom mode parameter %c %s removed',mode,parameter);
167                                         custom_mode_params.erase(i);
168                                         return;
169                                 }
170                         }
171                 }
172                 log(DEBUG,'*** BUG *** Attempt to remove non-existent mode parameter!');
173         }
174 }
.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 149 of file channels.h.
.SS "char \fBchanrec::binarymodes\fP"
.PP
Contains a bitmask of the CM_* builtin (RFC) binary mode symbols. Definition at line 145 of file channels.h.
.PP
Referenced by chanrec().
.SS "time_t \fBchanrec::created\fP"
.PP
Creation time. Definition at line 123 of file channels.h.
.PP
Referenced by chanrec().
.SS "char \fBchanrec::custom_modes\fP[MAXMODES]"
.PP
Custom modes for the channel. Plugins may use this field in any way they see fit.Definition at line 110 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 115 of file channels.h.
.PP
Referenced by AddUser(), chanrec(), DelUser(), GetUserCounter(), and GetUsers().
.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 141 of file channels.h.
.PP
Referenced by chanrec().
.SS "short int \fBchanrec::limit\fP"
.PP
Contains the channel user limit. If this value is zero, there is no limit in place.Definition at line 136 of file channels.h.
.PP
Referenced by chanrec().
.SS "char \fBchanrec::name\fP[CHANMAX]"
.PP
The channels name. Definition at line 106 of file channels.h.
.PP
Referenced by chanrec(), DelUser(), and Server::PseudoToUser().
.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 131 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 120 of file channels.h.
.PP
Referenced by chanrec(), and Server::PseudoToUser().
.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 127 of file channels.h.
.PP
Referenced by chanrec(), and Server::PseudoToUser().

.SH "Author"
.PP 
Generated automatically by Doxygen for InspIRCd from the source code.