ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/ermyth/modules/operserv/modload.C
Revision: 1.4
Committed: Sun Jul 22 18:38:43 2007 UTC (19 years, 2 months ago) by pippijn
Content type: text/plain
Branch: MAIN
Changes since 1.3: +3 -3 lines
Log Message:
-fixed help
- temporarily work around corruption in jsonrpc

File Contents

# User Rev Content
1 pippijn 1.1 /*
2     * 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.4 * $Id: modload.C,v 1.3 2007-07-21 13:23:21 pippijn Exp $
8 pippijn 1.1 */
9    
10     #include "atheme.h"
11    
12 pippijn 1.4 static char const rcsid[] = "$Id: modload.C,v 1.3 2007-07-21 13:23:21 pippijn Exp $";
13 pippijn 1.1
14     struct os_modload_listeners : callback::has_listeners
15     {
16     };
17    
18     os_modload_listeners listeners;
19    
20     DECLARE_MODULE_V1 ("operserv/modload", false, _modinit, _moddeinit, rcsid, "The Ermyth Team <http://ermyth.schmorp.de>");
21    
22     static void os_cmd_modload (sourceinfo_t *si, int parc, char *parv[]);
23    
24     command_t os_modload = { "MODLOAD", N_("Loads a module."), PRIV_ADMIN, 20, os_cmd_modload };
25    
26     cmdvec *os_cmdtree;
27     helpvec *os_helptree;
28    
29     void
30     _modinit (module_t *m)
31     {
32     MODULE_USE_SYMBOL_T (os_cmdtree, cmdvec, "operserv/main", "os_cmdtree");
33     MODULE_USE_SYMBOL_T (os_helptree, helpvec, "operserv/main", "os_helptree");
34    
35     os_cmdtree << os_modload;
36 pippijn 1.4 help_addentry (os_helptree, "MODLOAD", "help/operserv/modload", NULL);
37 pippijn 1.1 }
38    
39     void
40     _moddeinit ()
41     {
42     os_cmdtree >> os_modload;
43     help_delentry (os_helptree, "MODLOAD");
44     }
45    
46     static void
47     os_cmd_modload (sourceinfo_t *si, int parc, char *parv[])
48     {
49     char *module;
50     module_t *m;
51     char pbuf[BUFSIZE + 1];
52     int i;
53    
54     if (parc < 1)
55     {
56     command_fail (si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "MODLOAD");
57     command_fail (si, fault_needmoreparams, _("Syntax: MODLOAD <module...>"));
58     return;
59     }
60     i = 0;
61     while (i < parc)
62     {
63     module = parv[i++];
64     if (module_find_published (module))
65     {
66     command_fail (si, fault_nochange, _("\2%s\2 is already loaded."), module);
67     continue;
68     }
69    
70     logcommand (si, CMDLOG_ADMIN, "MODLOAD %s", module);
71     if (*module != '/')
72     {
73     snprintf (pbuf, BUFSIZE, "%s/%s", MODDIR "/modules", module);
74     m = module_load (pbuf);
75     }
76     else
77     m = module_load (module);
78    
79     if (m != NULL)
80     command_success_nodata (si, _("Module \2%s\2 loaded."), module);
81     else
82     command_fail (si, fault_nosuch_target, _("Module \2%s\2 failed to load."), module);
83     }
84     }
85    
86     /* vim:cinoptions=>s,e0,n0,f0,{0,}0,^0,=s,ps,t0,c3,+s,(2s,us,)20,*30,gs,hs
87     * vim:ts=8
88     * vim:sw=8
89     * vim:noexpandtab
90     */