]> jfr.im git - solanum.git/blame - extensions/extb_canjoin.c
Stop using chm_nosuch as a sentinel value (#53)
[solanum.git] / extensions / extb_canjoin.c
CommitLineData
212380e3
AC
1/*
2 * Canjoin extban type: matches users who are or are not banned from a
3 * specified channel.
4 * -- nenolod/jilles
212380e3
AC
5 */
6
7#include "stdinc.h"
8#include "modules.h"
9#include "client.h"
10#include "channel.h"
11#include "hash.h"
12#include "ircd.h"
13
eeabf33a
EM
14static const char extb_desc[] = "Can join ($j) extban type - matches users who are or are not banned from a specified channel";
15
212380e3
AC
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
c81afd15 20DECLARE_MODULE_AV2(extb_canjoin, _modinit, _moddeinit, NULL, NULL, NULL, NULL, NULL, extb_desc);
212380e3
AC
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;
d6b90058
EK
49 if (mode_type == CHFL_EXCEPTION)
50 return EXTBAN_INVALID;
212380e3
AC
51 chptr2 = find_channel(data);
52 /* must exist, and no point doing this with the same channel */
53 if (chptr2 == NULL || chptr2 == chptr)
54 return EXTBAN_INVALID;
55 /* require consistent target */
56 if (chptr->chname[0] == '#' && data[0] == '&')
57 return EXTBAN_INVALID;
58 /* this allows getting some information about ban exceptions
59 * but +s/+p doesn't seem the right criterion */
60#if 0
61 /* privacy! don't allow +s/+p channels to influence another channel */
62 if (!PubChannel(chptr2))
63 return EXTBAN_INVALID;
64#endif
65 recurse = 1;
a7d4a0ab 66 ret = is_banned(chptr2, client_p, NULL, NULL, NULL) == CHFL_BAN ? EXTBAN_MATCH : EXTBAN_NOMATCH;
212380e3
AC
67 recurse = 0;
68 return ret;
69}