Debian Codegraph @

modules/operserv/mode.c

raw
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 MODE command.
6 *
7 */
8
9 #include "atheme.h"
10
11 DECLARE_MODULE_V1
12 (
13 "operserv/mode", false, _modinit, _moddeinit,
14 PACKAGE_STRING,
15 VENDOR_STRING
16 );
17
18 static void os_cmd_mode(sourceinfo_t *si, int parc, char *parv[]);
19
20 command_t os_mode = { "MODE", N_("Changes modes on channels."), PRIV_OMODE, 2, os_cmd_mode, { .path = "oservice/mode" } };
21
22 void _modinit(module_t *m)
23 {
24 service_named_bind_command("operserv", &os_mode);
25 }
26
27 void _moddeinit(module_unload_intent_t intent)
28 {
29 service_named_unbind_command("operserv", &os_mode);
30 }
31
32 static void os_cmd_mode(sourceinfo_t *si, int parc, char *parv[])
33 {
34 char *channel = parv[0];
35 char *mode = parv[1];
36 channel_t *c;
37 int modeparc;
38 char *modeparv[256];
39
40 if (!channel || !mode)
41 {
42 command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "MODE");
43 command_fail(si, fault_needmoreparams, _("Syntax: MODE <channel> <parameters>"));
44 return;
45 }
46
47 c = channel_find(channel);
48 if (!c)
49 {
50 command_fail(si, fault_nosuch_target, _("Channel \2%s\2 does not exist."), channel);
51 return;
52 }
53
54 wallops("\2%s\2 is using MODE on \2%s\2 (set: \2%s\2)",
55 get_oper_name(si), channel, mode);
56 logcommand(si, CMDLOG_ADMIN, "MODE: \2%s\2 on \2%s\2", mode, channel);
57 command_success_nodata(si, _("Setting modes \2%s\2 on \2%s\2."), mode, channel);
58
59 modeparc = sjtoken(mode, ' ', modeparv);
60
61 channel_mode(si->service->me, c, modeparc, modeparv);
62 }
63
64 /* vim:cinoptions=>s,e0,n0,f0,{0,}0,^0,=s,ps,t0,c3,+s,(2s,us,)20,*30,gs,hs
65 * vim:ts=8
66 * vim:sw=8
67 * vim:noexpandtab
68 */