[NeoStats-Devel] [Commits] r2739 - in trunk: include lib/event src

[email protected] Tue, 16 Aug 2005 07:05:26 +1000
Newsgroups gmane.comp.neostats.devel
Message-ID <[email protected]>
Author: Mark
Date: Tue Aug 16 05:05:23 2005
New Revision: 2739

Added:
   trunk/include/nsevents.h   (contents, props changed)
   trunk/src/nsevents.c   (contents, props changed)
Modified:
   trunk/include/Makefile.am
   trunk/include/Makefile.in
   trunk/include/modules.h
   trunk/lib/event/Makefile.in
   trunk/src/Makefile.am
   trunk/src/Makefile.in
   trunk/src/bans.c
   trunk/src/bots.c
   trunk/src/channels.c
   trunk/src/ctcp.c
   trunk/src/dcc.c
   trunk/src/ircprotocol.c
   trunk/src/ircrecv.c
   trunk/src/modes.c
   trunk/src/modules.c
   trunk/src/neostats.vcproj
   trunk/src/perl.c
   trunk/src/servers.c
   trunk/src/services.c
   trunk/src/settings.c
   trunk/src/users.c
Log:
split event code into seperate file

Modified: trunk/include/Makefile.am
==============================================================================
--- trunk/include/Makefile.am	(original)
+++ trunk/include/Makefile.am	Tue Aug 16 05:05:23 2005
@@ -6,8 +6,8 @@
 						adns.h protocol.h perlmod.h
 
 noinst_HEADERS		=	commands.h dns.h servers.h users.h conf.h \
-				log.h services.h modes.h signals.h \
-				auth.h config.h.in  exclude.h  modules.h sock.h \
+				log.h services.h modes.h signals.h nsevents.h \
+				auth.h config.h.in exclude.h modules.h sock.h \
 				bans.h base64.h ctcp.h helpstrings.h support.h \
 				ircprotocol.h ircsend.h ircrecv.h \
 				bots.h dcc.h ircstring.h numeric.h timer.h \

Modified: trunk/include/Makefile.in
==============================================================================
--- trunk/include/Makefile.in	(original)
+++ trunk/include/Makefile.in	Tue Aug 16 05:05:23 2005
@@ -201,8 +201,8 @@
 						adns.h protocol.h perlmod.h
 
 noinst_HEADERS = commands.h dns.h servers.h users.h conf.h \
-				log.h services.h modes.h signals.h \
-				auth.h config.h.in  exclude.h  modules.h sock.h \
+				log.h services.h modes.h signals.h nsevents.h \
+				auth.h config.h.in exclude.h modules.h sock.h \
 				bans.h base64.h ctcp.h helpstrings.h support.h \
 				ircprotocol.h ircsend.h ircrecv.h \
 				bots.h dcc.h ircstring.h numeric.h timer.h \

Modified: trunk/include/modules.h
==============================================================================
--- trunk/include/modules.h	(original)
+++ trunk/include/modules.h	Tue Aug 16 05:05:23 2005
@@ -33,12 +33,9 @@
 void unload_modules( void );
 int ns_cmd_modlist( CmdParams* cmdparams );
 void ModulesVersion( const char* nick, const char *remoteserver );
-void SendAllModuleEvent( Event event, CmdParams* cmdparams );
-void SendModuleEvent( Event event, CmdParams* cmdparams, Module* module_ptr );
 int SynchModule( Module* module_ptr );
 int SynchAllModules( void );
 void assign_mod_number( Module *mod_ptr );
 void insert_module( Module *mod_ptr );
 void load_module_error( const Client *target, const char *module_name, const char *fmt, ... );
-void FreeEventList( Module* mod_ptr );
 #endif /* _MODULES_H_ */

Added: trunk/include/nsevents.h
==============================================================================
--- (empty file)
+++ trunk/include/nsevents.h	Tue Aug 16 05:05:23 2005
@@ -0,0 +1,31 @@
+/* NeoStats - IRC Statistical Services 
+** Copyright (c) 1999-2005 Adam Rutter, Justin Hammond, Mark Hetherington
+** http://www.neostats.net/
+**
+**  This program is free software; you can redistribute it and/or modify
+**  it under the terms of the GNU General Public License as published by
+**  the Free Software Foundation; either version 2 of the License, or
+**  (at your option) any later version.
+**
+**  This program is distributed in the hope that it will be useful,
+**  but WITHOUT ANY WARRANTY; without even the implied warranty of
+**  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+**  GNU General Public License for more details.
+**
+**  You should have received a copy of the GNU General Public License
+**  along with this program; if not, write to the Free Software
+**  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
+**  USA
+**
+** NeoStats CVS Identification
+** $Id$
+*/
+
+#ifndef _NSEVENTS_H_
+#define _NSEVENTS_H_
+
+void SendAllModuleEvent( Event event, CmdParams* cmdparams );
+void SendModuleEvent( Event event, CmdParams* cmdparams, Module* module_ptr );
+void FreeEventList( Module* mod_ptr );
+
+#endif /* _NSEVENTS_H_ */

Modified: trunk/lib/event/Makefile.in
==============================================================================
--- trunk/lib/event/Makefile.in	(original)
+++ trunk/lib/event/Makefile.in	Tue Aug 16 05:05:23 2005
@@ -222,7 +222,7 @@
 EXTRA_DIST = err.c event.h event-internal.h evsignal.h \
 	kqueue.c epoll_sub.c epoll.c select.c rtsig.c poll.c signal.c \
 	devpoll.c log.c log.h\
-	compat/err.h compat/sys/queue.h compat/sys/tree.h compat/sys/_time.h \
+	compat/sys/queue.h compat/sys/tree.h compat/sys/_time.h \
 	WIN32-Code/config.h WIN32-Code/misc.c \
 	WIN32-Code/win32.c WIN32-Code/misc.h \
 	WIN32-Prj/libevent.dsp \
@@ -358,7 +358,7 @@
 	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
 
 distdir: $(DISTFILES)
-	$(mkdir_p) $(distdir)/../../autotools $(distdir)/WIN32-Code $(distdir)/WIN32-Prj $(distdir)/compat $(distdir)/compat/sys
+	$(mkdir_p) $(distdir)/../../autotools $(distdir)/WIN32-Code $(distdir)/WIN32-Prj $(distdir)/compat/sys
 	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
 	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
 	list='$(DISTFILES)'; for file in $$list; do \

Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am	(original)
+++ trunk/src/Makefile.am	Tue Aug 16 05:05:23 2005
@@ -3,7 +3,7 @@
 neostats_SOURCES = auth.c bans.c bots.c channels.c commands.c confuse.c confuselexer.c nsdba.c \
 		conf.c dl.c dns.c exclude.c hash.c ircstring.c \
 		ircprotocol.c ircsend.c ircrecv.c \
-		lang.c list.c log.c main.c match.c misc.c modules.c \
+		lang.c list.c log.c main.c match.c misc.c modules.c nsevents.c \
 		helpstrings.c servers.c services.c signals.c sock.c support.c \
 		timer.c transfer.c users.c modes.c ctcp.c dcc.c nsmemory.c \
 		base64.c numerics.c settings.c botinfo.c \

Modified: trunk/src/Makefile.in
==============================================================================
--- trunk/src/Makefile.in	(original)
+++ trunk/src/Makefile.in	Tue Aug 16 05:05:23 2005
@@ -62,13 +62,13 @@
 am__neostats_SOURCES_DIST = auth.c bans.c bots.c channels.c commands.c \
 	confuse.c confuselexer.c nsdba.c conf.c dl.c dns.c exclude.c \
 	hash.c ircstring.c ircprotocol.c ircsend.c ircrecv.c lang.c \
-	list.c log.c main.c match.c misc.c modules.c helpstrings.c \
-	servers.c services.c signals.c sock.c support.c timer.c \
-	transfer.c users.c modes.c ctcp.c dcc.c nsmemory.c base64.c \
-	numerics.c settings.c botinfo.c adnscheck.c adnsevent.c \
-	adnsgeneral.c adnsparse.c adnsquery.c adnsreply.c adnssetup.c \
-	adnstransmit.c adnstypes.c oscalls.c ossocket.c osfile.c \
-	updates.c perl.c neostats.pm.h
+	list.c log.c main.c match.c misc.c modules.c nsevents.c \
+	helpstrings.c servers.c services.c signals.c sock.c support.c \
+	timer.c transfer.c users.c modes.c ctcp.c dcc.c nsmemory.c \
+	base64.c numerics.c settings.c botinfo.c adnscheck.c \
+	adnsevent.c adnsgeneral.c adnsparse.c adnsquery.c adnsreply.c \
+	adnssetup.c adnstransmit.c adnstypes.c oscalls.c ossocket.c \
+	osfile.c updates.c perl.c neostats.pm.h
 @DO_PERL_TRUE@am__objects_1 = perl.$(OBJEXT)
 am__objects_2 =
 am_neostats_OBJECTS = auth.$(OBJEXT) bans.$(OBJEXT) bots.$(OBJEXT) \
@@ -78,17 +78,18 @@
 	ircstring.$(OBJEXT) ircprotocol.$(OBJEXT) ircsend.$(OBJEXT) \
 	ircrecv.$(OBJEXT) lang.$(OBJEXT) list.$(OBJEXT) log.$(OBJEXT) \
 	main.$(OBJEXT) match.$(OBJEXT) misc.$(OBJEXT) \
