1
0
mirror of https://github.com/unrealircd/unrealircd.git synced 2026-07-09 12:43:13 +02:00

+- Added loadmodule "filename.so"; and made the modules

+  unable to get loaded twice with same name.
This commit is contained in:
stskeeps
2001-03-10 21:04:25 +00:00
parent f41c3bf679
commit 6d2a2e1bf9
3 changed files with 40 additions and 8 deletions
+2
View File
@@ -312,3 +312,5 @@
- Added Modules, using dlopen() and LoadLibrary for *nix/win32.
- Added /module load <path.to.so>, /module status (list modules),
/module unload <modulename>
- Added loadmodule "filename.so"; and made the modules
unable to get loaded twice with same name.
+18 -7
View File
@@ -34,6 +34,7 @@
#include <stdlib.h>
#include <string.h>
#ifdef _WIN32
#include <io.h>
#endif
#include <fcntl.h>
@@ -70,7 +71,7 @@ int load_module(char *module)
mod_init = irc_dlsym(Mod, "_mod_init");
if (!mod_init)
{
sendto_realops
config_progress
("Failed to load module %s: Could not locate mod_init",
module);
irc_dlclose(Mod);
@@ -81,7 +82,7 @@ int load_module(char *module)
(*mod_init) ();
if (!module_buffer)
{
sendto_realops
config_progress
("Failed to load module %s: mod_init did not set module_buffer",
module);
irc_dlclose(Mod);
@@ -89,7 +90,7 @@ int load_module(char *module)
}
if (module_buffer->mversion != MOD_VERSION)
{
sendto_realops
config_progress
("Failed to load module %s: mversion is %i, not %i as we require",
module, module_buffer->mversion, MOD_VERSION);
irc_dlclose(Mod);
@@ -98,7 +99,7 @@ int load_module(char *module)
if (!module_buffer->name || !module_buffer->version
|| !module_buffer->description)
{
sendto_realops
config_progress
("Failed to load module %s: name/version/description missing",
module);
irc_dlclose(Mod);
@@ -110,7 +111,7 @@ int load_module(char *module)
mod_unload = irc_dlsym(Mod, "_mod_unload");
if (!mod_unload)
{
sendto_realops
config_progress
("Failed to load module %s: Could not locate mod_unload",
module);
irc_dlclose(Mod);
@@ -119,6 +120,16 @@ int load_module(char *module)
}
module_buffer->dll = Mod;
module_buffer->unload = mod_unload;
for (i = 0; i < MAXMODULES; i++)
if (Modules[i] && !strcmp(Modules[i]->name, module_buffer->name))
{
/* We will unload it without notice, its a duplicate */
sendto_umode(UMODE_JUNK, "Ignoring load of module %s, duplicate names", module_buffer->name);
(*module_buffer->unload)();
irc_dlclose(Mod);
return 1;
}
for (i = 0; i <= MAXMODULES; i++)
{
if (!Modules[i])
@@ -130,7 +141,7 @@ int load_module(char *module)
}
if (i == MAXMODULES)
{
sendto_realops
config_progress
("Failed to load module %s: Too many modules loaded");
irc_dlclose(Mod);
return -1;
@@ -143,7 +154,7 @@ int load_module(char *module)
if (err)
{
sendto_realops("Failed to load module %s: %s",
config_progress("Failed to load module %s: %s",
module, err);
}
return -1;
+20 -1
View File
@@ -95,6 +95,7 @@ int _conf_deny_link (ConfigFile *conf, ConfigEntry *ce);
int _conf_deny_channel (ConfigFile *conf, ConfigEntry *ce);
int _conf_deny_version (ConfigFile *conf, ConfigEntry *ce);
int _conf_allow_channel (ConfigFile *conf, ConfigEntry *ce);
int _conf_loadmodule (ConfigFile *conf, ConfigEntry *ce);
extern int conf_debuglevel;
@@ -118,6 +119,7 @@ static ConfigCommand _ConfigCommands[] = {
{ "badword", _conf_badword },
#endif
{ "deny", _conf_deny },
{ "loadmodule", _conf_loadmodule },
{ NULL, NULL }
};
@@ -337,7 +339,7 @@ static void config_status(char *format, ...)
sendto_realops("warning: %s", buffer);
}
static void config_progress(char *format, ...)
void config_progress(char *format, ...)
{
va_list ap;
char buffer[1024];
@@ -1001,6 +1003,23 @@ int _conf_me(ConfigFile *conf, ConfigEntry *ce)
}
}
int _conf_loadmodule(ConfigFile *conf, ConfigEntry *ce)
{
if (!ce->ce_vardata)
{
config_error("%s:%i: loadmodule without filename",
ce->ce_fileptr->cf_filename, ce->ce_varlinenum);
return -1;
}
if (load_module(ce->ce_vardata) != 1)
{
config_error("%s:%i: loadmodule %s: failed to load",
ce->ce_fileptr->cf_filename, ce->ce_varlinenum,
ce->ce_vardata);
return -1;
}
return 1;
}
/*
* The oper {} block parser
*/