2012-01-22 10:46:08 +01:00
|
|
|
/*
|
|
|
|
* Usermode extban type: bans all users with a specific usermode
|
|
|
|
* -- nenolod
|
|
|
|
*/
|
|
|
|
|
2016-08-18 07:33:38 +02:00
|
|
|
namespace mode = ircd::chan::mode;
|
2016-08-17 05:01:20 +02:00
|
|
|
namespace ext = mode::ext;
|
2016-08-13 05:05:54 +02:00
|
|
|
using namespace ircd;
|
|
|
|
|
2016-03-09 08:29:41 +01:00
|
|
|
static const char extb_desc[] = "Usermode ($m) extban type";
|
|
|
|
|
2012-01-22 10:46:08 +01:00
|
|
|
static int _modinit(void);
|
|
|
|
static void _moddeinit(void);
|
2016-08-22 03:57:43 +02:00
|
|
|
static int eb_usermode(const char *data, client::client *client_p, chan::chan *chptr, mode::type);
|
2012-01-22 10:46:08 +01:00
|
|
|
|
2016-03-07 07:31:41 +01:00
|
|
|
DECLARE_MODULE_AV2(extb_usermode, _modinit, _moddeinit, NULL, NULL, NULL, NULL, NULL, extb_desc);
|
2012-01-22 10:46:08 +01:00
|
|
|
|
|
|
|
static int
|
|
|
|
_modinit(void)
|
|
|
|
{
|
2016-08-17 05:01:20 +02:00
|
|
|
ext::table['u'] = eb_usermode;
|
2012-01-22 10:46:08 +01:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_moddeinit(void)
|
|
|
|
{
|
2016-08-17 05:01:20 +02:00
|
|
|
ext::table['u'] = NULL;
|
2012-01-22 10:46:08 +01:00
|
|
|
}
|
|
|
|
|
2016-08-22 03:57:43 +02:00
|
|
|
static int eb_usermode(const char *data, client::client *client_p,
|
2016-08-18 07:33:38 +02:00
|
|
|
chan::chan *chptr, mode::type type)
|
2012-01-22 10:46:08 +01:00
|
|
|
{
|
2016-08-17 05:01:20 +02:00
|
|
|
using namespace ext;
|
|
|
|
|
2012-01-22 10:46:08 +01:00
|
|
|
int dir = MODE_ADD;
|
|
|
|
unsigned int modes_ack = 0, modes_nak = 0;
|
|
|
|
const char *p;
|
|
|
|
|
|
|
|
(void)chptr;
|
|
|
|
|
|
|
|
/* $m must have a specified mode */
|
|
|
|
if (data == NULL)
|
2016-08-17 05:01:20 +02:00
|
|
|
return INVALID;
|
2012-01-22 10:46:08 +01:00
|
|
|
|
|
|
|
for (p = data; *p != '\0'; p++)
|
|
|
|
{
|
|
|
|
switch (*p)
|
|
|
|
{
|
|
|
|
case '+':
|
|
|
|
dir = MODE_ADD;
|
|
|
|
break;
|
|
|
|
case '-':
|
|
|
|
dir = MODE_DEL;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
switch (dir)
|
|
|
|
{
|
|
|
|
case MODE_DEL:
|
2016-08-28 06:52:31 +02:00
|
|
|
modes_nak |= umode::table[(unsigned char) *p];
|
2012-01-22 10:46:08 +01:00
|
|
|
break;
|
|
|
|
case MODE_ADD:
|
|
|
|
default:
|
2016-08-28 06:52:31 +02:00
|
|
|
modes_ack |= umode::table[(unsigned char) *p];
|
2012-01-22 10:46:08 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-24 00:25:09 +02:00
|
|
|
return ((client_p->mode & modes_ack) == modes_ack &&
|
|
|
|
!(client_p->mode & modes_nak)) ?
|
2016-08-17 05:01:20 +02:00
|
|
|
MATCH : NOMATCH;
|
2012-01-22 10:46:08 +01:00
|
|
|
}
|