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