]> jfr.im git - solanum.git/blobdiff - ircd/modules.c
providers/opm: use a name that makes more sense for this variable
[solanum.git] / ircd / modules.c
index b10b737928fe5be0fa2bffba2d92632ce9507c9f..2173dd69fee0f972fe6442c55eb7495a5a30059d 100644 (file)
@@ -129,8 +129,8 @@ modules_init(void)
        mod_add_cmd(&modrestart_msgtab);
 
        /* Add the default paths we look in to the module system --nenolod */
-       mod_add_path(MODPATH);
-       mod_add_path(AUTOMODPATH);
+       mod_add_path(ircd_paths[IRCD_PATH_MODULES]);
+       mod_add_path(ircd_paths[IRCD_PATH_AUTOLOAD_MODULES]);
 }
 
 /* mod_find_path()
@@ -206,12 +206,20 @@ int
 findmodule_byname(const char *name)
 {
        int i;
+       char name_ext[PATH_MAX + 1];
+
+       rb_strlcpy(name_ext, name, sizeof name_ext);
+       rb_strlcat(name_ext, LT_MODULE_EXT, sizeof name_ext);
 
        for (i = 0; i < num_mods; i++)
        {
                if(!irccmp(modlist[i]->name, name))
                        return i;
+
+               if(!irccmp(modlist[i]->name, name_ext))
+                       return i;
        }
+
        return -1;
 }
 
@@ -235,23 +243,22 @@ load_all_modules(int warn)
 
        max_mods = MODS_INCREMENT;
 
-       system_module_dir = opendir(AUTOMODPATH);
+       system_module_dir = opendir(ircd_paths[IRCD_PATH_AUTOLOAD_MODULES]);
 
        if(system_module_dir == NULL)
        {
-               ilog(L_MAIN, "Could not load modules from %s: %s", AUTOMODPATH, strerror(errno));
+               ilog(L_MAIN, "Could not load modules from %s: %s", ircd_paths[IRCD_PATH_AUTOLOAD_MODULES], strerror(errno));
                return;
        }
 
        while ((ldirent = readdir(system_module_dir)) != NULL)
        {
-               struct stat s;
                size_t len;
 
                len = strlen(ldirent->d_name);
                if(len > module_ext_len && !strcasecmp(ldirent->d_name + (len - module_ext_len), LT_MODULE_EXT))
                {
-                       (void) snprintf(module_fq_name, sizeof(module_fq_name), "%s/%s", AUTOMODPATH, ldirent->d_name);
+                       (void) snprintf(module_fq_name, sizeof(module_fq_name), "%s%c%s", ircd_paths[IRCD_PATH_AUTOLOAD_MODULES], RB_PATH_SEPARATOR, ldirent->d_name);
                        (void) load_a_module(module_fq_name, warn, MAPI_ORIGIN_CORE, 0);
                }
 
@@ -274,8 +281,8 @@ load_core_modules(int warn)
 
        for (i = 0; core_module_table[i]; i++)
        {
-               snprintf(module_name, sizeof(module_name), "%s/%s", MODPATH,
-                           core_module_table[i]);
+               snprintf(module_name, sizeof(module_name), "%s%c%s%s", ircd_paths[IRCD_PATH_MODULES], RB_PATH_SEPARATOR,
+                           core_module_table[i], LT_MODULE_EXT);
 
                if(load_a_module(module_name, warn, MAPI_ORIGIN_CORE, 1) == -1)
                {
@@ -299,7 +306,6 @@ load_one_module(const char *path, int origin, int coremodule)
        char modpath[PATH_MAX];
        rb_dlink_node *pathst;
        const char *mpath;
-
        struct stat statbuf;
 
        if (server_state_foreground)
@@ -315,7 +321,7 @@ load_one_module(const char *path, int origin, int coremodule)
        {
                mpath = pathst->data;
 
-               snprintf(modpath, sizeof(modpath), "%s/%s", mpath, path);
+               snprintf(modpath, sizeof(modpath), "%s/%s%s", mpath, path, LT_MODULE_EXT);
                if((strstr(modpath, "../") == NULL) && (strstr(modpath, "/..") == NULL))
                {
                        if(stat(modpath, &statbuf) == 0)
@@ -1033,11 +1039,11 @@ load_a_module(const char *path, int warn, int origin, int core)
                }
 
                sendto_realops_snomask(SNO_GENERAL, L_ALL,
-                                    "Module %s [version: %s; MAPI version: %d; origin: %s; description: \"%s\"] loaded at 0x%lx",
+                                    "Module %s [version: %s; MAPI version: %d; origin: %s; description: \"%s\"] loaded at %p",
                                     mod_basename, ver, MAPI_VERSION(*mapi_version), o, description,
-                                    (unsigned long) tmpptr);
-               ilog(L_MAIN, "Module %s [version: %s; MAPI version: %d; origin: %s; description: \"%s\"] loaded at 0x%lx",
-                    mod_basename, ver, MAPI_VERSION(*mapi_version), o, description, (unsigned long) tmpptr);
+                                    (void *) tmpptr);
+               ilog(L_MAIN, "Module %s [version: %s; MAPI version: %d; origin: %s; description: \"%s\"] loaded at %p",
+                    mod_basename, ver, MAPI_VERSION(*mapi_version), o, description, (void *) tmpptr);
        }
        rb_free(mod_basename);
        return 0;