]> jfr.im git - irc/rqf/shadowircd.git/blobdiff - src/modules.c
Should just specify the name here.
[irc/rqf/shadowircd.git] / src / modules.c
index b8f42c4bbfdf41ce577d57a1957a4dab52dc9313..4547e42dfca95fba830d8c7e29891e7da41a5f3e 100644 (file)
@@ -28,7 +28,7 @@
 
 
 #include "modules.h"
-#include "s_log.h"
+#include "logger.h"
 #include "ircd.h"
 #include "client.h"
 #include "send.h"
@@ -37,8 +37,7 @@
 #include "numeric.h"
 #include "parse.h"
 #include "ircd_defs.h"
-#include "irc_string.h"
-#include "sprintf_irc.h"
+#include "match.h"
 
 
 
@@ -64,12 +63,12 @@ static const char *core_module_table[] = {
        "m_kick",
        "m_kill",
        "m_message",
+       "m_metadata",
        "m_mode",
        "m_nick",
        "m_part",
        "m_quit",
        "m_server",
-       "m_sjoin",
        "m_squit",
        NULL
 };
@@ -111,8 +110,6 @@ struct Message modrestart_msgtab = {
        {mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_modrestart, 0}}
 };
 
-extern struct Message error_msgtab;
-
 void
 modules_init(void)
 {
@@ -164,7 +161,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);
@@ -184,34 +181,13 @@ mod_clear_paths(void)
        RB_DLINK_FOREACH_SAFE(ptr, next_ptr, mod_paths.head)
        {
                rb_free(ptr->data);
-               free_rb_dlink_node(ptr);
+               rb_free_rb_dlink_node(ptr);
        }
 
        mod_paths.head = mod_paths.tail = NULL;
        mod_paths.length = 0;
 }
 
-/* irc_basename
- *
- * input       -
- * output      -
- * side effects -
- */
-char *
-irc_basename(const char *path)
-{
-       char *mod_basename = MyMalloc(strlen(path) + 1);
-       const char *s;
-
-       if(!(s = strrchr(path, '/')))
-               s = path;
-       else
-               s++;
-
-       (void) strcpy(mod_basename, s);
-       return mod_basename;
-}
-
 /* findmodule_byname
  *
  * input        -
@@ -248,7 +224,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;
 
@@ -359,7 +335,7 @@ mo_modload(struct Client *client_p, struct Client *source_p, int parc, const cha
                return 0;
        }
 
-       m_bn = irc_basename(parv[1]);
+       m_bn = rb_basename(parv[1]);
 
        if(findmodule_byname(m_bn) != -1)
        {
@@ -390,7 +366,7 @@ mo_modunload(struct Client *client_p, struct Client *source_p, int parc, const c
                return 0;
        }
 
-       m_bn = irc_basename(parv[1]);
+       m_bn = rb_basename(parv[1]);
 
        if((modindex = findmodule_byname(m_bn)) == -1)
        {
@@ -430,7 +406,7 @@ mo_modreload(struct Client *client_p, struct Client *source_p, int parc, const c
                return 0;
        }
 
-       m_bn = irc_basename(parv[1]);
+       m_bn = rb_basename(parv[1]);
 
        if((modindex = findmodule_byname(m_bn)) == -1)
        {
@@ -448,11 +424,11 @@ mo_modreload(struct Client *client_p, struct Client *source_p, int parc, const c
                return 0;
        }
 
-       if((load_one_module(parv[1], check_core) == -1) && check_core)
+       if((load_one_module(m_bn, check_core) == -1) && check_core)
        {
                sendto_realops_snomask(SNO_GENERAL, L_ALL,
-                                    "Error reloading core module: %s: terminating ircd", parv[1]);
-               ilog(L_MAIN, "Error loading core module %s: terminating ircd", parv[1]);
+                                    "Error reloading core module: %s: terminating ircd", m_bn);
+               ilog(L_MAIN, "Error loading core module %s: terminating ircd", m_bn);
                exit(0);
        }
 
@@ -535,6 +511,10 @@ mo_modrestart(struct Client *client_p, struct Client *source_p, int parc, const
 #define RTLD_NOW RTLD_LAZY     /* openbsd deficiency */
 #endif
 
+#ifndef RTLD_LOCAL
+#define RTLD_LOCAL 0
+#endif
+
 #ifdef CHARYBDIS_PROFILE
 # ifndef RTLD_PROFILE
 #  warning libdl may not support profiling, sucks. :(
@@ -791,12 +771,12 @@ load_a_module(const char *path, int warn, int core)
 
        int *mapi_version;
 
-       mod_basename = irc_basename(path);
+       mod_basename = rb_basename(path);
 
 #ifdef CHARYBDIS_PROFILE
-       tmpptr = dlopen(path, RTLD_NOW | RTLD_PROFILE);
+       tmpptr = dlopen(path, RTLD_NOW | RTLD_LOCAL | RTLD_PROFILE);
 #else
-       tmpptr = dlopen(path, RTLD_NOW);
+       tmpptr = dlopen(path, RTLD_NOW | RTLD_LOCAL);
 #endif
 
        if(tmpptr == NULL)
@@ -888,11 +868,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++;
@@ -925,7 +905,7 @@ 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);