m_modules: use new module api
This commit is contained in:
parent
1e37cb443d
commit
2185c50aad
1 changed files with 30 additions and 24 deletions
|
@ -265,7 +265,7 @@ do_modload(struct Client *source_p, const char *module)
|
||||||
char *m_bn = rb_basename(module);
|
char *m_bn = rb_basename(module);
|
||||||
int origin;
|
int origin;
|
||||||
|
|
||||||
if(findmodule_byname(m_bn) != -1)
|
if(findmodule_byname(m_bn) != NULL)
|
||||||
{
|
{
|
||||||
sendto_one_notice(source_p, ":Module %s is already loaded", m_bn);
|
sendto_one_notice(source_p, ":Module %s is already loaded", m_bn);
|
||||||
rb_free(m_bn);
|
rb_free(m_bn);
|
||||||
|
@ -281,17 +281,17 @@ do_modload(struct Client *source_p, const char *module)
|
||||||
static void
|
static void
|
||||||
do_modunload(struct Client *source_p, const char *module)
|
do_modunload(struct Client *source_p, const char *module)
|
||||||
{
|
{
|
||||||
int modindex;
|
struct module *mod;
|
||||||
char *m_bn = rb_basename(module);
|
char *m_bn = rb_basename(module);
|
||||||
|
|
||||||
if((modindex = findmodule_byname(m_bn)) == -1)
|
if((mod = findmodule_byname(m_bn)) == NULL)
|
||||||
{
|
{
|
||||||
sendto_one_notice(source_p, ":Module %s is not loaded", m_bn);
|
sendto_one_notice(source_p, ":Module %s is not loaded", m_bn);
|
||||||
rb_free(m_bn);
|
rb_free(m_bn);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(modlist[modindex]->core)
|
if(mod->core)
|
||||||
{
|
{
|
||||||
sendto_one_notice(source_p, ":Module %s is a core module and may not be unloaded", m_bn);
|
sendto_one_notice(source_p, ":Module %s is a core module and may not be unloaded", m_bn);
|
||||||
rb_free(m_bn);
|
rb_free(m_bn);
|
||||||
|
@ -307,18 +307,18 @@ do_modunload(struct Client *source_p, const char *module)
|
||||||
static void
|
static void
|
||||||
do_modreload(struct Client *source_p, const char *module)
|
do_modreload(struct Client *source_p, const char *module)
|
||||||
{
|
{
|
||||||
int modindex;
|
struct module *mod;
|
||||||
int check_core;
|
int check_core;
|
||||||
char *m_bn = rb_basename(module);
|
char *m_bn = rb_basename(module);
|
||||||
|
|
||||||
if((modindex = findmodule_byname(m_bn)) == -1)
|
if((mod = findmodule_byname(m_bn)) == NULL)
|
||||||
{
|
{
|
||||||
sendto_one_notice(source_p, ":Module %s is not loaded", m_bn);
|
sendto_one_notice(source_p, ":Module %s is not loaded", m_bn);
|
||||||
rb_free(m_bn);
|
rb_free(m_bn);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
check_core = modlist[modindex]->core;
|
check_core = mod->core;
|
||||||
|
|
||||||
if(unload_one_module(m_bn, true) == false)
|
if(unload_one_module(m_bn, true) == false)
|
||||||
{
|
{
|
||||||
|
@ -327,7 +327,7 @@ do_modreload(struct Client *source_p, const char *module)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((load_one_module(m_bn, modlist[modindex]->origin, check_core) == false) && check_core)
|
if((load_one_module(m_bn, mod->origin, check_core) == false) && check_core)
|
||||||
{
|
{
|
||||||
sendto_realops_snomask(SNO_GENERAL, L_NETWIDE,
|
sendto_realops_snomask(SNO_GENERAL, L_NETWIDE,
|
||||||
"Error reloading core module: %s: terminating ircd", m_bn);
|
"Error reloading core module: %s: terminating ircd", m_bn);
|
||||||
|
@ -341,33 +341,39 @@ do_modreload(struct Client *source_p, const char *module)
|
||||||
static void
|
static void
|
||||||
do_modrestart(struct Client *source_p)
|
do_modrestart(struct Client *source_p)
|
||||||
{
|
{
|
||||||
int modnum;
|
unsigned int modnum = 0;
|
||||||
|
rb_dlink_node *ptr, *nptr;
|
||||||
|
|
||||||
sendto_one_notice(source_p, ":Reloading all modules");
|
sendto_one_notice(source_p, ":Reloading all modules");
|
||||||
|
|
||||||
modnum = num_mods;
|
RB_DLINK_FOREACH_SAFE(ptr, nptr, module_list.head)
|
||||||
while (num_mods)
|
{
|
||||||
unload_one_module(modlist[0]->name, false);
|
struct module *mod = ptr->data;
|
||||||
|
unload_one_module(mod->name, false);
|
||||||
|
modnum++;
|
||||||
|
}
|
||||||
|
|
||||||
load_all_modules(false);
|
load_all_modules(false);
|
||||||
load_core_modules(false);
|
load_core_modules(false);
|
||||||
rehash(false);
|
rehash(false);
|
||||||
|
|
||||||
sendto_realops_snomask(SNO_GENERAL, L_NETWIDE,
|
sendto_realops_snomask(SNO_GENERAL, L_NETWIDE,
|
||||||
"Module Restart: %d modules unloaded, %d modules loaded",
|
"Module Restart: %u modules unloaded, %lu modules loaded",
|
||||||
modnum, num_mods);
|
modnum, rb_dlink_list_length(&module_list));
|
||||||
ilog(L_MAIN, "Module Restart: %d modules unloaded, %d modules loaded", modnum, num_mods);
|
ilog(L_MAIN, "Module Restart: %u modules unloaded, %lu modules loaded", modnum, rb_dlink_list_length(&module_list));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
do_modlist(struct Client *source_p, const char *pattern)
|
do_modlist(struct Client *source_p, const char *pattern)
|
||||||
{
|
{
|
||||||
|
rb_dlink_node *ptr;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < num_mods; i++)
|
RB_DLINK_FOREACH(ptr, module_list.head)
|
||||||
{
|
{
|
||||||
|
struct module *mod = ptr->data;
|
||||||
const char *origin;
|
const char *origin;
|
||||||
switch (modlist[i]->origin)
|
switch (mod->origin)
|
||||||
{
|
{
|
||||||
case MAPI_ORIGIN_EXTENSION:
|
case MAPI_ORIGIN_EXTENSION:
|
||||||
origin = "extension";
|
origin = "extension";
|
||||||
|
@ -382,21 +388,21 @@ do_modlist(struct Client *source_p, const char *pattern)
|
||||||
|
|
||||||
if(pattern)
|
if(pattern)
|
||||||
{
|
{
|
||||||
if(match(pattern, modlist[i]->name))
|
if(match(pattern, mod->name))
|
||||||
{
|
{
|
||||||
sendto_one(source_p, form_str(RPL_MODLIST),
|
sendto_one(source_p, form_str(RPL_MODLIST),
|
||||||
me.name, source_p->name,
|
me.name, source_p->name,
|
||||||
modlist[i]->name,
|
mod->name,
|
||||||
(unsigned long)(uintptr_t)modlist[i]->address, origin,
|
(unsigned long)(uintptr_t)mod->address, origin,
|
||||||
modlist[i]->core ? " (core)" : "", modlist[i]->version, modlist[i]->description);
|
mod->core ? " (core)" : "", mod->version, mod->description);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sendto_one(source_p, form_str(RPL_MODLIST),
|
sendto_one(source_p, form_str(RPL_MODLIST),
|
||||||
me.name, source_p->name, modlist[i]->name,
|
me.name, source_p->name, mod->name,
|
||||||
(unsigned long)(uintptr_t)modlist[i]->address, origin,
|
(unsigned long)(uintptr_t)mod->address, origin,
|
||||||
modlist[i]->core ? " (core)" : "", modlist[i]->version, modlist[i]->description);
|
mod->core ? " (core)" : "", mod->version, mod->description);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue