X-Git-Url: https://jfr.im/git/irc/rqf/shadowircd.git/blobdiff_plain/af81d5a0b09446188fd6f9c292b51519f2c1cedd..d3455e2c7e2f9040e1b7628d9cf52b26a24dcefc:/src/modules.c diff --git a/src/modules.c b/src/modules.c index e6a50e7..068ab75 100644 --- a/src/modules.c +++ b/src/modules.c @@ -28,7 +28,7 @@ #include "modules.h" -#include "s_log.h" +#include "logger.h" #include "ircd.h" #include "client.h" #include "send.h" @@ -38,8 +38,6 @@ #include "parse.h" #include "ircd_defs.h" #include "irc_string.h" -#include "memory.h" -#include "tools.h" #include "sprintf_irc.h" @@ -141,7 +139,7 @@ mod_find_path(const char *path) rb_dlink_node *ptr; struct module_path *mpath; - DLINK_FOREACH(ptr, mod_paths.head) + RB_DLINK_FOREACH(ptr, mod_paths.head) { mpath = ptr->data; @@ -166,7 +164,7 @@ mod_add_path(const char *path) if(mod_find_path(path)) return; - pathst = MyMalloc(sizeof(struct module_path)); + pathst = rb_malloc(sizeof(struct module_path)); strcpy(pathst->path, path); rb_dlinkAddAlloc(pathst, &mod_paths); @@ -183,10 +181,10 @@ mod_clear_paths(void) { 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_rb_dlink_node(ptr); + rb_free(ptr->data); + rb_free_rb_dlink_node(ptr); } mod_paths.head = mod_paths.tail = NULL; @@ -202,7 +200,7 @@ mod_clear_paths(void) 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, '/'))) @@ -250,7 +248,7 @@ load_all_modules(int warn) 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; @@ -321,7 +319,7 @@ load_one_module(const char *path, int coremodule) 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; @@ -366,13 +364,13 @@ mo_modload(struct Client *client_p, struct Client *source_p, int parc, const cha 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; } @@ -397,14 +395,14 @@ mo_modunload(struct Client *client_p, struct Client *source_p, int parc, const c 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; } @@ -413,7 +411,7 @@ mo_modunload(struct Client *client_p, struct Client *source_p, int parc, const c sendto_one_notice(source_p, ":Module %s is not loaded", m_bn); } - MyFree(m_bn); + rb_free(m_bn); return 0; } @@ -437,7 +435,7 @@ mo_modreload(struct Client *client_p, struct Client *source_p, int parc, const c 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; } @@ -446,7 +444,7 @@ mo_modreload(struct Client *client_p, struct Client *source_p, int parc, const c 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; } @@ -458,7 +456,7 @@ mo_modreload(struct Client *client_p, struct Client *source_p, int parc, const c exit(0); } - MyFree(m_bn); + rb_free(m_bn); return 0; } @@ -759,7 +757,7 @@ unload_one_module(const char *name, int warn) 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)); @@ -808,7 +806,7 @@ load_a_module(const char *path, int warn, int core) 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; } @@ -829,7 +827,7 @@ load_a_module(const char *path, int warn, int core) 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; } @@ -846,7 +844,7 @@ load_a_module(const char *path, int warn, int core) "Module %s indicated failure during load.", mod_basename); dlclose(tmpptr); - MyFree(mod_basename); + rb_free(mod_basename); return -1; } if(mheader->mapi_command_list) @@ -881,7 +879,7 @@ load_a_module(const char *path, int warn, int core) "Module %s has unknown/unsupported MAPI version %d.", mod_basename, *mapi_version); dlclose(tmpptr); - MyFree(mod_basename); + rb_free(mod_basename); return -1; } @@ -890,11 +888,11 @@ load_a_module(const char *path, int warn, int core) 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++; @@ -908,7 +906,7 @@ load_a_module(const char *path, int warn, int core) 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; } @@ -927,11 +925,11 @@ increase_modlist(void) 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; }