Debian Codegraph @

modules/nickserv/set_core.c

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