Debian Codegraph @

modules/groupserv/set.c

raw
1 /*
2 * Copyright (c) 2005 Atheme Development Group
3 * Rights to this code are documented in doc/LICENSE.
4 *
5 * This file contains routines to handle the GroupServ HELP command.
6 *
7 */
8
9 #include "atheme.h"
10
11 #define IN_GROUPSERV_SET
12 #include "groupserv.h"
13
14 DECLARE_MODULE_V1
15 (
16 "groupserv/set", false, _modinit, _moddeinit,
17 PACKAGE_STRING,
18 VENDOR_STRING
19 );
20
21 static void gs_help_set(sourceinfo_t *si, const char *subcmd);
22 static void gs_cmd_set(sourceinfo_t *si, int parc, char *parv[]);
23
24 command_t gs_set = { "SET", N_("Sets various control flags."), AC_AUTHENTICATED, 3, gs_cmd_set, { .func = gs_help_set } };
25
26 mowgli_patricia_t *gs_set_cmdtree;
27
28 void _modinit(module_t *m)
29 {
30 use_groupserv_main_symbols(m);
31
32 service_named_bind_command("groupserv", &gs_set);
33
34 gs_set_cmdtree = mowgli_patricia_create(strcasecanon);
35 }
36
37 void _moddeinit(module_unload_intent_t intent)
38 {
39 service_named_unbind_command("groupserv", &gs_set);
40
41 mowgli_patricia_destroy(gs_set_cmdtree, NULL, NULL);
42 }
43
44 static void gs_help_set(sourceinfo_t *si, const char *subcmd)
45 {
46 if (!subcmd)
47 {
48 command_success_nodata(si, _("***** \2%s Help\2 *****"), si->service->disp);
49 command_success_nodata(si, _("Help for \2SET\2:"));
50 command_success_nodata(si, " ");
51 command_success_nodata(si, _("SET allows you to set various control flags\n"
52 "for groups that change the way certain\n"
53 "operations are performed on them."));
54 command_success_nodata(si, " ");
55 command_help(si, gs_set_cmdtree);
56 command_success_nodata(si, " ");
57 command_success_nodata(si, _("For more specific help use \2/msg %s HELP SET \37command\37\2."), si->service->disp);
58 command_success_nodata(si, _("***** \2End of Help\2 *****"));
59 }
60 else
61 help_display_as_subcmd(si, si->service, "SET", subcmd, gs_set_cmdtree);
62 }
63
64 /* SET <!group> <setting> <parameters> */
65 static void gs_cmd_set(sourceinfo_t *si, int parc, char *parv[])
66 {
67 char *group;
68 char *cmd;
69 command_t *c;
70
71 if (parc < 2)
72 {
73 command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "SET");
74 command_fail(si, fault_needmoreparams, _("Syntax: SET <!group> <setting> [parameters]"));
75 return;
76 }
77
78 if (parv[0][0] == '!')
79 group = parv[0], cmd = parv[1];
80 else if (parv[1][0] == '!')
81 cmd = parv[0], group = parv[1];
82 else
83 {
84 command_fail(si, fault_badparams, STR_INVALID_PARAMS, "SET");
85 command_fail(si, fault_badparams, _("Syntax: SET <!group> <setting> [parameters]"));
86 return;
87 }
88
89 c = command_find(gs_set_cmdtree, cmd);
90 if (c == NULL)
91 {
92 command_fail(si, fault_badparams, _("Invalid command. Use \2/%s%s help\2 for a command listing."), (ircd->uses_rcommand == false) ? "msg " : "", si->service->disp);
93 return;
94 }
95
96 parv[1] = group;
97 command_exec(si->service, si, c, parc - 1, parv + 1);
98 }
99
100
101 /* vim:cinoptions=>s,e0,n0,f0,{0,}0,^0,=s,ps,t0,c3,+s,(2s,us,)20,*30,gs,hs
102 * vim:ts=8
103 * vim:sw=8
104 * vim:noexpandtab
105 */