[NeoStats-Devel] [Commits] r2671 - in trunk: . include modules/protocol modules/statserv modules/textserv src

[email protected]
Newsgroups gmane.comp.neostats.devel
Message-ID <[email protected]>
Author: Mark
Date: Sun Jul 17 05:33:50 2005
New Revision: 2671

Modified:
   trunk/ChangeLog
   trunk/include/ircstring.h
   trunk/include/modules.h
   trunk/include/neostats.h
   trunk/include/services.h
   trunk/modules/protocol/ircup10base.c
   trunk/modules/statserv/htmlstats.c
   trunk/modules/statserv/server.c
   trunk/modules/statserv/server.h
   trunk/modules/statserv/stats.c
   trunk/modules/textserv/main.c
   trunk/src/bots.c
   trunk/src/channels.c
   trunk/src/commands.c
   trunk/src/conf.c
   trunk/src/ctcp.c
   trunk/src/dns.c
   trunk/src/ircsend.c
   trunk/src/misc.c
   trunk/src/modules.c
   trunk/src/servers.c
   trunk/src/timer.c
   trunk/src/updates.c
   trunk/src/users.c
Log:
code tidy ups to fix some types, const correctness and warnings

Modified: trunk/ChangeLog
==============================================================================
--- trunk/ChangeLog	(original)
+++ trunk/ChangeLog	Sun Jul 17 05:33:50 2005
@@ -254,7 +254,7 @@
  - Combine standard and auth module load/unload systems so we can load and 
    unload auth modules easily. (M)
  - Remove me.onchan since it is always set with me.synched so is redundant. (M)
- - Replace me.synched references with is_synched for consistency. (M)
+ - Replace me.synched references with IsNeoStatsSynched() for consistency. (M)
  - Timers now have a new type field to select the standard interval timer or 
    a midnight timer. Other types to follow. (M)
  - Timers now check module synched before running. (M)

Modified: trunk/include/ircstring.h
==============================================================================
--- trunk/include/ircstring.h	(original)
+++ trunk/include/ircstring.h	Sun Jul 17 05:33:50 2005
@@ -73,6 +73,7 @@
 #define IsUserChar(c)   (CharAttrs[(unsigned char)(c)] & USER_C)
 #define IsChanPrefix(c) (CharAttrs[(unsigned char)(c)] & CHANPFX_C)
 #define IsChanChar(c)   (CharAttrs[(unsigned char)(c)] & CHAN_C)
+#define IsChanKeyChar(c)   (IsAlNum((c)))
 #define IsKWildChar(c)  (CharAttrs[(unsigned char)(c)] & KWILD_C)
 #define IsNickChar(c)   (CharAttrs[(unsigned char)(c)] & NICK_C)
 #define IsServChar(c)   (CharAttrs[(unsigned char)(c)] & (NICK_C | SERV_C))

Modified: trunk/include/modules.h
==============================================================================
--- trunk/include/modules.h	(original)
+++ trunk/include/modules.h	Sun Jul 17 05:33:50 2005
@@ -25,9 +25,6 @@
 #define _MODULES_H_
 
 extern jmp_buf sigvbuf;
-extern unsigned int fusermoddata;
-extern unsigned int fservermoddata;
-extern unsigned int fchannelmoddata;
 
 int InitModules( void );
 void FiniModules( void );

Modified: trunk/include/neostats.h
==============================================================================
--- trunk/include/neostats.h	(original)
+++ trunk/include/neostats.h	Sun Jul 17 05:33:50 2005
@@ -152,25 +152,25 @@
 char *LANGgettext( const char *string, int mylang );
 /* our own defines for language support */
 /* this one is for standard language support */
-#define _(x) LANGgettext( x, me.lang )
+#define _( x ) LANGgettext( ( x ), me.lang )
 /* this one is for custom langs based on chan/user struct */
-#define __(x,y) LANGgettext( x, (y)->lang )
+#define __( x, y ) LANGgettext( ( x ), ( y )->lang )
 #else /* USEGETTEXT */
-#define _(x) ( x )
-#define __(x, y) ( x )
+#define _( x ) ( x )
+#define __( x, y ) ( x )
 #endif /* USEGETTEXT */
 
 /* If we're not using GNU C, elide __attribute__ */
 #ifndef __GNUC__
-#define __attribute__(x)  /* NOTHING */
+#define __attribute__( x )  /* NOTHING */
 #endif /* __GNUC__ */
 
 /* va_copy handling*/
 #ifndef HAVE_VA_COPY
 #if HAVE___VA_COPY 
-#define va_copy(dest, src) __va_copy(dest, src) 
+#define va_copy( dest, src ) __va_copy( ( dest ), ( src ) ) 
 #else /* HAVE___VA_COPY */
-#define va_copy(dest, src) memcpy(&(dest), &(src), sizeof(dest)) 
+#define va_copy( dest, src ) memcpy( &( dest ), &( src ), sizeof( dest ) ) 
 #endif /* HAVE___VA_COPY */ 
 #endif /* HAVE_VA_COPY */
 
@@ -182,7 +182,7 @@
 #include "events.h"
 #include "numeric.h"
 
-#define arraylen(a)	(sizeof(a) / sizeof(*(a)))
+#define ARRAYLEN( a ) ( sizeof( a ) / sizeof( *( a ) ) )
 
 #define PROTOCOL_NOQUIT		0x00000001	/* NOQUIT */
 #define PROTOCOL_TOKEN		0x00000002	/* TOKEN */
@@ -258,9 +258,9 @@
  */
 
 /* Cmode macros */
-#define is_hidden_chan(x) ((x) && (x->modes & (CMODE_PRIVATE|CMODE_SECRET|CMODE_ADMONLY|CMODE_OPERONLY)))
-#define is_pub_chan(x)  ((x) && !(x->modes & (CMODE_PRIVATE|CMODE_SECRET|CMODE_RGSTRONLY|CMODE_ADMONLY|CMODE_OPERONLY|CMODE_INVITEONLY|CMODE_KEY)))
-#define is_priv_chan(x) ((x) && (x->modes & (CMODE_PRIVATE|CMODE_SECRET|CMODE_RGSTRONLY|CMODE_ADMONLY|CMODE_OPERONLY|CMODE_INVITEONLY|CMODE_KEY)))
+#define is_hidden_chan( x ) ( ( x ) && ( x->modes & ( CMODE_PRIVATE | CMODE_SECRET | CMODE_ADMONLY | CMODE_OPERONLY ) ) )
+#define is_pub_chan( x )  ( ( x ) && !( x->modes & ( CMODE_PRIVATE | CMODE_SECRET | CMODE_RGSTRONLY | CMODE_ADMONLY | CMODE_OPERONLY | CMODE_INVITEONLY | CMODE_KEY ) ) )
+#define is_priv_chan( x ) ( ( x ) && ( x->modes & ( CMODE_PRIVATE | CMODE_SECRET | CMODE_RGSTRONLY | CMODE_ADMONLY | CMODE_OPERONLY | CMODE_INVITEONLY | CMODE_KEY ) ) )
 
 /* User modes available on all IRCds */
 #define UMODE_INVISIBLE		0x00000001	/* makes user invisible */
@@ -312,7 +312,7 @@
 #define HaveUmodeDeaf() ( ircd_supported_umodes & UMODE_DEAF )
 
 /* Umode macros */
