Add new version information for checking modules and the core are compatible

This commit is contained in:
Mark 2004-02-19 21:54:50 +00:00
parent f017281766
commit f74e526399
10 changed files with 44 additions and 3 deletions

View file

@ -71,6 +71,7 @@ NeoStats ChangeLog - Anything we add/remove/fix/change is in here (even our rant
- Changed debug dump outputs to be more readable and make helper functions for
each dump type instead of having the dump code written twice (M)
- SERVERDUMP now takes an optional parameter of server name to work like chan/userdump (M)
- Add new version information for checking modules and the core are compatible (M)
* NeoStats * Fish (F) * Version 2.5.14
- Fix a bug with HostServ unable to load the database

9
dl.c
View file

@ -1454,9 +1454,16 @@ load_module (char *modfilename, User * u)
/* call __ModInit (replacement for library __init() call */
ModInit = ns_dlsym ((int *) dl_handle, "__ModInit");
if (ModInit) {
int err;
SET_SEGV_LOCATION();
SET_SEGV_INMODULE(mod_ptr->info->module_name);
if ((*ModInit) (i, API_VER) < 1) {
err = (*ModInit) (i, API_VER);
if (err == NS_ERR_VERSION ) {
nlog (LOG_NORMAL, LOG_CORE, "Module %s was built with an old version of NeoStats. Please recompile %s.", mod_ptr->info->module_name, mod_ptr->info->module_name);
unload_module(mod_ptr->info->module_name, NULL);
return NS_FAILURE;
}
else if (err < 1) {
nlog (LOG_NORMAL, LOG_CORE, "Unable to load module %s. See %s.log for further information.", mod_ptr->info->module_name, mod_ptr->info->module_name);
unload_module(mod_ptr->info->module_name, NULL);
return NS_FAILURE;

View file

@ -165,6 +165,10 @@ EventFnList __module_events[] = {
int __ModInit(int modnum, int apiver)
{
/* Check that our compiled version if compatible with the calling version of NeoStats */
if( ircstrncasecmp (me.version, NEOSTATS_VERSION, VERSIONSIZE) !=0) {
return NS_ERR_VERSION;
}
LoadConfig();
return 1;
}

View file

@ -264,6 +264,10 @@ EventFnList __module_events[] = {
int __ModInit(int modnum, int apiver)
{
/* Check that our compiled version if compatible with the calling version of NeoStats */
if( ircstrncasecmp (me.version, NEOSTATS_VERSION, VERSIONSIZE) !=0) {
return NS_ERR_VERSION;
}
vhosts = list_create(-1);
bannedvhosts = hash_create(-1, 0, 0);
if (!vhosts) {

View file

@ -97,6 +97,10 @@ int __ModInit(int modnum, int apiver)
{
char *temp = NULL;
/* Check that our compiled version if compatible with the calling version of NeoStats */
if( ircstrncasecmp (me.version, NEOSTATS_VERSION, VERSIONSIZE) !=0) {
return NS_ERR_VERSION;
}
if(GetConf((void *) &temp, CFGSTR, "Nick") < 0) {
strlcpy(s_LoveServ ,"LoveServ" ,MAXNICK);
}

View file

@ -93,6 +93,10 @@ int __ModInit(int modnum, int apiver)
{
char *temp = NULL;
/* Check that our compiled version if compatible with the calling version of NeoStats */
if( ircstrncasecmp (me.version, NEOSTATS_VERSION, VERSIONSIZE) !=0) {
return NS_ERR_VERSION;
}
if(GetConf((void *) &temp, CFGSTR, "Nick") < 0) {
strlcpy(s_MoraleServ ,"MoraleServ" ,MAXNICK);
}

View file

@ -157,6 +157,10 @@ int __ModInit(int modnum, int apiver)
SET_SEGV_LOCATION();
/* Check that our compiled version if compatible with the calling version of NeoStats */
if( ircstrncasecmp (me.version, NEOSTATS_VERSION, VERSIONSIZE) !=0) {
return NS_ERR_VERSION;
}
StatServ.onchan = 0;
StatServ.shutdown = 0;
ss_Config();

View file

@ -128,6 +128,10 @@ EventFnList __module_events[] = {
*/
int __ModInit(int modnum, int apiver)
{
/* Check that our compiled version if compatible with the calling version of NeoStats */
if( ircstrncasecmp (me.version, NEOSTATS_VERSION, VERSIONSIZE) !=0) {
return NS_ERR_VERSION;
}
strlcpy(s_module_bot_name, "TemplateBot", MAXNICK);
return 1;
}

4
main.c
View file

@ -99,6 +99,10 @@ main (int argc, char *argv[])
/* our crash trace variables */
SET_SEGV_LOCATION();
CLEAR_SEGV_INMODULE();
/* initialise version */
strlcpy(me.version, NEOSTATS_VERSION, VERSIONSIZE);
/* keep quiet if we are told to :) */
if (!config.quiet) {
printf ("NeoStats %s%s Loading...\n", NEOSTATS_VERSION, ircd_version);

View file

@ -207,6 +207,9 @@
*/
#define MAX_MOD_NAME 32
/* Buffer size for version string */
#define VERSIONSIZE 8
/* doesn't have to be so big atm */
#define NUM_MODULES 20
#define S_TABLE_SIZE -1
@ -247,6 +250,9 @@
typedef enum NS_ERR {
NS_ERR_NICK_IN_USE = 0x8000001,
NS_ERR_OUT_OF_MEMORY = 0x8000002,
/* Error value for incompatible version */
NS_ERR_VERSION = 0x8000003,
}NS_ERR ;
/* do_exit call exit type definitions */
@ -271,8 +277,6 @@ typedef enum NS_TRANSFER {
NS_MEMORY=1,
} NS_TRANSFER;
#define SEGV_LOCATION_BUFSIZE 255
#ifdef LEAN_AND_MEAN
#define SET_SEGV_LOCATION()
@ -385,6 +389,7 @@ struct me {
char sqlhost[MAXHOST];
int sqlport;
#endif
char version[VERSIONSIZE];
} me;
/** @brief Bans structure