- sendto_realops_snomask(SNO_GENERAL, L_ALL, "Cannot locate module %s", path);
- return false;
-}
-
-
-/* load a module .. */
-static void
-mo_modload(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char **parv)
-{
- if(!IsOperAdmin(source_p))
- {
- sendto_one(source_p, form_str(ERR_NOPRIVS),
- me.name, source_p->name, "admin");
- return;
- }
-
- if(parc > 2)
- {
- sendto_match_servs(source_p, parv[2], CAP_ENCAP, NOCAPS,
- "ENCAP %s MODLOAD %s", parv[2], parv[1]);
- if(match(parv[2], me.name) == 0)
- return;
- }
-
- do_modload(source_p, parv[1]);
-}
-
-static void
-me_modload(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char **parv)
-{
- if(!find_shared_conf(source_p->username, source_p->host, source_p->servptr->name, SHARED_MODULE))
- {
- sendto_one_notice(source_p, ":*** You do not have an appropriate shared block "
- "to load modules on this server.");
- return;
- }
-
- do_modload(source_p, parv[1]);
-}
-
-
-/* unload a module .. */
-static void
-mo_modunload(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char **parv)
-{
- if(!IsOperAdmin(source_p))
- {
- sendto_one(source_p, form_str(ERR_NOPRIVS),
- me.name, source_p->name, "admin");
- return;
- }
-
- if(parc > 2)
- {
- sendto_match_servs(source_p, parv[2], CAP_ENCAP, NOCAPS,
- "ENCAP %s MODUNLOAD %s", parv[2], parv[1]);
- if(match(parv[2], me.name) == 0)
- return;
- }
-
- do_modunload(source_p, parv[1]);
-}
-
-static void
-me_modunload(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char **parv)
-{
- if(!find_shared_conf(source_p->username, source_p->host, source_p->servptr->name, SHARED_MODULE))
- {
- sendto_one_notice(source_p, ":*** You do not have an appropriate shared block "
- "to load modules on this server.");
- return;
- }
-
- do_modunload(source_p, parv[1]);
-}
-
-/* unload and load in one! */
-static void
-mo_modreload(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char **parv)
-{
- if(!IsOperAdmin(source_p))
- {
- sendto_one(source_p, form_str(ERR_NOPRIVS),
- me.name, source_p->name, "admin");
- return;
- }
-
- if(parc > 2)
- {
- sendto_match_servs(source_p, parv[2], CAP_ENCAP, NOCAPS,
- "ENCAP %s MODRELOAD %s", parv[2], parv[1]);
- if(match(parv[2], me.name) == 0)
- return;
- }
-
- do_modreload(source_p, parv[1]);
-}
-
-static void
-me_modreload(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char **parv)
-{
- if(!find_shared_conf(source_p->username, source_p->host, source_p->servptr->name, SHARED_MODULE))
- {
- sendto_one_notice(source_p, ":*** You do not have an appropriate shared block "
- "to load modules on this server.");
- return;
- }
-
- do_modreload(source_p, parv[1]);
-}
-
-/* list modules .. */
-static void
-mo_modlist(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char **parv)
-{
- if(!IsOperAdmin(source_p))
- {
- sendto_one(source_p, form_str(ERR_NOPRIVS),
- me.name, source_p->name, "admin");
- return;
- }
-
- if(parc > 2)
- {
- sendto_match_servs(source_p, parv[2], CAP_ENCAP, NOCAPS,
- "ENCAP %s MODLIST %s", parv[2], parv[1]);
- if(match(parv[2], me.name) == 0)
- return;
- }
-
- do_modlist(source_p, parc > 1 ? parv[1] : 0);
-}
-
-static void
-me_modlist(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char **parv)
-{
- if(!find_shared_conf(source_p->username, source_p->host, source_p->servptr->name, SHARED_MODULE))
- {
- sendto_one_notice(source_p, ":*** You do not have an appropriate shared block "
- "to load modules on this server.");
- return;
- }
-
- do_modlist(source_p, parv[1]);
-}
-
-/* unload and reload all modules */
-static void
-mo_modrestart(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char **parv)
-{
- if(!IsOperAdmin(source_p))
- {
- sendto_one(source_p, form_str(ERR_NOPRIVS),
- me.name, source_p->name, "admin");
- return;
- }
-
- if(parc > 1)
- {
- sendto_match_servs(source_p, parv[1], CAP_ENCAP, NOCAPS,
- "ENCAP %s MODRESTART", parv[1]);
- if(match(parv[1], me.name) == 0)
- return;
- }
-
- do_modrestart(source_p);
-}
-
-static void
-me_modrestart(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char **parv)
-{
- if(!find_shared_conf(source_p->username, source_p->host, source_p->servptr->name, SHARED_MODULE))
- {
- sendto_one_notice(source_p, ":*** You do not have an appropriate shared block "
- "to load modules on this server.");
- return;
- }
-
- do_modrestart(source_p);
-}
-
-static void
-do_modload(struct Client *source_p, const char *module)
-{
- char *m_bn = rb_basename(module);
- int origin;
-
- if(findmodule_byname(m_bn) != -1)
- {
- sendto_one_notice(source_p, ":Module %s is already loaded", m_bn);
- rb_free(m_bn);
- return;
- }
-
- origin = strcmp(module, m_bn) == 0 ? MAPI_ORIGIN_CORE : MAPI_ORIGIN_EXTENSION;
- load_one_module(module, origin, false);
-
- rb_free(m_bn);
-}
-
-static void
-do_modunload(struct Client *source_p, const char *module)
-{
- int modindex;
- char *m_bn = rb_basename(module);
-
- if((modindex = findmodule_byname(m_bn)) == -1)
- {
- sendto_one_notice(source_p, ":Module %s is not loaded", m_bn);
- rb_free(m_bn);
- return;
- }
-
- if(modlist[modindex]->core)
- {
- sendto_one_notice(source_p, ":Module %s is a core module and may not be unloaded", m_bn);
- rb_free(m_bn);
- return;
- }
-
- if(unload_one_module(m_bn, true) == false)
- sendto_one_notice(source_p, ":Module %s is not loaded", m_bn);
-
- rb_free(m_bn);
-}
-
-static void
-do_modreload(struct Client *source_p, const char *module)
-{
- int modindex;
- int check_core;
- char *m_bn = rb_basename(module);
-
- if((modindex = findmodule_byname(m_bn)) == -1)
- {
- sendto_one_notice(source_p, ":Module %s is not loaded", m_bn);
- rb_free(m_bn);
- return;
- }
-
- check_core = modlist[modindex]->core;
-
- if(unload_one_module(m_bn, true) == false)
- {
- sendto_one_notice(source_p, ":Module %s is not loaded", m_bn);
- rb_free(m_bn);
- return;
- }
-
- if((load_one_module(m_bn, modlist[modindex]->origin, check_core) == false) && check_core)
- {
- sendto_realops_snomask(SNO_GENERAL, L_NETWIDE,
- "Error reloading core module: %s: terminating ircd", m_bn);
- ilog(L_MAIN, "Error loading core module %s: terminating ircd", m_bn);
- exit(0);
- }
-
- rb_free(m_bn);
-}
-
-static void
-do_modrestart(struct Client *source_p)
-{
- int modnum;
-
- sendto_one_notice(source_p, ":Reloading all modules");
-
- modnum = num_mods;
- while (num_mods)
- unload_one_module(modlist[0]->name, false);
-
- load_all_modules(0);
- load_core_modules(0);
- rehash(0);
-
- sendto_realops_snomask(SNO_GENERAL, L_NETWIDE,
- "Module Restart: %d modules unloaded, %d modules loaded",
- modnum, num_mods);
- ilog(L_MAIN, "Module Restart: %d modules unloaded, %d modules loaded", modnum, num_mods);
-}
-
-static void
-do_modlist(struct Client *source_p, const char *pattern)
-{
- int i;
-
- for (i = 0; i < num_mods; i++)
- {
- const char *origin;
- switch (modlist[i]->origin)
- {
- case MAPI_ORIGIN_EXTENSION:
- origin = "extension";
- break;
- case MAPI_ORIGIN_CORE:
- origin = "builtin";
- break;
- default:
- origin = "unknown";
- break;
- }