ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/ermyth/modules/operserv/modload.C
Revision: 1.6
Committed: Thu Aug 30 19:56:24 2007 UTC (19 years, 1 month ago) by pippijn
Content type: text/plain
Branch: MAIN
Changes since 1.5: +11 -11 lines
Log Message:
- put faultcodes into their own namespace
- removed old files
- limited header garbage in atheme.h
- macros to inline bools for connection_t::is_*
- put some connection_t functions into the connection_t class

File Contents

# User Rev Content
1 pippijn 1.1 /*
2 pippijn 1.5 * Copyright © 2005-2006 William Pitcock, et al.
3 pippijn 1.2 * Rights to this code are as documented in doc/pod/license.pod.
4 pippijn 1.1 *
5     * Loads a new module in.
6     *
7 pippijn 1.6 * $Id: modload.C,v 1.5 2007-08-28 17:08:11 pippijn Exp $
8 pippijn 1.1 */
9    
10     #include "atheme.h"
11 pippijn 1.5 #include <ermyth/module.h>
12 pippijn 1.1
13 pippijn 1.6 static char const rcsid[] = "$Id: modload.C,v 1.5 2007-08-28 17:08:11 pippijn Exp $";
14 pippijn 1.1
15 pippijn 1.5 REGISTER_MODULE ("operserv/modload", false, "The Ermyth Team <http://ermyth.schmorp.de>");
16 pippijn 1.1
17     static void os_cmd_modload (sourceinfo_t *si, int parc, char *parv[]);
18    
19 pippijn 1.5 command_t const os_modload = { "MODLOAD", N_("Loads a module."), PRIV_ADMIN, 20, os_cmd_modload };
20 pippijn 1.1
21 pippijn 1.5 E cmdvec os_cmdtree;
22     E helpvec os_helptree;
23 pippijn 1.1
24 pippijn 1.5 bool
25     _modinit (module *m)
26 pippijn 1.1 {
27     os_cmdtree << os_modload;
28 pippijn 1.4 help_addentry (os_helptree, "MODLOAD", "help/operserv/modload", NULL);
29 pippijn 1.5
30     return true;
31 pippijn 1.1 }
32    
33     void
34     _moddeinit ()
35     {
36     os_cmdtree >> os_modload;
37     help_delentry (os_helptree, "MODLOAD");
38     }
39    
40     static void
41     os_cmd_modload (sourceinfo_t *si, int parc, char *parv[])
42     {
43 pippijn 1.5 char *modname;
44 pippijn 1.1 int i;
45    
46     if (parc < 1)
47     {
48 pippijn 1.6 command_fail (si, fault::needmoreparams, STR_INSUFFICIENT_PARAMS, "MODLOAD");
49     command_fail (si, fault::needmoreparams, _("Syntax: MODLOAD <module...>"));
50 pippijn 1.1 return;
51     }
52     i = 0;
53     while (i < parc)
54     {
55 pippijn 1.5 modname = parv[i++];
56    
57     logcommand (si, CMDLOG_ADMIN, "MODLOAD %s", modname);
58 pippijn 1.6 fault::code success = modules::enable (modname);
59 pippijn 1.5
60     switch (success)
61     {
62 pippijn 1.6 case fault::nosuch_target:
63     command_fail (si, fault::nosuch_target, _("\2%s\2 does not exist."), modname);
64 pippijn 1.5 continue;
65 pippijn 1.6 case fault::nochange:
66     command_fail (si, fault::nochange, _("\2%s\2 is already loaded."), modname);
67 pippijn 1.5 continue;
68 pippijn 1.6 case fault::ok:
69 pippijn 1.5 command_success_nodata (si, _("Module \2%s\2 loaded."), modname);
70     continue;
71     default:
72 pippijn 1.6 command_fail (si, fault::nosuch_target, _("Module \2%s\2 failed to load."), modname);
73 pippijn 1.5 continue;
74     }
75 pippijn 1.1 }
76     }