-#define IsOper(x) ( ( x ) && ( (x->user->Umode & (UMODE_OPER|UMODE_LOCOP ) ) ) )
+#define IsOper(x) ( ( x ) && ( ( x->user->Umode & ( UMODE_OPER | UMODE_LOCOP ) ) ) )
 #define IsBot(x) ( ( x ) && ( x->user->Umode & UMODE_BOT ) )
 #define IsServerOperMode( mode ) ( mode & ( UMODE_ADMIN | UMODE_COADMIN | UMODE_OPER | UMODE_LOCOP ) )
 #define IsServerOperSMode( mode ) ( mode & ( UMODE_ADMIN | UMODE_COADMIN | UMODE_OPER | UMODE_LOCOP ) )
@@ -434,12 +434,12 @@
 /* Buffer size for version string */
 #define VERSIONSIZE		128
 
-/* doesn't have to be so big atm */
+/* Maximum number of modules that can be loaded */
 #define NUM_MODULES		40
 
-#define is_synched		me.synched
+#define IsNeoStatsSynched()		me.synched
 
-#define i_am_synched	GET_CUR_MODULE()->synched
+#define IsModuleSynched()	GET_CUR_MODULE()->synched
 
 /* Unified return values and error system */
 
@@ -473,7 +473,7 @@
 #define CLIENT_FLAG_EXCLUDED	NS_FLAG_EXCLUDED /* client is excluded */
 #define CLIENT_FLAG_ME			0x00000002 /* client is a NeoStats one */
 #define CLIENT_FLAG_SYNCHED		0x00000004 /* client is synched */
-#define CLIENT_FLAG_SETHOST		0x00000008 /* client is synched */
+#define CLIENT_FLAG_SETHOST		0x00000008 /* client is sethosted */
 #define CLIENT_FLAG_DCC			0x00000010 /* client is connected via DCC */
 #define CLIENT_FLAG_ZOMBIE		0x00000020 /* client is zombie */
 #define NS_FLAGS_NETJOIN		0x00000080 /* client is on a net join */
@@ -481,10 +481,9 @@
 #define CHANNEL_FLAG_EXCLUDED	NS_FLAG_EXCLUDED /* channel is excluded */
 #define CHANNEL_FLAG_ME			0x00000002 /* channel is services channel */
 
-#define IsServicesChannel(x) ((x)->flags & CHANNEL_FLAG_ME)
-
-#define IsNetSplit(x) ((x)->flags & NS_FLAGS_NETJOIN)
+#define IsServicesChannel( x ) ( ( x )->flags & CHANNEL_FLAG_ME )
 
+#define IsNetSplit( x ) ( ( x )->flags & NS_FLAGS_NETJOIN )
 
 typedef enum NS_EXCLUDE {
 	NS_EXCLUDE_HOST	= 0,
@@ -537,7 +536,7 @@
 	unsigned int awaycount;
 	int hops;
 	int numeric;
-	int ping;
+	time_t ping;
 	time_t uptime;
 } Server;
 
@@ -552,7 +551,7 @@
 	char swhois[MAXHOST];
 	char userhostmask[USERHOSTLEN];
 	char uservhostmask[USERHOSTLEN];
-	int flood;
+	unsigned int flood;
 	int is_away;
 	time_t tslastmsg;
 	time_t tslastnick;
@@ -586,7 +585,7 @@
 	int lang;
 	void *modptr[NUM_MODULES];
 	void *modvalue[NUM_MODULES];
-	int fd;
+	OS_SOCKET fd;
 	int port;
 	struct Sock *sock;
 } Client; 
@@ -637,7 +636,7 @@
 	struct sockaddr_in lsa;
 	struct sockaddr_in srvip;
 	time_t tslastping;
-	int ulag;
+	time_t ulag;
 } tme;
 
 EXPORTVAR extern tme me;
@@ -842,7 +841,7 @@
 #define	EVENT_FLAG_EXCLUDE_MODME	0x00000010	/* Event excludes module bots */
 
 #ifdef PERL
-/** @breif Forward Decl of Perl Events 
+/** @brief Forward declaration of perl events 
  */
 struct PerlEvent;
 #endif
@@ -989,15 +988,13 @@
  * have to set/reset when a module calls a core function which triggers
  * other modules to run (e.g. AddBot)
  */
-#define SET_RUN_LEVEL(moduleptr){if(RunLevel<10){RunLevel++;RunModule[RunLevel] = moduleptr;}}
-#define RESET_RUN_LEVEL(){if(RunLevel>0){RunLevel--;}}
+#define SET_RUN_LEVEL( moduleptr ) { if( RunLevel < 10 ) { RunLevel++; RunModule[RunLevel] = moduleptr; } }
+#define RESET_RUN_LEVEL() { if( RunLevel > 0 ) { RunLevel--; } }
 #define GET_CUR_MODULE() RunModule[RunLevel]
 #define GET_CUR_MODNUM() RunModule[RunLevel]->modnum
 #define GET_CUR_MODNAME() RunModule[RunLevel]->info->name
 #define GET_CUR_MODVERSION() RunModule[RunLevel]->info->version
 
-
-
 /** @brief Socket function types
  * 
  */
@@ -1092,7 +1089,7 @@
 	/** Timer name */
 	char name[MAX_MOD_NAME];
 	/** Timer interval */
-	int interval;
+	time_t interval;
 	/** Time last run */
 	time_t lastrun;
 	/** Timer handler */
@@ -1182,10 +1179,10 @@
 EXPORTFUNC void *ns_calloc( const int size );
 EXPORTFUNC void *ns_realloc( void *ptr, const int size );
 EXPORTFUNC void _ns_free( void **ptr );
-#define ns_free(ptr) _ns_free( ( void **) &(ptr) );
+#define ns_free( ptr ) _ns_free( ( void **) &( ptr ) );
 
 /* misc.c */
-EXPORTFUNC unsigned hrand(unsigned upperbound, unsigned lowerbound );
+EXPORTFUNC unsigned hrand( const unsigned upperbound, const unsigned lowerbound );
 EXPORTFUNC void strip( char *line );
 EXPORTFUNC char *sstrdup( const char *s );
 char *strlwr( char *s );
@@ -1278,26 +1275,26 @@
 /*  SVS functions 
  *  these operate from the server rather than a bot 
  */
-EXPORTFUNC int irc_svsnick( const Bot *botptr, Client *target, const char *newnick );
-EXPORTFUNC int irc_svsjoin( const Bot *botptr, Client *target, const char *chan );
-EXPORTFUNC int irc_svspart( const Bot *botptr, Client *target, const char *chan );
+EXPORTFUNC int irc_svsnick( const Bot *botptr, const Client *target, const char *newnick );
+EXPORTFUNC int irc_svsjoin( const Bot *botptr, const Client *target, const char *chan );
+EXPORTFUNC int irc_svspart( const Bot *botptr, const Client *target, const char *chan );
 EXPORTFUNC int irc_svshost( const Bot *botptr, Client *target, const char *vhost );
-EXPORTFUNC int irc_svsmode( const Bot *botptr, Client *target, const char *modes );
-EXPORTFUNC int irc_svskill( const Bot *botptr, Client *target, const char *reason, ...) __attribute__((format(printf,3,4))); /* 3=format 4=params */
-EXPORTFUNC int irc_svstime( const Bot *botptr, Client *target, const time_t ts );
+EXPORTFUNC int irc_svsmode( const Bot *botptr, const Client *target, const char *modes );
+EXPORTFUNC int irc_svskill( const Bot *botptr, const Client *target, const char *reason, ...) __attribute__((format(printf,3,4))); /* 3=format 4=params */
+EXPORTFUNC int irc_svstime( const Bot *botptr, const Client *target, const time_t ts );
 
 /*  CTCP functions to correctly format CTCP requests and replies
  */
