ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/ermyth/modules/operserv/modunload.C
Revision: 1.5
Committed: Tue Aug 28 17:08:11 2007 UTC (19 years, 1 month ago) by pippijn
Content type: text/plain
Branch: MAIN
Changes since 1.4: +36 -47 lines
Log Message:
- changed name
- updated the example config to the new system
- added more documentation
- enhanced documentation generators
- added a link to the pdf to the website
- added an RSS feed generator
- transitioned hooks to c++ callbacks
- did various merges with upstream along the way
- added const where appropriate
- removed the old block allocator
- fixed most memory leaks
- transitioned some dictionaries to std::map
- transitioned some lists to std::vector
- made some free functions members where appropriate
- renamed string to dynstr and added a static string ststr
- use NOW instead of time (NULL) if possible
- completely reworked database backends, crypto handlers and protocol handlers
  to use an object factory
- removed the old module system. ermyth does not do any dynamic loading anymore
- fixed most of the build system
- reworked how protocol commands work

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     * Removes a module from memory.
6     *
7 pippijn 1.5 * $Id: modunload.C,v 1.4 2007-07-22 18:38:43 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.5 static char const rcsid[] = "$Id: modunload.C,v 1.4 2007-07-22 18:38:43 pippijn Exp $";
14 pippijn 1.1
15 pippijn 1.5 REGISTER_MODULE ("operserv/modunload", false, "The Ermyth Team <http://ermyth.schmorp.de>");
16 pippijn 1.1
17     static void os_cmd_modunload (sourceinfo_t *si, int parc, char *parv[]);
18    
19 pippijn 1.5 command_t const os_modunload = { "MODUNLOAD", N_("Unloads a module."), PRIV_ADMIN, 20, os_cmd_modunload };
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_modunload;
28 pippijn 1.4 help_addentry (os_helptree, "MODUNLOAD", "help/operserv/modunload", NULL);
29 pippijn 1.5
30     return true;
31 pippijn 1.1 }
32    
33     void
34     _moddeinit ()
35     {
36     os_cmdtree >> os_modunload;
37     help_delentry (os_helptree, "MODUNLOAD");
38     }
39    
40     static void
41     os_cmd_modunload (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     command_fail (si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "MODUNLOAD");
49     command_fail (si, fault_needmoreparams, _("Syntax: MODUNLOAD <module...>"));
50     return;
51     }
52     i = 0;
53     while (i < parc)
54     {
55 pippijn 1.5 modname = parv[i++];
56 pippijn 1.1
57 pippijn 1.5 if (!strcmp (modname, "operserv/main")
58     || !strcmp (modname, "operserv/modload")
59     || !strcmp (modname, "operserv/modunload"))
60 pippijn 1.1 {
61 pippijn 1.5 command_fail (si, fault_noprivs, _("Refusing to unload \2%s\2."), modname);
62 pippijn 1.1 continue;
63     }
64    
65 pippijn 1.5 faultcode_t success = modules::disable (modname);
66    
67     switch (success)
68     {
69     case fault_nosuch_target:
70     command_fail (si, fault_nosuch_target, _("\2%s\2 does not exist."), modname);
71     continue;
72     case fault_nochange:
73     command_fail (si, fault_nosuch_target, _("\2%s\2 is not loaded; it cannot be unloaded."), modname);
74     continue;
75     case fault_noprivs:
76 pippijn 1.1 slog (LG_INFO, "%s tried to unload a permanent module", get_oper_name (si));
77 pippijn 1.5 command_fail (si, fault_noprivs, _("\2%s\2 is an permanent module; it cannot be unloaded."), modname);
78     continue;
79     default:
80     logcommand (si, CMDLOG_ADMIN, "MODUNLOAD %s", modname);
81     command_success_nodata (si, _("Module \2%s\2 unloaded."), modname);
82     continue;
83     }
84 pippijn 1.1 }
85     }