From: Matthew Wiggins Date: Sat, 15 Jan 2005 23:35:03 +0000 (+0000) Subject: Added an extra hook (and #ifdef), MODULE_HOOK_REMOTEMSG X-Git-Tag: rubiks-ircd-1-0-6~25 X-Git-Url: http://git.pulsar-zone.net/?a=commitdiff_plain;h=5fdae42baacbd2aa13e461a4acc716a10f45d2e8;p=rubiks-ircd.git Added an extra hook (and #ifdef), MODULE_HOOK_REMOTEMSG in m_message() CHOOK_MSG fires if MyClient(sender) if not CHOOK_REMOTEMSG fires --- diff --git a/include/config.h b/include/config.h index e43bb29..011e067 100644 --- a/include/config.h +++ b/include/config.h @@ -18,7 +18,7 @@ * */ -/* $Id: config.h,v 1.11 2005/01/14 13:47:07 mmondor Exp $ */ +/* $Id: config.h,v 1.12 2005/01/15 23:35:02 mwiggins Exp $ */ #ifndef __config_include__ #define __config_include__ @@ -581,6 +581,11 @@ */ #define AOPER_AUTO +/* MODULE_HOOK_REMOTEMSG + * Add an aditional hook for messages originating from other servers + */ +#define MODULE_HOOK_REMOTEMSG + /* SSL * SSL support stolen from fqircd */ diff --git a/include/hooks.h b/include/hooks.h index 99ce288..fc68fe3 100644 --- a/include/hooks.h +++ b/include/hooks.h @@ -30,6 +30,12 @@ enum c_hooktype { * Params: 3: (aClient *, int isnotice, char *msgtext), * Returns int */ +#ifdef MODULE_HOOK_REMOTEMSG + CHOOK_REMOTEMSG, /* called for privmsg or notice from !MyClient() + * Params: 5: (aClient *, aClient *,int isnotice,char *dest, char *msgtxt), + * Returns int + */ +#endif CHOOK_CHANMSG, /* called for every privmsg or notice to a channel * Params: 4: (aClient *source, aChannel *destination, \ * int isnotice, char *msgtxt) diff --git a/src/modules.c b/src/modules.c index fdced87..cd579e0 100644 --- a/src/modules.c +++ b/src/modules.c @@ -3,7 +3,7 @@ * Copyright (C) 2003, Lucas Madar */ -/* $Id: modules.c,v 1.1 2005/01/12 07:44:56 mmondor Exp $ */ +/* $Id: modules.c,v 1.2 2005/01/15 23:35:03 mwiggins Exp $ */ #include "struct.h" #include "common.h" @@ -474,6 +474,9 @@ static DLink *preaccess_hooks = NULL; static DLink *postaccess_hooks = NULL; static DLink *postmotd_hooks = NULL; static DLink *msg_hooks = NULL; +#ifdef MODULE_HOOK_REMOTEMSG +static DLink *remotemsg_hooks = NULL; +#endif static DLink *chanmsg_hooks = NULL; static DLink *usermsg_hooks = NULL; static DLink *mymsg_hooks = NULL; @@ -505,6 +508,10 @@ get_texthooktype(enum c_hooktype hooktype) case CHOOK_MSG: return "Message"; +#ifdef MODULE_HOOK_REMOTEMSG + case CHOOK_REMOTEMSG: + return "Remote Message"; +#endif case CHOOK_CHANMSG: return "Channel Message"; @@ -556,6 +563,11 @@ get_hooklist(enum c_hooktype hooktype) case CHOOK_MSG: hooklist = &msg_hooks; break; +#ifdef MODULE_HOOK_REMOTEMSG + case CHOOK_REMOTEMSG: + hooklist = &remotemsg_hooks; + break; +#endif case CHOOK_CHANMSG: hooklist = &chanmsg_hooks; @@ -736,6 +748,24 @@ call_hooks(enum c_hooktype hooktype, ...) } break; } +#ifdef MODULE_HOOK_REMOTEMSG + case CHOOK_REMOTEMSG: + { + aClient *acptr = va_arg(vl, aClient *); + aClient *asptr = va_arg(vl, aClient *); + int aint = va_arg(vl, int); + char *destptr = va_arg(vl, char *); + char *txtptr = va_arg(vl, char *); + for (lp = remotemsg_hooks; lp; lp = lp->next) + { + int (*rfunc) (aClient *, aClient *, int, char *, char *) = + ((aHook*)lp->value.cp)->funcptr; + if ((ret = (*rfunc)(acptr, asptr, aint, destptr, txtptr)) == FLUSH_BUFFER) + break; + } + break; + } +#endif case CHOOK_CHANMSG: { diff --git a/src/s_user.c b/src/s_user.c index c41dd1a..a1129eb 100644 --- a/src/s_user.c +++ b/src/s_user.c @@ -21,7 +21,7 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: s_user.c,v 1.8 2005/01/14 13:15:33 mmondor Exp $ */ +/* $Id: s_user.c,v 1.9 2005/01/15 23:35:03 mwiggins Exp $ */ #include "struct.h" #include "common.h" @@ -1533,8 +1533,18 @@ m_message(aClient *cptr, aClient *sptr, int parc, char *parv[], int notice) parv[1] = canonize(parv[1]); } - if(ismine && call_hooks(CHOOK_MSG, sptr, notice, parv[2]) == FLUSH_BUFFER) - return FLUSH_BUFFER; + if (ismine) + { + if(call_hooks(CHOOK_MSG, sptr, notice, parv[2]) == FLUSH_BUFFER) + return FLUSH_BUFFER; + } +#ifdef MODULE_HOOK_REMOTEMSG + else + { + if(call_hooks(CHOOK_REMOTEMSG, cptr, sptr, notice, parv[1], parv[2]) == FLUSH_BUFFER) + return FLUSH_BUFFER; + } +#endif for (p = NULL, nick = strtoken(&p, parv[1], ","), i = 0; nick && i<20 ; nick = strtoken(&p, NULL, ","))