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

Made extbans use the module objects system

This commit is contained in:
codemastr
2004-01-09 00:56:15 +00:00
parent 5ce3fcc1e3
commit aeff467a36
5 changed files with 52 additions and 9 deletions
+2
View File
@@ -2701,3 +2701,5 @@ seen. gmtime warning still there
- Fixed a bug with the dynamic umode and cmode systems
- Made CmodeAdd return MODERR_EXISTS if the mode already exists
- Fixes for TRE under win32
- Made Extbans use the module object system
+11 -1
View File
@@ -95,6 +95,7 @@ typedef struct {
#define MOBJ_SNOMASK 0x0020
#define MOBJ_UMODE 0x0040
#define MOBJ_CMDOVERRIDE 0x0080
#define MOBJ_EXTBAN 0x0100
typedef struct {
long mode;
@@ -226,6 +227,8 @@ typedef struct {
#define EXTBANTABLESZ 32
typedef struct {
/** extbans module */
Module *owner;
/** extended ban character */
char flag;
@@ -259,8 +262,14 @@ typedef struct {
* int: a value of BANCHK_* (see struct.h)
*/
int (*is_banned)(aClient *, aChannel *, char *, int);
} Extban;
typedef struct {
char flag;
int (*is_ok)(aClient *, aChannel *, char *para, int, int, int);
char * (*conv_param)(char *);
int (*is_banned)(aClient *, aChannel *, char *, int);
} ExtbanInfo;
typedef ExtbanInfo Extban; /* Just to be consistent */
typedef struct _command {
@@ -286,6 +295,7 @@ typedef struct _ModuleObject {
Snomask *snomask;
Umode *umode;
Cmdoverride *cmdoverride;
Extban *extban;
} object;
} ModuleObject;
+1 -1
View File
@@ -579,7 +579,7 @@ Ban *is_banned(aClient *sptr, aChannel *chptr, int type)
static char virthost[NICKLEN + USERLEN + HOSTLEN + 6];
static char nuip[NICKLEN + USERLEN + HOSTLEN + 6];
int dovirt = 0, mine = 0;
ExtbanInfo *extban;
Extban *extban;
if (!IsPerson(sptr))
return NULL;
+29 -7
View File
@@ -72,15 +72,15 @@ int i;
return NULL;
}
Extban *ExtbanAdd(Module *reserved, ExtbanInfo req)
Extban *ExtbanAdd(Module *module, ExtbanInfo req)
{
Extban *tmp;
int slot;
if (findmod_by_bantype(req.flag))
{
if (reserved)
reserved->errorcode = MODERR_EXISTS;
if (module)
module->errorcode = MODERR_EXISTS;
return NULL;
}
@@ -90,15 +90,23 @@ int slot;
break;
if (slot == EXTBANTABLESZ - 1)
{
if (reserved)
reserved->errorcode = MODERR_NOSPACE;
if (module)
module->errorcode = MODERR_NOSPACE;
return NULL;
}
ExtBan_Table[slot].flag = req.flag;
ExtBan_Table[slot].is_ok = req.is_ok;
ExtBan_Table[slot].conv_param = req.conv_param;
ExtBan_Table[slot].is_banned = req.is_banned;
ExtBan_Table[slot].owner = module;
if (module)
{
ModuleObject *banobj = MyMallocEx(sizeof(ModuleObject));
banobj->object.extban = banobj;
banobj->type = MOBJ_EXTBAN;
AddListItem(banobj, module->objects);
module->errorcode = MODERR_NOERROR;
}
ExtBan_highest = slot;
make_extbanstr();
return &ExtBan_Table[slot];
@@ -107,6 +115,20 @@ int slot;
void ExtbanDel(Extban *eb)
{
/* Just zero it all away.. */
if (eb->owner)
{
ModuleObject *banobj;
for (banobj = eb->owner->objects; banobj; banobj = banobj->next)
{
if (banobj->type == MOBJ_EXTBAN && banobj->object.extban == eb)
{
DelListItem(banobj, eb->owner->objects);
MyFree(banobj);
break;
}
}
}
memset(eb, 0, sizeof(Extban));
make_extbanstr();
/* Hmm do we want to go trough all chans and remove the bans?
@@ -223,7 +245,7 @@ char *ban = banin+3;
void extban_init(void)
{
Extban req;
ExtbanInfo req;
memset(&req, 0, sizeof(ExtbanInfo));
req.flag = 'c';
+9
View File
@@ -392,6 +392,9 @@ void Unload_all_loaded_modules(void)
else if (objs->type == MOBJ_CMDOVERRIDE) {
CmdoverrideDel(objs->object.cmdoverride);
}
else if (objs->type == MOBJ_EXTBAN) {
ExtbanDel(objs->object.extban);
}
}
for (child = mi->children; child; child = childnext)
{
@@ -446,6 +449,9 @@ void Unload_all_testing_modules(void)
else if (objs->type == MOBJ_CMDOVERRIDE) {
CmdoverrideDel(objs->object.cmdoverride);
}
else if (objs->type == MOBJ_EXTBAN) {
ExtbanDel(objs->object.extban);
}
}
for (child = mi->children; child; child = childnext)
{
@@ -506,6 +512,9 @@ int Module_free(Module *mod)
else if (objs->type == MOBJ_CMDOVERRIDE) {
CmdoverrideDel(objs->object.cmdoverride);
}
else if (objs->type == MOBJ_EXTBAN) {
ExtbanDel(objs->object.extban);
}
}
for (p = Modules; p; p = p->next)
{