]> jfr.im git - irc/evilnet/x3.git/blob - src/chanserv.h
Fixed a crash bug.
[irc/evilnet/x3.git] / src / chanserv.h
1 /* chanserv.h - Channel service bot
2 * Copyright 2000-2004 srvx Development Team
3 *
4 * This file is part of x3.
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 _chanserv_h
22 #define _chanserv_h
23
24 #include "nickserv.h"
25
26 enum UL_ALIASES {
27 UL_PEON = 100,
28 UL_HALFOP = 150,
29 UL_OP = 200,
30 UL_MANAGER = 300,
31 UL_PRESENT = UL_MANAGER,
32 UL_COOWNER = 400,
33 UL_OWNER = 500,
34 UL_HELPER = 600,
35 };
36
37 enum levelOption {
38 /* TODO: Does removing values here mess up reading the db files? */
39 // lvlGiveVoice, /* Depreciated */
40 // lvlGiveHalfOps, /* Depreciated */
41 // lvlGiveOps, /* Depreciated */
42 lvlEnfOps,
43 lvlEnfHalfOps,
44 lvlEnfModes,
45 lvlEnfTopic,
46 lvlPubCmd,
47 lvlSetters,
48 // lvlCTCPUsers,
49 lvlUserInfo,
50 lvlInviteMe,
51 lvlTopicSnarf,
52 NUM_LEVEL_OPTIONS
53 };
54
55 enum charOption {
56 chVoice,
57 chProtect,
58 chToys,
59 chTopicRefresh,
60 chCTCPReaction,
61 NUM_CHAR_OPTIONS
62 };
63
64 #define CHANNEL_NODELETE 0x00000001 /* (1 << 0) */
65 #define CHANNEL_SUSPENDED 0x00000002 /* (1 << 1) */
66 #define CHANNEL_INFO_LINES 0x00000004 /* (1 << 2) - DEPRECATED */
67 #define CHANNEL_VOICE_ALL 0x00000008 /* (1 << 3) - DEPRECATED */
68
69 /* No longer used. */ /* (1 << 4) */
70 #define CHANNEL_DYNAMIC_LIMIT 0x00000020 /* (1 << 5) */
71 #define CHANNEL_TOPIC_SNARF 0x00000040 /* (1 << 6) - DEPRECATED */
72 #define CHANNEL_PEON_INVITE 0x00000080 /* (1 << 7) - DEPRECATED */
73 #define CHANNEL_OFFCHANNEL 0x00000100 /* (1 << 8) */
74 #define CHANNEL_HOP_ALL 0x00000200 /* (1 << 9) */
75 /* Flags with values over 0x20000000 or (1 << 29) will not work
76 * because chanData.flags is a 30-bit field.
77 */
78
79 /* how many seconds a pending adduser will wait for a user
80 * to get auth or register
81 */
82 #define ADDUSER_PENDING_EXPIRE 7200 /* 2 hours */
83
84 #define IsProtected(x) ((x)->flags & CHANNEL_NODELETE)
85 #define IsSuspended(x) ((x)->flags & CHANNEL_SUSPENDED)
86 #define IsOffChannel(x) (((x)->flags & CHANNEL_OFFCHANNEL) && (off_channel > 1))
87
88 struct chanData
89 {
90 struct chanNode *channel;
91 struct mod_chanmode modes;
92
93 time_t registered;
94 time_t visited;
95 time_t limitAdjusted;
96 time_t ownerTransfer;
97
98 char *topic;
99 char *greeting;
100 char *user_greeting;
101 char *registrar;
102 char *topic_mask;
103
104 unsigned int flags : 30;
105 unsigned int may_opchan : 1;
106 unsigned int max;
107 unsigned int last_refresh;
108 unsigned short banCount;
109 unsigned short userCount;
110 unsigned short lvlOpts[NUM_LEVEL_OPTIONS];
111 unsigned char chOpts[NUM_CHAR_OPTIONS];
112
113 struct userData *users;
114 struct banData *bans;
115 struct dict *notes;
116 struct suspended *suspended;
117 struct chanData *prev;
118 struct chanData *next;
119 };
120
121 #define USER_NOAUTO_OP 0x00000001 /* OLD; Not used at all.. */
122 #define USER_SUSPENDED 0x00000002
123 #define USER_AUTO_INVITE 0x00000004
124 #define USER_AUTO_OP 0x00000008
125 #define USER_FLAGS_SIZE 15
126 #define USER_FLAGS_DEFAULT USER_AUTO_OP
127
128 #define IsUserAutoOp(USER) ((USER)->flags & USER_AUTO_OP)
129 #define IsUserSuspended(USER) ((USER)->flags & USER_SUSPENDED)
130 #define IsUserAutoInvite(USER) ((USER)->flags & USER_AUTO_INVITE)
131
132 struct userData
133 {
134 struct handle_info *handle;
135 struct chanData *channel;
136
137 char *info;
138 time_t seen;
139 unsigned short access;
140 unsigned int present : 1;
141 unsigned int flags : USER_FLAGS_SIZE;
142
143 /* linked list of userDatas for a chanData */
144 struct userData *prev;
145 struct userData *next;
146 /* linked list of userDatas for a handle_info */
147 struct userData *u_prev;
148 struct userData *u_next;
149 };
150
151 struct adduserPending
152 {
153 struct chanNode *channel;
154 struct userNode *user;
155 int level;
156 time_t created;
157
158 struct adduserPending *prev;
159 struct adduserPending *next;
160 };
161
162 struct banData
163 {
164 char mask[NICKLEN + USERLEN + HOSTLEN + 3];
165 char owner[NICKLEN+1];
166 struct chanData *channel;
167
168 time_t set;
169 time_t triggered;
170 time_t expires;
171
172 char *reason;
173
174 struct banData *prev;
175 struct banData *next;
176 };
177
178 struct suspended
179 {
180 struct chanData *cData;
181 char *suspender;
182 char *reason;
183 time_t issued, expires, revoked;
184 struct suspended *previous;
185 };
186
187 struct do_not_register
188 {
189 char chan_name[CHANNELLEN+1];
190 char setter[NICKSERV_HANDLE_LEN+1];
191 time_t set;
192 char reason[1];
193 };
194
195 void init_chanserv(const char *nick);
196 void del_channel_user(struct userData *user, int do_gc);
197 struct channelList *chanserv_support_channels(void);
198 unsigned short user_level_from_name(const char *name, unsigned short clamp_level);
199 struct do_not_register *chanserv_is_dnr(const char *chan_name, struct handle_info *handle);
200 int check_user_level(struct chanNode *channel, struct userNode *user, enum levelOption opt, int allow_override, int exempt_owner);
201
202 void do_math(char *Buffer, char *Math);
203 char* user_level_name_from_level(int level);
204
205 void process_adduser_pending(struct userNode *user);
206 void wipe_adduser_pending(struct chanNode *channel, struct userNode *user);
207
208 #endif