]>
Commit | Line | Data |
---|---|---|
d76ed9a9 AS |
1 | /* hash.h - IRC network state database |
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 |
348683aa | 8 | * the Free Software Foundation; either version 3 of the License, or |
d76ed9a9 AS |
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 HASH_H | |
22 | #define HASH_H | |
23 | ||
24 | #include "common.h" | |
25 | #include "dict.h" | |
37e08c82 | 26 | #include "eventhooks.h" |
d76ed9a9 | 27 | #include "policer.h" |
df7819d9 | 28 | #include "recdb.h" |
d76ed9a9 | 29 | |
d0cb2fb6 AS |
30 | #define MODE_CHANOP 0x00000001 /* +o USER */ |
31 | #define MODE_VOICE 0x00000002 /* +v USER */ | |
32 | #define MODE_PRIVATE 0x00000004 /* +p */ | |
33 | #define MODE_SECRET 0x00000008 /* +s */ | |
34 | #define MODE_MODERATED 0x00000010 /* +m */ | |
35 | #define MODE_TOPICLIMIT 0x00000020 /* +t */ | |
36 | #define MODE_INVITEONLY 0x00000040 /* +i */ | |
37 | #define MODE_NOPRIVMSGS 0x00000080 /* +n */ | |
38 | #define MODE_KEY 0x00000100 /* +k KEY */ | |
39 | #define MODE_BAN 0x00000200 /* +b BAN */ | |
40 | #define MODE_LIMIT 0x00000400 /* +l LIMIT */ | |
41 | #define MODE_DELAYJOINS 0x00000800 /* +D */ | |
7827220c | 42 | #define MODE_REGONLY 0x00001000 /* ircu +r */ |
d0cb2fb6 AS |
43 | #define MODE_NOCOLORS 0x00002000 /* +c */ |
44 | #define MODE_NOCTCPS 0x00004000 /* +C */ | |
45 | #define MODE_REGISTERED 0x00008000 /* Bahamut +r */ | |
46 | #define MODE_STRIPCOLOR 0x00010000 /* +S Strip mirc color codes */ | |
47 | #define MODE_MODUNREG 0x00020000 /* +M mod unregister */ | |
48 | #define MODE_NONOTICE 0x00040000 /* +N no notices */ | |
49 | #define MODE_OPERSONLY 0x00080000 /* +O Opers only */ | |
50 | #define MODE_NOQUITMSGS 0x00100000 /* +Q suppress messages from quit notices */ | |
51 | #define MODE_NOAMSG 0x00200000 /* +T no multi-target messages */ | |
c8ca69a0 | 52 | #define MODE_SSLONLY 0x00400000 /* +Z ssl only */ |
55342ce8 | 53 | #define MODE_HALFOP 0x00800000 /* +h USER */ |
2aef5f4b | 54 | #define MODE_EXEMPT 0x01000000 /* +e exempt */ |
88c7cb10 | 55 | #define MODE_HIDEMODE 0x02000000 /* +L hide modes */ |
2f61d1d7 | 56 | #define MODE_APASS 0x04000000 /* +A adminpass */ |
57 | #define MODE_UPASS 0x08000000 /* +U userpass */ | |
4648ded2 | 58 | #define MODE_ADMINSONLY 0x10000000 /* +a Admins only */ |
d76ed9a9 AS |
59 | #define MODE_REMOVE 0x80000000 |
60 | ||
8d882965 MB |
61 | #define FLAGS_OPER 0x00000001 /* Operator +o */ |
62 | #define FLAGS_LOCOP 0x00000002 /* Local operator +O */ | |
63 | #define FLAGS_INVISIBLE 0x00000004 /* invisible +i */ | |
64 | #define FLAGS_WALLOP 0x00000008 /* receives wallops +w */ | |
65 | #define FLAGS_DUMMY 0x00000010 /* user is not announced to other servers */ | |
66 | #define FLAGS_DEAF 0x00000020 /* deaf +d */ | |
67 | #define FLAGS_SERVICE 0x00000040 /* cannot be kicked, killed or deoped +k */ | |
68 | #define FLAGS_GLOBAL 0x00000080 /* receives global messages +g */ | |
69 | #define FLAGS_SETHOST 0x00000100 /* sethost +h */ | |
70 | #define FLAGS_PERSISTENT 0x00000200 /* for reserved nicks, this isn't just one-shot */ | |
71 | #define FLAGS_GAGGED 0x00000400 /* for gagged users */ | |
72 | #define FLAGS_AWAY 0x00000800 /* for away users */ | |
73 | #define FLAGS_STAMPED 0x00001000 /* for users who have been stamped */ | |
74 | #define FLAGS_HIDDEN_HOST 0x00002000 /* user's host is masked by their account +x */ | |
75 | #define FLAGS_REGNICK 0x00004000 /* user owns their current nick */ | |
76 | #define FLAGS_REGISTERING 0x00008000 /* user has issued account register command, is waiting for email cookie */ | |
77 | #define FLAGS_BOT 0x00010000 /* Bot +B */ | |
78 | #define FLAGS_HIDECHANS 0x00020000 /* Hidden channels +n */ | |
79 | #define FLAGS_HIDEIDLE 0x00040000 /* Hidden idle time +I */ | |
80 | #define FLAGS_XTRAOP 0x00080000 /* user is XtraOP +X */ | |
81 | #define FLAGS_CLOAKHOST 0x00100000 /* user has cloaked host +C */ | |
82 | #define FLAGS_CLOAKIP 0x00200000 /* user has cloaked ip +c */ | |
83 | #define FLAGS_ADMIN 0x00400000 /* Admin +a */ | |
84 | #define FLAGS_SSL 0x00800000 /* user is using a secure connection +z */ | |
85 | #define FLAGS_PRIVDEAF 0x01000000 /* user is deaf to private messages +D */ | |
86 | #define FLAGS_ACCOUNTONLY 0x02000000 /* user only receives PMs from authed users +R */ | |
87 | #define FLAGS_WHOIS 0x04000000 /* user receives notices when /whois'ed +W */ | |
88 | #define FLAGS_HIDEOPER 0x08000000 /* user is a hidden IRCop +H */ | |
89 | #define FLAGS_NOLINK 0x10000000 /* user has opted out of channel redirection +L */ | |
90 | #define FLAGS_COMMONCHANSONLY 0x20000000 /* user only receives PMs from users on same cahnnels +q */ | |
d76ed9a9 AS |
91 | |
92 | #define IsOper(x) ((x)->modes & FLAGS_OPER) | |
93 | #define IsService(x) ((x)->modes & FLAGS_SERVICE) | |
94 | #define IsDeaf(x) ((x)->modes & FLAGS_DEAF) | |
95 | #define IsInvisible(x) ((x)->modes & FLAGS_INVISIBLE) | |
96 | #define IsGlobal(x) ((x)->modes & FLAGS_GLOBAL) | |
97 | #define IsWallOp(x) ((x)->modes & FLAGS_WALLOP) | |
cf8bedff | 98 | #define IsBotM(x) ((x)->modes & FLAGS_BOT) |
99 | #define IsHideChans(x) ((x)->modes & FLAGS_HIDECHANS) | |
100 | #define IsHideIdle(x) ((x)->modes & FLAGS_HIDEIDLE) | |
101 | #define IsXtraOp(x) ((x)->modes & FLAGS_XTRAOP) | |
182dd032 | 102 | #define IsSetHost(x) ((x)->modes & FLAGS_SETHOST) |
d76ed9a9 AS |
103 | #define IsGagged(x) ((x)->modes & FLAGS_GAGGED) |
104 | #define IsPersistent(x) ((x)->modes & FLAGS_PERSISTENT) | |
105 | #define IsAway(x) ((x)->modes & FLAGS_AWAY) | |
106 | #define IsStamped(x) ((x)->modes & FLAGS_STAMPED) | |
107 | #define IsHiddenHost(x) ((x)->modes & FLAGS_HIDDEN_HOST) | |
108 | #define IsReggedNick(x) ((x)->modes & FLAGS_REGNICK) | |
109 | #define IsRegistering(x) ((x)->modes & FLAGS_REGISTERING) | |
1136f709 | 110 | #define IsDummy(x) ((x)->modes & FLAGS_DUMMY) |
d76ed9a9 AS |
111 | #define IsFakeHost(x) ((x)->fakehost[0] != '\0') |
112 | #define IsLocal(x) ((x)->uplink == self) | |
fc55e757 MB |
113 | #define IsAdmin(x) ((x)->modes & FLAGS_ADMIN) |
114 | #define IsSSL(x) ((x)->modes & FLAGS_SSL) | |
8d882965 MB |
115 | #define IsPrivDeaf(x) ((x)->modes & FLAGS_PRIVDEAF) |
116 | #define IsAccountOnly(x) ((x)->modes & FLAGS_ACCOUNTONLY) | |
117 | #define IsWhoisNotice(x) ((x)->modes & FLAGS_WHOIS) | |
118 | #define IsHideOper(x) ((x)->modes & FLAGS_HIDEOPER) | |
119 | #define IsNoRedirect(x) ((x)->modes & FLAGS_NOLINK) | |
120 | #define IsCommonChansOnly(x) ((x)->modes & FLAGS_COMMONCHANSONLY) | |
d76ed9a9 AS |
121 | |
122 | #define NICKLEN 30 | |
123 | #define USERLEN 10 | |
bdddfe43 | 124 | #define HOSTLEN 75 |
68b75482 | 125 | #define SOCKIPLEN 45 |
258d1427 | 126 | #define ACCOUNTLEN 15 |
d76ed9a9 AS |
127 | #define REALLEN 50 |
128 | #define TOPICLEN 250 | |
129 | #define CHANNELLEN 200 | |
6d58d26f | 130 | #define MARKLEN 200 |
2f61d1d7 | 131 | #define MAXOPLEVEL 999 |
d76ed9a9 AS |
132 | |
133 | #define MAXMODEPARAMS 6 | |
ac3bdc8d | 134 | #define MAXBANS 128 |
2aef5f4b | 135 | #define MAXEXEMPTS 45 |
d76ed9a9 AS |
136 | |
137 | /* IDLEN is 6 because it takes 5.33 Base64 digits to store 32 bytes. */ | |
138 | #define IDLEN 6 | |
139 | ||
89d871d8 | 140 | /** Operator privileges. */ |
141 | enum Priv { | |
142 | PRIV_CHAN_LIMIT, /**< no channel limit on oper */ | |
143 | PRIV_MODE_LCHAN, /**< oper can mode local chans */ | |
144 | PRIV_WALK_LCHAN, /**< oper can walk through local modes */ | |
145 | PRIV_DEOP_LCHAN, /**< no deop oper on local chans */ | |
146 | PRIV_SHOW_INVIS, /**< show local invisible users */ | |
147 | PRIV_SHOW_ALL_INVIS, /**< show all invisible users */ | |
148 | PRIV_UNLIMIT_QUERY, /**< unlimit who queries */ | |
149 | PRIV_KILL, /**< oper can KILL */ | |
150 | PRIV_LOCAL_KILL, /**< oper can local KILL */ | |
151 | PRIV_REHASH, /**< oper can REHASH */ | |
152 | PRIV_REMOTEREHASH, /**< oper can remote REHASH */ | |
153 | PRIV_RESTART, /**< oper can RESTART */ | |
154 | PRIV_DIE, /**< oper can DIE */ | |
625ccd4e MB |
155 | PRIV_ZLINE, /**< oper can ZLINE */ |
156 | PRIV_LOCAL_ZLINE, /**< oper can local ZLINE */ | |
89d871d8 | 157 | PRIV_GLINE, /**< oper can GLINE */ |
158 | PRIV_LOCAL_GLINE, /**< oper can local GLINE */ | |
159 | PRIV_SHUN, /**< oper can SHUN */ | |
160 | PRIV_LOCAL_SHUN, /**< oper can local SHUN */ | |
161 | PRIV_JUPE, /**< oper can JUPE */ | |
162 | PRIV_LOCAL_JUPE, /**< oper can local JUPE */ | |
163 | PRIV_OPMODE, /**< oper can OP/CLEARMODE */ | |
164 | PRIV_LOCAL_OPMODE, /**< oper can local OP/CLEARMODE */ | |
165 | PRIV_SET, /**< oper can SET */ | |
166 | PRIV_WHOX, /**< oper can use /who x */ | |
167 | PRIV_BADCHAN, /**< oper can BADCHAN */ | |
168 | PRIV_LOCAL_BADCHAN, /**< oper can local BADCHAN */ | |
169 | PRIV_SEE_CHAN, /**< oper can see in secret chans */ | |
170 | PRIV_PROPAGATE, /**< propagate oper status */ | |
171 | PRIV_DISPLAY, /**< "Is an oper" displayed */ | |
c9aeceb5 | 172 | PRIV_DISPLAY_MODE, /**< oper can set +H hide oper */ |
89d871d8 | 173 | PRIV_SEE_OPERS, /**< display hidden opers */ |
174 | PRIV_WIDE_GLINE, /**< oper can set wider G-lines */ | |
625ccd4e | 175 | PRIV_WIDE_ZLINE, /**< oper can set wider Z-Lines */ |
89d871d8 | 176 | PRIV_WIDE_SHUN, /**< oper can set wider G-lines */ |
177 | PRIV_LIST_CHAN, /**< oper can list secret channels */ | |
178 | PRIV_FORCE_OPMODE, /**< can hack modes on quarantined channels */ | |
179 | PRIV_FORCE_LOCAL_OPMODE, /**< can hack modes on quarantined local channels */ | |
180 | PRIV_CHECK, /**< oper can use CHECK */ | |
181 | PRIV_SEE_SECRET_CHAN, /**< oper can see +s channels in whois */ | |
055f3f30 MB |
182 | PRIV_WHOIS_NOTICE, /**< oper can set/unset user mode +W */ |
183 | PRIV_HIDE_IDLE, /**< oper can set/unset user mode +I */ | |
184 | PRIV_XTRAOP, /**< oper can set/unset user mode +X */ | |
185 | PRIV_HIDE_CHANNELS, /**< oper can set/unset user mode +n */ | |
c9aeceb5 | 186 | PRIV_FREEFORM, /**< oper can set any host on themseves using set host |
187 | as long as its a valid host */ | |
188 | PRIV_REMOVE, /**< oper can force remove deactivated glines, | |
189 | shuns and zlines. */ | |
190 | PRIV_SPAMFILTER, /**< oper can set spamfilters via SPAMFILTER */ | |
57cd328b MB |
191 | PRIV_ADMIN, /**< oper is an IRC Admin */ |
192 | PRIV_APASS_OPMODE, /**< oper can use OPMODE to set/unset channel modes +A and +U */ | |
193 | PRIV_HIDE_OPER, /**< oper can set/unset user mode +H */ | |
194 | PRIV_REMOTE, /**< oper can use his/her operator block from a remote server */ | |
195 | PRIV_SERVICE, /**< oper can set/unset user mode +k */ | |
89d871d8 | 196 | PRIV_LAST_PRIV /**< number of privileges */ |
197 | }; | |
198 | ||
199 | /** Number of bits */ | |
200 | #define _PRIV_NBITS (8 * sizeof(unsigned long)) | |
201 | /** Element number for priv \a priv. */ | |
202 | #define _PRIV_IDX(priv) ((priv) / _PRIV_NBITS) | |
203 | /** Element bit for priv \a priv. */ | |
204 | #define _PRIV_BIT(priv) (1UL << ((priv) % _PRIV_NBITS)) | |
205 | ||
206 | /** Operator privileges. */ | |
207 | struct Privs { | |
208 | unsigned long priv_mask[(PRIV_LAST_PRIV + _PRIV_NBITS - 1) / _PRIV_NBITS]; | |
209 | }; | |
210 | ||
d76ed9a9 AS |
211 | DECLARE_LIST(userList, struct userNode*); |
212 | DECLARE_LIST(modeList, struct modeNode*); | |
213 | DECLARE_LIST(banList, struct banNode*); | |
2aef5f4b | 214 | DECLARE_LIST(exemptList, struct exemptNode*); |
d76ed9a9 AS |
215 | DECLARE_LIST(channelList, struct chanNode*); |
216 | DECLARE_LIST(serverList, struct server*); | |
217 | ||
218 | struct userNode { | |
219 | char *nick; /* Unique name of the client, nick or host */ | |
220 | char ident[USERLEN + 1]; /* Per-host identification for user */ | |
221 | char info[REALLEN + 1]; /* Free form additional client information */ | |
222 | char hostname[HOSTLEN + 1]; /* DNS name or IP address */ | |
223 | char fakehost[HOSTLEN + 1]; /* Assigned fake host */ | |
37ef8ee3 | 224 | char crypthost[HOSTLEN + 30]; /* Crypted hostname */ |
225 | char cryptip[SOCKIPLEN + 30]; /* Crypted IP */ | |
d76ed9a9 AS |
226 | #ifdef WITH_PROTOCOL_P10 |
227 | char numeric[COMBO_NUMERIC_LEN+1]; | |
228 | unsigned int num_local : 18; | |
229 | #endif | |
3fdd6a74 | 230 | unsigned int loc; /* Is user connecting via LOC? */ |
da5b7dfc | 231 | unsigned int no_notice; /* Does the users client not see notices? */ |
d76ed9a9 | 232 | unsigned int dead : 1; /* Is user waiting to be recycled? */ |
2f61d1d7 | 233 | irc_in_addr_t ip; /* User's IP address */ |
d76ed9a9 AS |
234 | long modes; /* user flags +isw etc... */ |
235 | ||
182dd032 AS |
236 | // sethost - reed/apples |
237 | char sethost[USERLEN + HOSTLEN + 2]; /* 1 for '\0' and 1 for @ = 2 */ | |
238 | ||
21f6caee | 239 | /* GeoIP Data */ |
240 | char *country_name; | |
241 | ||
242 | /* GeoIP City Data */ | |
243 | char *country_code; | |
244 | char *city; | |
245 | char *region; | |
246 | char *postal_code; | |
247 | float latitude; | |
248 | float longitude; | |
249 | int dma_code; | |
250 | int area_code; | |
251 | ||
2c00fbc2 | 252 | char *mark; /* only filled if they are marked */ |
0e08a8e0 | 253 | char *version_reply; /* only filled in if a version query was triggered */ |
ba4b4d51 | 254 | char *sslfp; /* only filled in if a mark SSLCLIFP is received */ |
21f6caee | 255 | |
df7819d9 MB |
256 | struct string_list *marks; /* list of user's marks */ |
257 | ||
d76ed9a9 | 258 | time_t timestamp; /* Time of last nick change */ |
1136f709 | 259 | time_t idle_since; |
d76ed9a9 AS |
260 | struct server *uplink; /* Server that user is connected to */ |
261 | struct modeList channels; /* Vector of channels user is in */ | |
89d871d8 | 262 | struct Privs privs; |
d76ed9a9 AS |
263 | |
264 | /* from nickserv */ | |
265 | struct handle_info *handle_info; | |
266 | struct userNode *next_authed; | |
267 | struct policer auth_policer; | |
268 | }; | |
269 | ||
89d871d8 | 270 | #define privs(cli) ((cli)->privs) |
271 | #define PrivSet(pset, priv) ((pset)->priv_mask[_PRIV_IDX(priv)] |= \ | |
272 | _PRIV_BIT(priv)) | |
273 | #define PrivClr(pset, priv) ((pset)->priv_mask[_PRIV_IDX(priv)] &= \ | |
274 | ~(_PRIV_BIT(priv))) | |
275 | #define PrivHas(pset, priv) ((pset)->priv_mask[_PRIV_IDX(priv)] & \ | |
276 | _PRIV_BIT(priv)) | |
277 | ||
278 | #define PRIV_ADD 1 | |
279 | #define PRIV_DEL 0 | |
280 | ||
281 | #define GrantPriv(cli, priv) (PrivSet(&(privs(cli)), priv)) | |
282 | #define RevokePriv(cli, priv) (PrivClr(&(privs(cli)), priv)) | |
283 | #define HasPriv(cli, priv) (PrivHas(&(privs(cli)), priv)) | |
284 | ||
d76ed9a9 AS |
285 | struct chanNode { |
286 | chan_mode_t modes; | |
287 | unsigned int limit, locks; | |
288 | char key[KEYLEN + 1]; | |
2f61d1d7 | 289 | char upass[KEYLEN + 1]; |
290 | char apass[KEYLEN + 1]; | |
d76ed9a9 AS |
291 | time_t timestamp; /* creation time */ |
292 | ||
293 | char topic[TOPICLEN + 1]; | |
294 | char topic_nick[NICKLEN + 1]; | |
295 | time_t topic_time; | |
296 | ||
297 | struct modeList members; | |
298 | struct banList banlist; | |
2aef5f4b | 299 | struct exemptList exemptlist; |
d76ed9a9 AS |
300 | struct policer join_policer; |
301 | unsigned int join_flooded : 1; | |
302 | unsigned int bad_channel : 1; | |
303 | ||
304 | struct chanData *channel_info; | |
305 | struct channel_help *channel_help; | |
306 | char name[1]; | |
307 | }; | |
308 | ||
309 | struct banNode { | |
310 | char ban[NICKLEN + USERLEN + HOSTLEN + 3]; /* 1 for '\0', 1 for ! and 1 for @ = 3 */ | |
311 | char who[NICKLEN + 1]; /* who set ban */ | |
312 | time_t set; /* time ban was set */ | |
313 | }; | |
314 | ||
2aef5f4b | 315 | struct exemptNode { |
316 | char exempt[NICKLEN + USERLEN + HOSTLEN + 3]; /* 1 for '\0', 1 for ! and 1 for @ = 3 */ | |
317 | char who[NICKLEN + 1]; /* who set exempt */ | |
318 | time_t set; /* time exempt was set */ | |
319 | }; | |
320 | ||
d76ed9a9 AS |
321 | struct modeNode { |
322 | struct chanNode *channel; | |
323 | struct userNode *user; | |
acf3c6d5 | 324 | long modes; |
2f61d1d7 | 325 | short oplevel; |
d76ed9a9 AS |
326 | time_t idle_since; |
327 | }; | |
328 | ||
329 | #define SERVERNAMEMAX 64 | |
330 | #define SERVERDESCRIPTMAX 128 | |
331 | ||
332 | struct server { | |
333 | char name[SERVERNAMEMAX+1]; | |
334 | time_t boot; | |
1136f709 | 335 | time_t link_time; |
d76ed9a9 AS |
336 | char description[SERVERDESCRIPTMAX+1]; |
337 | #ifdef WITH_PROTOCOL_P10 | |
338 | char numeric[COMBO_NUMERIC_LEN+1]; | |
339 | unsigned int num_mask; | |
340 | #endif | |
341 | unsigned int hops, clients, max_clients; | |
342 | unsigned int burst : 1, self_burst : 1; | |
343 | struct server *uplink; | |
344 | #ifdef WITH_PROTOCOL_P10 | |
345 | struct userNode **users; /* flat indexed by numeric */ | |
346 | #else | |
347 | dict_t users; /* indexed by nick */ | |
348 | #endif | |
349 | struct serverList children; | |
350 | }; | |
351 | ||
47956fc5 AS |
352 | struct waitingConnection { |
353 | char *server; | |
354 | char *target; | |
355 | }; | |
356 | ||
357 | struct routingPlan { | |
358 | dict_t servers; | |
359 | }; | |
360 | ||
361 | struct routingPlanServer { | |
362 | char *uplink; | |
363 | char *secondaryuplink; | |
364 | unsigned int port; | |
365 | int karma; | |
366 | int offline; | |
367 | }; | |
368 | ||
369 | /* Ported from X2 */ | |
370 | struct routeList { | |
371 | char* server; /* Name of the server */ | |
372 | unsigned int port; /* connection port */ | |
373 | char *uplink; /* Server its linked to (towards us) */ | |
374 | char *secondaryuplink; | |
375 | int outsideness; /* 0 means leaf, 1 second layer, etc. my uplink is highest */ | |
376 | struct routeList *next; | |
377 | }; | |
378 | ||
379 | /* Ported from X2 */ | |
380 | struct route { | |
381 | int count; /* how many servers we have */ | |
382 | int maxdepth; /* biggest outsideness value */ | |
383 | int centered; /* set to TRUE when changerouteUplinks is run */ | |
384 | struct routeList *servers; | |
385 | }; | |
386 | ||
37e08c82 MB |
387 | /* generic hook function args */ |
388 | struct funcargs { | |
389 | void *func; | |
390 | void *extra; | |
391 | }; | |
47956fc5 | 392 | |
d76ed9a9 AS |
393 | extern struct server *self; |
394 | extern dict_t channels; | |
395 | extern dict_t clients; | |
396 | extern dict_t servers; | |
397 | extern unsigned int max_clients, invis_clients; | |
398 | extern time_t max_clients_time; | |
399 | extern struct userList curr_opers, curr_helpers; | |
400 | ||
dc92ef7c MB |
401 | extern unsigned int count_opers; |
402 | ||
d76ed9a9 AS |
403 | struct server* GetServerH(const char *name); /* using full name */ |
404 | struct userNode* GetUserH(const char *nick); /* using nick */ | |
405 | struct chanNode* GetChannel(const char *name); | |
406 | struct modeNode* GetUserMode(struct chanNode* channel, struct userNode* user); | |
1136f709 | 407 | int userList_contains(struct userList *list, struct userNode *user); |
f1d4a7db | 408 | unsigned int IsUserP(struct userNode *user); |
d76ed9a9 | 409 | |
9d59f196 | 410 | typedef int (*server_link_func_t) (struct server *server, void *extra); |
411 | void reg_server_link_func(server_link_func_t handler, void *extra); | |
412 | void call_server_link_funcs(struct server *server); | |
d76ed9a9 | 413 | |
c8b4b87b MB |
414 | typedef void (*sasl_input_func_t) (struct server* source ,const char *identifier, const char *subcmd, const char *data, const char *ext, void *extra); |
415 | void reg_sasl_input_func(sasl_input_func_t handler, void *extra); | |
416 | void call_sasl_input_func(struct server* source ,const char *identifier, const char *subcmd, const char *data, const char *ext); | |
417 | void unreg_sasl_input_func(sasl_input_func_t handler, void *extra); | |
418 | ||
f0fb2e2d | 419 | typedef int (*new_user_func_t) (struct userNode *user, void *extra); |
420 | void reg_new_user_func(new_user_func_t handler, void *extra); | |
37e08c82 | 421 | void reg_new_user_func_pos(new_user_func_t handler, void *extra, int pos); |
f0fb2e2d | 422 | void call_new_user_funcs(struct userNode *user); |
a6bcc929 | 423 | typedef void (*del_user_func_t) (struct userNode *user, struct userNode *killer, const char *why, void *extra); |
424 | void reg_del_user_func(del_user_func_t handler, void *extra); | |
425 | void call_del_user_funcs(struct userNode *user, struct userNode *killer, const char *why); | |
426 | void unreg_del_user_func(del_user_func_t handler, void *extra); | |
d76ed9a9 | 427 | void ReintroduceUser(struct userNode* user); |
63189c10 | 428 | typedef void (*nick_change_func_t)(struct userNode *user, const char *old_nick, void *extra); |
429 | void reg_nick_change_func(nick_change_func_t handler, void *extra); | |
d76ed9a9 | 430 | void NickChange(struct userNode* user, const char *new_nick, int no_announce); |
cf8bedff | 431 | void SVSNickChange(struct userNode* user, const char *new_nick); |
d76ed9a9 AS |
432 | |
433 | typedef void (*account_func_t) (struct userNode *user, const char *stamp); | |
434 | void reg_account_func(account_func_t handler); | |
435 | void call_account_func(struct userNode *user, const char *stamp); | |
b21e2cfe | 436 | void StampUser(struct userNode *user, const char *stamp, time_t timestamp); |
d76ed9a9 | 437 | void assign_fakehost(struct userNode *user, const char *host, int announce); |
21f6caee | 438 | void set_geoip_info(struct userNode *user); |
d76ed9a9 | 439 | |
157ce145 | 440 | typedef void (*new_channel_func_t) (struct chanNode *chan, void *extra); |
441 | void reg_new_channel_func(new_channel_func_t handler, void *extra); | |
fb38e2bc | 442 | typedef int (*join_func_t) (struct modeNode *mNode, void *extra); |
37e08c82 | 443 | void reg_join_func_pos(join_func_t handler, void *extra, int pos); |
fb38e2bc | 444 | void reg_join_func(join_func_t handler, void *extra); |
1898d8ea | 445 | typedef void (*del_channel_func_t) (struct chanNode *chan, void *extra); |
446 | void reg_del_channel_func(del_channel_func_t handler, void *extra); | |
d76ed9a9 | 447 | |
2aef5f4b | 448 | struct chanNode* AddChannel(const char *name, time_t time_, const char *modes, char *banlist, char *exemptlist); |
d76ed9a9 AS |
449 | void LockChannel(struct chanNode *channel); |
450 | void UnlockChannel(struct chanNode *channel); | |
451 | ||
452 | struct modeNode* AddChannelUser(struct userNode* user, struct chanNode* channel); | |
453 | ||
63637aea | 454 | typedef void (*part_func_t) (struct modeNode *mn, const char *reason, void *extra); |
455 | void reg_part_func(part_func_t handler, void *extra); | |
456 | void unreg_part_func(part_func_t handler, void *extra); | |
d76ed9a9 AS |
457 | void DelChannelUser(struct userNode* user, struct chanNode* channel, const char *reason, int deleting); |
458 | void KickChannelUser(struct userNode* target, struct chanNode* channel, struct userNode *kicker, const char *why); | |
459 | ||
91667658 | 460 | typedef void (*kick_func_t) (struct userNode *kicker, struct userNode *user, struct chanNode *chan, void *extra); |
461 | void reg_kick_func(kick_func_t handler, void *extra); | |
d76ed9a9 AS |
462 | void ChannelUserKicked(struct userNode* kicker, struct userNode* victim, struct chanNode* channel); |
463 | ||
464 | int ChannelBanExists(struct chanNode *channel, const char *ban); | |
2aef5f4b | 465 | int ChannelExemptExists(struct chanNode *channel, const char *exempt); |
d76ed9a9 | 466 | |
5a2c7cf6 | 467 | typedef int (*topic_func_t)(struct userNode *who, struct chanNode *chan, const char *old_topic, void *extra); |
468 | void reg_topic_func(topic_func_t handler, void *extra); | |
7fda2b52 | 469 | void SetChannelTopic(struct chanNode *channel, struct userNode *service, struct userNode *user, const char *topic, int announce); |
ac3bdc8d | 470 | struct userNode *IsInChannel(struct chanNode *channel, struct userNode *user); |
d76ed9a9 AS |
471 | |
472 | void init_structs(void); | |
473 | ||
474 | #endif |