1 |
/** |
2 |
* users.h: Data structures for connected clients. |
3 |
* |
4 |
* Copyright © 2007 Pippijn van Steenhoven / The Ermyth Team |
5 |
* Rights to this code are as documented in COPYING. |
6 |
* |
7 |
* |
8 |
* Portions of this file were derived from sources bearing the following license: |
9 |
* Copyright © 2005 William Pitcock, et al. |
10 |
* Rights to this code are as documented in doc/pod/license.pod. |
11 |
* |
12 |
* $Id: users.h,v 1.5 2007-09-16 18:54:42 pippijn Exp $ |
13 |
*/ |
14 |
|
15 |
#ifndef USERS_H |
16 |
#define USERS_H |
17 |
|
18 |
#include <ermyth/callback.h> |
19 |
#include <util/predicates.h> |
20 |
|
21 |
class user_t : public zero_initialised |
22 |
{ |
23 |
struct callbacks |
24 |
{ |
25 |
functor::callback3<char const * const /* uid */, char const /* mode */, char const * const /* buf */> sasl_input; |
26 |
functor::callback1<user_t *> add; |
27 |
functor::callback1<user_t *> away; |
28 |
functor::callback3<sourceinfo_t *, char const * const /* account */, char const * const /* email */, bool /* return value */, functor::combiner::boolean::strongtrue> can_register; |
29 |
functor::callback1<user_t *> remove; |
30 |
functor::callback1<user_t *> identify; |
31 |
functor::callback1<user_t *> oper; |
32 |
functor::callback1<user_t *> deoper; |
33 |
}; |
34 |
|
35 |
public: |
36 |
typedef std::pair<char const * const, user_t *> pair_type; |
37 |
typedef std::map<char const * const, user_t *, irccase_lt> map_type; |
38 |
typedef std::vector<user_t *> vector_type; |
39 |
static map_type map; |
40 |
|
41 |
unsigned mu_index; // index used in myuser_t::login_vector |
42 |
|
43 |
char nick[NICKLEN]; |
44 |
char user[USERLEN]; |
45 |
char host[HOSTLEN]; /* Real host */ |
46 |
char gecos[GECOSLEN]; |
47 |
char vhost[HOSTLEN]; /* Visible host */ |
48 |
char uid[IDLEN]; /* Used for TS6, P10, IRCNet ircd. */ |
49 |
char ip[HOSTIPLEN]; |
50 |
|
51 |
list_t channels; |
52 |
|
53 |
server_t *server; |
54 |
myuser_t *myuser; |
55 |
|
56 |
unsigned int offenses; |
57 |
unsigned int msgs; |
58 |
time_t lastmsg; |
59 |
|
60 |
unsigned int flags; |
61 |
|
62 |
time_t ts; |
63 |
|
64 |
static callbacks callback; |
65 |
}; |
66 |
|
67 |
#define UF_AWAY 0x00000002 |
68 |
#define UF_INVIS 0x00000004 |
69 |
#define UF_IRCOP 0x00000010 |
70 |
#define UF_ADMIN 0x00000020 |
71 |
#define UF_SEENINFO 0x00000080 |
72 |
#define UF_HIDEHOSTREQ 0x00000200 /* host hiding requested */ |
73 |
|
74 |
#define CLIENT_NAME(user) ((user)->uid[0] ? (user)->uid : (user)->nick) |
75 |
|
76 |
/* function.c */ |
77 |
E bool is_ircop (user_t *user); |
78 |
E bool is_admin (user_t *user); |
79 |
E bool is_internal_client (user_t *user); |
80 |
|
81 |
/* users.C */ |
82 |
E void init_users (void); |
83 |
|
84 |
E user_t *user_add (char const * const nick, char const * const user, char const * const host, char const * const vhost, char const * const ip, char const * const uid, char const * const gecos, server_t *server, time_t ts); |
85 |
E void user_delete (user_t *u); |
86 |
E user_t *user_find (char const * const nick); |
87 |
E user_t *user_find_named (char const * const nick); |
88 |
E void user_changeuid (user_t *u, char const * const uid); |
89 |
E void user_changenick (user_t *u, char const * const nick, time_t ts); |
90 |
E void user_mode (user_t *user, char const * const modes); |
91 |
|
92 |
/* uid.c */ |
93 |
E void init_uid (void); |
94 |
E char *uid_get (void); |
95 |
|
96 |
#endif |