| 1 |
/* |
| 2 |
* Copyright (c) 2007 William Pitcock |
| 3 |
* Rights to this code are as documented in doc/LICENSE. |
| 4 |
* |
| 5 |
* mlocktweaker.c: A module which tweaks mlock on registration. |
| 6 |
*/ |
| 7 |
|
| 8 |
#include "atheme-compat.h" |
| 9 |
|
| 10 |
/* Changed to allow for dynamic configuration, to configure this, set |
| 11 |
* chanserv::mlocktweak to the mode string you want set on channels as |
| 12 |
* they are registered. Keep in mind that +nt will be applied as well, |
| 13 |
* so if you do not want +n or +t, negate them in the configuration. |
| 14 |
* - Quora |
| 15 |
*/ |
| 16 |
static char *mlocktweak = NULL; |
| 17 |
|
| 18 |
static void |
| 19 |
handle_channel_register(hook_channel_req_t *hdata) |
| 20 |
{ |
| 21 |
mychan_t *mc = hdata->mc; |
| 22 |
unsigned int *target; |
| 23 |
char *it = mlocktweak; |
| 24 |
|
| 25 |
if (mc == NULL) |
| 26 |
return; |
| 27 |
|
| 28 |
target = &mc->mlock_on; |
| 29 |
|
| 30 |
while (*it != '\0') |
| 31 |
{ |
| 32 |
switch (*it) |
| 33 |
{ |
| 34 |
case '+': |
| 35 |
target = &mc->mlock_on; |
| 36 |
break; |
| 37 |
case '-': |
| 38 |
target = &mc->mlock_off; |
| 39 |
break; |
| 40 |
default: |
| 41 |
*target |= mode_to_flag(*it); |
| 42 |
break; |
| 43 |
} |
| 44 |
++it; |
| 45 |
} |
| 46 |
|
| 47 |
mc->mlock_off &= ~mc->mlock_on; |
| 48 |
} |
| 49 |
|
| 50 |
static void |
| 51 |
mod_init(module_t *const restrict m) |
| 52 |
{ |
| 53 |
add_dupstr_conf_item("MLOCKTWEAK", &chansvs.me->conf_table, 0, &mlocktweak, "-t+c"); |
| 54 |
hook_add_event("channel_register"); |
| 55 |
hook_add_first_channel_register(handle_channel_register); |
| 56 |
} |
| 57 |
|
| 58 |
static void |
| 59 |
mod_deinit(const module_unload_intent_t intent) |
| 60 |
{ |
| 61 |
del_conf_item("MLOCKTWEAK", &chansvs.me->conf_table); |
| 62 |
hook_del_channel_register(handle_channel_register); |
| 63 |
} |
| 64 |
|
| 65 |
VENDOR_DECLARE_MODULE_V1("contrib/mlocktweaker", MODULE_UNLOAD_CAPABILITY_OK, CONTRIB_VENDOR_NENOLOD) |