-EXPORTFUNC int irc_ctcp_version_req( Bot *botptr, Client *target );
-EXPORTFUNC int irc_ctcp_version_rpl( Bot *botptr, Client *target, const char *version );
-EXPORTFUNC int irc_ctcp_ping_req( Bot *botptr, Client *target );
+EXPORTFUNC int irc_ctcp_version_req( const Bot *botptr, const Client *target );
+EXPORTFUNC int irc_ctcp_version_rpl( const Bot *botptr, const Client *target, const char *version );
+EXPORTFUNC int irc_ctcp_ping_req( const Bot *botptr, const Client *target );
 
-EXPORTFUNC int irc_ctcp_finger_req( Bot *botptr, Client *target );
+EXPORTFUNC int irc_ctcp_finger_req( const Bot *botptr, const Client *target );
 
-EXPORTFUNC int irc_ctcp_action_req( Bot *botptr, Client *target, const char *action );
-EXPORTFUNC int irc_ctcp_action_req_channel( Bot* botptr, Channel* channel, const char *action );
+EXPORTFUNC int irc_ctcp_action_req( const Bot *botptr, const Client *target, const char *action );
+EXPORTFUNC int irc_ctcp_action_req_channel( const Bot* botptr, const Channel* channel, const char *action );
 
-EXPORTFUNC int irc_ctcp_time_req( Bot* botptr, Client* target );
+EXPORTFUNC int irc_ctcp_time_req( const Bot* botptr, const Client* target );
 
 /* bots.c */
 EXPORTFUNC int GenerateBotNick( char *nickbuf, int stublen, int alphacount, int numcount);
@@ -1318,12 +1315,12 @@
 EXPORTFUNC Client *GetRandomChannelMember(int uge, Channel *c);
 EXPORTFUNC char *GetRandomChannelKey( int length );
 
-#define IsChanOp( chan, nick ) test_cumode(chan, nick, CUMODE_CHANOP)
-#define IsChanHalfOp( chan, nick ) test_cumode(chan, nick, CUMODE_HALFOP)
-#define IsChanVoice( chan, nick ) test_cumode(chan, nick, CUMODE_VOICE)
-#define IsChanOwner( chan, nick ) test_cumode(chan, nick, CUMODE_CHANOWNER)
-#define IsChanProt( chan, nick ) test_cumode(chan, nick, CUMODE_CHANPROT)
-#define IsChanAdmin( chan, nick ) test_cumode(chan, nick, CUMODE_CHANADMIN)
+#define IsChanOp( chan, nick ) test_cumode( chan, nick, CUMODE_CHANOP )
+#define IsChanHalfOp( chan, nick ) test_cumode( chan, nick, CUMODE_HALFOP )
+#define IsChanVoice( chan, nick ) test_cumode( chan, nick, CUMODE_VOICE )
+#define IsChanOwner( chan, nick ) test_cumode( chan, nick, CUMODE_CHANOWNER )
+#define IsChanProt( chan, nick ) test_cumode( chan, nick, CUMODE_CHANPROT )
+#define IsChanAdmin( chan, nick ) test_cumode( chan, nick, CUMODE_CHANADMIN )
 
 EXPORTVAR unsigned char UmodeChRegNick;
 
@@ -1348,22 +1345,22 @@
 EXPORTFUNC int new_transfer( char *url, char *params, NS_TRANSFER savetofileormemory, char *filename, void *data, transfer_callback *callback );
 
 /* Is the client excluded */
-#define IsExcluded(x) ((x) && ((x)->flags & NS_FLAG_EXCLUDED))
+#define IsExcluded( x ) ( ( x ) && ( ( x )->flags & NS_FLAG_EXCLUDED ) )
 
 /* Is the client a NeoStats one? */
-#define IsMe(x) ((x) && ((x)->flags & CLIENT_FLAG_ME))
+#define IsMe( x ) ( ( x ) && ( ( x )->flags & CLIENT_FLAG_ME ) )
 
 /* Is the client synched? */
-#define IsSynched(x) ((x) && ((x)->flags & CLIENT_FLAG_SYNCHED))
+#define IsSynched( x ) ( ( x ) && ( ( x )->flags & CLIENT_FLAG_SYNCHED ) )
 
 /* Mark server as synched */
-#define SynchServer(x) (((x)->flags |= CLIENT_FLAG_SYNCHED))
+#define SynchServer( x ) ( ( ( x )->flags |= CLIENT_FLAG_SYNCHED ) )
 
 /* Has NeoStats issued a SETHOST for this user? */
-#define IsUserSetHosted(x)  ((x) && ((x)->flags & CLIENT_FLAG_SETHOST))
+#define IsUserSetHosted( x )  ( ( x ) && ( ( x )->flags & CLIENT_FLAG_SETHOST ) )
 
 /* Is the client marked away? */
-#define IsAway(x) ( ( x ) && ( x->user->is_away ) )
+#define IsAway( x ) ( ( x ) && ( x->user->is_away ) )
 
 EXPORTFUNC int ValidateNick( char *nick );
 EXPORTFUNC int ValidateUser( char *username );
@@ -1489,12 +1486,12 @@
 EXPORTFUNC void DisableEvent( Event event );
 
 /* String functions */
-/* [v]s[n]printf replacements */
+/* vs[n]printf replacements */
 EXPORTFUNC int ircvsprintf( char *buf, const char *fmt, va_list args );
 EXPORTFUNC int ircvsnprintf( char *buf, size_t size, const char *fmt, va_list args );
+/* s[n]printf replacements */
 EXPORTFUNC int ircsprintf( char *buf, const char *fmt, ...) __attribute__((format(printf,2,3)) ); /* 2=format 3=params */
 EXPORTFUNC int ircsnprintf( char *buf, size_t size, const char *fmt, ...) __attribute__((format(printf,3,4)) ); /* 3=format 4=params */
-
 /* str[n]casecmp replacements */
 EXPORTFUNC int ircstrcasecmp( const char *s1, const char *s2 );
 EXPORTFUNC int ircstrncasecmp( const char *s1, const char *s2, size_t size );
@@ -1572,52 +1569,60 @@
 #endif /* WIN32 */
 
 /* 
- * Module Interface 
+ * Module interface 
  */
-/* Module Basic Interface */
+/* Module basic interface */
 MODULEVAR extern ModuleInfo module_info;   
 MODULEFUNC int ModInit( void );
 MODULEFUNC int ModSynch( void );
 MODULEFUNC int ModFini( void );
-/* Module Event Interface */
+/* Module event interface */
 MODULEVAR extern ModuleEvent module_events[];  
-/* Module Auth Interface */
+/* Module auth interface */
 MODULEFUNC int ModAuthUser( Client *u );
-/* Module Exclude Interface */
+/* Module exclude interface */
 EXPORTFUNC int ModIsServerExcluded( Client *s );
 EXPORTFUNC int ModIsUserExcluded( Client *u );
 EXPORTFUNC int ModIsChannelExcluded( Channel *c );
 
