#include <ltdl.h>
+#ifndef LT_MODULE_EXT
+# error "Charybdis requires loadable module support."
+#endif
+
struct module **modlist = NULL;
static const char *core_module_table[] = {
findmodule_byname(const char *name)
{
int i;
+ char name_ext[PATH_MAX + 1];
+
+ rb_strlcpy(name_ext, name, sizeof basename_ext);
+ rb_strlcat(name_ext, LT_MODULE_EXT, sizeof basename_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;
}
DIR *system_module_dir = NULL;
struct dirent *ldirent = NULL;
char module_fq_name[PATH_MAX + 1];
- int len;
+ size_t module_ext_len = strlen(LT_MODULE_EXT);
modules_init();
while ((ldirent = readdir(system_module_dir)) != NULL)
{
+ struct stat s;
+ size_t len;
+
len = strlen(ldirent->d_name);
- if((len > 3) && !strcmp(ldirent->d_name+len-3, ".la"))
+ 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) load_a_module(module_fq_name, warn, MAPI_ORIGIN_CORE, 0);
for (i = 0; core_module_table[i]; i++)
{
snprintf(module_name, sizeof(module_name), "%s/%s%s", MODPATH,
- core_module_table[i], ".la");
+ core_module_table[i], LT_MODULE_EXT);
if(load_a_module(module_name, warn, MAPI_ORIGIN_CORE, 1) == -1)
{
ilog(L_MAIN,
- "Error loading core module %s%s: terminating ircd",
- core_module_table[i], ".la");
+ "Error loading core module %s: terminating ircd",
+ core_module_table[i]);
exit(0);
}
}
char modpath[PATH_MAX];
rb_dlink_node *pathst;
const char *mpath;
-
struct stat statbuf;
- if (server_state_foreground == 1)
+ if (server_state_foreground)
inotice("loading module %s ...", path);
if(coremodule != 0)
{
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)
mod_basename = rb_basename(path);
- tmpptr = lt_dlopen(path);
+ tmpptr = lt_dlopenext(path);
if(tmpptr == NULL)
{
return -1;
}
-
/*
* _mheader is actually a struct mapi_mheader_*, but mapi_version
* is always the first member of this structure, so we treate it
*/
if(mheader->mapi_datecode != datecode && mheader->mapi_datecode > 0)
{
- long int delta = labs(datecode - mheader->mapi_datecode);
+ long int delta = datecode - mheader->mapi_datecode;
if (delta > MOD_WARN_DELTA)
{
delta /= 86400;
- iwarn(L_MAIN,
- "Module %s build date is out of sync with ircd build date by %ld days, expect problems",
+ iwarn("Module %s build date is out of sync with ircd build date by %ld days, expect problems",
mod_basename, delta);
sendto_realops_snomask(SNO_GENERAL, L_ALL,
"Module %s build date is out of sync with ircd build date by %ld days, expect problems",
}
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;