Debian Codegraph @

modules/chanserv/clear.c

raw
1 /*
2 * Copyright (c) 2005 William Pitcock, et al.
3 * Rights to this code are as documented in doc/LICENSE.
4 *
5 * This file contains code for the CService KICK functions.
6 *
7 */
8
9 #include "atheme.h"
10
11 DECLARE_MODULE_V1
12 (
13 "chanserv/clear", false, _modinit, _moddeinit,
14 PACKAGE_STRING,
15 VENDOR_STRING
16 );
17
18 static void cs_cmd_clear(sourceinfo_t *si, int parc, char *parv[]);
19 static void cs_help_clear(sourceinfo_t *si, const char *subcmd);
20
21 command_t cs_clear = { "CLEAR", N_("Channel removal toolkit."),
22 AC_NONE, 3, cs_cmd_clear, { .func = cs_help_clear } };
23
24 mowgli_patricia_t *cs_clear_cmds;
25
26 void _modinit(module_t *m)
27 {
28 service_named_bind_command("chanserv", &cs_clear);
29
30 cs_clear_cmds = mowgli_patricia_create(strcasecanon);
31 }
32
33 void _moddeinit(module_unload_intent_t intent)
34 {
35 service_named_unbind_command("chanserv", &cs_clear);
36
37 mowgli_patricia_destroy(cs_clear_cmds, NULL, NULL);
38 }
39
40 static void cs_help_clear(sourceinfo_t *si, const char *subcmd)
41 {
42 if (!subcmd)
43 {
44 command_success_nodata(si, _("***** \2%s Help\2 *****"), chansvs.me->disp);
45 command_success_nodata(si, _("Help for \2CLEAR\2:"));
46 command_success_nodata(si, " ");
47 command_success_nodata(si, _("CLEAR allows you to clear various aspects of a channel."));
48 command_success_nodata(si, " ");
49 command_help(si, cs_clear_cmds);
50 command_success_nodata(si, " ");
51 command_success_nodata(si, _("For more information, use \2/msg %s HELP CLEAR \37command\37\2."), chansvs.me->disp);
52 command_success_nodata(si, _("***** \2End of Help\2 *****"));
53 }
54 else
55 help_display(si, si->service, subcmd, cs_clear_cmds);
56 }
57
58 static void cs_cmd_clear(sourceinfo_t *si, int parc, char *parv[])
59 {
60 char *chan;
61 char *cmd;
62 command_t *c;
63
64 if (parc < 2)
65 {
66 command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "CLEAR");
67 command_fail(si, fault_needmoreparams, _("Syntax: CLEAR <#channel> <command> [parameters]"));
68 return;
69 }
70
71 if (parv[0][0] == '#')
72 chan = parv[0], cmd = parv[1];
73 else if (parv[1][0] == '#')
74 cmd = parv[0], chan = parv[1];
75 else
76 {
77 command_fail(si, fault_badparams, STR_INVALID_PARAMS, "CLEAR");
78 command_fail(si, fault_badparams, _("Syntax: CLEAR <#channel> <command> [parameters]"));
79 return;
80 }
81
82 c = command_find(cs_clear_cmds, cmd);
83 if (c == NULL)
84 {
85 command_fail(si, fault_badparams, _("Invalid command. Use \2/%s%s help\2 for a command listing."), (ircd->uses_rcommand == false) ? "msg " : "", chansvs.me->disp);
86 return;
87 }
88
89 parv[1] = chan;
90 command_exec(si->service, si, c, parc - 1, parv + 1);
91 }
92
93 /* vim:cinoptions=>s,e0,n0,f0,{0,}0,^0,=s,ps,t0,c3,+s,(2s,us,)20,*30,gs,hs
94 * vim:ts=8
95 * vim:sw=8
96 * vim:noexpandtab
97 */