]> jfr.im git - solanum.git/blame - extensions/extb_usermode.c
Fix inconsistency between --sysconfdir and --with-confdir, deprecate --with-confdir.
[solanum.git] / extensions / extb_usermode.c
CommitLineData
0b18e32c
AC
1/*
2 * Usermode extban type: bans all users with a specific usermode
3 * -- nenolod
4 */
5
6#include "stdinc.h"
7#include "modules.h"
8#include "hook.h"
9#include "client.h"
10#include "ircd.h"
11#include "send.h"
12#include "hash.h"
13#include "s_conf.h"
14#include "s_user.h"
15#include "s_serv.h"
16#include "numeric.h"
17
18static int _modinit(void);
19static void _moddeinit(void);
20static int eb_usermode(const char *data, struct Client *client_p, struct Channel *chptr, long mode_type);
21
a8eae730 22DECLARE_MODULE_AV1(extb_usermode, _modinit, _moddeinit, NULL, NULL, NULL, "$Revision: 1299 $");
0b18e32c
AC
23
24static int
25_modinit(void)
26{
27 extban_table['m'] = eb_usermode;
28
29 return 0;
30}
31
32static void
33_moddeinit(void)
34{
35 extban_table['m'] = NULL;
36}
37
38static int eb_usermode(const char *data, struct Client *client_p,
39 struct Channel *chptr, long mode_type)
40{
41 int dir = MODE_ADD;
42 unsigned int modes_ack = 0, modes_nak = 0;
43 const char *p;
44
45 (void)chptr;
46
47 /* $m must have a specified mode */
48 if (data == NULL)
11f2e787 49 return EXTBAN_INVALID;
0b18e32c
AC
50
51 for (p = data; *p != '\0'; p++)
52 {
53 switch (*p)
54 {
55 case '+':
56 dir = MODE_ADD;
57 break;
58 case '-':
59 dir = MODE_DEL;
60 break;
61 default:
62 switch (dir)
63 {
64 case MODE_DEL:
65 modes_nak |= user_modes[(unsigned char) *p];
66 break;
67 case MODE_ADD:
68 default:
69 modes_ack |= user_modes[(unsigned char) *p];
70 break;
71 }
72 break;
73 }
74 }
75
63dd387b
JT
76 return ((client_p->umodes & modes_ack) == modes_ack &&
77 !(client_p->umodes & modes_nak)) ?
78 EXTBAN_MATCH : EXTBAN_NOMATCH;
0b18e32c 79}