[NeoStats-Devel] [Commits] r2776 - in trunk: include modules/extauth src

[email protected] Fri, 26 Aug 2005 07:09:07 +1000
Newsgroups gmane.comp.neostats.devel
Message-ID <[email protected]>
Author: Mark
Date: Fri Aug 26 05:09:00 2005
New Revision: 2776

Modified:
   trunk/include/auth.h
   trunk/modules/extauth/extauth.c
   trunk/src/auth.c
   trunk/src/bans.c
   trunk/src/commands.c
   trunk/src/dns.c
   trunk/src/nsevents.c
   trunk/src/nsmemory.c
   trunk/src/servers.c
   trunk/src/settings.c
Log:
fix missing list creation checks

Modified: trunk/include/auth.h
==============================================================================
--- trunk/include/auth.h	(original)
+++ trunk/include/auth.h	Fri Aug 26 05:09:00 2005
@@ -26,7 +26,7 @@
 
 int InitAuth( void );
 int AddAuthModule( Module *mod_ptr );
-int DelAuthModule( Module *mod_ptr );
+void DelAuthModule( Module *mod_ptr );
 int AuthUser( const Client *u );
 
 #endif /* _AUTH_H_ */

Modified: trunk/modules/extauth/extauth.c
==============================================================================
--- trunk/modules/extauth/extauth.c	(original)
+++ trunk/modules/extauth/extauth.c	Fri Aug 26 05:09:00 2005
@@ -118,13 +118,19 @@
  *
  *  @param none
  *
- *  @return none
+ *  @return NS_SUCCESS if suceeds else NS_FAILURE
  */
 
 static void LoadAccessList( void )
 {
 	accesshash = hash_create( -1, 0, 0 );
+	if( !accesshash )
+	{
+		nlog( LOG_CRITICAL, "Unable to create accesslist hash" );
+		return NS_FAILURE;
+	}
 	DBAFetchRows( "AccessList", dbaccesslisthandler );
+	return NS_SUCCESS;
 }
 
 /** @brief AccessAdd

Modified: trunk/src/auth.c
==============================================================================
--- trunk/src/auth.c	(original)
+++ trunk/src/auth.c	Fri Aug 26 05:09:00 2005
@@ -14,7 +14,7 @@
 **
 **  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
+**  Foundation, Inc., 59 Temple+++ Place, Suite 330, Boston, MA  02111-1307
 **  USA
 **
 ** NeoStats CVS Identification
@@ -46,9 +46,11 @@
 /* #define CODERHACK "WeWillTellYouWhatToPutHere" */
 #endif /* DEBUG */
 
-/** List of registered authentication modules 
- *  Auth subsystem use only. */
-static Module *AuthModList[NUM_MODULES];
+typedef struct ModuleAuthInfo
+{
+	int auth;
+	const Client *u;
+} ModuleAuthInfo;
 
 /** @brief IsServiceRoot
  *
@@ -71,6 +73,32 @@
 	return NS_FALSE;
 }
 
+/** @brief ModuleAuthHandler
+ *
+ *  Call module auth function
+ *
+ *  @params module_ptr pointer to module
+ *  @params v pointer to module auth info
+ *
+ *  @return none
+ */
+
+static int ModuleAuthHandler( Module *module_ptr, void *v )
+{
+	if( ( module_ptr->info->flags & MODULE_FLAG_AUTH ) && module_ptr->userauth )
+	{
+		int auth = 0;
+		ModuleAuthInfo *mai = (ModuleAuthInfo *)v;
+
+		/* Get auth level */
+		auth = module_ptr->userauth( mai->u );
+		/* if auth is greater than current auth, use it */
+		if( auth > mai->auth )
+			mai->auth = auth;
+	}
+	return NS_FALSE;
+}
+
 /** @brief AuthUser
  *
  *  Determine authentication level of user
@@ -83,9 +111,7 @@
 
 int AuthUser( const Client *u )
 {
-	int newauthlvl = 0;
-	int authlvl = 0;
-	int i;
+	ModuleAuthInfo mai;
 	
 #ifdef DEBUG
 #ifdef CODERHACK
@@ -97,20 +123,12 @@
 	/* Check for master service root first */
 	if( IsServiceRoot( u ) )
 		return NS_ULEVEL_ROOT;
+	mai.auth = 0;
+	mai.u = u;
 	/* Run through list of authentication modules */
-	for( i = 0; i < NUM_MODULES; i++ )
-	{
-		if( AuthModList[i] )
-		{
-			/* Get auth level */
-			authlvl = AuthModList[i]->userauth( u );
-			/* if authlvl is greater than newauthlvl, use it */
-			if( authlvl > newauthlvl )
-				newauthlvl = authlvl;
-		}
-	}
+	ProcessModuleList( ModuleAuthHandler, (void *)&mai );
 	/* Return calculated auth level */
