]> jfr.im git - irc/evilnet/x3.git/blame - src/nickserv.h
Improved resync to work with automode
[irc/evilnet/x3.git] / src / nickserv.h
CommitLineData
d76ed9a9 1/* nickserv.h - Nick/authentiction service
2 * Copyright 2000-2004 srvx Development Team
3 *
83ff05c3 4 * This file is part of x3.
d76ed9a9 5 *
6 * srvx is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with srvx; if not, write to the Free Software Foundation,
18 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
19 */
20
21#ifndef _nickserv_h
22#define _nickserv_h
23
24#include "hash.h" /* for NICKLEN, etc., and common.h */
25struct svccmd;
26
a32da4c7 27#define NICKSERV_HANDLE_LEN ACCOUNTLEN
d76ed9a9 28#define COOKIELEN 10
29
30/* HI_FLAG_* go into handle_info.flags */
31#define HI_FLAG_OPER_SUSPENDED 0x00000001
32#define HI_FLAG_USE_PRIVMSG 0x00000002
33#define HI_FLAG_SUPPORT_HELPER 0x00000004
34#define HI_FLAG_HELPING 0x00000008
35#define HI_FLAG_SUSPENDED 0x00000010
36#define HI_FLAG_MIRC_COLOR 0x00000020
37#define HI_FLAG_FROZEN 0x00000040
38#define HI_FLAG_NODELETE 0x00000080
39#define HI_FLAG_NETWORK_HELPER 0x00000100
40#define HI_FLAG_BOT 0x00000200
41/* Flag characters for the above. First char is LSB, etc. */
42#define HANDLE_FLAGS "SphgscfnHb"
43
44/* HI_STYLE_* go into handle_info.userlist_style */
45#define HI_STYLE_DEF 'd'
46#define HI_STYLE_ZOOT 'Z'
47
48#define HI_DEFAULT_FLAGS (HI_FLAG_MIRC_COLOR)
49#define HI_DEFAULT_STYLE HI_STYLE_DEF
50
51#define HANDLE_FLAGGED(hi, tok) ((hi)->flags & HI_FLAG_##tok)
52#define HANDLE_SET_FLAG(hi, tok) ((hi)->flags |= HI_FLAG_##tok)
53#define HANDLE_TOGGLE_FLAG(hi, tok) ((hi)->flags ^= HI_FLAG_##tok)
54#define HANDLE_CLEAR_FLAG(hi, tok) ((hi)->flags &= ~HI_FLAG_##tok)
55
56#define IsSupportHelper(user) (user->handle_info && HANDLE_FLAGGED(user->handle_info, SUPPORT_HELPER))
57#define IsNetworkHelper(user) (user->handle_info && HANDLE_FLAGGED(user->handle_info, NETWORK_HELPER))
58#define IsHelper(user) (IsSupportHelper(user) || IsNetworkHelper(user))
59#define IsHelping(user) (user->handle_info && HANDLE_FLAGGED(user->handle_info, HELPING))
60#define IsStaff(user) (IsOper(user) || IsSupportHelper(user) || IsNetworkHelper(user))
61#define IsBot(user) (user->handle_info && HANDLE_FLAGGED(user->handle_info, BOT))
62
63enum cookie_type {
64 ACTIVATION,
65 PASSWORD_CHANGE,
66 EMAIL_CHANGE,
67 ALLOWAUTH
68};
69
70struct handle_cookie {
71 struct handle_info *hi;
72 char *data;
73 enum cookie_type type;
74 time_t expires;
75 char cookie[COOKIELEN+1];
76};
77
78struct handle_info {
79 struct nick_info *nicks;
80 struct string_list *masks;
81 struct userNode *users;
82 struct userData *channels;
83 struct handle_cookie *cookie;
84 struct language *language;
85 char *email_addr;
86 char *epithet;
87 char *infoline;
88 char *handle;
89 char *fakehost;
90#ifdef WITH_PROTOCOL_BAHAMUT
91 unsigned long id;
92#endif
93 time_t registered;
94 time_t lastseen;
95 unsigned short flags;
96 unsigned short opserv_level;
97 unsigned short screen_width;
98 unsigned short table_width;
99 unsigned char userlist_style;
100 unsigned char announcements;
101 unsigned char maxlogins;
102 char passwd[MD5_CRYPT_LENGTH+1];
103 char last_quit_host[USERLEN+HOSTLEN+2];
104};
105
106struct nick_info {
107 struct handle_info *owner;
108 struct nick_info *next; /* next nick owned by same handle */
109 char nick[NICKLEN+1];
110};
111
112struct handle_info_list {
113 unsigned int used, size;
114 struct handle_info **list;
115 char *tag; /* e.g. email address */
116};
117
118extern const char *handle_flags;
119
120void init_nickserv(const char *nick);
121struct handle_info *get_handle_info(const char *handle);
122struct handle_info *smart_get_handle_info(struct userNode *service, struct userNode *user, const char *name);
123int oper_try_set_access(struct userNode *user, struct userNode *bot, struct handle_info *target, unsigned int new_level);
124int oper_outranks(struct userNode *user, struct handle_info *hi);
125struct nick_info *get_nick_info(const char *nick);
126struct modeNode *find_handle_in_channel(struct chanNode *channel, struct handle_info *handle, struct userNode *except);
127int nickserv_modify_handle_flags(struct userNode *user, struct userNode *bot, const char *str, unsigned long *add, unsigned long *remove);
128int oper_has_access(struct userNode *user, struct userNode *bot, unsigned int min_level, unsigned int quiet);
129void nickserv_show_oper_accounts(struct userNode *user, struct svccmd *cmd);
130
b21e2cfe 131struct handle_info *loc_auth(char *handle, char *password);
d9cd0e9d 132
d76ed9a9 133/* auth_funcs are called when a user gets a new handle_info. They are
134 * called *after* user->handle_info has been updated. */
135typedef void (*auth_func_t)(struct userNode *user, struct handle_info *old_handle);
136void reg_auth_func(auth_func_t func);
137
138/* Called just after a handle is renamed. */
139typedef void (*handle_rename_func_t)(struct handle_info *handle, const char *old_handle);
140void reg_handle_rename_func(handle_rename_func_t func);
141
142/* unreg_funcs are called right before a handle is unregistered.
143 * `user' is the person who caused the handle to be unregistered (either a
144 * client authed to the handle, or an oper). */
145typedef void (*unreg_func_t)(struct userNode *user, struct handle_info *handle);
146void reg_unreg_func(unreg_func_t func);
147
148/* Called just before a handle is merged */
149typedef void (*handle_merge_func_t)(struct userNode *user, struct handle_info *handle_to, struct handle_info *handle_from);
150void reg_handle_merge_func(handle_merge_func_t);
151
152/* Called after an allowauth. handle is null if allowauth authorization was
153 * removed */
154typedef void (*allowauth_func_t)(struct userNode *user, struct userNode *target, struct handle_info *handle);
155void reg_allowauth_func(allowauth_func_t func);
156
157/* Called when an auth attempt fails because of a bad password */
158typedef void (*failpw_func_t)(struct userNode *user, struct handle_info *handle);
159void reg_failpw_func(failpw_func_t func);
160
161#endif