]> jfr.im git - solanum.git/blame - extensions/extb_canjoin.c
Move module description headers to the top
[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;
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;
765d839d 64 ret = is_banned(chptr2, client_p, NULL, NULL, NULL, NULL) == CHFL_BAN ? EXTBAN_MATCH : EXTBAN_NOMATCH;
212380e3
AC
65 recurse = 0;
66 return ret;
67}