#include "modules.h"
-#include "s_log.h"
+#include "logger.h"
#include "ircd.h"
#include "client.h"
#include "send.h"
#include "numeric.h"
#include "parse.h"
#include "ircd_defs.h"
-#include "irc_string.h"
-#include "memory.h"
-#include "tools.h"
-#include "sprintf_irc.h"
+#include "match.h"
"m_part",
"m_quit",
"m_server",
- "m_sjoin",
"m_squit",
NULL
};
int num_mods = 0;
int max_mods = MODS_INCREMENT;
-static dlink_list mod_paths;
+static rb_dlink_list mod_paths;
static int mo_modload(struct Client *, struct Client *, int, const char **);
static int mo_modlist(struct Client *, struct Client *, int, const char **);
static struct module_path *
mod_find_path(const char *path)
{
- dlink_node *ptr;
+ rb_dlink_node *ptr;
struct module_path *mpath;
- DLINK_FOREACH(ptr, mod_paths.head)
+ RB_DLINK_FOREACH(ptr, mod_paths.head)
{
mpath = ptr->data;
if(mod_find_path(path))
return;
- pathst = MyMalloc(sizeof(struct module_path));
+ pathst = rb_malloc(sizeof(struct module_path));
strcpy(pathst->path, path);
- dlinkAddAlloc(pathst, &mod_paths);
+ rb_dlinkAddAlloc(pathst, &mod_paths);
}
/* mod_clear_paths()
void
mod_clear_paths(void)
{
- dlink_node *ptr, *next_ptr;
+ rb_dlink_node *ptr, *next_ptr;
- DLINK_FOREACH_SAFE(ptr, next_ptr, mod_paths.head)
+ RB_DLINK_FOREACH_SAFE(ptr, next_ptr, mod_paths.head)
{
- MyFree(ptr->data);
- free_dlink_node(ptr);
+ rb_free(ptr->data);
+ rb_free_rb_dlink_node(ptr);
}
mod_paths.head = mod_paths.tail = NULL;
char *
irc_basename(const char *path)
{
- char *mod_basename = MyMalloc(strlen(path) + 1);
+ char *mod_basename = rb_malloc(strlen(path) + 1);
const char *s;
if(!(s = strrchr(path, '/')))
modules_init();
- modlist = (struct module **) MyMalloc(sizeof(struct module) * (MODS_INCREMENT));
+ modlist = (struct module **) rb_malloc(sizeof(struct module) * (MODS_INCREMENT));
max_mods = MODS_INCREMENT;
len = strlen(ldirent->d_name);
if((len > 3) && !strcmp(ldirent->d_name+len-3, SHARED_SUFFIX))
{
- (void) ircsnprintf(module_fq_name, sizeof(module_fq_name), "%s/%s", AUTOMODPATH, ldirent->d_name);
+ (void) rb_snprintf(module_fq_name, sizeof(module_fq_name), "%s/%s", AUTOMODPATH, ldirent->d_name);
(void) load_a_module(module_fq_name, warn, 0);
}
for (i = 0; core_module_table[i]; i++)
{
- ircsnprintf(module_name, sizeof(module_name), "%s/%s%s", MODPATH,
+ rb_snprintf(module_name, sizeof(module_name), "%s/%s%s", MODPATH,
core_module_table[i], SHARED_SUFFIX);
if(load_a_module(module_name, warn, 1) == -1)
load_one_module(const char *path, int coremodule)
{
char modpath[MAXPATHLEN];
- dlink_node *pathst;
+ rb_dlink_node *pathst;
struct module_path *mpath;
struct stat statbuf;
if (server_state_foreground == 1)
inotice("loading module %s ...", path);
- DLINK_FOREACH(pathst, mod_paths.head)
+ RB_DLINK_FOREACH(pathst, mod_paths.head)
{
mpath = pathst->data;
- ircsnprintf(modpath, sizeof(modpath), "%s/%s", mpath->path, path);
+ rb_snprintf(modpath, sizeof(modpath), "%s/%s", mpath->path, path);
if((strstr(modpath, "../") == NULL) && (strstr(modpath, "/..") == NULL))
{
if(stat(modpath, &statbuf) == 0)
if(findmodule_byname(m_bn) != -1)
{
sendto_one_notice(source_p, ":Module %s is already loaded", m_bn);
- MyFree(m_bn);
+ rb_free(m_bn);
return 0;
}
load_one_module(parv[1], 0);
- MyFree(m_bn);
+ rb_free(m_bn);
return 0;
}
if((modindex = findmodule_byname(m_bn)) == -1)
{
sendto_one_notice(source_p, ":Module %s is not loaded", m_bn);
- MyFree(m_bn);
+ rb_free(m_bn);
return 0;
}
if(modlist[modindex]->core == 1)
{
sendto_one_notice(source_p, ":Module %s is a core module and may not be unloaded", m_bn);
- MyFree(m_bn);
+ rb_free(m_bn);
return 0;
}
sendto_one_notice(source_p, ":Module %s is not loaded", m_bn);
}
- MyFree(m_bn);
+ rb_free(m_bn);
return 0;
}
if((modindex = findmodule_byname(m_bn)) == -1)
{
sendto_one_notice(source_p, ":Module %s is not loaded", m_bn);
- MyFree(m_bn);
+ rb_free(m_bn);
return 0;
}
if(unload_one_module(m_bn, 1) == -1)
{
sendto_one_notice(source_p, ":Module %s is not loaded", m_bn);
- MyFree(m_bn);
+ rb_free(m_bn);
return 0;
}
exit(0);
}
- MyFree(m_bn);
+ rb_free(m_bn);
return 0;
}
dlclose(modlist[modindex]->address);
- MyFree(modlist[modindex]->name);
+ rb_free(modlist[modindex]->name);
memcpy(&modlist[modindex], &modlist[modindex + 1],
sizeof(struct module) * ((num_mods - 1) - modindex));
sendto_realops_snomask(SNO_GENERAL, L_ALL,
"Error loading module %s: %s", mod_basename, err);
ilog(L_MAIN, "Error loading module %s: %s", mod_basename, err);
- MyFree(mod_basename);
+ rb_free(mod_basename);
return -1;
}
mod_basename);
ilog(L_MAIN, "Data format error: module %s has no MAPI header.", mod_basename);
(void) dlclose(tmpptr);
- MyFree(mod_basename);
+ rb_free(mod_basename);
return -1;
}
"Module %s indicated failure during load.",
mod_basename);
dlclose(tmpptr);
- MyFree(mod_basename);
+ rb_free(mod_basename);
return -1;
}
if(mheader->mapi_command_list)
"Module %s has unknown/unsupported MAPI version %d.",
mod_basename, *mapi_version);
dlclose(tmpptr);
- MyFree(mod_basename);
+ rb_free(mod_basename);
return -1;
}
increase_modlist();
- modlist[num_mods] = MyMalloc(sizeof(struct module));
+ modlist[num_mods] = rb_malloc(sizeof(struct module));
modlist[num_mods]->address = tmpptr;
modlist[num_mods]->version = ver;
modlist[num_mods]->core = core;
- DupString(modlist[num_mods]->name, mod_basename);
+ modlist[num_mods]->name = rb_strdup(mod_basename);
modlist[num_mods]->mapi_header = mapi_version;
modlist[num_mods]->mapi_version = MAPI_VERSION(*mapi_version);
num_mods++;
ilog(L_MAIN, "Module %s [version: %s; MAPI version: %d] loaded at 0x%lx",
mod_basename, ver, MAPI_VERSION(*mapi_version), (unsigned long) tmpptr);
}
- MyFree(mod_basename);
+ rb_free(mod_basename);
return 0;
}
if((num_mods + 1) < max_mods)
return;
- new_modlist = (struct module **) MyMalloc(sizeof(struct module) *
+ new_modlist = (struct module **) rb_malloc(sizeof(struct module) *
(max_mods + MODS_INCREMENT));
memcpy((void *) new_modlist, (void *) modlist, sizeof(struct module) * num_mods);
- MyFree(modlist);
+ rb_free(modlist);
modlist = new_modlist;
max_mods += MODS_INCREMENT;
}