/** * modunload.C: Removes a module from memory. * * Copyright © 2007 Pippijn van Steenhoven / The Ermyth Team * Rights to this code are as documented in COPYING. * * * Portions of this file were derived from sources bearing the following license: * Copyright © 2005-2006 William Pitcock, et al. * Rights to this code are as documented in doc/pod/license.pod. * * $Id: modunload.C,v 1.8 2007/09/22 14:27:28 pippijn Exp $ */ #include "atheme.h" #include static char const rcsid[] = "$Id: modunload.C,v 1.8 2007/09/22 14:27:28 pippijn Exp $"; REGISTER_MODULE ("operserv/modunload", false, "The Ermyth Team "); static void os_cmd_modunload (sourceinfo_t *si, int parc, char *parv[]); command_t const os_modunload = { "MODUNLOAD", N_("Unloads a module."), PRIV_ADMIN, 20, os_cmd_modunload }; E cmdvec os_cmdtree; E helpvec os_helptree; bool _modinit (module *m) { os_cmdtree << os_modunload; help_addentry (os_helptree, "MODUNLOAD", "help/operserv/modunload", NULL); return true; } void _moddeinit () { os_cmdtree >> os_modunload; help_delentry (os_helptree, "MODUNLOAD"); } static void os_cmd_modunload (sourceinfo_t *si, int parc, char *parv[]) { char *modname; int i; if (parc < 1) { command_fail (si, fault::needmoreparams, STR_INSUFFICIENT_PARAMS, "MODUNLOAD"); command_fail (si, fault::needmoreparams, _("Syntax: MODUNLOAD ")); return; } i = 0; while (i < parc) { modname = parv[i++]; if (!strcmp (modname, "operserv/main") || !strcmp (modname, "operserv/modload") || !strcmp (modname, "operserv/modunload")) { command_fail (si, fault::noprivs, _("Refusing to unload \2%s\2."), modname); continue; } fault::code success = modules::disable (modname); switch (success) { case fault::nosuch_target: command_fail (si, fault::nosuch_target, _("\2%s\2 does not exist."), modname); continue; case fault::nochange: command_fail (si, fault::nosuch_target, _("\2%s\2 is not loaded; it cannot be unloaded."), modname); continue; case fault::noprivs: slog (LG_INFO, "%s tried to unload a permanent module", get_oper_name (si)); command_fail (si, fault::noprivs, _("\2%s\2 is an permanent module; it cannot be unloaded."), modname); continue; default: logcommand (si, CMDLOG_ADMIN, "MODUNLOAD %s", modname); command_success_nodata (si, _("Module \2%s\2 unloaded."), modname); continue; } } }