]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - include/users.h
731cb785ad986ce2b24c071010f33a5cd0e185b5
[user/henk/code/inspircd.git] / include / users.h
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
6  *                       E-mail:
7  *                <brain@chatspike.net>
8  *                <Craig@chatspike.net>
9  *     
10  * Written by Craig Edwards, Craig McLure, and others.
11  * This program is free but copyrighted software; see
12  *            the file COPYING for details.
13  *
14  * ---------------------------------------------------
15  */
16
17 #ifndef __USERS_H__ 
18 #define __USERS_H__ 
19
20 #include <string>
21 #include "inspircd_config.h" 
22 #include "socket.h"
23 #include "channels.h"
24 #include "inspstring.h"
25 #include "connection.h"
26 #include "hashcomp.h"
27 #include "dns.h"
28 #include "cull_list.h"
29
30 enum ChanStatus {
31         STATUS_OP     = 4,
32         STATUS_HOP    = 2,
33         STATUS_VOICE  = 1,
34         STATUS_NORMAL = 0
35 };
36
37 enum ClassTypes {
38         CC_ALLOW = 0,
39         CC_DENY  = 1
40 };
41
42 /** RFC1459 channel modes
43  *  */
44 enum UserModes {
45         UM_SERVERNOTICE = 's'-65,
46         UM_WALLOPS = 'w'-65,
47         UM_INVISIBLE = 'i'-65,
48         UM_OPERATOR = 'o'-65,
49         UM_SNOMASK = 'n'-65,
50 };
51
52 enum RegistrationState {
53         REG_NONE = 0,           /* Has sent nothing */
54         REG_USER = 1,           /* Has sent USER */
55         REG_NICK = 2,           /* Has sent NICK */
56         REG_NICKUSER = 3,       /* Bitwise combination of REG_NICK and REG_USER */
57         REG_ALL = 7             /* REG_NICKUSER plus next bit along */
58 };
59
60 /** Holds a channel name to which a user has been invited.
61  */
62 class Invited : public classbase
63 {
64  public:
65          irc::string channel;
66 };
67
68
69
70 class InspIRCd;
71
72 /** Derived from Resolver, and performs user forward/reverse lookups.
73  */
74 class UserResolver : public Resolver
75 {
76  private:
77         /** User this class is 'attached' to.
78          */
79         userrec* bound_user;
80         int bound_fd;
81         bool fwd;
82  public:
83         UserResolver(InspIRCd* Instance, userrec* user, std::string to_resolve, bool forward);
84
85         void OnLookupComplete(const std::string &result);
86         void OnError(ResolverError e, const std::string &errormessage);
87 };
88
89
90 /** Holds information relevent to &lt;connect allow&gt; and &lt;connect deny&gt; tags in the config file.
91  */
92 class ConnectClass : public classbase
93 {
94  public:
95         /** Type of line, either CC_ALLOW or CC_DENY
96          */
97         char type;
98         /** Max time to register the connection in seconds
99          */
100         int registration_timeout;
101         /** Number of lines in buffer before excess flood is triggered
102          */
103         int flood;
104         /** Host mask for this line
105          */
106         std::string host;
107         /** Number of seconds between pings for this line
108          */
109         int pingtime;
110         /** (Optional) Password for this line
111          */
112         std::string pass;
113
114         /** Threshold value for flood disconnect
115          */
116         int threshold;
117
118         /** Maximum size of sendq for users in this class (bytes)
119          */
120         long sendqmax;
121
122         /** Maximum size of recvq for users in this class (bytes)
123          */
124         long recvqmax;
125
126         /** Local max when connecting by this connection class
127          */
128         long maxlocal;
129
130         /** Global max when connecting by this connection class
131          */
132         long maxglobal;
133         
134         ConnectClass() : registration_timeout(0), flood(0), host(""), pingtime(0), pass(""), threshold(0), sendqmax(0), recvqmax(0)
135         {
136         }
137 };
138
139 /** Holds a complete list of all channels to which a user has been invited and has not yet joined.
140  */
141 typedef std::vector<Invited> InvitedList;
142
143
144
145 /** Holds a complete list of all allow and deny tags from the configuration file (connection classes)
146  */
147 typedef std::vector<ConnectClass> ClassVector;
148
149 /** Typedef for the list of user-channel records for a user
150  */
151 typedef std::vector<ucrec*> UserChanList;
152
153 /** Holds all information about a user
154  * This class stores all information about a user connected to the irc server. Everything about a
155  * connection is stored here primarily, from the user's socket ID (file descriptor) through to the
156  * user's nickname and hostname. Use the FindNick method of the InspIRCd class to locate a specific user
157  * by nickname, or the FindDescriptor method of the InspIRCd class to find a specific user by their
158  * file descriptor value.
159  */
160 class userrec : public connection
161 {
162  private:
163         /** Pointer to creator.
164          * This is required to make use of core functions
165          * from within the userrec class.
166          */
167         InspIRCd* ServerInstance;
168
169         /** A list of channels the user has a pending invite to.
170          * Upon INVITE channels are added, and upon JOIN, the
171          * channels are removed from this list.
172          */
173         InvitedList invites;
174  public:
175         /** Resolvers for looking up this users IP address
176          * This will occur if and when res_reverse completes.
177          * When this class completes its lookup, userrec::dns_done
178          * will be set from false to true.
179          */
180         UserResolver* res_forward;
181
182         /** Resolvers for looking up this users hostname
183          * This is instantiated by userrec::StartDNSLookup(),
184          * and on success, instantiates userrec::res_reverse.
185          */
186         UserResolver* res_reverse;
187
188         /** Stored reverse lookup from res_forward
189          */
190         std::string stored_host;
191
192         /** Starts a DNS lookup of the user's IP.
193          * This will cause two UserResolver classes to be instantiated.
194          * When complete, these objects set userrec::dns_done to true.
195          */
196         void StartDNSLookup();
197         
198         /** The users nickname.
199          * An invalid nickname indicates an unregistered connection prior to the NICK command.
200          * Use InspIRCd::IsNick() to validate nicknames.
201          */
202         char nick[NICKMAX];
203         
204         /** The users ident reply.
205          * Two characters are added to the user-defined limit to compensate for the tilde etc.
206          */
207         char ident[IDENTMAX+2];
208
209         /** The host displayed to non-opers (used for cloaking etc).
210          * This usually matches the value of userrec::host.
211          */
212         char dhost[65];
213         
214         /** The users full name (GECOS).
215          */
216         char fullname[MAXGECOS+1];
217         
218         /** The user's mode list.
219          * This is NOT a null terminated string! In the 1.1 version of InspIRCd
220          * this is an array of values in a similar way to channel modes.
221          * A value of 1 in field (modeletter-65) indicates that the mode is
222          * set, for example, to work out if mode +s is set, we  check the field
223          * userrec::modes['s'-65] != 0.
224          * The following RFC characters o, w, s, i have constants defined via an
225          * enum, such as UM_SERVERNOTICE and UM_OPETATOR.
226          */
227         char modes[64];
228
229         /** What snomasks are set on this user.
230          * This functions the same as the above modes.
231          */
232         char snomasks[64];
233
234         /** Channels this user is on, and the permissions they have there
235          */
236         UserChanList chans;
237         
238         /** The server the user is connected to.
239          */
240         const char* server;
241         
242         /** The user's away message.
243          * If this string is empty, the user is not marked as away.
244          */
245         char awaymsg[MAXAWAY+1];
246         
247         /** Number of lines the user can place into the buffer
248          * (up to the global NetBufferSize bytes) before they
249          * are disconnected for excess flood
250          */
251         int flood;
252         
253         /** Number of seconds this user is given to send USER/NICK
254          * If they do not send their details in this time limit they
255          * will be disconnected
256          */
257         unsigned int timeout;
258         
259         /** The oper type they logged in as, if they are an oper.
260          * This is used to check permissions in operclasses, so that
261          * we can say 'yay' or 'nay' to any commands they issue.
262          * The value of this is the value of a valid 'type name=' tag.
263          */
264         char oper[NICKMAX];
265
266         /** True when DNS lookups are completed.
267          * The UserResolver classes res_forward and res_reverse will
268          * set this value once they complete.
269          */
270         bool dns_done;
271
272         /** Number of seconds between PINGs for this user (set from &lt;connect:allow&gt; tag
273          */
274         unsigned int pingmax;
275
276         /** Password specified by the user when they registered.
277          * This is stored even if the <connect> block doesnt need a password, so that
278          * modules may check it.
279          */
280         char password[64];
281
282         /** User's receive queue.
283          * Lines from the IRCd awaiting processing are stored here.
284          * Upgraded april 2005, old system a bit hairy.
285          */
286         std::string recvq;
287
288         /** User's send queue.
289          * Lines waiting to be sent are stored here until their buffer is flushed.
290          */
291         std::string sendq;
292
293         /** Flood counters - lines received
294          */
295         int lines_in;
296
297         /** Flood counters - time lines_in is due to be reset
298          */
299         time_t reset_due;
300
301         /** Flood counters - Highest value lines_in may reach before the user gets disconnected
302          */
303         long threshold;
304
305         /** IPV4 or IPV6 ip address
306          */
307         sockaddr* ip;
308
309         /** Initialize the clients sockaddr
310          * @param protocol_family The protocol family of the IP address, AF_INET or AF_INET6
311          * @param ip A human-readable IP address for this user matching the protcol_family
312          * @param port The port number of this user or zero for a remote user
313          */
314         void SetSockAddr(int protocol_family, const char* ip, int port);
315
316         /** Get port number from sockaddr
317          * @return The port number of this user.
318          */
319         int GetPort();
320
321         /** Get protocol family from sockaddr
322          * @return The protocol family of this user, either AF_INET or AF_INET6
323          */
324         int GetProtocolFamily();
325
326         /** Get IP string from sockaddr, using static internal buffer
327          * @return The IP string
328          */
329         const char* GetIPString();
330
331         /** Get IP string from sockaddr, using caller-specified buffer
332          * @param buf A buffer to use
333          * @return The IP string
334          */
335         const char* GetIPString(char* buf);
336
337         /* Write error string
338          */
339         std::string WriteError;
340
341         /** Maximum size this user's sendq can become
342          */
343         long sendqmax;
344
345         /** Maximum size this user's recvq can become
346          */
347         long recvqmax;
348
349         /** Default constructor
350          * @throw Nothing at present
351          */
352         userrec(InspIRCd* Instance);
353         
354         /** Returns the full displayed host of the user
355          * This member function returns the hostname of the user as seen by other users
356          * on the server, in nick!ident&at;host form.
357          * @return The full masked host of the user
358          */
359         virtual char* GetFullHost();
360         
361         /** Returns the full real host of the user
362          * This member function returns the hostname of the user as seen by other users
363          * on the server, in nick!ident&at;host form. If any form of hostname cloaking is in operation,
364          * e.g. through a module, then this method will ignore it and return the true hostname.
365          * @return The full real host of the user
366          */
367         virtual char* GetFullRealHost();
368
369         /** Create a displayable mode string for this users snomasks
370          * @return The notice mask character sequence
371          */
372         const char* FormatNoticeMasks();
373
374         /** Process a snomask modifier string, e.g. +abc-de
375          * @param sm A sequence of notice mask characters
376          * @return The cleaned mode sequence which can be output,
377          * e.g. in the above example if masks c and e are not
378          * valid, this function will return +ab-d
379          */
380         std::string userrec::ProcessNoticeMasks(const char *sm);
381
382         /** Returns true if a notice mask is set
383          * @param sm A notice mask character to check
384          * @return True if the notice mask is set
385          */
386         bool IsNoticeMaskSet(unsigned char sm);
387
388         /** Changed a specific notice mask value
389          * @param sm The server notice mask to change
390          * @param value An on/off value for this mask
391          */
392         void SetNoticeMask(unsigned char sm, bool value);
393
394         /** Create a displayable mode string for this users umodes
395          * @param The mode string
396          */
397         const char* FormatModes();
398
399         /** Returns true if a specific mode is set
400          * @param m The user mode
401          * @return True if the mode is set
402          */
403         bool IsModeSet(unsigned char m);
404
405         /** Set a specific usermode to on or off
406          * @param m The user mode
407          * @param value On or off setting of the mode
408          */
409         void SetMode(unsigned char m, bool value);
410         
411         /** Returns true if a user is invited to a channel.
412          * @param channel A channel name to look up
413          * @return True if the user is invited to the given channel
414          */
415         virtual bool IsInvited(irc::string &channel);
416         
417         /** Adds a channel to a users invite list (invites them to a channel)
418          * @param channel A channel name to add
419          */
420         virtual void InviteTo(irc::string &channel);
421         
422         /** Removes a channel from a users invite list.
423          * This member function is called on successfully joining an invite only channel
424          * to which the user has previously been invited, to clear the invitation.
425          * @param channel The channel to remove the invite to
426          */
427         virtual void RemoveInvite(irc::string &channel);
428         
429         /** Returns true or false for if a user can execute a privilaged oper command.
430          * This is done by looking up their oper type from userrec::oper, then referencing
431          * this to their oper classes and checking the commands they can execute.
432          * @param command A command (should be all CAPS)
433          * @return True if this user can execute the command
434          */
435         bool HasPermission(const std::string &command);
436
437         /** Calls read() to read some data for this user using their fd.
438          * @param buffer The buffer to read into
439          * @param size The size of data to read
440          * @return The number of bytes read, or -1 if an error occured.
441          */
442         int ReadData(void* buffer, size_t size);
443
444         /** This method adds data to the read buffer of the user.
445          * The buffer can grow to any size within limits of the available memory,
446          * managed by the size of a std::string, however if any individual line in
447          * the buffer grows over 600 bytes in length (which is 88 chars over the
448          * RFC-specified limit per line) then the method will return false and the
449          * text will not be inserted.
450          * @param a The string to add to the users read buffer
451          * @return True if the string was successfully added to the read buffer
452          */
453         bool AddBuffer(std::string a);
454
455         /** This method returns true if the buffer contains at least one carriage return
456          * character (e.g. one complete line may be read)
457          * @return True if there is at least one complete line in the users buffer
458          */
459         bool BufferIsReady();
460
461         /** This function clears the entire buffer by setting it to an empty string.
462          */
463         void ClearBuffer();
464
465         /** This method returns the first available string at the tail end of the buffer
466          * and advances the tail end of the buffer past the string. This means it is
467          * a one way operation in a similar way to strtok(), and multiple calls return
468          * multiple lines if they are available. The results of this function if there
469          * are no lines to be read are unknown, always use BufferIsReady() to check if
470          * it is ok to read the buffer before calling GetBuffer().
471          * @return The string at the tail end of this users buffer
472          */
473         std::string GetBuffer();
474
475         /** Sets the write error for a connection. This is done because the actual disconnect
476          * of a client may occur at an inopportune time such as half way through /LIST output.
477          * The WriteErrors of clients are checked at a more ideal time (in the mainloop) and
478          * errored clients purged.
479          * @param error The error string to set.
480          */
481         void SetWriteError(const std::string &error);
482
483         /** Returns the write error which last occured on this connection or an empty string
484          * if none occured.
485          * @return The error string which has occured for this user
486          */
487         const char* GetWriteError();
488
489         /** Adds to the user's write buffer.
490          * You may add any amount of text up to this users sendq value, if you exceed the
491          * sendq value, SetWriteError() will be called to set the users error string to
492          * "SendQ exceeded", and further buffer adds will be dropped.
493          * @param data The data to add to the write buffer
494          */
495         void AddWriteBuf(const std::string &data);
496
497         /** Flushes as much of the user's buffer to the file descriptor as possible.
498          * This function may not always flush the entire buffer, rather instead as much of it
499          * as it possibly can. If the send() call fails to send the entire buffer, the buffer
500          * position is advanced forwards and the rest of the data sent at the next call to
501          * this method.
502          */
503         void FlushWriteBuf();
504
505         /** Returns the list of channels this user has been invited to but has not yet joined.
506          * @return A list of channels the user is invited to
507          */
508         InvitedList* GetInviteList();
509
510         /** Creates a wildcard host.
511          * Takes a buffer to use and fills the given buffer with the host in the format *!*@hostname
512          * @return The wildcarded hostname in *!*@host form
513          */
514         char* MakeWildHost();
515
516         /** Creates a host.
517          * Takes a buffer to use and fills the given buffer with the host in the format nick!user@host
518          * @param Buffer to fill with host information
519          */
520         void MakeHost(char* nhost);
521
522         /** Shuts down and closes the user's socket
523          * This will not cause the user to be deleted. Use InspIRCd::QuitUser for this,
524          * which will call CloseSocket() for you.
525          */
526         void CloseSocket();
527
528         /** Disconnect a user gracefully
529          * @param user The user to remove
530          * @param r The quit reason
531          * @return Although this function has no return type, on exit the user provided will no longer exist.
532          */
533         static void QuitUser(InspIRCd* Instance, userrec *user, const std::string &r);
534
535         /** Add the user to WHOWAS system
536          */
537         void AddToWhoWas();
538
539         /** Oper up the user using the given opertype.
540          * This will also give the +o usermode.
541          * @param opertype The oper type to oper as
542          */
543         void Oper(const std::string &opertype);
544
545         /** Use this method to fully connect a user.
546          * This will send the message of the day, check G/K/E lines, etc.
547          * @param Goners If the user is disconnected by this method call, the
548          * value of 'this' will be pushed onto this CullList. This is used by
549          * the core to connect many users in rapid succession without invalidating
550          * iterators.
551          * @param Goners a CullList to use for failed connections
552          */
553         void FullConnect(CullList* Goners);
554
555         /** Change this users hash key to a new string.
556          * You should not call this function directly. It is used by the core
557          * to update the users hash entry on a nickchange.
558          * @param New new user_hash key
559          * @return Pointer to userrec in hash (usually 'this')
560          */
561         userrec* UpdateNickHash(const char* New);
562
563         /** Force a nickname change.
564          * If the nickname change fails (for example, because the nick in question
565          * already exists) this function will return false, and you must then either
566          * output an error message, or quit the user for nickname collision.
567          * @param newnick The nickname to change to
568          * @return True if the nickchange was successful.
569          */
570         bool ForceNickChange(const char* newnick);
571
572         /** Add a client to the system.
573          * This will create a new userrec, insert it into the user_hash,
574          * initialize it as not yet registered, and add it to the socket engine.
575          * @param Instance a pointer to the server instance
576          * @param socket The socket id (file descriptor) this user is on
577          * @param port The port number this user connected on
578          * @param iscached This variable is reserved for future use
579          * @param ip The IP address of the user
580          * @return This function has no return value, but a call to AddClient may remove the user.
581          */
582         static void AddClient(InspIRCd* Instance, int socket, int port, bool iscached, insp_inaddr ip);
583
584         /** Oper down.
585          * This will clear the +o usermode and unset the user's oper type
586          */
587         void UnOper();
588
589         /** Return the number of global clones of this user
590          * @return The global clone count of this user
591          */
592         long GlobalCloneCount();
593
594         /** Return the number of local clones of this user
595          * @return The local clone count of this user
596          */
597         long LocalCloneCount();
598
599         /** Write text to this user, appending CR/LF.
600          * @param text A std::string to send to the user
601          */
602         void Write(std::string text);
603
604         /** Write text to this user, appending CR/LF.
605          * @param text The format string for text to send to the user
606          * @param ... POD-type format arguments
607          */
608         void Write(const char *text, ...);
609
610         /** Write text to this user, appending CR/LF and prepending :server.name
611          * @param text A std::string to send to the user
612          */
613         void WriteServ(const std::string& text);
614
615         /** Write text to this user, appending CR/LF and prepending :server.name
616          * @param text The format string for text to send to the user
617          * @param ... POD-type format arguments
618          */
619         void WriteServ(const char* text, ...);
620
621         /** Write text to this user, appending CR/LF and prepending :nick!user@host of the user provided in the first parameter.
622          * @param user The user to prepend the :nick!user@host of
623          * @param text A std::string to send to the user
624          */
625         void WriteFrom(userrec *user, const std::string &text);
626
627         /** Write text to this user, appending CR/LF and prepending :nick!user@host of the user provided in the first parameter.
628          * @param user The user to prepend the :nick!user@host of
629          * @param text The format string for text to send to the user
630          * @param ... POD-type format arguments
631          */
632         void WriteFrom(userrec *user, const char* text, ...);
633
634         /** Write text to the user provided in the first parameter, appending CR/LF, and prepending THIS user's :nick!user@host.
635          * @param dest The user to route the message to
636          * @param text A std::string to send to the user
637          */
638         void WriteTo(userrec *dest, const std::string &data);
639
640         /** Write text to the user provided in the first parameter, appending CR/LF, and prepending THIS user's :nick!user@host.
641          * @param dest The user to route the message to
642          * @param text The format string for text to send to the user
643          * @param ... POD-type format arguments
644          */
645         void WriteTo(userrec *dest, const char *data, ...);
646
647         /** Write to all users that can see this user (including this user in the list), appending CR/LF
648          * @param text A std::string to send to the users
649          */
650         void WriteCommon(const std::string &text);
651
652         /** Write to all users that can see this user (including this user in the list), appending CR/LF
653          * @param text The format string for text to send to the users
654          * @param ... POD-type format arguments
655          */
656         void WriteCommon(const char* text, ...);
657
658         /** Write to all users that can see this user (not including this user in the list), appending CR/LF
659          * @param text The format string for text to send to the users
660          * @param ... POD-type format arguments
661          */
662         void WriteCommonExcept(const char* text, ...);
663
664         /** Write to all users that can see this user (not including this user in the list), appending CR/LF
665          * @param text A std::string to send to the users
666          */
667         void WriteCommonExcept(const std::string &text);
668
669         /** Write a WALLOPS message from this user to all local opers.
670          * If this user is not opered, the function will return without doing anything.
671          * @param text The format string to send in the WALLOPS message
672          * @param ... Format arguments
673          */
674         void WriteWallOps(const char* text, ...);
675
676         /** Write a WALLOPS message from this user to all local opers.
677          * If this user is not opered, the function will return without doing anything.
678          * @param text The text to send in the WALLOPS message
679          */
680         void WriteWallOps(const std::string &text);
681
682         /** Return true if the user shares at least one channel with another user
683          * @param other The other user to compare the channel list against
684          * @return True if the given user shares at least one channel with this user
685          */
686         bool SharesChannelWith(userrec *other);
687
688         /** Change the displayed host of a user.
689          * ALWAYS use this function, rather than writing userrec::dhost directly,
690          * as this triggers module events allowing the change to be syncronized to
691          * remote servers. This will also emulate a QUIT and rejoin (where configured)
692          * before setting their host field.
693          * @param host The new hostname to set
694          * @return True if the change succeeded, false if it didn't
695          */
696         bool ChangeDisplayedHost(const char* host);
697
698         /** Change the ident (username) of a user.
699          * ALWAYS use this function, rather than writing userrec::ident directly,
700          * as this correctly causes the user to seem to quit (where configured)
701          * before setting their ident field.
702          * @param host The new ident to set
703          * @return True if the change succeeded, false if it didn't
704          */
705         bool ChangeIdent(const char* newident);
706
707         /** Change a users realname field.
708          * ALWAYS use this function, rather than writing userrec::fullname directly,
709          * as this triggers module events allowing the change to be syncronized to
710          * remote servers.
711          * @param gecos The user's new realname
712          * @return True if the change succeeded, false if otherwise
713          */
714         bool ChangeName(const char* gecos);
715
716         /** Return the total number of channels this user is on.
717          * @return The number of channels the user is on
718          */
719         int CountChannels();
720
721         /** Send a notice to all local users from this user
722          * @param text The text format string to send
723          * @param ... Format arguments
724          */
725         void NoticeAll(char* text, ...);
726
727         /** Compile a channel list for this user, and send it to the user 'source'
728          * Used internally by WHOIS
729          * @param The user to send the channel list to if it is not too long
730          * @return This user's channel list
731          */
732         std::string ChannelList(userrec* source);
733
734         /** Split the channel list in cl which came from dest, and spool it to this user
735          * Used internally by WHOIS
736          * @param dest The user the original channel list came from
737          * @param cl The  channel list as a string obtained from userrec::ChannelList()
738          */
739         void SplitChanList(userrec* dest, const std::string &cl);
740
741         /** Remove this user from all channels they are on, and delete any that are now empty.
742          * This is used by QUIT, and will not send part messages!
743          */
744         void PurgeEmptyChannels();
745
746         /** Get the connect class which matches this user's host or IP address
747          * @return A reference to this user's connect class
748          */
749         ConnectClass& GetClass();
750
751         /** Show the message of the day to this user
752          */
753         void ShowMOTD();
754
755         /** Show the server RULES file to this user
756          */
757         void ShowRULES();
758
759         /** Handle socket event.
760          * From EventHandler class.
761          */
762         void HandleEvent(EventType et);
763
764         /** Default destructor
765          */
766         virtual ~userrec();
767 };
768
769
770 namespace irc
771 {
772         /** Holds whowas related functions and classes
773          */
774         namespace whowas
775         {
776
777                 /** Used to hold WHOWAS information
778                  */
779                 class WhoWasGroup : public classbase
780                 {
781                  public:
782                         /** Real host
783                          */
784                         char* host;
785                         /** Displayed host
786                          */
787                         char* dhost;
788                         /** Ident
789                          */
790                         char* ident;
791                         /** Server name
792                          */
793                         const char* server;
794                         /** Fullname (GECOS)
795                          */
796                         char* gecos;
797                         /** Signon time
798                          */
799                         time_t signon;
800         
801                         /** Initialize this WhoQasFroup with a user
802                          */
803                         WhoWasGroup(userrec* user);
804                         /** Destructor
805                          */
806                         ~WhoWasGroup();
807                 };
808
809                 /** A group of users related by nickname
810                  */
811                 typedef std::deque<WhoWasGroup*> whowas_set;
812
813                 /** Sets of users in the whowas system
814                  */
815                 typedef std::map<irc::string,whowas_set*> whowas_users;
816
817                 /** Called every hour by the core to remove expired entries
818                  */
819                 void MaintainWhoWas(time_t TIME);
820         };
821 };
822
823 /* Configuration callbacks */
824 class ServerConfig;
825 bool InitTypes(ServerConfig* conf, const char* tag);
826 bool InitClasses(ServerConfig* conf, const char* tag);
827 bool DoType(ServerConfig* conf, const char* tag, char** entries, void** values, int* types);
828 bool DoClass(ServerConfig* conf, const char* tag, char** entries, void** values, int* types);
829 bool DoneClassesAndTypes(ServerConfig* conf, const char* tag);
830
831 #endif