mirror of
https://github.com/unrealircd/unrealircd.git
synced 2026-06-30 21:06:37 +02:00
+- Added Hooks, only one working now is HOOKTYPE_LOCAL_QUIT
This commit is contained in:
@@ -347,3 +347,4 @@
|
||||
- Using ERR_NOPRIVLEDGES (says you aren't oper)
|
||||
- Disabled commands allowed by unregistered users from registered users
|
||||
- Removed networks/unrealircd.conf
|
||||
- Added Hooks, only one working now is HOOKTYPE_LOCAL_QUIT
|
||||
|
||||
+11
-1
@@ -21,6 +21,8 @@
|
||||
|
||||
#define MOD_VERSION 1
|
||||
#define MAXMODULES 50
|
||||
#define MAXHOOKTYPES 20
|
||||
|
||||
#ifdef _WIN32
|
||||
#define DLLFUNC _declspec(dllexport)
|
||||
#define irc_dlopen(x,y) LoadLibrary(x)
|
||||
@@ -55,10 +57,18 @@ struct moduleInfo
|
||||
};
|
||||
|
||||
extern ModuleInfo *module_buffer;
|
||||
|
||||
extern Hook *Hooks[MAXHOOKTYPES];
|
||||
extern Hook *global_i;
|
||||
|
||||
void module_init(void);
|
||||
int load_module(char *module);
|
||||
int unload_module(char *name);
|
||||
vFP module_sym(char *name);
|
||||
|
||||
void add_Hook(int hooktype, int (*func)());
|
||||
void del_Hook(int hooktype, int (*func)());
|
||||
|
||||
#define RunHook(hooktype,x) for (global_i = Hooks[hooktype]; global_i; global_i = global_i->next) (*global_i->func)(x)
|
||||
|
||||
#define HOOKTYPE_LOCAL_QUIT 1
|
||||
|
||||
|
||||
+10
-1
@@ -27,7 +27,6 @@
|
||||
#include "common.h"
|
||||
#include "sys.h"
|
||||
#include "hash.h"
|
||||
#include "modules.h"
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#ifdef ZIP_LINKS
|
||||
@@ -102,6 +101,8 @@ typedef struct Command aCommand;
|
||||
typedef struct SMember Member;
|
||||
typedef struct SMembership Membership;
|
||||
typedef struct SMembershipL MembershipL;
|
||||
typedef struct _irchook Hook;
|
||||
|
||||
#ifdef NEED_U_INT32_T
|
||||
typedef unsigned int u_int32_t; /* XXX Hope this works! */
|
||||
#endif
|
||||
@@ -924,6 +925,7 @@ struct _configflag_ban
|
||||
#define CRULE_AUTO 1
|
||||
|
||||
|
||||
|
||||
struct _configitem {
|
||||
ConfigFlag flag;
|
||||
ConfigItem *prev, *next;
|
||||
@@ -1067,6 +1069,12 @@ struct _configitem_allow_channel {
|
||||
char *channel;
|
||||
};
|
||||
|
||||
struct _irchook {
|
||||
ConfigFlag flag;
|
||||
Hook *prev, *next;
|
||||
int (*func)();
|
||||
};
|
||||
|
||||
/*
|
||||
* statistics structures
|
||||
*/
|
||||
@@ -1365,6 +1373,7 @@ extern char *gnulicense[];
|
||||
#include "ssl.h"
|
||||
#endif
|
||||
#define HASH_TEST HASH_CHECK
|
||||
#include "modules.h"
|
||||
|
||||
#endif /* __struct_include__ */
|
||||
|
||||
|
||||
+26
-2
@@ -43,11 +43,15 @@
|
||||
#include "h.h"
|
||||
|
||||
ModuleInfo *Modules[MAXMODULES];
|
||||
Hook *Hooks[MAXHOOKTYPES];
|
||||
Hook *global_i = NULL;
|
||||
int modules_loaded = 0;
|
||||
|
||||
ModuleInfo *module_buffer;
|
||||
void module_init(void)
|
||||
{
|
||||
bzero(Modules, sizeof(Modules));
|
||||
bzero(Hooks, sizeof(Hooks));
|
||||
modules_loaded = 0;
|
||||
}
|
||||
|
||||
@@ -235,7 +239,7 @@ int m_module(aClient *cptr, aClient *sptr, int parc, char *parv[])
|
||||
if (parc < 3)
|
||||
{
|
||||
sendto_one(sptr, err_str(ERR_NEEDMOREPARAMS),
|
||||
me.name, parv[0], "MODULES LOAD");
|
||||
me.name, parv[0], "MODULE LOAD");
|
||||
return 0;
|
||||
}
|
||||
sendto_realops("Trying to load module %s", parv[2]);
|
||||
@@ -248,7 +252,7 @@ int m_module(aClient *cptr, aClient *sptr, int parc, char *parv[])
|
||||
if (parc < 3)
|
||||
{
|
||||
sendto_one(sptr, err_str(ERR_NEEDMOREPARAMS),
|
||||
me.name, parv[0], "MODULES UNLOAD");
|
||||
me.name, parv[0], "MODULE UNLOAD");
|
||||
return 0;
|
||||
}
|
||||
sendto_realops("Trying to unload module %s", parv[2]);
|
||||
@@ -279,4 +283,24 @@ int m_module(aClient *cptr, aClient *sptr, int parc, char *parv[])
|
||||
return 1;
|
||||
}
|
||||
|
||||
void add_Hook(int hooktype, int (*func)())
|
||||
{
|
||||
Hook *p;
|
||||
|
||||
p = (Hook *) MyMallocEx(sizeof(Hook));
|
||||
p->func = func;
|
||||
add_ConfigItem((ConfigItem *) p, (ConfigItem **) &Hooks[hooktype]);
|
||||
}
|
||||
|
||||
void del_Hook(int hooktype, int (*func)())
|
||||
{
|
||||
Hook *p;
|
||||
|
||||
for (p = Hooks[hooktype]; p; p = p->next)
|
||||
if (p->func == func)
|
||||
{
|
||||
del_ConfigItem((ConfigItem *) p, (ConfigItem **) &Hooks[hooktype]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -306,7 +306,7 @@ ConfigItem *del_ConfigItem(ConfigItem *item, ConfigItem **list)
|
||||
|
||||
int config_error_flag = 0;
|
||||
/* Small function to bitch about stuff */
|
||||
static void config_error(char *format, ...)
|
||||
void config_error(char *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
char buffer[1024];
|
||||
|
||||
@@ -474,6 +474,7 @@ int exit_client(cptr, sptr, from, comment)
|
||||
sptr->flags |= FLAGS_CLOSING;
|
||||
if (IsPerson(sptr))
|
||||
{
|
||||
RunHook(HOOKTYPE_LOCAL_QUIT, sptr);
|
||||
sendto_umode(UMODE_OPER | UMODE_CLIENT,
|
||||
"*** Notice -- Client exiting: %s (%s@%s) [%s]",
|
||||
sptr->name, sptr->user->username,
|
||||
|
||||
Reference in New Issue
Block a user