-	modules.$(OBJEXT) helpstrings.$(OBJEXT) servers.$(OBJEXT) \
-	services.$(OBJEXT) signals.$(OBJEXT) sock.$(OBJEXT) \
-	support.$(OBJEXT) timer.$(OBJEXT) transfer.$(OBJEXT) \
-	users.$(OBJEXT) modes.$(OBJEXT) ctcp.$(OBJEXT) dcc.$(OBJEXT) \
-	nsmemory.$(OBJEXT) base64.$(OBJEXT) numerics.$(OBJEXT) \
-	settings.$(OBJEXT) botinfo.$(OBJEXT) adnscheck.$(OBJEXT) \
-	adnsevent.$(OBJEXT) adnsgeneral.$(OBJEXT) adnsparse.$(OBJEXT) \
-	adnsquery.$(OBJEXT) adnsreply.$(OBJEXT) adnssetup.$(OBJEXT) \
-	adnstransmit.$(OBJEXT) adnstypes.$(OBJEXT) oscalls.$(OBJEXT) \
-	ossocket.$(OBJEXT) osfile.$(OBJEXT) updates.$(OBJEXT) \
-	$(am__objects_1) $(am__objects_2)
+	modules.$(OBJEXT) nsevents.$(OBJEXT) helpstrings.$(OBJEXT) \
+	servers.$(OBJEXT) services.$(OBJEXT) signals.$(OBJEXT) \
+	sock.$(OBJEXT) support.$(OBJEXT) timer.$(OBJEXT) \
+	transfer.$(OBJEXT) users.$(OBJEXT) modes.$(OBJEXT) \
+	ctcp.$(OBJEXT) dcc.$(OBJEXT) nsmemory.$(OBJEXT) \
+	base64.$(OBJEXT) numerics.$(OBJEXT) settings.$(OBJEXT) \
+	botinfo.$(OBJEXT) adnscheck.$(OBJEXT) adnsevent.$(OBJEXT) \
+	adnsgeneral.$(OBJEXT) adnsparse.$(OBJEXT) adnsquery.$(OBJEXT) \
+	adnsreply.$(OBJEXT) adnssetup.$(OBJEXT) adnstransmit.$(OBJEXT) \
+	adnstypes.$(OBJEXT) oscalls.$(OBJEXT) ossocket.$(OBJEXT) \
+	osfile.$(OBJEXT) updates.$(OBJEXT) $(am__objects_1) \
+	$(am__objects_2)
 neostats_OBJECTS = $(am_neostats_OBJECTS)
 neostats_DEPENDENCIES = $(top_srcdir)/lib/event/libevent.a
 DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)/include
@@ -238,13 +239,13 @@
 neostats_SOURCES = auth.c bans.c bots.c channels.c commands.c \
 	confuse.c confuselexer.c nsdba.c conf.c dl.c dns.c exclude.c \
 	hash.c ircstring.c ircprotocol.c ircsend.c ircrecv.c lang.c \
-	list.c log.c main.c match.c misc.c modules.c helpstrings.c \
-	servers.c services.c signals.c sock.c support.c timer.c \
-	transfer.c users.c modes.c ctcp.c dcc.c nsmemory.c base64.c \
-	numerics.c settings.c botinfo.c adnscheck.c adnsevent.c \
-	adnsgeneral.c adnsparse.c adnsquery.c adnsreply.c adnssetup.c \
-	adnstransmit.c adnstypes.c oscalls.c ossocket.c osfile.c \
-	updates.c $(am__append_1) $(am__append_2)
+	list.c log.c main.c match.c misc.c modules.c nsevents.c \
+	helpstrings.c servers.c services.c signals.c sock.c support.c \
+	timer.c transfer.c users.c modes.c ctcp.c dcc.c nsmemory.c \
+	base64.c numerics.c settings.c botinfo.c adnscheck.c \
+	adnsevent.c adnsgeneral.c adnsparse.c adnsquery.c adnsreply.c \
+	adnssetup.c adnstransmit.c adnstypes.c oscalls.c ossocket.c \
+	osfile.c updates.c $(am__append_1) $(am__append_2)
 AM_CFLAGS = @PCRE_CFLAGS@ @CURL_CFLAGS@ -DNEOSTATSCORE @PERL_CFLAGS@ \
 		-I$(top_srcdir)/lib/event
 
@@ -353,6 +354,7 @@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/modes.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/modules.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nsdba.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nsevents.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nsmemory.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/numerics.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/oscalls.Po@am__quote@

