]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - docs/man/man3/userrec.3
Added final documentation for inspircd Beta 4
[user/henk/code/inspircd.git] / docs / man / man3 / userrec.3
1 .TH "userrec" 3 "7 May 2005" "InspIRCd" \" -*- nroff -*-
2 .ad l
3 .nh
4 .SH NAME
5 userrec \- Holds all information about a user This class stores all information about a user connected to the irc server.  
6
7 .PP
8 .SH SYNOPSIS
9 .br
10 .PP
11 \fC#include <users.h>\fP
12 .PP
13 Inherits \fBconnection\fP.
14 .PP
15 .SS "Public Member Functions"
16
17 .in +1c
18 .ti -1c
19 .RI "\fBuserrec\fP ()"
20 .br
21 .ti -1c
22 .RI "virtual \fB~userrec\fP ()"
23 .br
24 .ti -1c
25 .RI "virtual char * \fBGetFullHost\fP ()"
26 .br
27 .RI "\fIReturns the full displayed host of the user This member function returns the hostname of the user as seen by other users on the server, in nick!identhost form. \fP"
28 .ti -1c
29 .RI "virtual char * \fBGetFullRealHost\fP ()"
30 .br
31 .RI "\fIReturns the full real host of the user This member function returns the hostname of the user as seen by other users on the server, in nick!identhost form. \fP"
32 .ti -1c
33 .RI "virtual bool \fBIsInvited\fP (char *channel)"
34 .br
35 .RI "\fIReturns true if a user is invited to a channel. \fP"
36 .ti -1c
37 .RI "virtual void \fBInviteTo\fP (char *channel)"
38 .br
39 .RI "\fIAdds a channel to a users invite list (invites them to a channel). \fP"
40 .ti -1c
41 .RI "virtual void \fBRemoveInvite\fP (char *channel)"
42 .br
43 .RI "\fIRemoves a channel from a users invite list. \fP"
44 .ti -1c
45 .RI "bool \fBHasPermission\fP (char *command)"
46 .br
47 .RI "\fIReturns true or false for if a user can execute a privilaged oper command. \fP"
48 .ti -1c
49 .RI "bool \fBAddBuffer\fP (std::string a)"
50 .br
51 .RI "\fIThis method adds data to the buffer of the user. \fP"
52 .ti -1c
53 .RI "bool \fBBufferIsReady\fP ()"
54 .br
55 .RI "\fIThis method returns true if the buffer contains at least one carriage return character (e.g. \fP"
56 .ti -1c
57 .RI "void \fBClearBuffer\fP ()"
58 .br
59 .RI "\fIThis function clears the entire buffer by setting it to an empty string. \fP"
60 .ti -1c
61 .RI "std::string \fBGetBuffer\fP ()"
62 .br
63 .RI "\fIThis method returns the first available string at the tail end of the buffer and advances the tail end of the buffer past the string. \fP"
64 .in -1c
65 .SS "Public Attributes"
66
67 .in +1c
68 .ti -1c
69 .RI "char \fBnick\fP [NICKMAX]"
70 .br
71 .RI "\fIThe users nickname. \fP"
72 .ti -1c
73 .RI "char \fBident\fP [64]"
74 .br
75 .RI "\fIThe users ident reply. \fP"
76 .ti -1c
77 .RI "char \fBdhost\fP [256]"
78 .br
79 .RI "\fIThe host displayed to non-opers (used for cloaking etc). \fP"
80 .ti -1c
81 .RI "char \fBfullname\fP [128]"
82 .br
83 .RI "\fIThe users full name. \fP"
84 .ti -1c
85 .RI "char \fBmodes\fP [MAXBUF]"
86 .br
87 .RI "\fIThe user's mode string. \fP"
88 .ti -1c
89 .RI "\fBucrec\fP \fBchans\fP [MAXCHANS]"
90 .br
91 .ti -1c
92 .RI "char \fBserver\fP [256]"
93 .br
94 .RI "\fIThe server the user is connected to. \fP"
95 .ti -1c
96 .RI "char \fBawaymsg\fP [512]"
97 .br
98 .RI "\fIThe user's away message. \fP"
99 .ti -1c
100 .RI "char \fBresult\fP [256]"
101 .br
102 .RI "\fIStores the result of the last GetFullHost or GetRealHost call. \fP"
103 .ti -1c
104 .RI "int \fBflood\fP"
105 .br
106 .RI "\fINumber of lines the user can place into the buffer (up to the global NetBufferSize bytes) before they are disconnected for excess flood. \fP"
107 .ti -1c
108 .RI "unsigned long \fBtimeout\fP"
109 .br
110 .RI "\fINumber of seconds this user is given to send USER/NICK If they do not send their details in this time limit they will be disconnected. \fP"
111 .ti -1c
112 .RI "char \fBoper\fP [NICKMAX]"
113 .br
114 .RI "\fIThe oper type they logged in as, if they are an oper. \fP"
115 .ti -1c
116 .RI "bool \fBdns_done\fP"
117 .br
118 .RI "\fITrue when \fBDNS\fP lookups are completed. \fP"
119 .ti -1c
120 .RI "unsigned long \fBpingmax\fP"
121 .br
122 .RI "\fINumber of seconds between PINGs for this user (set from <connect:allow> tag. \fP"
123 .ti -1c
124 .RI "char \fBpassword\fP [MAXBUF]"
125 .br
126 .RI "\fIPassword specified by the user when they registered. \fP"
127 .ti -1c
128 .RI "std::string \fBrecvq\fP"
129 .br
130 .RI "\fIUser's receive queue. \fP"
131 .ti -1c
132 .RI "long \fBlines_in\fP"
133 .br
134 .RI "\fIFlood counters. \fP"
135 .ti -1c
136 .RI "time_t \fBreset_due\fP"
137 .br
138 .ti -1c
139 .RI "long \fBthreshold\fP"
140 .br
141 .in -1c
142 .SS "Private Attributes"
143
144 .in +1c
145 .ti -1c
146 .RI "\fBInvitedList\fP \fBinvites\fP"
147 .br
148 .RI "\fIA list of channels the user has a pending invite to. \fP"
149 .in -1c
150 .SH "Detailed Description"
151 .PP 
152 Holds all information about a user This class stores all information about a user connected to the irc server. 
153
154 Everything about a connection is stored here primarily, from the user's socket ID (file descriptor) through to the user's nickname and hostname. Use the Find method of the server class to locate a specific user by nickname. 
155 .PP
156 Definition at line 98 of file users.h.
157 .SH "Constructor & Destructor Documentation"
158 .PP 
159 .SS "userrec::userrec ()"
160 .PP
161 Definition at line 28 of file users.cpp.
162 .PP
163 References awaymsg, connection::bytes_in, connection::bytes_out, ucrec::channel, chans, connection::cmds_in, connection::cmds_out, dhost, dns_done, connection::fd, flood, fullname, connection::haspassed, connection::host, ident, connection::idle_lastmsg, connection::inbuf, invites, connection::ip, connection::lastping, lines_in, modes, nick, connection::nping, oper, connection::port, recvq, connection::registered, reset_due, result, server, connection::signon, TIME, timeout, and ucrec::uc_modes.
164 .PP
165 .nf
166 29 {
167 30         // the PROPER way to do it, AVOID bzero at *ALL* costs
168 31         strcpy(nick,'');
169 32         strcpy(ip,'127.0.0.1');
170 33         timeout = 0;
171 34         strcpy(ident,'');
172 35         strcpy(host,'');
173 36         strcpy(dhost,'');
174 37         strcpy(fullname,'');
175 38         strcpy(modes,'');
176 39         strcpy(inbuf,'');
177 40         strcpy(server,'');
178 41         strcpy(awaymsg,'');
179 42         strcpy(oper,'');
180 43         reset_due = TIME;
181 44         lines_in = 0;
182 45         fd = lastping = signon = idle_lastmsg = nping = registered = 0;
183 46         flood = port = bytes_in = bytes_out = cmds_in = cmds_out = 0;
184 47         haspassed = false;
185 48         dns_done = false;
186 49         recvq = '';
187 50         strcpy(result,'');
188 51         for (int i = 0; i < MAXCHANS; i++)
189 52         {
190 53                 this->chans[i].channel = NULL;
191 54                 this->chans[i].uc_modes = 0;
192 55         }
193 56         invites.clear();
194 57 }
195 .fi
196 .SS "virtual userrec::~\fBuserrec\fP ()\fC [inline, virtual]\fP"
197 .PP
198 Definition at line 195 of file users.h.
199 .PP
200 .nf
201 195 {  }
202 .fi
203 .SH "Member Function Documentation"
204 .PP 
205 .SS "bool userrec::AddBuffer (std::string a)"
206 .PP
207 This method adds data to the buffer of the user. The buffer can grow to any size within limits of the available memory, managed by the size of a std::string, however if any individual line in the buffer grows over 600 bytes in length (which is 88 chars over the RFC-specified limit per line) then the method will return false and the text will not be inserted.Definition at line 169 of file users.cpp.
208 .PP
209 References recvq.
210 .PP
211 .nf
212 170 {
213 171         std::string b = '';
214 172         for (int i = 0; i < a.length(); i++)
215 173                 if ((a[i] != '\r') && (a[i] != '\0') && (a[i] != 7))
216 174                         b = b + a[i];
217 175         std::stringstream stream(recvq);
218 176         stream << b;
219 177         recvq = stream.str();
220 178         int i = 0;
221 179         // count the size of the first line in the buffer.
222 180         while (i < recvq.length())
223 181         {
224 182                 if (recvq[i++] == '\n')
225 183                         break;
226 184         }
227 185         // return false if we've had more than 600 characters WITHOUT
228 186         // a carriage return (this is BAD, drop the socket)
229 187         return (i < 600);
230 188 }
231 .fi
232 .SS "bool userrec::BufferIsReady ()"
233 .PP
234 This method returns true if the buffer contains at least one carriage return character (e.g. one complete line may be read)Definition at line 190 of file users.cpp.
235 .PP
236 References recvq.
237 .PP
238 .nf
239 191 {
240 192         for (int i = 0; i < recvq.length(); i++)
241 193                 if (recvq[i] == '\n')
242 194                         return true;
243 195         return false;
244 196 }
245 .fi
246 .SS "void userrec::ClearBuffer ()"
247 .PP
248 This function clears the entire buffer by setting it to an empty string. Definition at line 198 of file users.cpp.
249 .PP
250 References recvq.
251 .PP
252 Referenced by Server::PseudoToUser(), and Server::UserToPseudo().
253 .PP
254 .nf
255 199 {
256 200         recvq = '';
257 201 }
258 .fi
259 .SS "std::string userrec::GetBuffer ()"
260 .PP
261 This method returns the first available string at the tail end of the buffer and advances the tail end of the buffer past the string. This means it is a one way operation in a similar way to strtok(), and multiple calls return multiple lines if they are available. The results of this function if there are no lines to be read are unknown, always use \fBBufferIsReady()\fP to check if it is ok to read the buffer before calling \fBGetBuffer()\fP.Definition at line 203 of file users.cpp.
262 .PP
263 References recvq.
264 .PP
265 .nf
266 204 {
267 205         if (recvq == '')
268 206                 return '';
269 207         char* line = (char*)recvq.c_str();
270 208         std::string ret = '';
271 209         while ((*line != '\n') && (strlen(line)))
272 210         {
273 211                 ret = ret + *line;
274 212                 line++;
275 213         }
276 214         if ((*line == '\n') || (*line == '\r'))
277 215                 line++;
278 216         recvq = line;
279 217         return ret;
280 218 }
281 .fi
282 .SS "char * userrec::GetFullHost ()\fC [virtual]\fP"
283 .PP
284 Returns the full displayed host of the user This member function returns the hostname of the user as seen by other users on the server, in nick!identhost form. Definition at line 61 of file users.cpp.
285 .PP
286 References dhost, ident, nick, and result.
287 .PP
288 .nf
289 62 {
290 63         snprintf(result,MAXBUF,'%s!%s@%s',nick,ident,dhost);
291 64         return result;
292 65 }
293 .fi
294 .SS "char * userrec::GetFullRealHost ()\fC [virtual]\fP"
295 .PP
296 Returns the full real host of the user This member function returns the hostname of the user as seen by other users on the server, in nick!identhost form. If any form of hostname cloaking is in operation, e.g. through a module, then this method will ignore it and return the true hostname.Definition at line 68 of file users.cpp.
297 .PP
298 References connection::host, ident, nick, and result.
299 .PP
300 .nf
301 69 {
302 70         snprintf(result,MAXBUF,'%s!%s@%s',nick,ident,host);
303 71         return result;
304 72 }
305 .fi
306 .SS "bool userrec::HasPermission (char * command)"
307 .PP
308 Returns true or false for if a user can execute a privilaged oper command. This is done by looking up their oper type from \fBuserrec::oper\fP, then referencing this to their oper classes and checking the commands they can execute.Definition at line 117 of file users.cpp.
309 .PP
310 References config_f, and DEBUG.
311 .PP
312 .nf
313 118 {
314 119         char TypeName[MAXBUF],Classes[MAXBUF],ClassName[MAXBUF],CommandList[MAXBUF];
315 120         char* mycmd;
316 121         char* savept;
317 122         char* savept2;
318 123         
319 124         // are they even an oper at all?
320 125         if (strchr(this->modes,'o'))
321 126         {
322 127                 log(DEBUG,'*** HasPermission: %s is an oper',this->nick);
323 128                 for (int j =0; j < ConfValueEnum('type',&config_f); j++)
324 129                 {
325 130                         ConfValue('type','name',j,TypeName,&config_f);
326 131                         if (!strcmp(TypeName,this->oper))
327 132                         {
328 133                                 log(DEBUG,'*** HasPermission: %s is an oper of type '%s'',this->nick,this->oper);
329 134                                 ConfValue('type','classes',j,Classes,&config_f);
330 135                                 char* myclass = strtok_r(Classes,' ',&savept);
331 136                                 while (myclass)
332 137                                 {
333 138                                         log(DEBUG,'*** HasPermission: checking classtype '%s'',myclass);
334 139                                         for (int k =0; k < ConfValueEnum('class',&config_f); k++)
335 140                                         {
336 141                                                 ConfValue('class','name',k,ClassName,&config_f);
337 142                                                 if (!strcmp(ClassName,myclass))
338 143                                                 {
339 144                                                         ConfValue('class','commands',k,CommandList,&config_f);
340 145                                                         log(DEBUG,'*** HasPermission: found class named %s with commands: '%s'',ClassName,CommandList);
341 146                                                         
342 147                                                         
343 148                                                         mycmd = strtok_r(CommandList,' ',&savept2);
344 149                                                         while (mycmd)
345 150                                                         {
346 151                                                                 if (!strcasecmp(mycmd,command))
347 152                                                                 {
348 153                                                                         log(DEBUG,'*** Command %s found, returning true',command);
349 154                                                                         return true;
350 155                                                                 }
351 156                                                                 mycmd = strtok_r(NULL,' ',&savept2);
352 157                                                         }
353 158                                                 }
354 159                                         }
355 160                                         myclass = strtok_r(NULL,' ',&savept);
356 161                                 }
357 162                         }
358 163                 }
359 164         }
360 165         return false;
361 166 }
362 .fi
363 .SS "void userrec::InviteTo (char * channel)\fC [virtual]\fP"
364 .PP
365 Adds a channel to a users invite list (invites them to a channel). Definition at line 88 of file users.cpp.
366 .PP
367 References Invited::channel, and invites.
368 .PP
369 .nf
370 89 {
371 90         Invited i;
372 91         strlcpy(i.channel,channel,CHANMAX);
373 92         invites.push_back(i);
374 93 }
375 .fi
376 .SS "bool userrec::IsInvited (char * channel)\fC [virtual]\fP"
377 .PP
378 Returns true if a user is invited to a channel. Definition at line 74 of file users.cpp.
379 .PP
380 References invites.
381 .PP
382 .nf
383 75 {
384 76         for (InvitedList::iterator i = invites.begin(); i != invites.end(); i++)
385 77         {
386 78                 if (i->channel) {
387 79                         if (!strcasecmp(i->channel,channel))
388 80                         {
389 81                                 return true;
390 82                         }
391 83                 }
392 84         }
393 85         return false;
394 86 }
395 .fi
396 .SS "void userrec::RemoveInvite (char * channel)\fC [virtual]\fP"
397 .PP
398 Removes a channel from a users invite list. This member function is called on successfully joining an invite only channel to which the user has previously been invited, to clear the invitation.Definition at line 95 of file users.cpp.
399 .PP
400 References DEBUG, and invites.
401 .PP
402 .nf
403 96 {
404 97         log(DEBUG,'Removing invites');
405 98         if (channel)
406 99         {
407 100                 if (invites.size())
408 101                 {
409 102                         for (InvitedList::iterator i = invites.begin(); i != invites.end(); i++)
410 103                         {
411 104                                 if (i->channel)
412 105                                 {
413 106                                         if (!strcasecmp(i->channel,channel))
414 107                                         {
415 108                                                 invites.erase(i);
416 109                                                 return;
417 110                                         }
418 111                                 }
419 112                         }
420 113                 }
421 114         }
422 115 }
423 .fi
424 .SH "Member Data Documentation"
425 .PP 
426 .SS "char \fBuserrec::awaymsg\fP[512]"
427 .PP
428 The user's away message. If this string is empty, the user is not marked as away.Definition at line 141 of file users.h.
429 .PP
430 Referenced by userrec().
431 .SS "\fBucrec\fP \fBuserrec::chans\fP[MAXCHANS]"
432 .PP
433 Definition at line 132 of file users.h.
434 .PP
435 Referenced by Server::PseudoToUser(), and userrec().
436 .SS "char \fBuserrec::dhost\fP[256]"
437 .PP
438 The host displayed to non-opers (used for cloaking etc). This usually matches the value of \fBuserrec::host\fP.Definition at line 120 of file users.h.
439 .PP
440 Referenced by GetFullHost(), and userrec().
441 .SS "bool \fBuserrec::dns_done\fP"
442 .PP
443 True when \fBDNS\fP lookups are completed. Definition at line 169 of file users.h.
444 .PP
445 Referenced by userrec().
446 .SS "int \fBuserrec::flood\fP"
447 .PP
448 Number of lines the user can place into the buffer (up to the global NetBufferSize bytes) before they are disconnected for excess flood. Definition at line 152 of file users.h.
449 .PP
450 Referenced by userrec().
451 .SS "char \fBuserrec::fullname\fP[128]"
452 .PP
453 The users full name. Definition at line 124 of file users.h.
454 .PP
455 Referenced by userrec().
456 .SS "char \fBuserrec::ident\fP[64]"
457 .PP
458 The users ident reply. Definition at line 115 of file users.h.
459 .PP
460 Referenced by GetFullHost(), GetFullRealHost(), Server::PseudoToUser(), userrec(), and Server::UserToPseudo().
461 .SS "\fBInvitedList\fP \fBuserrec::invites\fP\fC [private]\fP"
462 .PP
463 A list of channels the user has a pending invite to. Definition at line 104 of file users.h.
464 .PP
465 Referenced by InviteTo(), IsInvited(), RemoveInvite(), and userrec().
466 .SS "long \fBuserrec::lines_in\fP"
467 .PP
468 Flood counters. Definition at line 189 of file users.h.
469 .PP
470 Referenced by userrec().
471 .SS "char \fBuserrec::modes\fP[MAXBUF]"
472 .PP
473 The user's mode string. This may contain any of the following RFC characters: o, w, s, i Your module may define other mode characters as it sees fit.Definition at line 130 of file users.h.
474 .PP
475 Referenced by userrec().
476 .SS "char \fBuserrec::nick\fP[NICKMAX]"
477 .PP
478 The users nickname. An invalid nickname indicates an unregistered connection prior to the NICK command.Definition at line 111 of file users.h.
479 .PP
480 Referenced by ConfigReader::DumpErrors(), GetFullHost(), GetFullRealHost(), Server::PseudoToUser(), and userrec().
481 .SS "char \fBuserrec::oper\fP[NICKMAX]"
482 .PP
483 The oper type they logged in as, if they are an oper. This is used to check permissions in operclasses, so that we can say 'yay' or 'nay' to any commands they issue. The value of this is the value of a valid 'type name=' tag.Definition at line 165 of file users.h.
484 .PP
485 Referenced by userrec().
486 .SS "char \fBuserrec::password\fP[MAXBUF]"
487 .PP
488 Password specified by the user when they registered. This is stored even if the  block doesnt need a password, so that modules may check it.Definition at line 179 of file users.h.
489 .SS "unsigned long \fBuserrec::pingmax\fP"
490 .PP
491 Number of seconds between PINGs for this user (set from <connect:allow> tag. Definition at line 173 of file users.h.
492 .SS "std::string \fBuserrec::recvq\fP"
493 .PP
494 User's receive queue. Lines from the IRCd awaiting processing are stored here. Upgraded april 2005, old system a bit hairy.Definition at line 185 of file users.h.
495 .PP
496 Referenced by AddBuffer(), BufferIsReady(), ClearBuffer(), GetBuffer(), and userrec().
497 .SS "time_t \fBuserrec::reset_due\fP"
498 .PP
499 Definition at line 190 of file users.h.
500 .PP
501 Referenced by userrec().
502 .SS "char \fBuserrec::result\fP[256]"
503 .PP
504 Stores the result of the last GetFullHost or GetRealHost call. You may use this to increase the speed of use of this class.Definition at line 146 of file users.h.
505 .PP
506 Referenced by GetFullHost(), GetFullRealHost(), and userrec().
507 .SS "char \fBuserrec::server\fP[256]"
508 .PP
509 The server the user is connected to. Definition at line 136 of file users.h.
510 .PP
511 Referenced by userrec().
512 .SS "long \fBuserrec::threshold\fP"
513 .PP
514 Definition at line 191 of file users.h.
515 .SS "unsigned long \fBuserrec::timeout\fP"
516 .PP
517 Number of seconds this user is given to send USER/NICK If they do not send their details in this time limit they will be disconnected. Definition at line 158 of file users.h.
518 .PP
519 Referenced by userrec().
520
521 .SH "Author"
522 .PP 
523 Generated automatically by Doxygen for InspIRCd from the source code.