]> jfr.im git - irc/evilnet/x3.git/blame - src/nickserv.h
Some minor cleanup of previous commits
[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 *
d0f04f71 6 * x3 is free software; you can redistribute it and/or modify
d76ed9a9 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
7fdb7639 41#define HI_FLAG_AUTOHIDE 0x00000400
d76ed9a9 42/* Flag characters for the above. First char is LSB, etc. */
7fdb7639 43#define HANDLE_FLAGS "SphgscfnHbx"
d76ed9a9 44
45/* HI_STYLE_* go into handle_info.userlist_style */
338a82b5 46#define HI_STYLE_NORMAL 'n'
47#define HI_STYLE_CLEAN 'c'
48#define HI_STYLE_ADVANCED 'a'
d76ed9a9 49
50#define HI_DEFAULT_FLAGS (HI_FLAG_MIRC_COLOR)
338a82b5 51
52/* This is overridden by conf file */
53#define HI_DEFAULT_STYLE HI_STYLE_NORMAL
d76ed9a9 54
55#define HANDLE_FLAGGED(hi, tok) ((hi)->flags & HI_FLAG_##tok)
56#define HANDLE_SET_FLAG(hi, tok) ((hi)->flags |= HI_FLAG_##tok)
57#define HANDLE_TOGGLE_FLAG(hi, tok) ((hi)->flags ^= HI_FLAG_##tok)
58#define HANDLE_CLEAR_FLAG(hi, tok) ((hi)->flags &= ~HI_FLAG_##tok)
59
60#define IsSupportHelper(user) (user->handle_info && HANDLE_FLAGGED(user->handle_info, SUPPORT_HELPER))
61#define IsNetworkHelper(user) (user->handle_info && HANDLE_FLAGGED(user->handle_info, NETWORK_HELPER))
62#define IsHelper(user) (IsSupportHelper(user) || IsNetworkHelper(user))
63#define IsHelping(user) (user->handle_info && HANDLE_FLAGGED(user->handle_info, HELPING))
64#define IsStaff(user) (IsOper(user) || IsSupportHelper(user) || IsNetworkHelper(user))
65#define IsBot(user) (user->handle_info && HANDLE_FLAGGED(user->handle_info, BOT))
66
67enum cookie_type {
68 ACTIVATION,
69 PASSWORD_CHANGE,
70 EMAIL_CHANGE,
71 ALLOWAUTH
72};
73
74struct handle_cookie {
75 struct handle_info *hi;
76 char *data;
77 enum cookie_type type;
78 time_t expires;
79 char cookie[COOKIELEN+1];
80};
81
2362161a 82struct handle_note {
83 char setter[NICKSERV_HANDLE_LEN+1];
84 time_t date;
85 char note[1];
86};
87
d76ed9a9 88struct handle_info {
89 struct nick_info *nicks;
90 struct string_list *masks;
91 struct userNode *users;
92 struct userData *channels;
93 struct handle_cookie *cookie;
2362161a 94 struct handle_note *note;
d76ed9a9 95 struct language *language;
96 char *email_addr;
97 char *epithet;
98 char *infoline;
99 char *handle;
100 char *fakehost;
101#ifdef WITH_PROTOCOL_BAHAMUT
102 unsigned long id;
103#endif
104 time_t registered;
105 time_t lastseen;
106 unsigned short flags;
107 unsigned short opserv_level;
108 unsigned short screen_width;
109 unsigned short table_width;
110 unsigned char userlist_style;
111 unsigned char announcements;
112 unsigned char maxlogins;
113 char passwd[MD5_CRYPT_LENGTH+1];
114 char last_quit_host[USERLEN+HOSTLEN+2];
115};
116
117struct nick_info {
118 struct handle_info *owner;
119 struct nick_info *next; /* next nick owned by same handle */
120 char nick[NICKLEN+1];
121};
122
123struct handle_info_list {
124 unsigned int used, size;
125 struct handle_info **list;
126 char *tag; /* e.g. email address */
127};
128
129extern const char *handle_flags;
130
131void init_nickserv(const char *nick);
132struct handle_info *get_handle_info(const char *handle);
133struct handle_info *smart_get_handle_info(struct userNode *service, struct userNode *user, const char *name);
134int oper_try_set_access(struct userNode *user, struct userNode *bot, struct handle_info *target, unsigned int new_level);
135int oper_outranks(struct userNode *user, struct handle_info *hi);
136struct nick_info *get_nick_info(const char *nick);
137struct modeNode *find_handle_in_channel(struct chanNode *channel, struct handle_info *handle, struct userNode *except);
138int nickserv_modify_handle_flags(struct userNode *user, struct userNode *bot, const char *str, unsigned long *add, unsigned long *remove);
139int oper_has_access(struct userNode *user, struct userNode *bot, unsigned int min_level, unsigned int quiet);
140void nickserv_show_oper_accounts(struct userNode *user, struct svccmd *cmd);
141
b21e2cfe 142struct handle_info *loc_auth(char *handle, char *password);
d9cd0e9d 143
ec311f39 144typedef void (*user_mode_func_t)(struct userNode *user, const char *mode_change);
145void reg_user_mode_func(user_mode_func_t func);
146typedef void (*channel_mode_func_t)(struct userNode *who, struct chanNode *channel, char **mode, unsigned int argc);
147void reg_channel_mode_func(channel_mode_func_t func);
148
d76ed9a9 149/* auth_funcs are called when a user gets a new handle_info. They are
150 * called *after* user->handle_info has been updated. */
151typedef void (*auth_func_t)(struct userNode *user, struct handle_info *old_handle);
152void reg_auth_func(auth_func_t func);
153
154/* Called just after a handle is renamed. */
155typedef void (*handle_rename_func_t)(struct handle_info *handle, const char *old_handle);
156void reg_handle_rename_func(handle_rename_func_t func);
157
158/* unreg_funcs are called right before a handle is unregistered.
159 * `user' is the person who caused the handle to be unregistered (either a
160 * client authed to the handle, or an oper). */
161typedef void (*unreg_func_t)(struct userNode *user, struct handle_info *handle);
162void reg_unreg_func(unreg_func_t func);
163
164/* Called just before a handle is merged */
165typedef void (*handle_merge_func_t)(struct userNode *user, struct handle_info *handle_to, struct handle_info *handle_from);
166void reg_handle_merge_func(handle_merge_func_t);
167
168/* Called after an allowauth. handle is null if allowauth authorization was
169 * removed */
170typedef void (*allowauth_func_t)(struct userNode *user, struct userNode *target, struct handle_info *handle);
171void reg_allowauth_func(allowauth_func_t func);
172
173/* Called when an auth attempt fails because of a bad password */
174typedef void (*failpw_func_t)(struct userNode *user, struct handle_info *handle);
175void reg_failpw_func(failpw_func_t func);
176
3fdd6a74 177void send_func_list(struct userNode *user);
178
d76ed9a9 179#endif