Modified: trunk/src/bans.c
==============================================================================
--- trunk/src/bans.c	(original)
+++ trunk/src/bans.c	Tue Aug 16 05:05:23 2005
@@ -27,7 +27,7 @@
  */
 
 #include "neostats.h"
-#include "modules.h"
+#include "nsevents.h"
 #include "services.h"
 
 /** Bans subsystem

Modified: trunk/src/bots.c
==============================================================================
--- trunk/src/bots.c	(original)
+++ trunk/src/bots.c	Tue Aug 16 05:05:23 2005
@@ -22,7 +22,7 @@
 */
 
 #include "neostats.h"
-#include "modules.h"
+#include "nsevents.h"
 #include "protocol.h"
 #include "ircprotocol.h"
 #include "modes.h"

Modified: trunk/src/channels.c
==============================================================================
--- trunk/src/channels.c	(original)
+++ trunk/src/channels.c	Tue Aug 16 05:05:23 2005
@@ -34,7 +34,7 @@
 #include "channels.h"
 #include "exclude.h"
 #include "services.h"
-#include "modules.h"
+#include "nsevents.h"
 
 /* @brief hash and list sizes */
 #define CHANNEL_TABLE_SIZE	-1

Modified: trunk/src/ctcp.c
==============================================================================
--- trunk/src/ctcp.c	(original)
+++ trunk/src/ctcp.c	Tue Aug 16 05:05:23 2005
@@ -22,7 +22,7 @@
 */
 
 #include "neostats.h"
-#include "modules.h"
+#include "nsevents.h"
 #include "ctcp.h"
 #include "dcc.h"
 

Modified: trunk/src/dcc.c
==============================================================================
--- trunk/src/dcc.c	(original)
+++ trunk/src/dcc.c	Tue Aug 16 05:05:23 2005
@@ -22,7 +22,7 @@
 */
 
 #include "neostats.h"
-#include "modules.h"
+#include "nsevents.h"
 #include "commands.h"
 #include "services.h"
 

Modified: trunk/src/ircprotocol.c
==============================================================================
--- trunk/src/ircprotocol.c	(original)
+++ trunk/src/ircprotocol.c	Tue Aug 16 05:05:23 2005
@@ -30,7 +30,7 @@
 #include "ircrecv.h"
 #include "numerics.h"
 #include "modes.h"
-#include "modules.h"
+#include "nsevents.h"
 #include "dl.h"
 #include "bots.h"
 #include "commands.h"

Modified: trunk/src/ircrecv.c
==============================================================================
--- trunk/src/ircrecv.c	(original)
+++ trunk/src/ircrecv.c	Tue Aug 16 05:05:23 2005
@@ -29,6 +29,7 @@
 #include "main.h"
 #include "bots.h"
 #include "modules.h"
+#include "nsevents.h"
 #include "modes.h"
 #include "users.h"
 #include "servers.h"

Modified: trunk/src/modes.c
==============================================================================
--- trunk/src/modes.c	(original)
+++ trunk/src/modes.c	Tue Aug 16 05:05:23 2005
@@ -29,7 +29,7 @@
 #include "services.h"
 #include "users.h"
 #include "channels.h"
-#include "modules.h"
+#include "nsevents.h"
 
 #define MODE_TABLE_SIZE	256
 

Modified: trunk/src/modules.c
==============================================================================
--- trunk/src/modules.c	(original)
+++ trunk/src/modules.c	Tue Aug 16 05:05:23 2005
@@ -27,6 +27,7 @@
 #include "sock.h"
 #include "services.h"
 #include "modules.h"
+#include "nsevents.h"
 #include "bots.h"
 #include "dns.h"
 #include "protocol.h"
@@ -130,104 +131,6 @@
 }
 
 
