1
0
mirror of https://github.com/anope/anope.git synced 2026-07-01 12:46:39 +02:00

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
This commit is contained in:
rob rob@31f1291d-b8d6-0310-a050-a5561fc1590b
2004-05-02 09:11:57 +00:00
parent f2ed3ecc8b
commit ee1ca39543
8 changed files with 74 additions and 38 deletions
+1
View File
@@ -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.
+1
View File
@@ -22,6 +22,7 @@
/**** modules.c ****/
E void moduleCallBackRun(void);
E void moduleCleanStruct(ModuleData * moduleData[]);
/**** actions.c ****/
+37 -1
View File
@@ -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 */
+1 -1
View File
@@ -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 */
/*************************************************************************/
+5
View File
@@ -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);
+23 -18
View File
@@ -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;
+1 -17
View File
@@ -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");
+5 -1
View File
@@ -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