-/* Module Data Pointer Interface */
-/* Module Data Pointer Interface Channel */
+/* Module data pointer interface */
+/* Module data pointer interface channel */
 EXPORTFUNC void *AllocChannelModPtr( Channel *c, int size );
 EXPORTFUNC void FreeChannelModPtr( Channel *c );
 EXPORTFUNC void *GetChannelModPtr( Channel *c );
-/* Module Data Pointer Interface User */
+/* Module data pointer interface user */
 EXPORTFUNC void *AllocUserModPtr( Client *u, int size );
 EXPORTFUNC void FreeUserModPtr( Client *u );
 EXPORTFUNC void *GetUserModPtr( Client *u );
-/* Module Data Pointer Interface Server */
+/* Module data pointer interface server */
 EXPORTFUNC void *AllocServerModPtr( Client *s, int size );
 EXPORTFUNC void FreeServerModPtr( Client *s );
 EXPORTFUNC void *GetServerModPtr( Client *s );
-/* Module Data Value Interface */
-/* Module Data Value Interface Channel */
+/* Module data pointer interface bot */
+EXPORTFUNC void *AllocBotModPtr( Bot *pBot, int size );
+EXPORTFUNC void FreeBotModPtr( Bot *pBot );
+EXPORTFUNC void* GetBotModPtr( Bot *pBot );
+/* Module data value interface */
+/* Module data value interface channel */
 EXPORTFUNC void ClearChannelModValue( Channel *c );
 EXPORTFUNC void SetChannelModValue( Channel *c, void *data );
 EXPORTFUNC void *GetChannelModValue( Channel *c );
-/* Module Data Value Interface User */
+/* Module data value interface user */
 EXPORTFUNC void ClearUserModValue( Client *u );
 EXPORTFUNC void SetUserModValue( Client *u, void *data );
 EXPORTFUNC void *GetUserModValue( Client *u );
-/* Module Data Value Interface Server */
+/* Module data value interface server */
 EXPORTFUNC void ClearServerModValue( Client *s );
 EXPORTFUNC void SetServerModValue( Client *s, void *data );
 EXPORTFUNC void *GetServerModValue( Client *s );
-/* Module Data Value Interface Bot */
-#define ClearBotModValue( b ) b->moddata = 0
-#define SetBotModValue( b, data ) b->moddata = data
-#define GetBotModValue( b ) b->moddata
+/* Module data value interface bot */
+EXPORTFUNC void ClearBotModValue( Bot *pBot );
+EXPORTFUNC void SetBotModValue( Bot *pBot, void *data );
+EXPORTFUNC void *GetBotModValue( Bot *pBot );
+
+//#define ClearBotModValue( b ) b->moddata = 0
+//#define SetBotModValue( b, data ) b->moddata = data
+//#define GetBotModValue( b ) b->moddata
 
 /* MQ Server update sending functions */
 typedef enum MQ_MSG_TYPE {

Modified: trunk/include/services.h
==============================================================================
--- trunk/include/services.h	(original)
+++ trunk/include/services.h	Sun Jul 17 05:33:50 2005
@@ -44,9 +44,9 @@
 	unsigned int foreground:1;
 	unsigned int want_privmsg:1;
 	unsigned int onlyopers:1;
-	unsigned int setservertimes;
-	unsigned int splittime;
-	unsigned int msgsampletime;
+	time_t setservertimes;
+	time_t splittime;
+	time_t msgsampletime;
 	unsigned int msgthreshold;
 	unsigned int versionscan;
 	unsigned int r_time;
@@ -54,7 +54,7 @@
 	unsigned int debug;
 	unsigned int debugtochan;
 	char debugchan[MAXCHANLEN];
-	unsigned int pingtime;
+	time_t pingtime;
 	unsigned int joinserviceschan;
 	neoroot rootuser;
 	char debugmodule[MAX_MOD_NAME];

Modified: trunk/modules/protocol/ircup10base.c
==============================================================================
--- trunk/modules/protocol/ircup10base.c	(original)
+++ trunk/modules/protocol/ircup10base.c	Sun Jul 17 05:33:50 2005
@@ -209,7 +209,7 @@
 
 void send_end_of_burst_ack( void )
 {
-	if( !is_synched ) {
+	if( !IsNeoStatsSynched() ) {
 		do_synch_neostats();
 		send_end_of_burst();
 	}

Modified: trunk/modules/statserv/htmlstats.c
==============================================================================
--- trunk/modules/statserv/htmlstats.c	(original)
+++ trunk/modules/statserv/htmlstats.c	Sun Jul 17 05:33:50 2005
@@ -139,7 +139,7 @@
 	os_fprintf( opf, "<tr><td>Server Kills</td><td colspan = 2>%d</td></tr>",
 		ss->serverkills.alltime.runningtotal );
 	os_fprintf( opf, "<tr><td>Highest Ping</td><td>%d</td><td>at %s</td></tr>",
-		( int )ss->highest_ping, sftime( ss->t_highest_ping ) );
+		( int )ss->highest_ping, sftime( ss->ts_highest_ping ) );
 	if( ss->s )
 		os_fprintf( opf, "<tr><td>Current Ping</td><td colspan = 2>%d</td></tr>",
 			ss->s->server->ping );

Modified: trunk/modules/statserv/server.c
==============================================================================
--- trunk/modules/statserv/server.c	(original)
+++ trunk/modules/statserv/server.c	Sun Jul 17 05:33:50 2005
@@ -173,11 +173,11 @@
 		return;
 	if (s->server->ping > ss->highest_ping) {
 		ss->highest_ping = s->server->ping;
-		ss->t_highest_ping = me.now;
+		ss->ts_highest_ping = me.now;
 	}
 	if (s->server->ping < ss->lowest_ping) {
 		ss->lowest_ping = s->server->ping;
-		ss->t_lowest_ping = me.now;
+		ss->ts_lowest_ping = me.now;
 	}
 	/* ok, updated the statistics, now lets see if this server is "lagged out" */
 	if (s->server->ping > StatServ.lagtime) {
@@ -382,9 +382,9 @@
 	irc_prefmsg (ss_bot, cmdparams->source, "IRCop kills: %d", ss->operkills.alltime.runningtotal);
 	irc_prefmsg (ss_bot, cmdparams->source, "Server kills: %d", ss->serverkills.alltime.runningtotal);
 	irc_prefmsg (ss_bot, cmdparams->source, "Lowest ping: %-3d at %s",
-		(int)ss->lowest_ping, sftime(ss->t_lowest_ping));
+		(int)ss->lowest_ping, sftime(ss->ts_lowest_ping));
 	irc_prefmsg (ss_bot, cmdparams->source, "Higest ping: %-3d at %s",
-		(int)ss->highest_ping, sftime(ss->t_highest_ping));
+		(int)ss->highest_ping, sftime(ss->ts_highest_ping));
 	if (s) {
 		irc_prefmsg (ss_bot, cmdparams->source, "Current Ping: %-3d", s->server->ping);
 	}

Modified: trunk/modules/statserv/server.h
==============================================================================
--- trunk/modules/statserv/server.h	(original)
+++ trunk/modules/statserv/server.h	Sun Jul 17 05:33:50 2005
@@ -34,10 +34,10 @@
 	statistic operkills;
 	statistic serverkills;
 	statistic splits;
-	long lowest_ping;
-	time_t t_lowest_ping;
-	long highest_ping;
-	time_t t_highest_ping;
+	time_t lowest_ping;
+	time_t ts_lowest_ping;
+	time_t highest_ping;
+	time_t ts_highest_ping;
 }serverstat;
 
 extern hash_t *serverstathash;