-/** @brief SendModuleEvent
- *
- *	Call event handler for a specific module
- *  NeoStats core use only
- *
- *  @param event to send
- *  @param cmdparams
- *  @param module_ptr pointer to module to raise event for
- *
- *  @return none
- */
-
-void SendModuleEvent( Event event, CmdParams* cmdparams, Module* module_ptr )
-{
-	SET_SEGV_LOCATION();
-	dlog( DEBUG5, "SendModuleEvent: event %d to module %s", event, module_ptr->info->name );
-	if( !module_ptr->event_list )
-	{
-		dlog( DEBUG5, "SendModuleEvent: module %s has no events associated with it", module_ptr->info->name );
-		return;
-	}
-	if ((IS_STD_MOD(module_ptr) && module_ptr->event_list[event] && module_ptr->event_list[event]->handler)
-#ifdef USE_PERL
-		|| (IS_PERL_MOD(module_ptr) && module_ptr->event_list[event])
-#endif
-		){
-		/* If we are not yet synched, check that the module supports 
-			* the event before we are synched. */
-		if (!module_ptr->synched && !(module_ptr->event_list[event]->flags & EVENT_FLAG_IGNORE_SYNCH)) {
-			dlog( DEBUG5, "Skipping module %s for event %d since module is not yet synched", module_ptr->info->name, event );
-			return;
-		}
-		if ((module_ptr->event_list[event]->flags & EVENT_FLAG_DISABLED)) {
-			dlog( DEBUG5, "Skipping module %s for event %d since it is disabled", module_ptr->info->name, event );
-			return;
-		}
-		if ((module_ptr->event_list[event]->flags & EVENT_FLAG_EXCLUDE_ME) && IsMe (cmdparams->source) ) {
-			dlog( DEBUG5, "Skipping module %s for event %d since %s is excluded as a NeoStats client", module_ptr->info->name, event, cmdparams->source->name );
-			return;
-		}
-		if (module_ptr->event_list[event]->flags & EVENT_FLAG_EXCLUDE_MODME) {
-			if (cmdparams->source && cmdparams->source->user && cmdparams->source->user->bot && cmdparams->source->user->bot->moduleptr == module_ptr) {
-				dlog( DEBUG5, "Skipping module %s for event %d since %s is excluded as a Module client", module_ptr->info->name, event, cmdparams->source->name );
-				return;
-			}
-		}			
-		if ((module_ptr->event_list[event]->flags & EVENT_FLAG_USE_EXCLUDE) && IsExcluded (cmdparams->source)) {
-			dlog( DEBUG5, "Skipping module %s for event %d since %s is excluded", module_ptr->info->name, event, cmdparams->source->name );
-			return;
-		}			
-		dlog(DEBUG1, "Running module %s with event %d", module_ptr->info->name, event);
-		SET_SEGV_LOCATION();
-		if (IS_STD_MOD(module_ptr)) {
-			if (setjmp (sigvbuf) == 0) {
-				SET_RUN_LEVEL(module_ptr);
-				module_ptr->event_list[event]->handler (cmdparams);
-				RESET_RUN_LEVEL();
-			} else {
-				nlog (LOG_CRITICAL, "setjmp() failed, not calling module %s", module_ptr->info->name);
-			}
-			return;
-#if USE_PERL
-		} else if (IS_PERL_MOD(module_ptr)) {
-			perl_event_cb(event, cmdparams, module_ptr);
-			return;
-#endif
-		}			
-	}
-	dlog( DEBUG5, "Module %s has no event handler for %d", module_ptr->info->name, event );
-}
-
-/** @brief SendAllModuleEvent
- *
- *	Call event handler for all modules
- *  NeoStats core use only
- *
- *  @param event to send
- *  @param cmdparams
- *
- *  @return none
- */
-
-void SendAllModuleEvent( Event event, CmdParams* cmdparams )
-{
-	Module *module_ptr;
-	hscan_t ms;
-	hnode_t *mn;
-
-	SET_SEGV_LOCATION();
-	hash_scan_begin (&ms, modulehash);
-	while ((mn = hash_scan_next (&ms)) != NULL) {
-		module_ptr = hnode_get (mn);
-		if (module_ptr->event_list) {
-			SendModuleEvent(event, cmdparams, module_ptr);
-		}
-	}
-}
-
 /** @brief 
  *
  * 
@@ -688,150 +591,6 @@
 	return NS_SUCCESS;
 }
 
-/** @brief 
- *
- * 
- *
- * @return none
- */
-void AddEvent( ModuleEvent* eventptr )
-{
-	Module* mod_ptr;
-
-	mod_ptr = GET_CUR_MODULE();
-	if( !mod_ptr->event_list )
-		mod_ptr->event_list = ns_calloc( sizeof( ModuleEvent * ) * EVENT_COUNT );
-	dlog( DEBUG5, "AddEvent: adding event %d to %s", eventptr->event, mod_ptr->info->name );
-	mod_ptr->event_list[eventptr->event] = eventptr;
-	if( eventptr->event == EVENT_NICKIP )
-		me.want_nickip = 1; 		
-}
-
-/** @brief 
- *
- * 
- *
- * @return none
- */
-void AddEventList( ModuleEvent *eventlistptr )
-{
-	while( eventlistptr->event != EVENT_NULL )
-	{
-		AddEvent( eventlistptr );
-		eventlistptr ++;
-	}
-}
-
-/** @brief 
- *
- * 
- *
- * @return none
- */
-void DeleteEvent( Event event )
-{
-	Module* mod_ptr;
-
-	mod_ptr = GET_CUR_MODULE();
-	if( mod_ptr->event_list )
-		mod_ptr->event_list[event] = NULL;
-	dlog( DEBUG5, "DeleteEvent: deleting event %d from %s", event, mod_ptr->info->name );
-}
-
-/** @brief 
- *
- * 
- *
- * @return none
- */
-void DeleteEventList( ModuleEvent *eventlistptr )
-{
-	while( eventlistptr->event )
-	{
-		DeleteEvent( eventlistptr->event );
-		eventlistptr++;
-	}
-}
-
-/** @brief 
- *
- * 
- *
- * @return none
- */
-void FreeEventList( Module* mod_ptr )
-{
-	if( mod_ptr->event_list )
-		ns_free( mod_ptr->event_list );
-	mod_ptr->event_list = NULL;
-}
-
-/** @brief 
- *
- * @param 
- * 
- * @return
- */
-void SetAllEventFlags (unsigned int flag, unsigned int enable)
-{
-	int i;
-	ModuleEvent** eventlistptr;
-
-	eventlistptr = GET_CUR_MODULE()->event_list;
-	if (eventlistptr) {
-		for (i = 0; i < EVENT_COUNT; i++) {
-			if (eventlistptr[i]) {
-				if (enable)
-					eventlistptr[i]->flags |= flag;
-				else
-					eventlistptr[i]->flags &= ~flag;
-			}
-		}
-	}
-}
-
-/** @brief 
- *
- * @param 
- * 
- * @return
- */
-void SetEventFlags (Event event, unsigned int flag, unsigned int enable)
-{
-	ModuleEvent** eventlistptr;
-
-	eventlistptr = GET_CUR_MODULE()->event_list;
-	if (eventlistptr)
-	{
-		if (enable)
-			eventlistptr[event]->flags |= flag;
-		else
-			eventlistptr[event]->flags &= ~flag;
-	}
-}
-
-/** @brief 
- *
- * @param 
- * 
- * @return
- */
-void EnableEvent (Event event)
-{
-	GET_CUR_MODULE()->event_list[event]->flags &= ~EVENT_FLAG_DISABLED;
-}
-
-/** @brief 
- *
- * @param 
- * 
- * @return
- */
-void DisableEvent (Event event)
-{
-	GET_CUR_MODULE()->event_list[event]->flags |= EVENT_FLAG_DISABLED;
-}
-
 hash_t *GetModuleHash (void)
 {
 	return modulehash;

Modified: trunk/src/neostats.vcproj
==============================================================================
--- trunk/src/neostats.vcproj	(original)
+++ trunk/src/neostats.vcproj	Tue Aug 16 05:05:23 2005
@@ -361,6 +361,9 @@
 				RelativePath=".\nsdba.c">
 			</File>
 			<File
+				RelativePath=".\nsevents.c">
+			</File>
+			<File
 				RelativePath=".\nsmemory.c">
 			</File>
 			<File
@@ -537,6 +540,9 @@
 				RelativePath="..\include\nsdbm.h">
 			</File>
 			<File
+				RelativePath="..\include\nsevents.h">
+			</File>
+			<File
 				RelativePath="..\include\numeric.h">
 			</File>
 			<File

Added: trunk/src/nsevents.c
==============================================================================
--- (empty file)
+++ trunk/src/nsevents.c	Tue Aug 16 05:05:23 2005
@@ -0,0 +1,273 @@
+/* NeoStats - IRC Statistical Services
+** Copyright (c) 1999-2005 Adam Rutter, Justin Hammond, Mark Hetherington
+** http://www.neostats.net/
+**
+**  This program is free software; you can redistribute it and/or modify
+**  it under the terms of the GNU General Public License as published by
+**  the Free Software Foundation; either version 2 of the License, or
+**  (at your option) any later version.
+**
+**  This program is distributed in the hope that it will be useful,
+**  but WITHOUT ANY WARRANTY; without even the implied warranty of
+**  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+**  GNU General Public License for more details.
+**
+**  You should have received a copy of the GNU General Public License
+**  along with this program; if not, write to the Free Software
+**  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
+**  USA
+**
+** NeoStats CVS Identification
+** $Id$
+*/
+
+#include "neostats.h"
+#include "nsevents.h"
+#include "modules.h"
+#ifdef USE_PERL
+#undef _
+#define PERLDEFINES
+#include "perlmod.h"
+#endif /* USE_PERL */
+
+/** @brief SendModuleEvent
+ *
+ *	Call event handler for a specific module
+ *  NeoStats core use only
+ *
+ *  @param event to send
+ *  @param cmdparams
+ *  @param module_ptr pointer to module to raise event for
+ *
+ *  @return none
+ */
+
+void SendModuleEvent( Event event, CmdParams* cmdparams, Module* module_ptr )
+{
+	SET_SEGV_LOCATION();
+	dlog( DEBUG5, "SendModuleEvent: event %d to module %s", event, module_ptr->info->name );
+	if( !module_ptr->event_list )
+	{
+		dlog( DEBUG5, "SendModuleEvent: module %s has no events associated with it", module_ptr->info->name );
+		return;
+	}
+	if ((IS_STD_MOD(module_ptr) && module_ptr->event_list[event] && module_ptr->event_list[event]->handler)
+#ifdef USE_PERL
+		|| (IS_PERL_MOD(module_ptr) && module_ptr->event_list[event])
+#endif
+		){
+		/* If we are not yet synched, check that the module supports 
+			* the event before we are synched. */
+		if (!module_ptr->synched && !(module_ptr->event_list[event]->flags & EVENT_FLAG_IGNORE_SYNCH)) {
+			dlog( DEBUG5, "Skipping module %s for event %d since module is not yet synched", module_ptr->info->name, event );
+			return;
+		}
+		if ((module_ptr->event_list[event]->flags & EVENT_FLAG_DISABLED)) {
+			dlog( DEBUG5, "Skipping module %s for event %d since it is disabled", module_ptr->info->name, event );
+			return;
+		}
+		if ((module_ptr->event_list[event]->flags & EVENT_FLAG_EXCLUDE_ME) && IsMe (cmdparams->source) ) {
+			dlog( DEBUG5, "Skipping module %s for event %d since %s is excluded as a NeoStats client", module_ptr->info->name, event, cmdparams->source->name );
+			return;
+		}
+		if (module_ptr->event_list[event]->flags & EVENT_FLAG_EXCLUDE_MODME) {
+			if (cmdparams->source && cmdparams->source->user && cmdparams->source->user->bot && cmdparams->source->user->bot->moduleptr == module_ptr) {
+				dlog( DEBUG5, "Skipping module %s for event %d since %s is excluded as a Module client", module_ptr->info->name, event, cmdparams->source->name );
+				return;
+			}
+		}			
+		if ((module_ptr->event_list[event]->flags & EVENT_FLAG_USE_EXCLUDE) && IsExcluded (cmdparams->source)) {
+			dlog( DEBUG5, "Skipping module %s for event %d since %s is excluded", module_ptr->info->name, event, cmdparams->source->name );
+			return;
+		}			
+		dlog(DEBUG1, "Running module %s with event %d", module_ptr->info->name, event);
+		SET_SEGV_LOCATION();
+		if (IS_STD_MOD(module_ptr)) {
+			if (setjmp (sigvbuf) == 0) {
+				SET_RUN_LEVEL(module_ptr);
+				module_ptr->event_list[event]->handler (cmdparams);
+				RESET_RUN_LEVEL();
+			} else {
+				nlog (LOG_CRITICAL, "setjmp() failed, not calling module %s", module_ptr->info->name);
+			}
+			return;
+#if USE_PERL
+		} else if (IS_PERL_MOD(module_ptr)) {
+			perl_event_cb(event, cmdparams, module_ptr);
+			return;
+#endif
+		}			
+	}
+	dlog( DEBUG5, "Module %s has no event handler for %d", module_ptr->info->name, event );
+}
+
+/** @brief SendAllModuleEvent
+ *
+ *	Call event handler for all modules
+ *  NeoStats core use only
+ *
+ *  @param event to send
+ *  @param cmdparams
+ *
+ *  @return none
+ */
+
+void SendAllModuleEvent( Event event, CmdParams* cmdparams )
+{
+	Module *module_ptr;
+	hscan_t ms;
+	hnode_t *mn;
+
+	SET_SEGV_LOCATION();
+	hash_scan_begin (&ms, GetModuleHash());
+	while ((mn = hash_scan_next (&ms)) != NULL) {
+		module_ptr = hnode_get (mn);
+		if (module_ptr->event_list) {
+			SendModuleEvent(event, cmdparams, module_ptr);
+		}
+	}
+}
+
+/** @brief 
+ *
+ * 
+ *
+ * @return none
+ */
+void AddEvent( ModuleEvent* eventptr )
+{
+	Module* mod_ptr;
+
+	mod_ptr = GET_CUR_MODULE();
+	if( !mod_ptr->event_list )
+		mod_ptr->event_list = ns_calloc( sizeof( ModuleEvent * ) * EVENT_COUNT );
+	dlog( DEBUG5, "AddEvent: adding event %d to %s", eventptr->event, mod_ptr->info->name );
+	mod_ptr->event_list[eventptr->event] = eventptr;
+	if( eventptr->event == EVENT_NICKIP )
+		me.want_nickip = 1; 		
+}
+
+/** @brief 
+ *
+ * 
+ *
+ * @return none
+ */
+void AddEventList( ModuleEvent *eventlistptr )
+{
+	while( eventlistptr->event != EVENT_NULL )
+	{
+		AddEvent( eventlistptr );
+		eventlistptr ++;
+	}
+}
+
+/** @brief 
+ *
+ * 
+ *
+ * @return none
+ */
+void DeleteEvent( Event event )
+{
+	Module* mod_ptr;
+
+	mod_ptr = GET_CUR_MODULE();
+	if( mod_ptr->event_list )
+		mod_ptr->event_list[event] = NULL;
+	dlog( DEBUG5, "DeleteEvent: deleting event %d from %s", event, mod_ptr->info->name );
+}
+
+/** @brief 
+ *
+ * 
+ *
+ * @return none
+ */
+void DeleteEventList( ModuleEvent *eventlistptr )
+{
+	while( eventlistptr->event )
+	{
+		DeleteEvent( eventlistptr->event );
+		eventlistptr++;
+	}
+}
+
+/** @brief 
+ *
+ * 
+ *
+ * @return none
+ */
+void FreeEventList( Module* mod_ptr )
+{
+	if( mod_ptr->event_list )
+		ns_free( mod_ptr->event_list );
+	mod_ptr->event_list = NULL;
+}
+
+/** @brief 
+ *
+ * @param 
+ * 
+ * @return
+ */
+void SetAllEventFlags (unsigned int flag, unsigned int enable)
+{
+	int i;
+	ModuleEvent** eventlistptr;
+
+	eventlistptr = GET_CUR_MODULE()->event_list;
+	if (eventlistptr) {
+		for (i = 0; i < EVENT_COUNT; i++) {
+			if (eventlistptr[i]) {
+				if (enable)
+					eventlistptr[i]->flags |= flag;
+				else
+					eventlistptr[i]->flags &= ~flag;
+			}
+		}
+	}
+}
+
+/** @brief 
+ *
+ * @param 
+ * 
+ * @return
+ */
+void SetEventFlags (Event event, unsigned int flag, unsigned int enable)
+{
+	ModuleEvent** eventlistptr;
+
+	eventlistptr = GET_CUR_MODULE()->event_list;
+	if (eventlistptr)
+	{
+		if (enable)
+			eventlistptr[event]->flags |= flag;
+		else
+			eventlistptr[event]->flags &= ~flag;
+	}
+}
+
+/** @brief 
+ *
+ * @param 
+ * 
+ * @return
+ */
+void EnableEvent (Event event)
+{
+	GET_CUR_MODULE()->event_list[event]->flags &= ~EVENT_FLAG_DISABLED;
+}
+
+/** @brief 
+ *
+ * @param 
+ * 
+ * @return
+ */
+void DisableEvent (Event event)
+{
+	GET_CUR_MODULE()->event_list[event]->flags |= EVENT_FLAG_DISABLED;
+}

Modified: trunk/src/perl.c
==============================================================================
--- trunk/src/perl.c	(original)
+++ trunk/src/perl.c	Tue Aug 16 05:05:23 2005
@@ -28,6 +28,7 @@
 #include "neostats.h"
 #include "services.h"
 #include "modules.h"
+#include "nsevents.h"
 #include "commands.h"
 //#include <sys/types.h>
 //#include <dirent.h>

Modified: trunk/src/servers.c
==============================================================================
--- trunk/src/servers.c	(original)
+++ trunk/src/servers.c	Tue Aug 16 05:05:23 2005
@@ -26,7 +26,7 @@
 #include "neostats.h"
 #include "protocol.h"
 #include "exclude.h"
-#include "modules.h"
+#include "nsevents.h"
 #include "servers.h"
 #include "services.h"
 #include "users.h"

Modified: trunk/src/services.c
==============================================================================
--- trunk/src/services.c	(original)
+++ trunk/src/services.c	Tue Aug 16 05:05:23 2005
@@ -26,6 +26,7 @@
 #include "neostats.h"
 #include "main.h"
 #include "modules.h"
+#include "nsevents.h"
 #include "bots.h"
 #include "timer.h"
 #include "commands.h"

Modified: trunk/src/settings.c
==============================================================================
--- trunk/src/settings.c	(original)
+++ trunk/src/settings.c	Tue Aug 16 05:05:23 2005
@@ -23,7 +23,6 @@
 
 #include "neostats.h"
 #include "helpstrings.h"
-#include "modules.h"
 #include "services.h"
 #include "ircstring.h"
 #include "commands.h"

Modified: trunk/src/users.c
==============================================================================
--- trunk/src/users.c	(original)
+++ trunk/src/users.c	Tue Aug 16 05:05:23 2005
@@ -30,7 +30,7 @@
 #include "users.h"
 #include "channels.h"
 #include "exclude.h"
-#include "modules.h"
+#include "nsevents.h"
 #include "bots.h"
 #include "auth.h"
 #include "services.h"