2012-04-17 20:09:50 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2007 William Pitcock
|
|
|
|
* Rights to this code are as documented in doc/LICENSE.
|
|
|
|
*
|
|
|
|
* mlocktweaker.c: A module which tweaks mlock on registration.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2012-10-04 05:01:29 +00:00
|
|
|
#include "atheme-compat.h"
|
2012-04-17 20:09:50 +00:00
|
|
|
|
2013-07-07 18:57:38 +00:00
|
|
|
/* Changed to allow for dynamic configuration, to configure this, set
|
|
|
|
* chanserv::mlocktweak to the mode string you want set on channels as
|
|
|
|
* they are registered. Keep in mind that +nt will be applied as well,
|
|
|
|
* so if you do not want +n or +t, negate them in the configuration.
|
|
|
|
* - Quora
|
2012-04-17 20:09:50 +00:00
|
|
|
*/
|
2013-07-07 18:57:38 +00:00
|
|
|
char * mlocktweak;
|
2012-04-17 20:09:50 +00:00
|
|
|
|
|
|
|
DECLARE_MODULE_V1
|
|
|
|
(
|
|
|
|
"contrib/mlocktweaker", false, _modinit, _moddeinit,
|
|
|
|
PACKAGE_STRING,
|
|
|
|
"William Pitcock <nenolod@atheme.org>"
|
|
|
|
);
|
|
|
|
|
2012-04-17 20:51:55 +00:00
|
|
|
static void handle_channel_register(hook_channel_req_t *hdata);
|
2012-04-17 20:09:50 +00:00
|
|
|
|
|
|
|
void _modinit(module_t *m)
|
|
|
|
{
|
2013-07-07 18:57:38 +00:00
|
|
|
add_dupstr_conf_item("MLOCKTWEAK", &chansvs.me->conf_table, 0, &mlocktweak, "-t+c");
|
2012-04-17 20:09:50 +00:00
|
|
|
hook_add_event("channel_register");
|
|
|
|
hook_add_first_channel_register(handle_channel_register);
|
|
|
|
}
|
|
|
|
|
|
|
|
void _moddeinit(module_unload_intent_t intent)
|
|
|
|
{
|
2013-07-07 18:57:38 +00:00
|
|
|
del_conf_item("MLOCKTWEAK", &chansvs.me->conf_table);
|
2012-04-17 20:09:50 +00:00
|
|
|
hook_del_channel_register(handle_channel_register);
|
|
|
|
}
|
|
|
|
|
2012-04-17 20:50:41 +00:00
|
|
|
static void handle_channel_register(hook_channel_req_t *hdata)
|
2012-04-17 20:09:50 +00:00
|
|
|
{
|
|
|
|
mychan_t *mc = hdata->mc;
|
|
|
|
unsigned int *target;
|
2013-07-07 18:57:38 +00:00
|
|
|
char *it = mlocktweak;
|
2012-04-17 20:09:50 +00:00
|
|
|
|
|
|
|
if (mc == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
target = &mc->mlock_on;
|
|
|
|
|
2012-06-03 08:22:43 +00:00
|
|
|
while (*it != '\0')
|
2012-04-17 20:09:50 +00:00
|
|
|
{
|
2012-06-03 08:22:43 +00:00
|
|
|
switch (*it)
|
|
|
|
{
|
|
|
|
case '+':
|
|
|
|
target = &mc->mlock_on;
|
|
|
|
break;
|
|
|
|
case '-':
|
|
|
|
target = &mc->mlock_off;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
*target |= mode_to_flag(*it);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
++it;
|
2012-04-17 20:09:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
mc->mlock_off &= ~mc->mlock_on;
|
|
|
|
}
|