diff options
author | rob rob@31f1291d-b8d6-0310-a050-a5561fc1590b <rob rob@31f1291d-b8d6-0310-a050-a5561fc1590b@5417fbe8-f217-4b02-8779-1006273d7864> | 2004-05-02 09:11:57 +0000 |
---|---|---|
committer | rob rob@31f1291d-b8d6-0310-a050-a5561fc1590b <rob rob@31f1291d-b8d6-0310-a050-a5561fc1590b@5417fbe8-f217-4b02-8779-1006273d7864> | 2004-05-02 09:11:57 +0000 |
commit | ee1ca39543172236e40ea98e88e9be6bd1fd0d24 (patch) | |
tree | 11845ea1fc005f0a7fe6ab84e929d3e14915b378 | |
parent | f2ed3ecc8b66de929e0beeecfb2fc81f81201509 (diff) |
BUILD : 1.7.2 (78) BUGS : N/A NOTES : Added the ability to add module data to the NickCore and the NickAlias structs
git-svn-id: svn://svn.anope.org/anope/trunk@78 31f1291d-b8d6-0310-a050-a5561fc1590b
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@54 5417fbe8-f217-4b02-8779-1006273d7864
-rw-r--r-- | Changes | 1 | ||||
-rw-r--r-- | extern.h | 1 | ||||
-rw-r--r-- | modules.c | 38 | ||||
-rw-r--r-- | modules.h | 2 | ||||
-rw-r--r-- | nickserv.c | 5 | ||||
-rw-r--r-- | services.h | 41 | ||||
-rw-r--r-- | users.c | 18 | ||||
-rw-r--r-- | version.log | 6 |
8 files changed, 74 insertions, 38 deletions
@@ -1,6 +1,7 @@ Anope Version 1.7.x (will be renamed when next release is produced) ------------------- Provided by Anope Dev. <dev@anope.org> +2004/05/02 Added NickCore and NickAlias to the moduleAddData stuff, its going well! 2004/04/29 Added new MemoServ command CHECK to check whether a memo has been read or not. 2004/04/26 Added module data ability, currently only added to User struct 2004/04/23 Added new MemoServ command RSEND to send a memo requesting a receipt memo once the recipient reads it. @@ -22,6 +22,7 @@ /**** modules.c ****/ E void moduleCallBackRun(void); +E void moduleCleanStruct(ModuleData * moduleData[]); /**** actions.c ****/ @@ -1941,23 +1941,59 @@ void moduleDelAllDataMod(Module * m) boolean freeme = false; int i; User *user; + NickAlias *na; + NickCore *nc; if (!mod_current_module_name) { mod_current_module_name = sstrdup(m->name); freeme = true; } for (i = 0; i < 1024; i++) { + /* Remove the users */ for (user = userlist[i]; user; user = user->next) { moduleDelAllData(user->moduleData); } + /* Remove the nick Cores */ + for (nc = nclists[i]; nc; nc = nc->next) { + moduleDelAllData(nc->moduleData); + } + /* Remove the nick Aliases */ + for (na = nalists[i]; na; na = na->next) { + moduleDelAllData(na->moduleData); + } } - if (freeme) { free(mod_current_module_name); mod_current_module_name = NULL; } } +/** + * Remove any data fro many module used in the given struct. + * Useful for cleaning up when a User leave's the net, a NickCore is deleted, etc... + * @param moduleData the moduleData struct to "clean" + **/ +void moduleCleanStruct(ModuleData * moduleData[]) +{ + ModuleData *md = NULL, *nextMd = NULL; + ModuleDataItem *item = NULL, *nextItem = NULL; + int i; + for (i = 0; i < 1024; i++) { + for (md = moduleData[i]; md; md = nextMd) { + nextMd = md->next; + for (item = md->di; item; item = nextItem) { + nextItem = item->next; + free(item->key); + free(item->value); + item->next = NULL; + free(item); + } + free(md->moduleName); + free(md); + } + } +} + /* EOF */ @@ -224,7 +224,7 @@ char *moduleGetData(ModuleData *md[], char *key); /* Get the value for this ke int moduleAddData(ModuleData *md[], char *key, char *value); /* Set the value for this key for this struct */ void moduleDelData(ModuleData *md[], char *key); /* Delete this key/value pair */ void moduleDelAllData(ModuleData *md[]); /* Delete all key/value pairs for this module for this struct */ - +void moduleCleanStruct(ModuleData * moduleData[]); /* Clean a moduleData hash */ void moduleDelAllDataMod(Module *m); /* remove all module data from all structs for this module */ /*************************************************************************/ diff --git a/nickserv.c b/nickserv.c index e0a10b692..451f961e5 100644 --- a/nickserv.c +++ b/nickserv.c @@ -1519,6 +1519,9 @@ static int delcore(NickCore * nc) free(nc->memos.memos); } + moduleCleanStruct(nc->moduleData); + + free(nc); return 1; @@ -1620,6 +1623,8 @@ int delnick(NickAlias * na) if (na->last_quit) free(na->last_quit); + moduleCleanStruct(na->moduleData); + free(na); diff --git a/services.h b/services.h index 18a505d7a..9e2e13c60 100644 --- a/services.h +++ b/services.h @@ -185,6 +185,26 @@ typedef struct channel_ Channel; #define PRE_NICK_VERSION 1 #define OPER_VERSION 13 +/** + * ModuleData strucs used to allow modules to add / delete module Data from existing structs + */ +typedef struct ModuleData_ ModuleData; /* ModuleData struct */ +typedef struct ModuleDataItem_ ModuleDataItem; /* A Module Data Item struct */ + +struct ModuleDataItem_ { + char *key; /* The key */ + char *value; /* The Value */ + ModuleDataItem *next; /* The next ModuleDataItem in this list */ +}; + +struct ModuleData_ { + char *moduleName; /* Which module we belong to */ + ModuleDataItem *di; /* The first Item they own */ + ModuleData *next; /* The next ModuleData record */ +}; + + + typedef enum { false, true } boolean; /*************************************************************************/ @@ -222,6 +242,7 @@ struct nickrequest_ { char *passcode; char *password; char *email; + time_t requested; time_t lastmail; /* Unsaved */ @@ -244,6 +265,7 @@ struct nickalias_ { NickCore *nc; /* I'm an alias of this */ /* Not saved */ + ModuleData *moduleData[1024]; /* Module saved data attached to the nick alias */ User *u; /* Current online user that has me */ }; @@ -270,7 +292,7 @@ struct nickcore_ { uint16 channelmax; /* Maximum number of channels allowed */ /* Unsaved data */ - + ModuleData *moduleData[1024]; /* Module saved data attached to the NickCore */ time_t lastmail; /* Last time this nick record got a mail */ SList aliases; /* List of aliases */ }; @@ -644,23 +666,6 @@ struct csmodeutil_ { #endif /*************************************************************************/ -typedef struct ModuleData_ ModuleData; /* ModuleData struct */ -typedef struct ModuleDataItem_ ModuleDataItem; /* A Module Data Item struct */ - -struct ModuleDataItem_ { - char *key; /* The key */ - char *value; /* The Value */ - ModuleDataItem *next; /* The next ModuleDataItem in this list */ -}; - -struct ModuleData_ { - char *moduleName; /* Which module we belong to */ - ModuleDataItem *di; /* The first Item they own */ - ModuleData *next; /* The next ModuleData record */ -}; - - - /* Online user and channel data. */ struct user_ { User *next, *prev; @@ -362,9 +362,6 @@ static void delete_user(User * user) { struct u_chanlist *c, *c2; struct u_chaninfolist *ci, *ci2; - int i; - ModuleData *md, *nextMd; - ModuleDataItem *item, *nextItem; if (LogUsers) { #ifdef HAS_VHOST @@ -416,20 +413,7 @@ static void delete_user(User * user) ci = ci2; } - for (i = 0; i < 1024; i++) { /* Clear up any module data used be the User struct */ - for (md = user->moduleData[i]; md; md = nextMd) { - nextMd = md->next; - for (item = md->di; item; item = nextItem) { - nextItem = item->next; - free(item->key); - free(item->value); - item->next = NULL; - free(item); - } - free(md->moduleName); - free(md); - } - } + moduleCleanStruct(user->moduleData); if (debug >= 2) alog("debug: delete_user(): delete from list"); diff --git a/version.log b/version.log index 80d06bffe..390290925 100644 --- a/version.log +++ b/version.log @@ -8,11 +8,15 @@ VERSION_MAJOR="1" VERSION_MINOR="7" VERSION_PATCH="2" -VERSION_BUILD="77" +VERSION_BUILD="78" VERSION_EXTRA="" # $Log$ # +# BUILD : 1.7.2 (78) +# BUGS : N/A +# NOTES : Added the ability to add module data to the NickCore and the NickAlias structs +# # BUILD : 1.7.2 (77) # BUGS : Compile errors on picky compilers # NOTES : fixed a compile error on picky compilers |