1
0
mirror of https://github.com/unrealircd/unrealircd.git synced 2026-07-02 10:26:38 +02:00

Made it so it is no longer necessary for modules to copy the ModuleInfo structure

This commit is contained in:
codemastr
2003-05-10 18:53:50 +00:00
parent f0a5ab1310
commit 370acc2abe
6 changed files with 67 additions and 70 deletions
+2
View File
@@ -2149,3 +2149,5 @@ seen. gmtime warning still there
- Updated example.conf about U-lines since many people set them wrong.
- Fixed numeric checking.
- Moved /stats zip from NOTICE to RPL_TEXT, updated stats documentation.
- Made it so it is no longer necessary to copy the ModuleInfo structure passed to Mod_Test
and Mod_Init. Unreal now does this internally.
+1
View File
@@ -152,6 +152,7 @@ struct _Module
unsigned char flags; /* 8-bits for flags .. */
ModuleChild *children;
ModuleObject *objects;
ModuleInfo modinfo; /* Used to store handle info for module */
};
/*
* Symbol table
+5 -10
View File
@@ -121,7 +121,6 @@ char *Module_Create(char *path_)
int ret = 0;
Module *mod = NULL, **Mod_Handle = NULL;
int betaversion,tag;
ModuleInfo modinfo;
Debug((DEBUG_DEBUG, "Attempting to load module from %s",
path_));
path = path_;
@@ -197,10 +196,7 @@ char *Module_Create(char *path_)
if (Mod_Test)
{
if (betaversion >= 8) {
modinfo.size = sizeof(ModuleInfo);
modinfo.module_load = 0;
modinfo.handle = mod;
if ((ret = (*Mod_Test)(&modinfo)) < MOD_SUCCESS) {
if ((ret = (*Mod_Test)(&mod->modinfo)) < MOD_SUCCESS) {
ircsprintf(errorbuf, "Mod_Test returned %i",
ret);
/* We EXPECT the module to have cleaned up it's mess */
@@ -263,6 +259,9 @@ Module *Module_make(ModuleHeader *header,
modp->dll = mod;
modp->flags = MODFLAG_NONE;
modp->children = NULL;
modp->modinfo.size = sizeof(ModuleInfo);
modp->modinfo.module_load = 0;
modp->modinfo.handle = modp;
return (modp);
}
@@ -272,7 +271,6 @@ void Init_all_testing_modules(void)
Module *mi, *next;
int betaversion, tag, ret;
iFP Mod_Init;
ModuleInfo modinfo;
for (mi = Modules; mi; mi = next)
{
next = mi->next;
@@ -281,10 +279,7 @@ void Init_all_testing_modules(void)
irc_dlsym(mi->dll, "Mod_Init", Mod_Init);
sscanf(mi->header->modversion, "3.2-b%d-%d", &betaversion, &tag);
if (betaversion >= 8) {
modinfo.size = sizeof(ModuleInfo);
modinfo.module_load = 0;
modinfo.handle = mi;
if ((ret = (*Mod_Init)(&modinfo)) < MOD_SUCCESS) {
if ((ret = (*Mod_Init)(&mi->modinfo)) < MOD_SUCCESS) {
config_error("Error loading %s: Mod_Init returned %i",
mi->header->name, ret);
Module_free(mi);
+49 -50
View File
@@ -48,7 +48,7 @@
#endif
extern ModuleHeader m_svsnoop_Header;
ModuleInfo ModCmdsInfo;
ModuleInfo *ModCmdsInfo;
/* Place includes here */
/* replace this with a common name of your module */
#ifdef DYNAMIC_LINKING
@@ -136,8 +136,8 @@ int l_commands_Test(ModuleInfo *modinfo)
#ifdef SCAN_API
Module p;
#endif
bcopy(modinfo,&ModCmdsInfo,modinfo->size);
m_htm_Test(&ModCmdsInfo);
ModCmdsInfo = modinfo;
m_htm_Test(ModCmdsInfo);
return MOD_SUCCESS;
}
@@ -155,54 +155,53 @@ int l_commands_Init(ModuleInfo *modinfo)
/*
* We call our add_Command crap here
*/
bcopy(modinfo,&ModCmdsInfo,modinfo->size);
module_load = ModCmdsInfo.module_load;
m_sethost_Init(&ModCmdsInfo);
m_setname_Init(&ModCmdsInfo);
m_chghost_Init(&ModCmdsInfo);
m_chgident_Init(&ModCmdsInfo);
m_setident_Init(&ModCmdsInfo);
m_sdesc_Init(&ModCmdsInfo);
m_svsmode_Init(&ModCmdsInfo);
m_swhois_Init(&ModCmdsInfo);
m_svsmotd_Init(&ModCmdsInfo);
m_svsnline_Init(&ModCmdsInfo);
m_who_Init(&ModCmdsInfo);
m_mkpasswd_Init(&ModCmdsInfo);
m_away_Init(&ModCmdsInfo);
m_svsnoop_Init(&ModCmdsInfo);
m_svso_Init(&ModCmdsInfo);
m_svsnick_Init(&ModCmdsInfo);
m_adminchat_Init(&ModCmdsInfo);
m_nachat_Init(&ModCmdsInfo);
m_lag_Init(&ModCmdsInfo);
m_rping_Init(&ModCmdsInfo);
m_sendumode_Init(&ModCmdsInfo);
m_tsctl_Init(&ModCmdsInfo);
m_htm_Init(&ModCmdsInfo);
m_chgname_Init(&ModCmdsInfo);
m_message_Init(&ModCmdsInfo);
m_whois_Init(&ModCmdsInfo);
m_quit_Init(&ModCmdsInfo);
m_kill_Init(&ModCmdsInfo);
m_pingpong_Init(&ModCmdsInfo);
m_oper_Init(&ModCmdsInfo);
m_akill_Init(&ModCmdsInfo);
m_rakill_Init(&ModCmdsInfo);
m_unzline_Init(&ModCmdsInfo);
m_unkline_Init(&ModCmdsInfo);
m_sqline_Init(&ModCmdsInfo);
m_unsqline_Init(&ModCmdsInfo);
m_tkl_Init(&ModCmdsInfo);
m_vhost_Init(&ModCmdsInfo);
m_cycle_Init(&ModCmdsInfo);
m_svsjoin_Init(&ModCmdsInfo);
m_svspart_Init(&ModCmdsInfo);
m_svswatch_Init(&ModCmdsInfo);
m_svssilence_Init(&ModCmdsInfo);
m_svslusers_Init(&ModCmdsInfo);
module_load = ModCmdsInfo->module_load;
m_sethost_Init(ModCmdsInfo);
m_setname_Init(ModCmdsInfo);
m_chghost_Init(ModCmdsInfo);
m_chgident_Init(ModCmdsInfo);
m_setident_Init(ModCmdsInfo);
m_sdesc_Init(ModCmdsInfo);
m_svsmode_Init(ModCmdsInfo);
m_swhois_Init(ModCmdsInfo);
m_svsmotd_Init(ModCmdsInfo);
m_svsnline_Init(ModCmdsInfo);
m_who_Init(ModCmdsInfo);
m_mkpasswd_Init(ModCmdsInfo);
m_away_Init(ModCmdsInfo);
m_svsnoop_Init(ModCmdsInfo);
m_svso_Init(ModCmdsInfo);
m_svsnick_Init(ModCmdsInfo);
m_adminchat_Init(ModCmdsInfo);
m_nachat_Init(ModCmdsInfo);
m_lag_Init(ModCmdsInfo);
m_rping_Init(ModCmdsInfo);
m_sendumode_Init(ModCmdsInfo);
m_tsctl_Init(ModCmdsInfo);
m_htm_Init(ModCmdsInfo);
m_chgname_Init(ModCmdsInfo);
m_message_Init(ModCmdsInfo);
m_whois_Init(ModCmdsInfo);
m_quit_Init(ModCmdsInfo);
m_kill_Init(ModCmdsInfo);
m_pingpong_Init(ModCmdsInfo);
m_oper_Init(ModCmdsInfo);
m_akill_Init(ModCmdsInfo);
m_rakill_Init(ModCmdsInfo);
m_unzline_Init(ModCmdsInfo);
m_unkline_Init(ModCmdsInfo);
m_sqline_Init(ModCmdsInfo);
m_unsqline_Init(ModCmdsInfo);
m_tkl_Init(ModCmdsInfo);
m_vhost_Init(ModCmdsInfo);
m_cycle_Init(ModCmdsInfo);
m_svsjoin_Init(ModCmdsInfo);
m_svspart_Init(ModCmdsInfo);
m_svswatch_Init(ModCmdsInfo);
m_svssilence_Init(ModCmdsInfo);
m_svslusers_Init(ModCmdsInfo);
#ifdef GUEST
m_guest_Init(&ModCmdsInfo);
m_guest_Init(ModCmdsInfo);
#endif
return MOD_SUCCESS;
}
+3 -3
View File
@@ -62,7 +62,7 @@ ModuleHeader Mod_Header
NULL
};
ModuleInfo ModGuestInfo;
ModuleInfo *ModGuestInfo;
/* The purpose of these ifdefs, are that we can "static" link the ircd if we
* want to
*/
@@ -78,8 +78,8 @@ int m_guest_Init(ModuleInfo *modinfo)
* We call our add_Command crap here
*/
#ifdef GUEST
bcopy(modinfo,&ModGuestInfo,modinfo.size);
GuestHook = HookAddEx(ModGuestInfo.handle, HOOKTYPE_GUEST, m_guest);
ModGuestInfo = modinfo;
GuestHook = HookAddEx(ModGuestInfo->handle, HOOKTYPE_GUEST, m_guest);
#endif
return MOD_SUCCESS;
+7 -7
View File
@@ -69,7 +69,7 @@ DLLFUNC int htm_config_test(ConfigFile *, ConfigEntry *, int, int *);
DLLFUNC int htm_config_run(ConfigFile *, ConfigEntry *, int);
DLLFUNC int htm_stats(aClient *, char *);
ModuleInfo HtmModInfo;
ModuleInfo *HtmModInfo;
static Hook *ConfTest, *ConfRun, *ServerStats;
#ifndef DYNAMIC_LINKING
ModuleHeader m_htm_Header
@@ -99,8 +99,8 @@ int m_htm_Test(ModuleInfo *modinfo)
/*
* We call our add_Command crap here
*/
bcopy(modinfo,&HtmModInfo,modinfo->size);
ConfTest = HookAddEx(HtmModInfo.handle, HOOKTYPE_CONFIGTEST, htm_config_test);
HtmModInfo = modinfo;
ConfTest = HookAddEx(HtmModInfo->handle, HOOKTYPE_CONFIGTEST, htm_config_test);
return MOD_SUCCESS;
}
@@ -116,12 +116,12 @@ int m_htm_Init(ModuleInfo *modinfo)
* We call our add_Command crap here
*/
add_Command(MSG_HTM, TOK_HTM, m_htm, MAXPARA);
ConfRun = HookAddEx(HtmModInfo.handle, HOOKTYPE_CONFIGRUN, htm_config_run);
ServerStats = HookAddEx(HtmModInfo.handle, HOOKTYPE_STATS, htm_stats);
ConfRun = HookAddEx(HtmModInfo->handle, HOOKTYPE_CONFIGRUN, htm_config_run);
ServerStats = HookAddEx(HtmModInfo->handle, HOOKTYPE_STATS, htm_stats);
#ifndef NO_FDLIST
LockEventSystem();
e_lcf = EventAddEx(HtmModInfo.handle, "lcf", LCF, 0, lcf_check, NULL);
e_htmcalc = EventAddEx(HtmModInfo.handle, "htmcalc", 1, 0, htm_calc, NULL);
e_lcf = EventAddEx(HtmModInfo->handle, "lcf", LCF, 0, lcf_check, NULL);
e_htmcalc = EventAddEx(HtmModInfo->handle, "htmcalc", 1, 0, htm_calc, NULL);
UnlockEventSystem();
#endif
return MOD_SUCCESS;