Modified: trunk/modules/statserv/stats.c
==============================================================================
--- trunk/modules/statserv/stats.c	(original)
+++ trunk/modules/statserv/stats.c	Sun Jul 17 05:33:50 2005
@@ -181,7 +181,7 @@
 	static time_t lasttime;
 	static int count;
 
-	if (!i_am_synched) {
+	if (!IsModuleSynched()) {
 		return -1;
 	}
 	if ((me.now - lasttime) < StatServ.msginterval ) {

Modified: trunk/modules/textserv/main.c
==============================================================================
--- trunk/modules/textserv/main.c	(original)
+++ trunk/modules/textserv/main.c	Sun Jul 17 05:33:50 2005
@@ -929,10 +929,7 @@
 static int ts_cmd_add_chan( CmdParams *cmdparams )
 {
 	dbbot *db;
-	int i;
 	char *channame;
-	hnode_t *hn;
-	hscan_t hs;
 	botchanentry *bce;
 
 	SET_SEGV_LOCATION();
@@ -980,8 +977,6 @@
 	dbbot *db;
 	char *channame, *botchan;
 	hnode_t *hn;
-	hscan_t hs;
-	botchanentry *bce;
 
 	SET_SEGV_LOCATION();
 	db = (dbbot *) GetBotModValue( cmdparams->bot );

Modified: trunk/src/bots.c
==============================================================================
--- trunk/src/bots.c	(original)
+++ trunk/src/bots.c	Sun Jul 17 05:33:50 2005
@@ -762,3 +762,46 @@
 	}
 	ns_free( cmdparams );
 }
+
+void *AllocBotModPtr( Bot *pBot, int size )
+{
+	void *ptr;
+	ptr = ns_calloc( size );
+	pBot->moddata = ptr;
+	return ptr;
+}
+
+void FreeBotModPtr( Bot *pBot )
+{
+	ns_free( pBot->moddata );
+}
+
+void* GetBotModPtr( Bot *pBot )
+{
+	return pBot->moddata;
+}
+
+void ClearBotModValue( Bot *pBot )
+{
+	if( pBot )
+	{
+		pBot->moddata = NULL;
+	}
+}
+
+void SetBotModValue( Bot *pBot, void *data )
+{
+	if( pBot )
+	{
+		pBot->moddata = data;
+	}
+}
+
+void *GetBotModValue( Bot *pBot )
+{
+	if( pBot )
+	{
+		return pBot->moddata;
+	}
+	return NULL;	
+}

Modified: trunk/src/channels.c
==============================================================================
--- trunk/src/channels.c	(original)
+++ trunk/src/channels.c	Sun Jul 17 05:33:50 2005
@@ -48,7 +48,8 @@
 /* temp buffer to save kick info for IRCu */
 static char savekicker[MAXHOST];
 static char savekickreason[BUFSIZE];
-
+/** @brief Module data flags */
+static unsigned int fchannelmoddata = 0;
 static unsigned int moddatacnt[NUM_MODULES];
 
 int comparechanmember( const void *key1, const void *key2 )
@@ -817,17 +818,19 @@
 	Channel *c;
 
 	SET_SEGV_LOCATION();
-	if( moddatacnt[index] > 0 ) {
-		nlog( LOG_WARNING, "Cleaning up channels after dirty module!" );
-		hash_scan_begin( &scan, channelhash );
-		while( ( node = hash_scan_next( &scan ) ) != NULL ) {
-			c = hnode_get( node );
-			if( c->modptr[index] ) {
-				ns_free( c->modptr[index] );		
+	if (fchannelmoddata & (1 << index)) {
+		if( moddatacnt[index] > 0 ) {
+			nlog( LOG_WARNING, "Cleaning up channels after dirty module!" );
+			hash_scan_begin( &scan, channelhash );
+			while( ( node = hash_scan_next( &scan ) ) != NULL ) {
+				c = hnode_get( node );
+				if( c->modptr[index] ) {
+					ns_free( c->modptr[index] );		
+				}
+				c->modvalue[index] = NULL;
 			}
-			c->modvalue[index] = NULL;
 		}
+		fchannelmoddata &= ~( 1 << index );
+		moddatacnt[index] = 0;
 	}
-	fchannelmoddata &= ~( 1 << index );
-	moddatacnt[index] = 0;
 }

Modified: trunk/src/commands.c
==============================================================================
--- trunk/src/commands.c	(original)
+++ trunk/src/commands.c	Sun Jul 17 05:33:50 2005
@@ -118,7 +118,7 @@
 	static char buf[BUFSIZE];
 	va_list ap;
 
-	if( !is_synched || !botptr || !nsconfig.cmdreport )
+	if( !IsNeoStatsSynched() || !botptr || !nsconfig.cmdreport )
 		return;
 	va_start( ap, fmt );
 	ircvsnprintf( buf, BUFSIZE, fmt, ap );

Modified: trunk/src/conf.c
==============================================================================
--- trunk/src/conf.c	(original)
+++ trunk/src/conf.c	Sun Jul 17 05:33:50 2005
@@ -147,7 +147,7 @@
 	/* Read in the Config File */
 	printf ("Reading the Config File. Please wait.....\n");
 	cfg = cfg_init (fileconfig, CFGF_NOCASE);
-	for (i = 0; i < arraylen (arg_validate); i++) {
+	for (i = 0; i < ARRAYLEN (arg_validate); i++) {
 		cfg_set_validate_func (cfg, arg_validate[i].name, arg_validate[i].cb);
 	}
 	if ((ret = cfg_parse (cfg, CONFIG_NAME)) != 0) {
@@ -377,7 +377,7 @@
 		return CFG_PARSE_ERROR;
 	}
 	/* if we get here, the socket is ok*/
-	os_close( s );
+	os_sock_close( s );
 	me.dobind = 1;
 	return CFG_SUCCESS;
 }

Modified: trunk/src/ctcp.c
==============================================================================
--- trunk/src/ctcp.c	(original)
+++ trunk/src/ctcp.c	Sun Jul 17 05:33:50 2005
@@ -145,7 +145,7 @@
 	return NS_SUCCESS;
 }
 
-int irc_ctcp_version_req( Bot* botptr, Client* target ) 
+int irc_ctcp_version_req( const Bot* botptr, const Client* target ) 
 {
 	dlog( DEBUG5, "TX: CTCP VERSION request from %s to %s", botptr->name, target->name );
 	irc_privmsg( botptr, target, "\1VERSION\1" );
@@ -166,7 +166,7 @@
 	return NS_SUCCESS;
 }
 
-int irc_ctcp_finger_req( Bot* botptr, Client* target ) 
+int irc_ctcp_finger_req( const Bot* botptr, const Client* target ) 
 {
 	dlog( DEBUG5, "TX: CTCP FINGER request from %s to %s", botptr->name, target->name );
 	irc_privmsg( botptr, target, "\1FINGER\1" );
@@ -180,14 +180,14 @@
 	return NS_SUCCESS;
 }
 
-int irc_ctcp_action_req( Bot* botptr, Client* target, const char *action ) 
+int irc_ctcp_action_req( const Bot* botptr, const Client* target, const char *action ) 
 {
 	dlog( DEBUG5, "TX: Sending CTCP ACTION request from %s to %s", botptr->name, target->name );
 	irc_privmsg( botptr, target, "\1ACTION %s\1", action );
 	return NS_SUCCESS;
 }
 
-int irc_ctcp_action_req_channel( Bot* botptr, Channel* channel, const char *action ) 
+int irc_ctcp_action_req_channel( const Bot* botptr, const Channel* channel, const char *action ) 
 {
 	dlog( DEBUG5, "TX: Sending CTCP ACTION request from %s to %s", botptr->name, channel->name );
 	irc_chanprivmsg( botptr, channel->name, "\1ACTION %s\1", action );
@@ -222,7 +222,7 @@
 	return NS_SUCCESS;
 }
 
-int irc_ctcp_time_req( Bot* botptr, Client* target ) 
+int irc_ctcp_time_req( const Bot* botptr, const Client* target ) 
 {
 	dlog( DEBUG5, "TX: CTCP TIME request from %s to %s", botptr->name, target->name );
 	irc_privmsg( botptr, target, "\1TIME\1" );
@@ -243,7 +243,7 @@
 	return NS_SUCCESS;
 }
 
-int irc_ctcp_ping_req( Bot* botptr, Client* target ) 
+int irc_ctcp_ping_req( const Bot* botptr, const Client* target ) 
 {
 	dlog( DEBUG5, "TX: CTCP PING request from %s to %s", botptr->name, target->name );
 	irc_privmsg( botptr, target, "\1PING\1" );

Modified: trunk/src/dns.c
==============================================================================
--- trunk/src/dns.c	(original)
+++ trunk/src/dns.c	Sun Jul 17 05:33:50 2005
@@ -25,16 +25,17 @@
 /* this file does the dns checking for adns. it provides a callback mechinism for dns lookups
 ** so that DNS lookups will not block. It uses the adns libary (installed in the adns directory
 */
+
 #include "neostats.h"
 #include "dns.h"
 #include "services.h"
 #include "event.h"
 #ifdef HAVE_POLL_H
 #include <poll.h>
-#endif
+#endif /* HAVE_POLL_H */
 #ifdef HAVE_SYS_TIME_H
 #include <sys/time.h>
-#endif
+#endif /* HAVE_SYS_TIME_H */
 
 #define DNS_QUEUE_SIZE  300	/* number on concurrent DNS lookups */
 #define DNS_DATA_SIZE	255
@@ -54,11 +55,11 @@
 struct event *dnstimeout;
 
 struct DNSStats {
-	int totalq;
-	int maxqueued;
-	int totalqueued;
-	int success;
-	int failure;
+	unsigned int totalq;
+	unsigned int maxqueued;
+	unsigned int totalqueued;
+	unsigned int success;
+	unsigned int failure;
 } DNSStats;
 
 /** @brief List of DNS queryies

Modified: trunk/src/ircsend.c
==============================================================================
--- trunk/src/ircsend.c	(original)
+++ trunk/src/ircsend.c	Sun Jul 17 05:33:50 2005
@@ -699,7 +699,7 @@
 {
 	va_list ap;
 
-	if( !is_synched )
+	if( !IsNeoStatsSynched() )
 		return NS_SUCCESS;
 	va_start( ap, fmt );
 	ircvsnprintf( ircd_buf, BUFSIZE, fmt, ap );
@@ -818,7 +818,7 @@
 	va_start( ap, fmt );
 	ircvsnprintf( ircd_buf, BUFSIZE, fmt, ap );
 	va_end( ap );
-	if( is_synched ) {
+	if( IsNeoStatsSynched() ) {
 		if( !irc_send_globops ) {
 			unsupported_cmd( "GLOBOPS" );
 			nlog( LOG_NOTICE, "Dropping unhandled globops: %s", ircd_buf );
@@ -1190,7 +1190,7 @@
  *  @return NS_SUCCESS if succeeds, NS_FAILURE if not 
  */
 
-int irc_svstime( const Bot *botptr, Client *target, const time_t ts )
+int irc_svstime( const Bot *botptr, const Client *target, const time_t ts )
 {
 	if( !irc_send_svstime ) {
 		unsupported_cmd( "SVSTIME" );
@@ -1206,7 +1206,7 @@
  *  @return NS_SUCCESS if succeeds, NS_FAILURE if not 
  */
 
-int irc_svskill( const Bot *botptr, Client *target, const char *reason, ... )
+int irc_svskill( const Bot *botptr, const Client *target, const char *reason, ... )
 {
 	va_list ap;
 
@@ -1230,7 +1230,7 @@
  *  @return NS_SUCCESS if succeeds, NS_FAILURE if not 
  */
 
-int irc_svsmode( const Bot *botptr, Client *target, const char *modes )
+int irc_svsmode( const Bot *botptr, const Client *target, const char *modes )
 {
 	if( !irc_send_svsmode ) {
 		unsupported_cmd( "SVSMODE" );
@@ -1271,7 +1271,7 @@
  *  @return NS_SUCCESS if succeeds, NS_FAILURE if not 
  */
 
-int irc_svsjoin( const Bot *botptr, Client *target, const char *chan )
+int irc_svsjoin( const Bot *botptr, const Client *target, const char *chan )
 {
 	if( !irc_send_svsjoin ) {
 		unsupported_cmd( "SVSJOIN" );
@@ -1286,7 +1286,7 @@
  *  @return NS_SUCCESS if succeeds, NS_FAILURE if not 
  */
 
-int irc_svspart( const Bot *botptr, Client *target, const char *chan )
+int irc_svspart( const Bot *botptr, const Client *target, const char *chan )
 {
 	if( !irc_send_svspart ) {
 		unsupported_cmd( "SVSPART" );
@@ -1316,7 +1316,7 @@
  *  @return NS_SUCCESS if succeeds, NS_FAILURE if not 
  */
 
-int irc_svsnick( const Bot *botptr, Client *target, const char *newnick )
+int irc_svsnick( const Bot *botptr, const Client *target, const char *newnick )
 {
 	if( !irc_send_svsnick ) {
 		unsupported_cmd( "SVSNICK" );

Modified: trunk/src/misc.c
==============================================================================
--- trunk/src/misc.c	(original)
+++ trunk/src/misc.c	Sun Jul 17 05:33:50 2005
@@ -38,13 +38,13 @@
  *  @returns result
  */
 
-unsigned hrand( unsigned upperbound, unsigned lowerbound ) 
+unsigned int hrand( const unsigned int upperbound, const unsigned int lowerbound ) 
 {
 	if( ( upperbound < 1 ) ) {
 		nlog( LOG_WARNING, "hrand() invalid value for upperbound" );
 		return -1;
 	}
-	return( ( unsigned )( rand()%( ( int )( upperbound-lowerbound+1 ) )-( ( int )( lowerbound-1 ) ) ) );
+	return( ( unsigned )( rand()%( ( int )( upperbound - lowerbound + 1 ) )-( ( int )( lowerbound - 1 ) ) ) );
 }
 
 /** @brief make_safe_filename
@@ -108,7 +108,7 @@
  *  @returns pointer to the new string
  */
 
-char* sstrdup( const char *s )
+char *sstrdup( const char *s )
 {
 	char *t = ns_malloc( strlen( s )+1 );
 	strlcpy( t, s, strlen( s )+1 );
@@ -128,7 +128,7 @@
  *  @returns pointer to the new string
  */
 
-char* strlwr( char *s )
+char *strlwr( char *s )
 {
 	char *t;
 	t = s;
@@ -150,7 +150,7 @@
  *  @returns count of arguments created from split
  */
 
-EXPORTFUNC int ircsplitbuf( char *buf, char ***argv, int colon_special )
+int ircsplitbuf( char *buf, char ***argv, int colon_special )
 {
 	int argvsize = 8;
 	int argc;
@@ -250,7 +250,7 @@
  *  @returns buffer containing combined arguments
  */
 
-char* joinbuf( char **av, int ac, int from )
+char *joinbuf( char **av, int ac, int from )
 {
 	int i;
 	char *buf;
@@ -372,7 +372,7 @@
  *  @returns 
  */
 
-char* sctime( time_t stuff )
+char *sctime( time_t stuff )
 {
 	char *s, *c;
 
@@ -394,7 +394,7 @@
 
 static char fmtime[TIMEBUFSIZE];
 
-char* sftime( time_t stuff )
+char *sftime( time_t stuff )
 {
 	struct tm *ltm = localtime( &stuff );
 
@@ -411,15 +411,15 @@
  *  @return NS_SUCCESS if succeeds, NS_FAILURE if not 
  */
 
-int ValidateNick( char* nick )
+int ValidateNick( char *nick )
 {
-	char* ptr;
+	char *ptr;
 
 	ptr = nick;
-	while( *ptr ) {
-		if( !IsNickChar( *ptr ) ) {
+	while( *ptr )
+	{
+		if( !IsNickChar( *ptr ) )
 			return NS_FAILURE;
-		}
 		ptr++;
 	}
 	return NS_SUCCESS;
@@ -434,15 +434,15 @@
  *  @return NS_SUCCESS if succeeds, NS_FAILURE if not 
  */
 
-int ValidateUser( char* username )
+int ValidateUser( char *username )
 {
-	char* ptr;
+	char *ptr;
 
 	ptr = username;
-	while( *ptr ) {
-		if( !IsUserChar( *ptr ) ) {
+	while( *ptr )
+	{
+		if( !IsUserChar( *ptr ) )
 			return NS_FAILURE;
-		}
 		ptr++;
 	}
 	return NS_SUCCESS;
@@ -457,15 +457,15 @@
  *  @return NS_SUCCESS if succeeds, NS_FAILURE if not 
  */
 
-int ValidateHost( char* hostname )
+int ValidateHost( char *hostname )
 {
-	char* ptr;
+	char *ptr;
 
 	ptr = hostname;
-	while( *ptr ) {
-		if( !IsHostChar( *ptr ) ) {
+	while( *ptr )
+	{
+		if( !IsHostChar( *ptr ) )
 			return NS_FAILURE;
-		}
 		ptr++;
 	}
 	return NS_SUCCESS;
@@ -480,18 +480,20 @@
  *  @return NS_SUCCESS if succeeds, NS_FAILURE if not 
  */
 
-int ValidateURL( char* url )
+int ValidateURL( char *url )
 {
-	char* ptr;
+	char *ptr;
 
-	if( ircstrncasecmp( url, "http://", 7 ) !=0 )
+	/* URL must begin with http:// */
+	if( ircstrncasecmp( url, "http://", 7 ) != 0 )
 		return NS_FAILURE;
+	/* Get pointer to rest of URL to test */
 	ptr = url;
 	ptr += 7;
-	while( *ptr ) {
-		if( !IsURLChar( *ptr ) ) {
+	while( *ptr )
+	{
+		if( !IsURLChar( *ptr ) )
 			return NS_FAILURE;
-		}
 		ptr++;
 	}
 	return NS_SUCCESS;
@@ -506,19 +508,19 @@
  *  @return NS_SUCCESS if succeeds, NS_FAILURE if not 
  */
 
-int ValidateChannel( char* channel_name )
+int ValidateChannel( char *channel_name )
 {
-	char* ptr;
+	char *ptr;
 
 	ptr = channel_name;
-	if( !IsChanPrefix( *ptr ) ) {
+	/* Channel name must start with channel prefix */
+	if( !IsChanPrefix( *ptr ) )
 		return NS_FAILURE;
-	}
 	ptr ++;
-	while( *ptr ) {
-		if( !IsChanChar( *ptr ) ) {
+	while( *ptr )
+	{
+		if( !IsChanChar( *ptr ) )
 			return NS_FAILURE;
-		}
 		ptr++;
 	}
 	return NS_SUCCESS;
@@ -531,19 +533,17 @@
  *  @param channel key to check
  *  
  *  @return NS_SUCCESS if succeeds, NS_FAILURE if not 
- *  
- *  @TODO: establish valid key charset
  */
 
-int ValidateChannelKey( char* key )
+int ValidateChannelKey( char *key )
 {
-	char* ptr;
+	char *ptr;
 
 	ptr = key;
-	while( *ptr ) {
-		if( !IsAlNum( *ptr ) ) {
+	while( *ptr )
+	{
+		if( !IsChanKeyChar( *ptr ) )
 			return NS_FAILURE;
-		}
 		ptr++;
 	}
 	return NS_SUCCESS;

Modified: trunk/src/modules.c
==============================================================================
--- trunk/src/modules.c	(original)
+++ trunk/src/modules.c	Sun Jul 17 05:33:50 2005
@@ -42,18 +42,11 @@
 #include "perlmod.h"
 #endif /* USE_PERL */
 
-/** @brief Module list
- * 
- */
+/** @brief Module list */
 static Module *ModList[NUM_MODULES];
+/** @brief Module run level stack control variables */
 Module* RunModule[10];
 int RunLevel = 0;
-unsigned int fusermoddata = 0;
-unsigned int fservermoddata = 0;
-unsigned int fchannelmoddata = 0;
-Module *load_stdmodule (const char *modfilename, Client * u);
-
-
 /* @brief Module hash list */
 static hash_t *modulehash;
 
@@ -264,41 +257,13 @@
 	nlog (LOG_WARNING, buf);
 }
 
-/** @brief determine the type of module based on extension and then
- * call the relevent procedure to load it
- */
-Module *
-ns_load_module(const char *modfilename, Client * u)
-{ 
-	char path[255];
-	char loadmodname[255];
-	struct stat buf;
-
-	strlcpy (loadmodname, modfilename, 255);
-	strlwr (loadmodname);
-	ircsnprintf (path, 255, "%s/%s%s", MOD_PATH, loadmodname, MOD_STDEXT);
-	if (stat(path, &buf) != -1) {
-		return load_stdmodule(path, u);
-	}
-#ifdef USE_PERL
-	ircsnprintf (path, 255, "%s/%s%s", MOD_PATH, loadmodname, MOD_PERLEXT);
-	if (stat(path, &buf) != -1) {
-		return load_perlmodule(path, u);
-	}
-#endif
-	/* if we get here, ehhh, doesn't exist */
-	load_module_error (u, __("Unable to load module: %s", u), modfilename);
-	return NULL;
-
-}
 /** @brief 
  *
  * @param 
  * 
  * @return
  */
-Module *
-load_stdmodule (const char *modfilename, Client * u)
+Module *load_stdmodule (const char *modfilename, Client * u)
 {
 	int err;
 	void *handle;
@@ -411,7 +376,7 @@
 	SET_SEGV_LOCATION();
 
 	/* Let this module know we are online if we are! */
-	if (is_synched) {
+	if (IsNeoStatsSynched()) {
 		if (SynchModule (mod_ptr) != NS_SUCCESS || mod_ptr->error)
 		{
 			load_module_error (u, __("Unable to load module: %s. See %s.log for further information.", u), mod_ptr->info->name, mod_ptr->info->name);
@@ -429,6 +394,34 @@
 	}
 	return mod_ptr;
 }
+
+/** @brief determine the type of module based on extension and then
+ * call the relevent procedure to load it
+ */
+Module *ns_load_module(const char *modfilename, Client * u)
+{ 
+	char path[255];
+	char loadmodname[255];
+	struct stat buf;
+
+	strlcpy (loadmodname, modfilename, 255);
+	strlwr (loadmodname);
+	ircsnprintf (path, 255, "%s/%s%s", MOD_PATH, loadmodname, MOD_STDEXT);
+	if (stat(path, &buf) != -1) {
+		return load_stdmodule(path, u);
+	}
+#ifdef USE_PERL
+	ircsnprintf (path, 255, "%s/%s%s", MOD_PATH, loadmodname, MOD_PERLEXT);
+	if (stat(path, &buf) != -1) {
+		return load_perlmodule(path, u);
+	}
+#endif
+	/* if we get here, ehhh, doesn't exist */
+	load_module_error (u, __("Unable to load module: %s", u), modfilename);
+	return NULL;
+
+}
+
 /** @brief generate module number and assign it
  *
  * @param mod_ptr module pointer 
@@ -584,15 +577,9 @@
 		ModList[moduleindex] = NULL;
 	}
 	/* Cleanup moddata */
-	if (fusermoddata & (1 << moduleindex)) {
-		CleanupUserModdata (moduleindex);
-	}
-	if (fservermoddata & (1 << moduleindex)) {
-		CleanupServerModdata (moduleindex);
-	}
-	if (fchannelmoddata & (1 << moduleindex)) {
-		CleanupChannelModdata (moduleindex);
-	}
+	CleanupUserModdata (moduleindex);
+	CleanupServerModdata (moduleindex);
+	CleanupChannelModdata (moduleindex);
 	return NS_SUCCESS;
 }
 

Modified: trunk/src/servers.c
==============================================================================
--- trunk/src/servers.c	(original)
+++ trunk/src/servers.c	Sun Jul 17 05:33:50 2005
@@ -35,6 +35,8 @@
 
 config nsconfig;
 static hash_t *serverhash;
+/** @brief Module data flags */
+static unsigned int fservermoddata = 0;
 
 static unsigned int moddatacnt[NUM_MODULES];
 
@@ -241,7 +243,7 @@
 	hscan_t ss;
 	hnode_t *sn;
 
-	if(!is_synched)
+	if(!IsNeoStatsSynched())
 		return;
 	dlog(DEBUG3, "Sending pings...");
 	me.ulag = 0;
@@ -374,17 +376,19 @@
 	Client *s;
 
 	SET_SEGV_LOCATION();
-	hash_scan_begin(&scan, serverhash);
-	if (moddatacnt[index] > 0) {
-		nlog (LOG_WARNING, "Cleaning up servers after dirty module!");
-		while ((node = hash_scan_next(&scan)) != NULL) {
-			s = hnode_get(node);
-			if (s->modptr[index]) {
-				ns_free (s->modptr[index]);		
+	if (fservermoddata & (1 << index)) {
+		hash_scan_begin(&scan, serverhash);
+		if (moddatacnt[index] > 0) {
+			nlog (LOG_WARNING, "Cleaning up servers after dirty module!");
+			while ((node = hash_scan_next(&scan)) != NULL) {
+				s = hnode_get(node);
+				if (s->modptr[index]) {
+					ns_free (s->modptr[index]);		
+				}
+				s->modvalue[index] = NULL;
 			}
-			s->modvalue[index] = NULL;
 		}
+		fservermoddata &= ~(1 << index);	
+		moddatacnt[index] = 0;
 	}
-	fservermoddata &= ~(1 << index);	
-	moddatacnt[index] = 0;
 }

Modified: trunk/src/timer.c
==============================================================================
--- trunk/src/timer.c	(original)
+++ trunk/src/timer.c	Sun Jul 17 05:33:50 2005
@@ -87,7 +87,7 @@
 		/* flush log files */
 		fflush (NULL);
 	}
-	if (is_synched && nsconfig.setservertimes) {
+	if (IsNeoStatsSynched() && nsconfig.setservertimes) {
 		if((me.now - lastservertimesync) > nsconfig.setservertimes) {
 			/* The above check does not need to be exact, but 
 			   setting times ought to be so reset me.now */

Modified: trunk/src/updates.c
==============================================================================
--- trunk/src/updates.c	(original)
+++ trunk/src/updates.c	Sun Jul 17 05:33:50 2005
@@ -31,7 +31,7 @@
 struct updateserver {
 	int ok;
 	struct sockaddr_in sendtomq;
-	int sock;
+	OS_SOCKET sock;
 } mqs;
 
 int InitUpdate(void) 

Modified: trunk/src/users.c
==============================================================================
--- trunk/src/users.c	(original)
+++ trunk/src/users.c	Sun Jul 17 05:33:50 2005
@@ -41,6 +41,8 @@
 #define MAXJOINCHANS	-1
 
 static hash_t *userhash;
+/** @brief Module data flags */
+static unsigned int fusermoddata = 0;
 
 static unsigned int moddatacnt[NUM_MODULES];
 
@@ -127,9 +129,8 @@
 	}
 
 	u->tsconnect = TS ? strtoul (TS, NULL, 10) : me.now;
-	if (time(NULL) - u->tsconnect > nsconfig.splittime) {
+	if( ( time( NULL ) - u->tsconnect ) > nsconfig.splittime )
 		u->flags |= NS_FLAGS_NETJOIN;
-	}
 	strlcpy (u->user->hostname, host, MAXHOST);
 	strlcpy (u->user->vhost, host, MAXHOST);
 	ircsnprintf( u->user->userhostmask, USERHOSTLEN, "%s!%s@%s", nick, user, host );
@@ -160,7 +161,7 @@
 	}
 	ns_free (cmdparams);
 	/* Send CTCP VERSION request if we are configured to do so */
-	if (is_synched && nsconfig.versionscan && !IsExcluded(u) && !IsMe(u)) {
+	if (IsNeoStatsSynched() && nsconfig.versionscan && !IsExcluded(u) && !IsMe(u)) {
 		irc_ctcp_version_req (ns_botptr, u);
 	}
 	return u;
@@ -725,17 +726,19 @@
 	hnode_t *node;
 
 	SET_SEGV_LOCATION();
-	hash_scan_begin (&scan, userhash);
-	if (moddatacnt[index] > 0) {
-		nlog (LOG_WARNING, "Cleaning up users after dirty module!");
-		while ((node = hash_scan_next (&scan)) != NULL) {
-			u = hnode_get (node);
-			if (u->modptr[index]) {
-				ns_free (u->modptr[index]);		
+	if (fusermoddata & (1 << index)) {
+		hash_scan_begin (&scan, userhash);
+		if (moddatacnt[index] > 0) {
+			nlog (LOG_WARNING, "Cleaning up users after dirty module!");
+			while ((node = hash_scan_next (&scan)) != NULL) {
+				u = hnode_get (node);
+				if (u->modptr[index]) {
+					ns_free (u->modptr[index]);		
+				}
+				u->modvalue[index] = NULL;
 			}
-			u->modvalue[index] = NULL;
 		}
+		fusermoddata &= ~(1 << index);
+		moddatacnt[index] = 0;
 	}
-	fusermoddata &= ~(1 << index);
-	moddatacnt[index] = 0;
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.