]> jfr.im git - irc/rqf/shadowircd.git/blame - extensions/extb_canjoin.c
Don't suggest putting values in an enum that are not in the enum.
[irc/rqf/shadowircd.git] / extensions / extb_canjoin.c
CommitLineData
212380e3 1/*
2 * Canjoin extban type: matches users who are or are not banned from a
3 * specified channel.
4 * -- nenolod/jilles
5 *
6 * $Id: extb_canjoin.c 1841 2006-08-22 17:30:03Z jilles $
7 */
8
9#include "stdinc.h"
10#include "modules.h"
11#include "client.h"
12#include "channel.h"
13#include "hash.h"
14#include "ircd.h"
15
16static int _modinit(void);
17static void _moddeinit(void);
18static int eb_canjoin(const char *data, struct Client *client_p, struct Channel *chptr, long mode_type);
19
20DECLARE_MODULE_AV1(extb_canjoin, _modinit, _moddeinit, NULL, NULL, NULL, "$Revision: 1841 $");
21
22static int
23_modinit(void)
24{
25 extban_table['j'] = eb_canjoin;
26
27 return 0;
28}
29
30static void
31_moddeinit(void)
32{
33 extban_table['j'] = NULL;
34}
35
36static int eb_canjoin(const char *data, struct Client *client_p,
37 struct Channel *chptr, long mode_type)
38{
39 struct Channel *chptr2;
40 int ret;
41 static int recurse = 0;
42
43 (void)mode_type;
44 /* don't process a $j in a $j'ed list */
45 if (recurse)
46 return EXTBAN_INVALID;
47 if (data == NULL)
48 return EXTBAN_INVALID;
49 chptr2 = find_channel(data);
50 /* must exist, and no point doing this with the same channel */
51 if (chptr2 == NULL || chptr2 == chptr)
52 return EXTBAN_INVALID;
53 /* require consistent target */
54 if (chptr->chname[0] == '#' && data[0] == '&')
55 return EXTBAN_INVALID;
56 /* this allows getting some information about ban exceptions
57 * but +s/+p doesn't seem the right criterion */
58#if 0
59 /* privacy! don't allow +s/+p channels to influence another channel */
60 if (!PubChannel(chptr2))
61 return EXTBAN_INVALID;
62#endif
63 recurse = 1;
64 ret = is_banned(chptr2, client_p, NULL, NULL, NULL) == CHFL_BAN ? EXTBAN_MATCH : EXTBAN_NOMATCH;
65 recurse = 0;
66 return ret;
67}