]>
Commit | Line | Data |
---|---|---|
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 | ||
18 | static int _modinit(void); | |
19 | static void _moddeinit(void); | |
20 | static int eb_usermode(const char *data, struct Client *client_p, struct Channel *chptr, long mode_type); | |
21 | ||
22 | DECLARE_MODULE_AV1(extb_usermode, _modinit, _moddeinit, NULL, NULL, NULL, "$Revision: 1299 $"); | |
23 | ||
24 | static int | |
25 | _modinit(void) | |
26 | { | |
27 | extban_table['m'] = eb_usermode; | |
28 | ||
29 | return 0; | |
30 | } | |
31 | ||
32 | static void | |
33 | _moddeinit(void) | |
34 | { | |
35 | extban_table['m'] = NULL; | |
36 | } | |
37 | ||
38 | static 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) | |
49 | return EXTBAN_INVALID; | |
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 | ||
76 | return ((client_p->umodes & modes_ack) == modes_ack && | |
77 | !(client_p->umodes & modes_nak)) ? | |
78 | EXTBAN_MATCH : EXTBAN_NOMATCH; | |
79 | } |