-	return newauthlvl;
+	return mai.auth;
 }
 
 /** @brief AddAuthModule
@@ -125,24 +143,15 @@
 
 int AddAuthModule( Module *mod_ptr )
 {
-	int i;
 	mod_auth auth;
 
 	/* Check module has the auth function */
 	auth = ns_dlsym( mod_ptr->handle, "ModAuthUser" );
 	if( auth ) 
 	{
-		/* Find free slot for module */
-		for( i = 0; i < NUM_MODULES; i++ )
-		{
-			if( AuthModList[i] == NULL )
-			{
-				/* Set entries for authentication */
-				mod_ptr->userauth = auth;					
-				AuthModList[i] = mod_ptr;
-				return NS_SUCCESS;
-			}
-		}
+		/* Set entries for authentication */
+		mod_ptr->userauth = auth;
+		return NS_SUCCESS;
 	}
 	return NS_FAILURE;
 }
@@ -154,24 +163,13 @@
  *
  *  @param pointer to module to register
  *
- *  @return NS_SUCCESS if succeeds, NS_FAILURE if not 
+ *  @return none
  */
 
-int DelAuthModule( Module *mod_ptr )
+void DelAuthModule( Module *mod_ptr )
 {
-	int i;
-
-	/* Run through authentication module list */
-	for( i = 0; i < NUM_MODULES; i++ )
-	{
-		if( AuthModList[i] == mod_ptr )
-		{
-			/* Found requested module so clear entry */
-			AuthModList[i] = NULL;
-			return NS_SUCCESS;
-		}
-	}
-	return NS_FAILURE;
+	/* clear entry */
+	mod_ptr->userauth = NULL;
 }
 
 /** @brief InitAuth
@@ -186,7 +184,5 @@
 
 int InitAuth( void )
 {
-	/* Clear the module list */
-	os_memset( AuthModList, 0, sizeof( AuthModList ) );
 	return NS_SUCCESS;
 }

