| 1 |
/* |
| 2 |
* Copyright (c) 2005-2006 William Pitcock, et al. |
| 3 |
* Rights to this code are as documented in doc/LICENSE. |
| 4 |
* |
| 5 |
* This file contains functionality which implements the OService MODEALL |
| 6 |
* command. |
| 7 |
*/ |
| 8 |
|
| 9 |
#include "atheme-compat.h" |
| 10 |
|
| 11 |
static void |
| 12 |
set_channel_mode(service_t *s, channel_t *c, int modeparc, char *modeparv[]) |
| 13 |
{ |
| 14 |
channel_mode(s->me, c, modeparc, modeparv); |
| 15 |
} |
| 16 |
|
| 17 |
static void |
| 18 |
os_cmd_modeall(sourceinfo_t *si, int parc, char *parv[]) |
| 19 |
{ |
| 20 |
char *mode = parv[0]; |
| 21 |
channel_t *c; |
| 22 |
int modeparc; |
| 23 |
char *modeparv[256]; |
| 24 |
mowgli_patricia_iteration_state_t state; |
| 25 |
unsigned int count = 0; |
| 26 |
|
| 27 |
if (!mode) |
| 28 |
{ |
| 29 |
command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "MODEALL"); |
| 30 |
command_fail(si, fault_needmoreparams, _("Syntax: MODEALL <parameters>")); |
| 31 |
return; |
| 32 |
} |
| 33 |
|
| 34 |
modeparc = sjtoken(mode, ' ', modeparv); |
| 35 |
|
| 36 |
MOWGLI_PATRICIA_FOREACH(c, &state, chanlist) |
| 37 |
{ |
| 38 |
set_channel_mode(si->service, c, modeparc, modeparv); |
| 39 |
count++; |
| 40 |
} |
| 41 |
|
| 42 |
command_success_nodata(si, _("Set modes \2%s\2 on \2%u\2 channels."), mode, count); |
| 43 |
wallops("\2%s\2 is using MODEALL (set: \2%s\2)", |
| 44 |
get_oper_name(si), mode); |
| 45 |
logcommand(si, CMDLOG_ADMIN, "MODEALL: \2%s\2", mode); |
| 46 |
} |
| 47 |
|
| 48 |
static command_t os_modeall = { |
| 49 |
.name = "MODEALL", |
| 50 |
.desc = N_("Changes modes on all channels."), |
| 51 |
.access = PRIV_OMODE, |
| 52 |
.maxparc = 2, |
| 53 |
.cmd = &os_cmd_modeall, |
| 54 |
.help = { .path = "contrib/os_modeall" }, |
| 55 |
}; |
| 56 |
|
| 57 |
static void |
| 58 |
mod_init(module_t *const restrict m) |
| 59 |
{ |
| 60 |
service_named_bind_command("operserv", &os_modeall); |
| 61 |
} |
| 62 |
|
| 63 |
static void |
| 64 |
mod_deinit(const module_unload_intent_t intent) |
| 65 |
{ |
| 66 |
service_named_unbind_command("operserv", &os_modeall); |
| 67 |
} |
| 68 |
|
| 69 |
SIMPLE_DECLARE_MODULE_V1("contrib/os_modeall", MODULE_UNLOAD_CAPABILITY_OK) |