[NeoStats-Devel] [Commits] r2789 - in trunk: . include src
[email protected] Tue, 6 Sep 2005 07:21:56 +1000
| Newsgroups | gmane.comp.neostats.devel |
|---|---|
| Message-ID | <[email protected]> |
Author: Mark
Date: Tue Sep 6 05:21:52 2005
New Revision: 2789
Modified:
trunk/ChangeLog
trunk/include/auth.h
trunk/include/bans.h
trunk/include/channels.h
trunk/include/ctcp.h
trunk/include/modules.h
trunk/include/neostats.h
trunk/include/servers.h
trunk/include/users.h
trunk/src/auth.c
trunk/src/bans.c
trunk/src/bots.c
trunk/src/channels.c
trunk/src/ctcp.c
trunk/src/modes.c
trunk/src/modules.c
trunk/src/servers.c
trunk/src/services.c
trunk/src/users.c
Log:
introduce CTCP master bot system and debug report tidy ups
Modified: trunk/ChangeLog
==============================================================================
--- trunk/ChangeLog (original)
+++ trunk/ChangeLog Tue Sep 6 05:21:52 2005
@@ -4,6 +4,8 @@
Fish (F), Mark (M), DeadNotBuried (D)
===============================================================================
* NeoStats * Version 3.0.a3-dev
+ - Introduce module override to allow a module bot to become the primary source
+ of signon CTCP version requests. (M)
- Add broadcast forms of CTCP events so that modules can watch just their own
CTCP transactions or all CTCP transactions on the network. (M)
- Introduce framework for unknown ctcp messages. (M)
Modified: trunk/include/auth.h
==============================================================================
--- trunk/include/auth.h (original)
+++ trunk/include/auth.h Tue Sep 6 05:21:52 2005
@@ -27,6 +27,6 @@
int InitAuth( void );
int AddAuthModule( Module *mod_ptr );
void DelAuthModule( Module *mod_ptr );
-int AuthUser( const Client *u );
+int ns_cmd_level( CmdParams *cmdparams );
#endif /* _AUTH_H_ */
Modified: trunk/include/bans.h
==============================================================================
--- trunk/include/bans.h (original)
+++ trunk/include/bans.h Tue Sep 6 05:21:52 2005
@@ -30,6 +30,6 @@
const char *reason, const char *setby, const char *tsset, const char *tsexpires );
void DelBan( const char *type, const char *user, const char *host, const char *mask,
const char *reason, const char *setby, const char *tsset, const char *tsexpires );
-void ListBans( void );
+int ns_cmd_banlist( CmdParams *cmdparams );
#endif /* _BANS_H_ */
Modified: trunk/include/channels.h
==============================================================================
--- trunk/include/channels.h (original)
+++ trunk/include/channels.h Tue Sep 6 05:21:52 2005
@@ -24,7 +24,7 @@
#ifndef _CHANNELS_H_
#define _CHANNELS_H_
-void ListChannels( CmdParams* cmdparams, const char *chan );
+int ns_cmd_channellist( CmdParams *cmdparams );
void PartChannel( Client *u, const char *chan, const char *reason );
void PartAllChannels( Client *u, const char *reason );
void JoinChannel( const char *nick, const char *chan );
Modified: trunk/include/ctcp.h
==============================================================================
--- trunk/include/ctcp.h (original)
+++ trunk/include/ctcp.h Tue Sep 6 05:21:52 2005
@@ -28,5 +28,7 @@
int ctcp_notice( CmdParams *cmdparams );
int ctcp_cprivate( CmdParams *cmdparams );
int ctcp_cnotice( CmdParams *cmdparams );
+int master_ctcp_version_req( const Client *target );
+void SetCTCPVersionMaster( const Bot *bot );
#endif /* _CTCP_H_ */
Modified: trunk/include/modules.h
==============================================================================
--- trunk/include/modules.h (original)
+++ trunk/include/modules.h Tue Sep 6 05:21:52 2005
@@ -32,6 +32,8 @@
int unload_module( const char *module_name, Client * u );
void unload_modules( void );
int ns_cmd_modlist( CmdParams* cmdparams );
+int ns_cmd_load( CmdParams *cmdparams );
+int ns_cmd_unload( CmdParams *cmdparams );
void AllModuleVersions( const char* nick, const char *remoteserver );
int SynchModule( Module* module_ptr );
void SynchAllModules( void );
Modified: trunk/include/neostats.h
==============================================================================
--- trunk/include/neostats.h (original)
+++ trunk/include/neostats.h Tue Sep 6 05:21:52 2005
@@ -785,6 +785,10 @@
* E.g. TextServ db bots
*/
#define BOT_FLAG_NOINTRINSICLEVELS 0x00000020
+/* Bot becomes CTCP master for version requests and replies
+ * E.g. SecureServ issuing CTCP VERSION rather than NeoStats
+ */
+#define BOT_FLAG_CTCPVERSIONMASTER 0x00000040
/* This defines a "NULL" string for the purpose of BotInfo structures that
* want to inherit the main host used by NeoStats and still make the info
Modified: trunk/include/servers.h
==============================================================================
--- trunk/include/servers.h (original)
+++ trunk/include/servers.h Tue Sep 6 05:21:52 2005
@@ -26,7 +26,7 @@
Client *AddServer( const char *name, const char *uplink, const char *hops, const char *numeric, const char *infoline );
void DelServer( const char *name, const char* reason );
-void ListServers( CmdParams *cmdparams, const char *name );
+int ns_cmd_serverlist( CmdParams *cmdparams );
int InitServers( void );
void PingServers( void );
void FiniServers( void );
Modified: trunk/include/users.h
==============================================================================
--- trunk/include/users.h (original)
+++ trunk/include/users.h Tue Sep 6 05:21:52 2005
@@ -36,7 +36,7 @@
void UserSMode( const char *nick, const char *modes );
void UserAway( const char *nick, const char *awaymsg );
Client *find_user_base64( const char *num );
-void ListUsers( CmdParams* cmdparams, const char *nick );
+int ns_cmd_userlist( CmdParams *cmdparams );
void QuitServerUsers( Client *s );
EXPORTFUNC void AddFakeUser( const char *mask );
EXPORTFUNC void DelFakeUser( const char *mask );
Modified: trunk/src/auth.c
==============================================================================
--- trunk/src/auth.c (original)
+++ trunk/src/auth.c Tue Sep 6 05:21:52 2005
@@ -76,6 +76,7 @@
/** @brief ModuleAuthHandler
*
* Call module auth function
+ * Auth subsystem use only.
*
* @params module_ptr pointer to module
* @params v pointer to module auth info
@@ -102,14 +103,14 @@
/** @brief AuthUser
*
* Determine authentication level of user
- * NeoStats core use only.
+ * Auth subsystem use only.
*
* @param u pointer to client to test
*
* @return authentication level
*/
-int AuthUser( const Client *u )
+static int AuthUser( const Client *u )
{
ModuleAuthInfo mai;
@@ -131,6 +132,58 @@
return mai.auth;
}
+/** @brief UserLevel
+ *
+ * Calculate user authentication level
+ * NeoStats core use only.
+ *
+ * @param u pointer to client to authenticate
+ *
+ * @return user level
+ */
+
+int UserLevel( Client *u )
+{
+ /* Have we already calculated the user level? */
+ if( u->user->ulevel != -1 )
+ return u->user->ulevel;
+ u->user->ulevel = AuthUser( u );
+ /* Set user level so we no longer need to calculate */
+ dlog( DEBUG1, "UserLevel for %s set to %d", u->name, u->user->ulevel );
+ return u->user->ulevel;
+}
+
+/** @brief ns_cmd_level
+ *
+ * LEVEL command handler
+ * Display user level
+ *
+ * @param cmdparams structure with command information
+ *
+ * @return NS_SUCCESS if succeeds, NS_FAILURE if not
+ */
+
+int ns_cmd_level( CmdParams *cmdparams )
+{
+ SET_SEGV_LOCATION();
+ if( cmdparams->ac < 1 ) {
+ /* Force recalc user level */
+ cmdparams->source->user->ulevel = -1;
+ irc_prefmsg( ns_botptr, cmdparams->source, __( "Your level is %d", cmdparams->source ), UserLevel( cmdparams->source ) );
+ } else {
+ Client * otheruser;
+ otheruser = FindUser( cmdparams->av[0] );
+ /* Force recalc user level */
+ otheruser->user->ulevel = -1;
+ if( !otheruser ) {
+ irc_prefmsg( ns_botptr, cmdparams->source, __( "User %s not found", cmdparams->source ), cmdparams->av[0] );
+ return NS_FAILURE;
+ }
+ irc_prefmsg( ns_botptr, cmdparams->source, __( "User level for %s is %d", cmdparams->source ), otheruser->name, UserLevel( otheruser ) );
+ }
+ return NS_SUCCESS;
+}
+
/** @brief AddAuthModule
*
* Add an authentication module
Modified: trunk/src/bans.c
==============================================================================
--- trunk/src/bans.c (original)
+++ trunk/src/bans.c Tue Sep 6 05:21:52 2005
@@ -176,7 +176,7 @@
ns_free( ban );
}
-/** @brief ReportBan
+/** @brief ListBan
*
* BANS LIST helper
* report ban info
@@ -187,27 +187,37 @@
* @return none
*/
-static int ReportBan( Ban *ban, void *v )
+static int ListBan( Ban *ban, void *v )
{
- irc_chanalert( ns_botptr, _( "Ban: %s " ), ban->mask );
+ CmdParams *cmdparams;
+
+ cmdparams = ( CmdParams * ) v;
+ irc_prefmsg( ns_botptr, cmdparams->source, _( "Ban: %s " ), ban->mask );
return NS_FALSE;
}
-/** @brief ListBans
- *
- * List all bans currently set
- * NeoStats core use only.
+/** @brief ns_cmd_banlist
*
- * @param none
+ * BANLIST command handler
+ * Dump ban list
+ *
+ * @param cmdparams structure with command information
*
- * @return nothing
+ * @return NS_SUCCESS if succeeds, NS_FAILURE if not
*/
-void ListBans( void )
+int ns_cmd_banlist( CmdParams *cmdparams )
{
- irc_chanalert( ns_botptr, _( "Ban Listing:" ) );
- ProcessBanList( ReportBan, NULL );
- irc_chanalert( ns_botptr, _( "End of list." ) );
+ SET_SEGV_LOCATION();
+ if( !nsconfig.debug )
+ {
+ irc_prefmsg( ns_botptr, cmdparams->source, __( "\2Error:\2 debug mode disabled", cmdparams->source ) );
+ return NS_FAILURE;
+ }
+ irc_prefmsg( ns_botptr, cmdparams->source, _( "Ban Listing:" ) );
+ ProcessBanList( ListBan, (void *)cmdparams );
+ irc_prefmsg( ns_botptr, cmdparams->source, _( "End of list." ) );
+ return NS_SUCCESS;
}
/** @brief FiniBans
Modified: trunk/src/bots.c
==============================================================================
--- trunk/src/bots.c (original)
+++ trunk/src/bots.c Tue Sep 6 05:21:52 2005
@@ -436,6 +436,8 @@
return NS_FAILURE;
}
botptr = hnode_get( bn );
+ if( botptr->flags & BOT_FLAG_CTCPVERSIONMASTER )
+ SetCTCPVersionMaster( NULL );
del_all_bot_cmds( botptr );
del_bot_info_settings( botptr );
del_all_bot_settings( botptr );
@@ -754,6 +756,8 @@
if( botptr->moduleptr->info->flags & MODULE_FLAG_LOCAL_EXCLUDES )
AddBotExcludeCommands( botptr );
}
+ if( botptr->flags & BOT_FLAG_CTCPVERSIONMASTER )
+ SetCTCPVersionMaster( botptr );
return botptr;
}
Modified: trunk/src/channels.c
==============================================================================
--- trunk/src/channels.c (original)
+++ trunk/src/channels.c Tue Sep 6 05:21:52 2005
@@ -553,35 +553,38 @@
return NS_FALSE;
}
-/** @brief ListChannels
+/** @brief ns_cmd_channellist
*
- * Report channels
+ * CHANNELLIST command handler
+ * Dump channel list
+ *
+ * @param cmdparams structure with command information
*
- * @param cmdparams
- * @param chan
- *
- * @returns none
-*/
+ * @return NS_SUCCESS if succeeds, NS_FAILURE if not
+ */
-void ListChannels( CmdParams * cmdparams, const char *chan )
+int ns_cmd_channellist( CmdParams *cmdparams )
{
Channel *c;
- if( !nsconfig.debug )
- return;
SET_SEGV_LOCATION();
+ if( !nsconfig.debug )
+ {
+ irc_prefmsg( ns_botptr, cmdparams->source, __( "\2Error:\2 debug mode disabled", cmdparams->source ) );
+ return NS_FAILURE;
+ }
irc_prefmsg( ns_botptr, cmdparams->source, __( "================CHANLIST================",cmdparams->source ) );
- if( chan )
+ if( cmdparams->ac < 1 )
{
- c = FindChannel( chan );
- if( c )
- ListChannel( c, cmdparams );
- else
- irc_prefmsg( ns_botptr, cmdparams->source, __( "ListChannels: can't find channel %s", cmdparams->source ), chan );
- return;
+ ProcessChannelList( ListChannel, cmdparams );
+ return NS_SUCCESS;
}
- irc_prefmsg( ns_botptr, cmdparams->source, __( "Channels %d", cmdparams->source ),( int )hash_count( channelhash ) );
- ProcessChannelList( ListChannel, cmdparams );
+ c = FindChannel( cmdparams->av[0] );
+ if( c )
+ ListChannel( c, cmdparams );
+ else
+ irc_prefmsg( ns_botptr, cmdparams->source, __( "can't find channel %s", cmdparams->source ), cmdparams->av[0] );
+ return NS_SUCCESS;
}
/** @brief FindChannel
Modified: trunk/src/ctcp.c
==============================================================================
--- trunk/src/ctcp.c (original)
+++ trunk/src/ctcp.c Tue Sep 6 05:21:52 2005
@@ -25,12 +25,16 @@
#include "nsevents.h"
#include "ctcp.h"
#include "dcc.h"
+#include "services.h"
/** CTCP subsystem
*
* Handle incoming and outgoing CTCP messages
*/
+/* CTCP master version request bot pointer */
+static const Bot *CTCPVersionMasterBot = NULL;
+
/* CTCP command handler type */
typedef int( *ctcp_cmd_handler )( CmdParams *cmdparams );
@@ -250,6 +254,43 @@
return NS_SUCCESS;
}
+/** @brief master_ctcp_version_req
+ *
+ * Send a correctly formatted CTCP VERSION request
+ * Module call.
+ *
+ * @param target, pointer to client to send to
+ *
+ * @return NS_SUCCESS if succeeds, NS_FAILURE if not
+ */
+
+int master_ctcp_version_req( const Client *target )
+{
+ const Bot *botptr;
+
+ botptr = CTCPVersionMasterBot;
+ if( !botptr )
+ botptr = ns_botptr;
+ dlog( DEBUG5, "TX: CTCP VERSION request from %s to %s", botptr->name, target->name );
+ irc_privmsg( botptr, target, "\1VERSION\1" );
+ return NS_SUCCESS;
+}
+
+/** @brief SetCTCPVersionMaster
+ *
+ * Set CTCP version master
+ * Module call.
+ *
+ * @param botptr, pointer to bot sending request
+ *
+ * @return none
+ */
+
+void SetCTCPVersionMaster( const Bot *bot )
+{
+ CTCPVersionMasterBot = bot;
+}
+
/** @brief ctcp_req_finger
*
* handle incoming CTCP FINGER request
Modified: trunk/src/modes.c
==============================================================================
--- trunk/src/modes.c (original)
+++ trunk/src/modes.c Tue Sep 6 05:21:52 2005
@@ -680,7 +680,7 @@
}
}
-void ListChannelModes (CmdParams* cmdparams, Channel* c)
+void ListChannelModes(CmdParams* cmdparams, Channel* c)
{
lnode_t *cmn;
ModesParm *m;
Modified: trunk/src/modules.c
==============================================================================
--- trunk/src/modules.c (original)
+++ trunk/src/modules.c Tue Sep 6 05:21:52 2005
@@ -485,6 +485,44 @@
return 0;
}
+/** @brief ns_cmd_load
+ *
+ * LOAD command handler
+ * Load module
+ *
+ * @param cmdparams structure with command information
+ *
+ * @return NS_SUCCESS if succeeds, NS_FAILURE if not
+ */
+
+int ns_cmd_load( CmdParams *cmdparams )
+{
+ SET_SEGV_LOCATION();
+ if( ns_load_module( cmdparams->av[0], cmdparams->source ) )
+ irc_chanalert( ns_botptr, _( "%s loaded module %s" ), cmdparams->source->name, cmdparams->av[0] );
+ else
+ irc_chanalert( ns_botptr, _( "%s tried to load module %s, but load failed" ), cmdparams->source->name, cmdparams->av[0] );
+ return NS_SUCCESS;
+}
+
+/** @brief ns_cmd_unload
+ *
+ * UNLOAD command handler
+ * Unload module
+ *
+ * @param cmdparams structure with command information
+ *
+ * @return NS_SUCCESS if succeeds, NS_FAILURE if not
+ */
+
+int ns_cmd_unload( CmdParams *cmdparams )
+{
+ SET_SEGV_LOCATION();
+ if( unload_module( cmdparams->av[0], cmdparams->source ) > 0 )
+ irc_chanalert( ns_botptr, _( "%s unloaded module %s" ), cmdparams->source->name, cmdparams->av[0] );
+ return NS_SUCCESS;
+}
+
/** @brief unload_module
*
* Unloads module
@@ -571,7 +609,10 @@
SET_RUN_LEVEL( mod_ptr );
DBACloseDatabase();
-
+ /* Cleanup moddata */
+ CleanupUserModdata( moduleindex );
+ CleanupServerModdata( moduleindex );
+ CleanupChannelModdata( moduleindex );
if( IS_STANDARD_MOD( mod_ptr ) ) {
ns_dlclose( mod_ptr->handle );
@@ -580,10 +621,6 @@
unload_perlmod( mod_ptr );
#endif
}
- /* Cleanup moddata */
- CleanupUserModdata( moduleindex );
- CleanupServerModdata( moduleindex );
- CleanupChannelModdata( moduleindex );
RESET_RUN_LEVEL();
ns_free( mod_ptr );
/* free the module number */
Modified: trunk/src/servers.c
==============================================================================
--- trunk/src/servers.c (original)
+++ trunk/src/servers.c Tue Sep 6 05:21:52 2005
@@ -49,7 +49,7 @@
* @return pointer to Client or NULL if fails
*/
-static Client * new_server( const char *name )
+static Client *new_server( const char *name )
{
Client *s;
@@ -236,7 +236,7 @@
return NULL;
}
-/** @brief dumpserver
+/** @brief ListServer
*
* Report server information
* NeoStats core use only.
@@ -247,7 +247,7 @@
* @return none
*/
-static int dumpserver( Client *s, void *v )
+static int ListServer( Client *s, void *v )
{
CmdParams *cmdparams;
time_t uptime;
@@ -267,31 +267,38 @@
return NS_FALSE;
}
-/** @brief ListServers
+/** @brief ns_cmd_serverlist
*
- * Report current server list
- * NeoStats core use only.
- *
- * @param name
+ * SERVERLIST command handler
+ * Dump server list
+ *
+ * @param cmdparams structure with command information
*
- * @return none
+ * @return NS_SUCCESS if succeeds, NS_FAILURE if not
*/
-void ListServers( CmdParams *cmdparams, const char *name )
+int ns_cmd_serverlist( CmdParams *cmdparams )
{
+ Client *s;
+
+ SET_SEGV_LOCATION();
+ if( !nsconfig.debug )
+ {
+ irc_prefmsg( ns_botptr, cmdparams->source, __( "\2Error:\2 debug mode disabled", cmdparams->source ) );
+ return NS_FAILURE;
+ }
irc_prefmsg( ns_botptr, cmdparams->source, _( "===============SERVERLIST===============" ) );
- if( name )
+ if( cmdparams->ac < 1 )
{
- Client *s;
-
- s = FindServer( name );
- if( s )
- dumpserver( s, NULL );
- else
- irc_prefmsg( ns_botptr, cmdparams->source, _( "ListServers: can't find server %s" ), name );
- return;
+ ProcessServerList( ListServer, NULL );
+ return NS_SUCCESS;
}
- ProcessServerList( dumpserver, NULL );
+ s = FindServer( cmdparams->av[0] );
+ if( s )
+ ListServer( s, NULL );
+ else
+ irc_prefmsg( ns_botptr, cmdparams->source, _( "can't find server %s" ), cmdparams->av[0] );
+ return NS_SUCCESS;
}
/** @brief InitServers
Modified: trunk/src/services.c
==============================================================================
--- trunk/src/services.c (original)
+++ trunk/src/services.c Tue Sep 6 05:21:52 2005
@@ -39,6 +39,7 @@
#include "exclude.h"
#include "services.h"
#include "bans.h"
+#include "auth.h"
/* Command function prototypes */
static int ns_cmd_shutdown( CmdParams *cmdparams );
@@ -47,14 +48,7 @@
#ifdef USE_RAW
static int ns_cmd_raw( CmdParams *cmdparams );
#endif
-static int ns_cmd_userlist( CmdParams *cmdparams );
-static int ns_cmd_serverlist( CmdParams *cmdparams );
-static int ns_cmd_channellist( CmdParams *cmdparams );
-static int ns_cmd_banlist( CmdParams *cmdparams );
static int ns_cmd_status( CmdParams *cmdparams );
-static int ns_cmd_level( CmdParams *cmdparams );
-static int ns_cmd_load( CmdParams *cmdparams );
-static int ns_cmd_unload( CmdParams *cmdparams );
static int services_event_ctcpversion( CmdParams *cmdparams );
@@ -241,7 +235,7 @@
ns_botinfo.flags |= BOT_FLAG_ONLY_OPERS;
SetModuleInSynch( &ns_module );
ns_botptr = AddBot( &ns_botinfo );
- add_services_set_list (ns_debugsettings);
+ add_services_set_list( ns_debugsettings );
AddEventList( neostats_events );
SetModuleSynched( &ns_module );
me.synched = 1;
@@ -325,90 +319,6 @@
return NS_SUCCESS;
}
-/** @brief ns_cmd_userlist
- *
- * USERLIST command handler
- * Dump user list
- *
- * @param cmdparams structure with command information
- *
- * @return NS_SUCCESS if succeeds, NS_FAILURE if not
- */
-
-static int ns_cmd_userlist( CmdParams *cmdparams )
-{
- SET_SEGV_LOCATION();
- if( !nsconfig.debug ) {
- irc_prefmsg( ns_botptr, cmdparams->source, __( "\2Error:\2 debug mode disabled", cmdparams->source ) );
- return NS_FAILURE;
- }
- ListUsers( cmdparams, ( cmdparams->ac < 1 ) ? NULL : cmdparams->av[0] );
- return NS_SUCCESS;
-}
-
-/** @brief ns_cmd_serverlist
- *
- * SERVERLIST command handler
- * Dump server list
- *
- * @param cmdparams structure with command information
- *
- * @return NS_SUCCESS if succeeds, NS_FAILURE if not
- */
-
-static int ns_cmd_serverlist( CmdParams *cmdparams )
-{
- SET_SEGV_LOCATION();
- if( !nsconfig.debug ) {
- irc_prefmsg( ns_botptr, cmdparams->source, __( "\2Error:\2 debug mode disabled", cmdparams->source ) );
- return NS_FAILURE;
- }
- ListServers( cmdparams, ( cmdparams->ac < 1 ) ? NULL : cmdparams->av[0] );
- return NS_SUCCESS;
-}
-
-/** @brief ns_cmd_channellist
- *
- * CHANNELLIST command handler
- * Dump channel list
- *
- * @param cmdparams structure with command information
- *
- * @return NS_SUCCESS if succeeds, NS_FAILURE if not
- */
-
-static int ns_cmd_channellist( CmdParams *cmdparams )
-{
- SET_SEGV_LOCATION();
- if( !nsconfig.debug ) {
- irc_prefmsg( ns_botptr, cmdparams->source, __( "\2Error:\2 debug mode disabled", cmdparams->source ) );
- return NS_FAILURE;
- }
- ListChannels( cmdparams, ( cmdparams->ac < 1 ) ? NULL : cmdparams->av[0] );
- return NS_SUCCESS;
-}
-
-/** @brief ns_cmd_banlist
- *
- * BANLIST command handler
- * Dump ban list
- *
- * @param cmdparams structure with command information
- *
- * @return NS_SUCCESS if succeeds, NS_FAILURE if not
- */
-
-static int ns_cmd_banlist( CmdParams *cmdparams )
-{
- SET_SEGV_LOCATION();
- if( !nsconfig.debug ) {
- irc_prefmsg( ns_botptr, cmdparams->source, __( "\2Error:\2 debug mode disabled", cmdparams->source ) );
- return NS_FAILURE;
- }
- ListBans();
- return NS_SUCCESS;
-}
-
/** @brief ns_cmd_status
*
* STATUS command handler
@@ -448,75 +358,6 @@
return NS_SUCCESS;
}
-/** @brief ns_cmd_level
- *
- * LEVEL command handler
- * Display user level
- *
- * @param cmdparams structure with command information
- *
- * @return NS_SUCCESS if succeeds, NS_FAILURE if not
- */
-
-static int ns_cmd_level( CmdParams *cmdparams )
-{
- SET_SEGV_LOCATION();
- if( cmdparams->ac < 1 ) {
- /* Force recalc user level */
- cmdparams->source->user->ulevel = -1;
- irc_prefmsg( ns_botptr, cmdparams->source, __( "Your level is %d", cmdparams->source ), UserLevel( cmdparams->source ) );
- } else {
- Client * otheruser;
- otheruser = FindUser( cmdparams->av[0] );
- /* Force recalc user level */
- otheruser->user->ulevel = -1;
- if( !otheruser ) {
- irc_prefmsg( ns_botptr, cmdparams->source, __( "User %s not found", cmdparams->source ), cmdparams->av[0] );
- return NS_FAILURE;
- }
- irc_prefmsg( ns_botptr, cmdparams->source, __( "User level for %s is %d", cmdparams->source ), otheruser->name, UserLevel( otheruser ) );
- }
- return NS_SUCCESS;
-}
-
-/** @brief ns_cmd_load
- *
- * LOAD command handler
- * Load module
- *
- * @param cmdparams structure with command information
- *
- * @return NS_SUCCESS if succeeds, NS_FAILURE if not
- */
-
-static int ns_cmd_load( CmdParams *cmdparams )
-{
- SET_SEGV_LOCATION();
- if( ns_load_module( cmdparams->av[0], cmdparams->source ) )
- irc_chanalert( ns_botptr, _( "%s loaded module %s" ), cmdparams->source->name, cmdparams->av[0] );
- else
- irc_chanalert( ns_botptr, _( "%s tried to load module %s, but load failed" ), cmdparams->source->name, cmdparams->av[0] );
- return NS_SUCCESS;
-}
-
-/** @brief ns_cmd_unload
- *
- * UNLOAD command handler
- * Unload module
- *
- * @param cmdparams structure with command information
- *
- * @return NS_SUCCESS if succeeds, NS_FAILURE if not
- */
-
-static int ns_cmd_unload( CmdParams *cmdparams )
-{
- SET_SEGV_LOCATION();
- if( unload_module( cmdparams->av[0], cmdparams->source ) > 0 )
- irc_chanalert( ns_botptr, _( "%s unloaded module %s" ), cmdparams->source->name, cmdparams->av[0] );
- return NS_SUCCESS;
-}
-
#ifdef USE_RAW
/** @brief ns_cmd_raw
*
Modified: trunk/src/users.c
==============================================================================
--- trunk/src/users.c (original)
+++ trunk/src/users.c Tue Sep 6 05:21:52 2005
@@ -209,7 +209,7 @@
ns_free( cmdparams );
/* Send CTCP VERSION request if we are configured to do so */
if( IsNeoStatsSynched() && me.versionscan && !IsExcluded( u ) && !IsMe( u ) )
- irc_ctcp_version_req( ns_botptr, u );
+ master_ctcp_version_req( u );
return u;
}
@@ -529,7 +529,7 @@
return NS_SUCCESS;
}
-/** @brief dumpuser
+/** @brief ListUser
*
* Report user information
* NeoStats core use only.
@@ -540,7 +540,7 @@
* @return NS_FALSE
*/
-static int dumpuser( Client *u, void* v )
+static int ListUser( Client *u, void* v )
{
CmdParams *cmdparams;
lnode_t *cm;
@@ -574,56 +574,38 @@
return NS_FALSE;
}
-/** @brief ListUsers
+/** @brief ns_cmd_userlist
*
- * Report current user list
- * NeoStats core use only.
- *
- * @param cmdparams
- * @param nick
+ * USERLIST command handler
+ * Dump user list
+ *
+ * @param cmdparams structure with command information
*
- * @return none
+ * @return NS_SUCCESS if succeeds, NS_FAILURE if not
*/
-void ListUsers( CmdParams *cmdparams, const char *nick )
+int ns_cmd_userlist( CmdParams *cmdparams )
{
Client *u;
- if( !nsconfig.debug )
- return;
SET_SEGV_LOCATION();
+ if( !nsconfig.debug )
+ {
+ irc_prefmsg( ns_botptr, cmdparams->source, __( "\2Error:\2 debug mode disabled", cmdparams->source ) );
+ return NS_FAILURE;
+ }
irc_prefmsg( ns_botptr, cmdparams->source, __( "================USERLIST================", cmdparams->source ) );
- if( !nick )
+ if( cmdparams->ac < 1 )
{
- ProcessUserList( dumpuser, cmdparams );
- return;
+ ProcessUserList( ListUser, cmdparams );
+ return NS_SUCCESS;
}
- u = FindUser( nick );
+ u = FindUser( cmdparams->av[0] );
if( u )
- dumpuser( u,( void * )cmdparams );
+ ListUser( u,( void * )cmdparams );
else
- irc_prefmsg( ns_botptr, cmdparams->source, __( "ListUsers: can't find user %s", cmdparams->source ), nick );
-}
-
-/** @brief UserLevel
- *
- * Calculate user authentication level
- * NeoStats core use only.
- *
- * @param u pointer to client to authenticate
- *
- * @return user level
- */
-
-int UserLevel( Client *u )
-{
- /* Have we already calculated the user level? */
- if( u->user->ulevel != -1 )
- return u->user->ulevel;
- u->user->ulevel = AuthUser( u );
- /* Set user level so we no longer need to calculate */
- dlog( DEBUG1, "UserLevel for %s set to %d", u->name, u->user->ulevel );
- return u->user->ulevel;
+ irc_prefmsg( ns_botptr, cmdparams->source, __( "can't find user %s", cmdparams->source ), cmdparams->av[0] );
+ return NS_SUCCESS;
}
/** @brief SetUserVhost