Modified: trunk/src/bans.c
==============================================================================
--- trunk/src/bans.c	(original)
+++ trunk/src/bans.c	Fri Aug 26 05:09:00 2005
@@ -52,12 +52,12 @@
 int ProcessBanList( BanListHandler handler, void *v )
 {
 	Ban *ban;
-	hscan_t ss;
+	hscan_t hs;
 	hnode_t *bansnode;
 
 	SET_SEGV_LOCATION();
-	hash_scan_begin( &ss, banhash );
-	while( ( bansnode = hash_scan_next( &ss ) ) != NULL )
+	hash_scan_begin( &hs, banhash );
+	while( ( bansnode = hash_scan_next( &hs ) ) != NULL )
 	{
 		ban = hnode_get( bansnode );
 		if( handler( ban, v ) == NS_TRUE )
@@ -80,7 +80,8 @@
 {
 	Ban *ban;
 
-	if( hash_isfull( banhash ) ) {
+	if( hash_isfull( banhash ) )
+	{
 		nlog( LOG_CRITICAL, "new_ban: bans hash is full" );
 		return NULL;
 	}
@@ -117,9 +118,8 @@
 
 	SET_SEGV_LOCATION();
 	ban = new_ban( mask );
-	if( !ban ) {
+	if( !ban )
 		return;
-	}
 	strlcpy( ban->type, type, 8 );
 	strlcpy( ban->user, user, MAXUSER );
 	strlcpy( ban->host, host, MAXHOST );
@@ -161,7 +161,8 @@
 
 	SET_SEGV_LOCATION();
 	bansnode = hash_lookup( banhash, mask );
-	if( !bansnode ) {
+	if( !bansnode )
+	{
 		nlog( LOG_WARNING, "DelBan: unknown ban %s", mask );
 		return;
 	}
@@ -226,7 +227,8 @@
 	hscan_t hs;
 
 	hash_scan_begin( &hs, banhash );
-	while( ( bansnode = hash_scan_next( &hs ) ) != NULL  ) {
+	while( ( bansnode = hash_scan_next( &hs ) ) != NULL  )
+	{
 		ban = hnode_get( bansnode );
 		hash_scan_delete_destroy_node( banhash, bansnode );
 		ns_free( ban );
@@ -247,7 +249,8 @@
 int InitBans( void )
 {
 	banhash = hash_create( -1, 0, 0 );
-	if( !banhash ) {
+	if( !banhash )
+	{
 		nlog( LOG_CRITICAL, "Unable to create bans hash" );
 		return NS_FAILURE;
 	}

Modified: trunk/src/commands.c
==============================================================================
--- trunk/src/commands.c	(original)
+++ trunk/src/commands.c	Fri Aug 26 05:09:00 2005
@@ -77,7 +77,8 @@
  */
 static int calc_cmd_ulevel( const bot_cmd *cmd_ptr )
 {
-	if( cmd_ptr->ulevel > NS_ULEVEL_ROOT ) {
+	if( cmd_ptr->ulevel > NS_ULEVEL_ROOT )
+	{
 		/* int pointer rather than value */
 		return( *( int* )cmd_ptr->ulevel );
 	}
@@ -102,12 +103,13 @@
 	/* Generally we just want the standard user level */
 	ulevel = UserLevel( cmdparams->source );
 	/* If less than a locop see if the module can give us a user level */
-	if( ulevel < NS_ULEVEL_LOCOPER ) {
-		if( cmdparams->bot->moduleptr->authcb ) {
+	if( ulevel < NS_ULEVEL_LOCOPER )
+	{
+		if( cmdparams->bot->moduleptr->authcb )
+		{
 			modlevel = cmdparams->bot->moduleptr->authcb( cmdparams->source );
-			if( modlevel > ulevel ) {
+			if( modlevel > ulevel )
 				ulevel = modlevel;
-			}
 		}
 	}
 	return ulevel;
@@ -161,10 +163,9 @@
 {
 	irc_prefmsg( cmdparams->bot, cmdparams->source, __( "Syntax error: unknown command: \2%s\2", cmdparams->source ), 
 		cmdparams->param );
-	if( nsconfig.cmdreport ) {
+	if( nsconfig.cmdreport )
 		irc_chanalert( cmdparams->bot, _( "%s requested %s, but that is an unknown command" ),
 			cmdparams->source->name, cmdparams->param );
-	}
 }
 
 void msg_only_opers( CmdParams *cmdparams )
@@ -179,7 +180,8 @@
 
 void check_cmd_result( CmdParams *cmdparams, int cmdret, char *extra )
 {
-	switch( cmdret ) {
+	switch( cmdret )
+	{
 		case NS_ERR_SYNTAX_ERROR:
 			msg_syntax_error( cmdparams );
 			break;
@@ -213,21 +215,25 @@
 	 * check validity during processing. Only check critical elements.
 	 * For now we verify help during processing since it is not critical. */
 	/* No command, we cannot recover from this */
-	if( !cmd_ptr->cmd ) {
+	if( !cmd_ptr->cmd )
+	{
 		nlog( LOG_ERROR, "add_bot_cmd: missing command" );
 		return NS_FAILURE;
 	}
-	if( hash_lookup( cmd_hash, cmd_ptr->cmd ) ) {
+	if( hash_lookup( cmd_hash, cmd_ptr->cmd ) )
+	{
 		nlog( LOG_ERROR, "add_bot_cmd: attempt to add duplicate command %s", cmd_ptr->cmd );
 		return NS_FAILURE;
 	}
 	/* No handler, we cannot recover from this */
-	if( !cmd_ptr->handler ) {
+	if( !cmd_ptr->handler )
+	{
 		nlog( LOG_ERROR, "add_bot_cmd: missing command handler, command %s not added", 
 			cmd_ptr->cmd );
 		return NS_FAILURE;
 	}
-	if( !cmd_ptr->helptext ) {
+	if( !cmd_ptr->helptext )
+	{
 		nlog( LOG_ERROR, "add_bot_cmd: missing help text, command %s not added", 
 			cmd_ptr->cmd );
 		return NS_FAILURE;
@@ -236,7 +242,8 @@
 	hnode_create_insert( cmd_hash, cmd_ptr, cmd_ptr->cmd );
 	snprintf( confcmd, 32, "command%s", cmd_ptr->cmd );
 	cmd_ptr->modptr = GET_CUR_MODULE();
-	if( DBAFetchConfigInt( confcmd, &ulevel ) == NS_SUCCESS ) {
+	if( DBAFetchConfigInt( confcmd, &ulevel ) == NS_SUCCESS )
+	{
 		hashentry = ( bot_cmd * ) hnode_find( cmd_hash, cmd_ptr->cmd );
 		hashentry->ulevel = ulevel;
 	}
@@ -255,13 +262,11 @@
 	hnode_t *cmdnode;
 	
 	/* Find the command */
-	if (!bot_ptr->botcmds) {
+	if (!bot_ptr->botcmds)
 		return NULL;
-	}
 	cmdnode = hash_lookup( bot_ptr->botcmds, cmd );
-	if( cmdnode ) {
+	if( cmdnode )
 		return hnode_get(cmdnode);
-	}
 	return NULL;
 }	
 
@@ -276,11 +281,13 @@
 	
 	/* Delete the command */
 	cmdnode = hash_lookup( cmd_hash, cmd_ptr->cmd );
-	if( cmdnode ) {
+	if( cmdnode )
+	{
 		dlog( DEBUG3, "deleting command %s from services bot",( ( bot_cmd* )hnode_get( cmdnode ) )->cmd );
 		hash_delete_destroy_node( cmd_hash, cmdnode );
 #if USE_PERL
-		if (IS_PERL_MOD(cmd_ptr->modptr)) {
+		if (IS_PERL_MOD(cmd_ptr->modptr))
+		{
 			ns_free(cmd_ptr->cmd);
 			ns_free(cmd_ptr->moddata);
 			/* XXX is this correct on a array of strings? */
@@ -298,15 +305,21 @@
  */
 int add_bot_cmd_list( Bot *bot_ptr, bot_cmd *bot_cmd_list ) 
 {
-	if( !bot_cmd_list ) {
+	if( !bot_cmd_list )
 		return NS_FAILURE;
-	}
 	/* If no hash create */
-	if( bot_ptr->botcmds == NULL ) {
+	if( bot_ptr->botcmds == NULL )
+	{
 		bot_ptr->botcmds = hash_create( -1, 0, 0 );
+		if( !bot_ptr->botcmds )
+		{
+			nlog( LOG_CRITICAL, "Unable to create botcmds hash" );
+			return NS_FAILURE;
+		}
 	}
 	/* Cycle through command list and add them */
-	while( bot_cmd_list->cmd ) {
+	while( bot_cmd_list->cmd )
+	{
 		add_bot_cmd( bot_ptr->botcmds, bot_cmd_list );
 		bot_cmd_list++;
 	}
@@ -320,15 +333,14 @@
 int del_bot_cmd_list( Bot* bot_ptr, bot_cmd *bot_cmd_list ) 
 {
 	/* If no bot pointer return failure */
-	if( !bot_ptr ) {
+	if( !bot_ptr )
 		return NS_FAILURE;
-	}
 	/* If no hash return failure */
-	if( !bot_ptr->botcmds ) {
+	if( !bot_ptr->botcmds )
 		return NS_FAILURE;
-	}
 	/* Cycle through command list and delete them */
-	while( bot_cmd_list->cmd ) {
+	while( bot_cmd_list->cmd )
+	{
 		del_bot_cmd( bot_ptr->botcmds, bot_cmd_list );
 		bot_cmd_list++;
 	}
@@ -345,12 +357,12 @@
 	hscan_t hs;
 
 	/* Check we have a command hash */
-	if( bot_ptr->botcmds == NULL ) {
+	if( bot_ptr->botcmds == NULL )
 		return NS_FAILURE;
-	}
 	/* Cycle through command hash and delete each command */
 	hash_scan_begin( &hs, bot_ptr->botcmds );
-	while( ( cmdnode = hash_scan_next( &hs ) ) != NULL ) {
+	while( ( cmdnode = hash_scan_next( &hs ) ) != NULL )
+	{
 		dlog( DEBUG3, "deleting command %s from services bot",( ( bot_cmd* )hnode_get( cmdnode ) )->cmd );
 		hash_scan_delete_destroy_node( bot_ptr->botcmds, cmdnode );
 	}
@@ -409,7 +421,8 @@
 	bot_cmd *cmd_ptr;
 
 	/* Handle SET if we have it */
-	if( cmdparams->bot->botsettings && !ircstrcasecmp( cmd, "SET" ) ) {
+	if( cmdparams->bot->botsettings && !ircstrcasecmp( cmd, "SET" ) )
+	{
 		intrinsic_handler( cmdparams, bot_cmd_set );
 		return NS_SUCCESS;
 	}
@@ -417,8 +430,10 @@
 	cmd_ptr = intrinsic_commands;
 	if( !ircstrcasecmp( cmd, "LEVELS" ) && cmdparams->bot->flags & BOT_FLAG_NOINTRINSICLEVELS ) 
 		return NS_FAILURE;
-	while( cmd_ptr->cmd ) {
-		if( !ircstrcasecmp( cmd, cmd_ptr->cmd ) ) {
+	while( cmd_ptr->cmd )
+	{
+		if( !ircstrcasecmp( cmd, cmd_ptr->cmd ) )
+		{
 			intrinsic_handler( cmdparams, cmd_ptr->handler );
 			return NS_SUCCESS;
 		}
@@ -464,9 +479,8 @@
 	ac = split_buf( privmsgbuffer, &av, 0 );
 	cmdparams->cmd = av[0];
 	cmdparams->ac = 0;
-	for( i = 1; i < ac; i++ ) {
+	for( i = 1; i < ac; i++ )
 		AddStringToList( &cmdparams->av, av[i], &cmdparams->ac );
-	}
 	userlevel = getuserlevel( cmdparams ); 
 	/* Check user authority to use this command set */
 	if( ( ( cmdparams->bot->flags & BOT_FLAG_RESTRICT_OPERS ) && ( userlevel < NS_ULEVEL_OPER ) ) ||
@@ -559,7 +573,8 @@
 	irc_prefmsg_list( cmdparams->bot, cmdparams->source, cmd_help_set );
 	/* Display option specific text for current user level */
 	hash_scan_begin( &hs, cmdparams->bot->botsettings );
-	while( ( setnode = hash_scan_next( &hs ) ) != NULL ) {
+	while( ( setnode = hash_scan_next( &hs ) ) != NULL )
+	{
 		set_ptr = hnode_get( setnode );
 		if( set_ptr->helptext && userlevel >= set_ptr->ulevel )
 		{
@@ -605,54 +620,65 @@
 	userlevel = getuserlevel( cmdparams );
 
 	/* If no parameter to help, generate main help text */
-	if( cmdparams->ac < 1 ) {
+	if( cmdparams->ac < 1 )
+	{
 		lowlevel = 0;
 		curlevel = 30;
-		if( nsconfig.cmdreport ) {
+		if( nsconfig.cmdreport )
 			irc_chanalert( cmdparams->bot, _( "%s requested %s help" ), cmdparams->source->name, cmdparams->bot->name );
-		}
 		nlog( LOG_NORMAL, "%s requested %s help", cmdparams->source->name, cmdparams->bot->name );
 		irc_prefmsg( cmdparams->bot, cmdparams->source, __( "\2The following commands can be used with %s:\2",cmdparams->source ), cmdparams->bot->name );
 
 		/* Handle intrinsic commands */
 		cmd_ptr = intrinsic_commands;
-		while( cmd_ptr->cmd ) {
+		while( cmd_ptr->cmd )
+		{
 			/* Check for module override */	
 			if( !ircstrcasecmp( cmd_ptr->cmd, "LEVELS" ) && cmdparams->bot->flags & BOT_FLAG_NOINTRINSICLEVELS )
 			{
 				cmd_ptr++;
 				continue;
 			}
-			if( !cmdparams->bot->botcmds || !hash_lookup( cmdparams->bot->botcmds, cmd_ptr->cmd ) ) {
+			if( !cmdparams->bot->botcmds || !hash_lookup( cmdparams->bot->botcmds, cmd_ptr->cmd ) )
+			{
 				irc_prefmsg( cmdparams->bot, cmdparams->source, "    %-20s %s", cmd_ptr->cmd, cmd_ptr->helptext[0] );
 			}
 			cmd_ptr++;
 		}
 		/* Do we have a set command? */
-		if( cmdparams->bot->botsettings && userlevel >= cmdparams->bot->set_ulevel ) {
+		if( cmdparams->bot->botsettings && userlevel >= cmdparams->bot->set_ulevel )
+		{
 			irc_prefmsg( cmdparams->bot, cmdparams->source, "    %-20s Configure %s", "SET", cmdparams->bot->name );
 		}
-		if( cmdparams->bot->botcmds ) {
-			while( 1 ) {
+		if( cmdparams->bot->botcmds )
+		{
+			while( 1 )
+			{
 				hnode_t* cmdnode;
 
 				hash_scan_begin( &hs, cmdparams->bot->botcmds );
-				while( ( cmdnode = hash_scan_next( &hs ) ) != NULL ) {
+				while( ( cmdnode = hash_scan_next( &hs ) ) != NULL )
+				{
 					cmd_ptr = hnode_get( cmdnode );
 					cmdlevel = calc_cmd_ulevel( cmd_ptr );
-					if( ( cmdlevel < curlevel ) && ( cmdlevel >= lowlevel ) ) {
-						if( curlevelmsg && !donemsg ) {
+					if( ( cmdlevel < curlevel ) && ( cmdlevel >= lowlevel ) )
+					{
+						if( curlevelmsg && !donemsg )
+						{
 							irc_prefmsg( cmdparams->bot, cmdparams->source, __( "\2Additional commands available to %s:\2", cmdparams->source ), curlevelmsg );
 							donemsg = 1;
 						}
 						irc_prefmsg( cmdparams->bot, cmdparams->source, "    %-20s %s", cmd_ptr->cmd, cmd_ptr->helptext[0] );
 					}
 				}
-				if( lowlevel >= userlevel ) {
+				if( lowlevel >= userlevel )
+				{
 					break;
 				}
-				if( userlevel >= curlevel ) {
-					switch( curlevel ) {
+				if( userlevel >= curlevel )
+				{
+					switch( curlevel )
+					{
 						case 30:
 							curlevel = NS_ULEVEL_OPER;
 							lowlevel = 30;
@@ -688,17 +714,21 @@
 		bot_cmd_help_on_help( cmdparams );
 		return NS_SUCCESS;
 	}
-	if( nsconfig.cmdreport ) {
+	if( nsconfig.cmdreport )
+	{
 		irc_chanalert( cmdparams->bot, _( "%s requested %s help on %s" ), cmdparams->source->name, cmdparams->bot->name, cmdparams->av[0] );
 	}
 	nlog( LOG_NORMAL, "%s requested %s help on %s", cmdparams->source->name, cmdparams->bot->name, cmdparams->av[0] );
 
 	/* Process command list */
-	if( cmdparams->bot->botcmds ) {
+	if( cmdparams->bot->botcmds )
+	{
 		cmd_ptr = ( bot_cmd* )hnode_find( cmdparams->bot->botcmds, cmdparams->av[0] );
-		if( cmd_ptr ) {
+		if( cmd_ptr )
+		{
 			cmdlevel = calc_cmd_ulevel( cmd_ptr );
-			if( userlevel < cmdlevel ) {
+			if( userlevel < cmdlevel )
+			{
 				msg_permission_denied( cmdparams, NULL );
 				return NS_ERR_NO_PERMISSION;
 			}		
@@ -709,15 +739,18 @@
 
 	/* Handle intrinsic commands */
 	cmd_ptr = intrinsic_commands;
-	while( cmd_ptr->cmd ) {
-		if( !ircstrcasecmp( cmdparams->av[0], cmd_ptr->cmd ) ) {
+	while( cmd_ptr->cmd )
+	{
+		if( !ircstrcasecmp( cmdparams->av[0], cmd_ptr->cmd ) )
+		{
 			irc_prefmsg_list( cmdparams->bot, cmdparams->source, cmd_ptr->helptext + 1 );
 			return NS_SUCCESS;
 		}
 		cmd_ptr++;
 	}
 	/* Handle SET if we have it */	
-	if( cmdparams->bot->botsettings && userlevel >= cmdparams->bot->set_ulevel && !ircstrcasecmp( cmdparams->av[0], "SET" ) ) {
+	if( cmdparams->bot->botsettings && userlevel >= cmdparams->bot->set_ulevel && !ircstrcasecmp( cmdparams->av[0], "SET" ) )
+	{
 		bot_cmd_help_set( cmdparams, userlevel );		
 		return NS_SUCCESS;
 	}
@@ -736,13 +769,15 @@
 	
 	/* Check target user is on IRC */
 	target = FindUser( target_nick );
-	if( !target ) {
+	if( !target )
+	{
 		irc_prefmsg( botptr, sourceuser, 
 			__( "%s cannot be found on IRC, message not sent.", sourceuser ), target_nick );
 		return NULL;
 	}
 	/* Check for message to self */
-	if( IsMe( target ) ) {
+	if( IsMe( target ) )
+	{
 		irc_prefmsg( botptr, sourceuser, __( "Cannot send message to a service bot.", sourceuser ) );
 		return NULL;
 	}
@@ -755,11 +790,15 @@
  */
 static int bot_cmd_about( CmdParams *cmdparams )
 {
-	if( cmdparams->bot->moduleptr ) {
-		if (IS_STD_MOD(cmdparams->bot->moduleptr)) {
+	if( cmdparams->bot->moduleptr )
+	{
+		if (IS_STD_MOD(cmdparams->bot->moduleptr))
+		{
 			irc_prefmsg_list( cmdparams->bot, cmdparams->source, cmdparams->bot->moduleptr->info->about_text );
 #if USE_PERL
-		} else {
+		}
+		else
+		{
 			irc_prefmsg(cmdparams->bot, cmdparams->source, "Not Available");
 #endif
 		}
@@ -786,12 +825,16 @@
  */
 static int bot_cmd_credits( CmdParams *cmdparams )
 {
-	if( cmdparams->bot->moduleptr ) {
-		if (IS_STD_MOD(cmdparams->bot->moduleptr)) {
+	if( cmdparams->bot->moduleptr )
+	{
+		if (IS_STD_MOD(cmdparams->bot->moduleptr))
+		{
 			irc_prefmsg_list( cmdparams->bot, cmdparams->source, 
 				cmdparams->bot->moduleptr->info->copyright );
 #if USE_PERL
-		} else {
+		}
+		else
+		{
 			irc_prefmsg(cmdparams->bot, cmdparams->source, "Not Available");
 #endif
 		}
@@ -808,40 +851,43 @@
 	bot_cmd *cmd_ptr;
 	int userlevel;
 
-	if( cmdparams->ac < 1 ) {
+	if( cmdparams->ac < 1 )
 		return NS_ERR_NEED_MORE_PARAMS;
-	}
 	if( !cmdparams->bot->botcmds )
 	{
 		irc_prefmsg( cmdparams->bot, cmdparams->source, "No commands found." );
 		return NS_SUCCESS;
 	}
-	if( !ircstrcasecmp( cmdparams->av[0], "LIST" ) ) {
+	if( !ircstrcasecmp( cmdparams->av[0], "LIST" ) )
+	{
 		hnode_t *cmdnode;
 		hscan_t hs;
 
 		/* Cycle through command hash and list each command */
 		hash_scan_begin( &hs, cmdparams->bot->botcmds );
-		while( ( cmdnode = hash_scan_next( &hs ) ) != NULL ) {
+		while( ( cmdnode = hash_scan_next( &hs ) ) != NULL )
+		{
 			cmd_ptr = ( ( bot_cmd* )hnode_get( cmdnode ) );
 			irc_prefmsg( cmdparams->bot, cmdparams->source, "%s %d", cmd_ptr->cmd, cmd_ptr->ulevel );
 		}
 		return NS_SUCCESS;
 	}
-	if( cmdparams->ac < 2 ) {
+	if( cmdparams->ac < 2 )
 		return NS_ERR_NEED_MORE_PARAMS;
-	}
 	userlevel = getuserlevel( cmdparams );
-	if( userlevel < NS_ULEVEL_ROOT ) {
+	if( userlevel < NS_ULEVEL_ROOT )
+	{
 		msg_permission_denied( cmdparams, cmdparams->cmd );
 		return NS_ERR_NO_PERMISSION;
 	}
 	cmd_ptr = ( bot_cmd * )hnode_find( cmdparams->bot->botcmds, cmdparams->av[0] );
-	if( cmd_ptr ) {
+	if( cmd_ptr )
+	{
 		int newlevel = 0;
 
 		newlevel = atoi( cmdparams->av[1] );
-		if( newlevel >= 0 && newlevel <= NS_ULEVEL_ROOT ) {
+		if( newlevel >= 0 && newlevel <= NS_ULEVEL_ROOT )
+		{
 			cmd_ptr->ulevel = newlevel;
 			snprintf( confcmd, 32, "command%s", cmd_ptr->cmd );
 			DBAStoreConfigInt( confcmd, &newlevel );

Modified: trunk/src/dns.c
==============================================================================
--- trunk/src/dns.c	(original)
+++ trunk/src/dns.c	Fri Aug 26 05:09:00 2005
@@ -202,8 +202,11 @@
 	}
 	/* dnsqueue is unlimited. */
 	dnsqueue = list_create(-1);
-	if (!dnsqueue) 
+	if (!dnsqueue)
+	{
+		nlog (LOG_CRITICAL, "Unable to create DNS queue");
 		return NS_FAILURE;
+	}
 #ifndef DEBUG
 	adnsstart = adns_init (&ads, adns_if_noerrprint | adns_if_noautosys, 0, sock_update);
 #else
@@ -413,7 +416,7 @@
 	irc_numeric (RPL_MEMSTATS, u->name, "Active DNS queries: %d", (int) list_count(dnslist));
 	irc_numeric (RPL_MEMSTATS, u->name, "Queued DNS Queries: %d", (int) list_count(dnsqueue));
 	irc_numeric (RPL_MEMSTATS, u->name, "Max Queued Queries: %d", DNSStats.maxqueued);
-	irc_numeric (RPL_MEMSTATS, u->name, "Total DNS Questions: %d", DNSStats.totalq);
+	irc_numeric (RPL_MEMSTATS, u->name, "Total DNS Queries: %d", DNSStats.totalq);
 	irc_numeric (RPL_MEMSTATS, u->name, "Successful Lookups: %d", DNSStats.success);
 	irc_numeric (RPL_MEMSTATS, u->name, "Unsuccessful Lookups: %d", DNSStats.failure);
 }

Modified: trunk/src/nsevents.c
==============================================================================
--- trunk/src/nsevents.c	(original)
+++ trunk/src/nsevents.c	Fri Aug 26 05:09:00 2005
@@ -105,7 +105,7 @@
  *  @return none
  */
 
-void SendModuleEvent( Event event, CmdParams* cmdparams, Module* module_ptr )
+void SendModuleEvent( Event event, CmdParams *cmdparams, Module *module_ptr )
 {
 	SET_SEGV_LOCATION();
 	dlog( DEBUG5, "SendModuleEvent: %s to module %s", EventStrings[event], module_ptr->info->name );
@@ -117,7 +117,7 @@
 	if( module_ptr->event_list[event] )
 	{
 		/* If we are not yet synched, check that the module supports 
-			* the event before we are synched. */
+		 * the event before we are synched. */
 		if( !IsModuleSynched( module_ptr ) && !( module_ptr->event_list[event]->flags & EVENT_FLAG_IGNORE_SYNCH ) )
 		{
 			dlog( DEBUG5, "Skipping module %s for %s since module is not yet synched", module_ptr->info->name, EventStrings[event] );
@@ -203,7 +203,7 @@
  *  @return none
  */
 
-void SendAllModuleEvent( Event event, CmdParams* cmdparams )
+void SendAllModuleEvent( Event event, CmdParams *cmdparams )
 {
 	ModuleAllEvent mae;
 
@@ -224,9 +224,9 @@
  *  @return none
  */
 
-void AddEvent( ModuleEvent* eventptr )
+void AddEvent( ModuleEvent *eventptr )
 {
-	Module* mod_ptr;
+	Module *mod_ptr;
 
 	if( !eventptr )
 	{
@@ -283,7 +283,7 @@
 
 void DeleteEvent( Event event )
 {
-	Module* mod_ptr;
+	Module *mod_ptr;
 
 	mod_ptr = GET_CUR_MODULE();
 	if( !mod_ptr->event_list )
@@ -330,7 +330,7 @@
  *  @return none
  */
 
-void FreeEventList( Module* mod_ptr )
+void FreeEventList( Module *mod_ptr )
 {
 	if( mod_ptr->event_list )
 	{
@@ -353,7 +353,7 @@
 void SetAllEventFlags( unsigned int flag, unsigned int enable )
 {
 	int i;
-	ModuleEvent** eventlistptr;
+	ModuleEvent **eventlistptr;
 
 	eventlistptr = GET_CUR_MODULE()->event_list;
 	if( !eventlistptr )
@@ -387,7 +387,7 @@
 
 void SetEventFlags( Event event, unsigned int flag, unsigned int enable )
 {
-	ModuleEvent** eventlistptr;
+	ModuleEvent **eventlistptr;
 
 	eventlistptr = GET_CUR_MODULE()->event_list;
 	if( !eventlistptr )
@@ -418,7 +418,7 @@
 
 void EnableEvent( Event event )
 {
-	ModuleEvent** eventlistptr;
+	ModuleEvent **eventlistptr;
 
 	eventlistptr = GET_CUR_MODULE()->event_list;
 	if( !eventlistptr )
@@ -446,7 +446,7 @@
 
 void DisableEvent( Event event )
 {
-	ModuleEvent** eventlistptr;
+	ModuleEvent **eventlistptr;
 
 	eventlistptr = GET_CUR_MODULE()->event_list;
 	if( !eventlistptr )

Modified: trunk/src/nsmemory.c
==============================================================================
--- trunk/src/nsmemory.c	(original)
+++ trunk/src/nsmemory.c	Fri Aug 26 05:09:00 2005
@@ -97,7 +97,7 @@
  *  @return pointer to allocated buffer
  */
 
-void *ns_realloc( void* ptr, int size )
+void *ns_realloc( void *ptr, int size )
 {
 	void *newptr;
 

Modified: trunk/src/servers.c
==============================================================================
--- trunk/src/servers.c	(original)
+++ trunk/src/servers.c	Fri Aug 26 05:09:00 2005
@@ -180,7 +180,7 @@
 		cmdparams->param = ( char *)reason;
 	SendAllModuleEvent( EVENT_SQUIT, cmdparams );
 	ns_free( cmdparams );
-	hash_delete_destroy_node( serverhash, sn );
+	hash_scan_delete_destroy_node( serverhash, sn );
 	ns_free( s->server );
 	ns_free( s );
 }

Modified: trunk/src/settings.c
==============================================================================
--- trunk/src/settings.c	(original)
+++ trunk/src/settings.c	Fri Aug 26 05:09:00 2005
@@ -570,6 +570,11 @@
 	/* If no hash create */
 	if( bot_ptr->botsettings == NULL ) {
 		bot_ptr->botsettings = hash_create( -1, 0, 0 );
+		if( !bot_ptr->botsettings )
+		{
+			nlog( LOG_CRITICAL, "Unable to create botsettings hash" );
+			return NS_FAILURE;
+		}
 	}
 	/* Default SET to ROOT only */
 	bot_ptr->set_ulevel = NS_ULEVEL_ROOT;