[NeoStats-Devel] [Commits] r2787 - in trunk: . include modules/statserv src
[email protected] Sat, 3 Sep 2005 06:21:15 +1000
| Newsgroups | gmane.comp.neostats.devel |
|---|---|
| Message-ID | <[email protected]> |
Author: Mark
Date: Sat Sep 3 04:21:10 2005
New Revision: 2787
Modified:
trunk/ChangeLog
trunk/include/events.h
trunk/include/neostats.h
trunk/include/servers.h
trunk/modules/statserv/statserv.c
trunk/modules/statserv/version.c
trunk/modules/statserv/version.h
trunk/src/ctcp.c
trunk/src/nsevents.c
trunk/src/servers.c
trunk/src/services.c
trunk/src/users.c
Log:
Add broadcast forms of CTCP events
Modified: trunk/ChangeLog
==============================================================================
--- trunk/ChangeLog (original)
+++ trunk/ChangeLog Sat Sep 3 04:21:10 2005
@@ -4,6 +4,8 @@
Fish (F), Mark (M), DeadNotBuried (D)
===============================================================================
* NeoStats * Version 3.0.a3-dev
+ - 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)
- Fix a memleak in ExtAuth (F)
- Netinfo on Ultimate3 is like Globops, not a burst function (F)
Modified: trunk/include/events.h
==============================================================================
--- trunk/include/events.h (original)
+++ trunk/include/events.h Sat Sep 3 04:21:10 2005
@@ -335,12 +335,14 @@
* version in cmdparams->param
*/
EVENT_CTCPVERSIONRPL,
+ EVENT_CTCPVERSIONRPLBC,
/* EVENT_CTCPVERSIONREQ
* parameters:
* user in cmdparams->source
*/
EVENT_CTCPVERSIONREQ,
+ EVENT_CTCPVERSIONREQBC,
/* EVENT_CTCPFINGERRPL
* parameters:
@@ -348,18 +350,21 @@
* finger in cmdparams->param
*/
EVENT_CTCPFINGERRPL,
+ EVENT_CTCPFINGERRPLBC,
/* EVENT_CTCPFINGERREQ
* parameters:
* user in cmdparams->source
*/
EVENT_CTCPFINGERREQ,
+ EVENT_CTCPFINGERREQBC,
/* EVENT_CTCPACTIONREQ
* parameters:
* user in cmdparams->source
*/
EVENT_CTCPACTIONREQ,
+ EVENT_CTCPACTIONREQBC,
/* EVENT_CTCPTIMERPL
* parameters:
@@ -367,12 +372,14 @@
* time in cmdparams->param
*/
EVENT_CTCPTIMERPL,
+ EVENT_CTCPTIMERPLBC,
/* EVENT_CTCPTIMEREQ
* parameters:
* user in cmdparams->source
*/
EVENT_CTCPTIMEREQ,
+ EVENT_CTCPTIMEREQBC,
/* EVENT_CTCPPINGRPL
* parameters:
@@ -380,12 +387,14 @@
* ping in cmdparams->param
*/
EVENT_CTCPPINGRPL,
+ EVENT_CTCPPINGRPLBC,
/* EVENT_CTCPPINGREQ
* parameters:
* user in cmdparams->source
*/
EVENT_CTCPPINGREQ,
+ EVENT_CTCPPINGREQBC,
/* EVENT_CTCPUNHANDLEDRPL
* parameters:
@@ -393,6 +402,7 @@
* ???
*/
EVENT_CTCPUNHANDLEDRPL,
+ EVENT_CTCPUNHANDLEDRPLBC,
/* EVENT_CTCPUNHANDLEDREQ
* parameters:
@@ -400,6 +410,7 @@
* ???
*/
EVENT_CTCPUNHANDLEDREQ,
+ EVENT_CTCPUNHANDLEDREQBC,
/* DCC events
* Generated in response to ctcp dcc events
Modified: trunk/include/neostats.h
==============================================================================
--- trunk/include/neostats.h (original)
+++ trunk/include/neostats.h Sat Sep 3 04:21:10 2005
@@ -869,6 +869,7 @@
#define MODULE_FLAG_NONE 0x00000000
#define MODULE_FLAG_AUTH 0x00000001
#define MODULE_FLAG_LOCAL_EXCLUDES 0x00000002
+#define MODULE_FLAG_CTCP_VERSION 0x00000004
typedef enum MOD_TYPE {
/* standard C Modules */
Modified: trunk/include/servers.h
==============================================================================
--- trunk/include/servers.h (original)
+++ trunk/include/servers.h Sat Sep 3 04:21:10 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( const char *name );
+void ListServers( CmdParams *cmdparams, const char *name );
int InitServers( void );
void PingServers( void );
void FiniServers( void );
Modified: trunk/modules/statserv/statserv.c
==============================================================================
--- trunk/modules/statserv/statserv.c (original)
+++ trunk/modules/statserv/statserv.c Sat Sep 3 04:21:10 2005
@@ -65,7 +65,7 @@
{EVENT_PART, ss_event_part, EVENT_FLAG_IGNORE_SYNCH},
{EVENT_KICK, ss_event_kick, EVENT_FLAG_IGNORE_SYNCH},
{EVENT_TOPIC, ss_event_topic, EVENT_FLAG_IGNORE_SYNCH},
- {EVENT_CTCPVERSIONRPL, ss_event_ctcpversion, EVENT_FLAG_IGNORE_SYNCH},
+ {EVENT_CTCPVERSIONRPLBC,ss_event_ctcpversionbc, EVENT_FLAG_IGNORE_SYNCH},
{EVENT_NULL, NULL, 0}
};
Modified: trunk/modules/statserv/version.c
==============================================================================
--- trunk/modules/statserv/version.c (original)
+++ trunk/modules/statserv/version.c Sat Sep 3 04:21:10 2005
@@ -213,7 +213,7 @@
return NS_SUCCESS;
}
-/** @brief ss_event_ctcpversion
+/** @brief ss_event_ctcpversionbc
*
* CTCP VERSION event handler
*
@@ -222,7 +222,7 @@
* @return NS_SUCCESS if succeeds, else NS_FAILURE
*/
-int ss_event_ctcpversion( CmdParams *cmdparams )
+int ss_event_ctcpversionbc( CmdParams *cmdparams )
{
static char nocols[BUFSIZE];
ss_ctcp_version *cv;
@@ -230,16 +230,14 @@
strlcpy( nocols, cmdparams->param, BUFSIZE );
strip_mirc_codes( nocols );
cv = findctcpversion( nocols );
- if( cv )
+ if( !cv )
{
- IncStatistic( &cv->users );
- return NS_SUCCESS;
+ cv = ns_calloc( sizeof( ss_ctcp_version ) );
+ strlcpy( cv->name, nocols, BUFSIZE );
+ lnode_create_append( ctcp_version_list, cv );
+ dlog( DEBUG2, "Added version: %s", cv->name );
}
- cv = ns_calloc( sizeof( ss_ctcp_version ) );
- strlcpy( cv->name, nocols, BUFSIZE );
IncStatistic( &cv->users );
- lnode_create_append( ctcp_version_list, cv );
- dlog( DEBUG2, "Added version: %s", cv->name );
return NS_SUCCESS;
}
Modified: trunk/modules/statserv/version.h
==============================================================================
--- trunk/modules/statserv/version.h (original)
+++ trunk/modules/statserv/version.h Sat Sep 3 04:21:10 2005
@@ -33,7 +33,7 @@
void GetClientStats( const CTCPVersionHandler handler, int limit, const void *v );
int ss_cmd_ctcpversion( CmdParams *cmdparams );
-int ss_event_ctcpversion( CmdParams *cmdparams );
+int ss_event_ctcpversionbc( CmdParams *cmdparams );
int InitVersionStats( void );
void FiniVersionStats( void );
Modified: trunk/src/ctcp.c
==============================================================================
--- trunk/src/ctcp.c (original)
+++ trunk/src/ctcp.c Sat Sep 3 04:21:10 2005
@@ -26,69 +26,100 @@
#include "ctcp.h"
#include "dcc.h"
-typedef int( *ctcp_cmd_handler )( CmdParams* cmdparams );
+/** CTCP subsystem
+ *
+ * Handle incoming and outgoing CTCP messages
+ */
+/* CTCP command handler type */
+typedef int( *ctcp_cmd_handler )( CmdParams *cmdparams );
+
+/* CTCP command lookup table */
typedef struct ctcp_cmd {
- const char* cmd;
+ const char *cmd;
ctcp_cmd_handler req_handler;
ctcp_cmd_handler rpl_handler;
} ctcp_cmd;
-static int ctcp_req_version( CmdParams* cmdparams );
-static int ctcp_rpl_version( CmdParams* cmdparams );
-static int ctcp_req_finger( CmdParams* cmdparams );
-static int ctcp_rpl_finger( CmdParams* cmdparams );
-static int ctcp_req_action( CmdParams* cmdparams );
-static int ctcp_req_dcc( CmdParams* cmdparams );
-static int ctcp_rpl_dcc( CmdParams* cmdparams );
-static int ctcp_req_time( CmdParams* cmdparams );
-static int ctcp_rpl_time( CmdParams* cmdparams );
-static int ctcp_req_ping( CmdParams* cmdparams );
-static int ctcp_rpl_ping( CmdParams* cmdparams );
-static int ctcp_req_unhandled( CmdParams* cmdparams );
-static int ctcp_rpl_unhandled( CmdParams* cmdparams );
+/* CTCP command type prototypes */
+static int ctcp_req_version( CmdParams *cmdparams );
+static int ctcp_rpl_version( CmdParams *cmdparams );
+static int ctcp_req_finger( CmdParams *cmdparams );
+static int ctcp_rpl_finger( CmdParams *cmdparams );
+static int ctcp_req_action( CmdParams *cmdparams );
+static int ctcp_req_dcc( CmdParams *cmdparams );
+static int ctcp_rpl_dcc( CmdParams *cmdparams );
+static int ctcp_req_time( CmdParams *cmdparams );
+static int ctcp_rpl_time( CmdParams *cmdparams );
+static int ctcp_req_ping( CmdParams *cmdparams );
+static int ctcp_rpl_ping( CmdParams *cmdparams );
+static int ctcp_req_unhandled( CmdParams *cmdparams );
+static int ctcp_rpl_unhandled( CmdParams *cmdparams );
-static ctcp_cmd ctcp_cmds[]= {
+/* CTCP command lookup table */
+static ctcp_cmd ctcp_cmds[] =
+{
{"VERSION", ctcp_req_version, ctcp_rpl_version },
{"FINGER", ctcp_req_finger, ctcp_rpl_finger },
{"ACTION", ctcp_req_action, NULL },
{"DCC", ctcp_req_dcc, ctcp_rpl_dcc },
{"TIME", ctcp_req_time, ctcp_rpl_time },
{"PING", ctcp_req_ping, ctcp_rpl_ping },
- {NULL, NULL, NULL}
+ {NULL, NULL, NULL}
};
+/** @brief strip_ctcp_codes
+ *
+ * strip ctcp codes from given message
+ * CTCP subsystem use only.
+ *
+ * @param line to strip
+ *
+ * @return none but line is modified
+ */
+
static void strip_ctcp_codes( char *line )
{
char *outline = line;
- while( *line ) {
- if( (*line ) == 1 ) {
- line++;
- } else {
+ while( *line )
+ {
+ if( (*line ) != '\1' )
+ {
*outline = *line;
outline++;
- line++;
}
+ line++;
}
*outline = 0;
}
+/** @brief ctcp_private
+ *
+ * handle incoming CTCP PRIVMSG i.e. requests
+ * NeoStats core use only.
+ *
+ * @param cmdparams
+ *
+ * @return NS_SUCCESS if succeeds, NS_FAILURE if not
+ */
+
int ctcp_private( CmdParams *cmdparams )
{
ctcp_cmd* cmd;
int len;
- if( cmdparams->param[0] == '\1' ) {
+ if( cmdparams->param[0] == '\1' )
+ {
strip_ctcp_codes( cmdparams->param );
cmd = ctcp_cmds;
- while( cmd->cmd ) {
+ while( cmd->cmd )
+ {
len = strlen( cmd->cmd );
if( ircstrncasecmp( cmd->cmd, cmdparams->param, len ) == 0 )
{
cmdparams->param += ( len + 1 );
- if( cmd->req_handler ) {
+ if( cmd->req_handler )
cmd->req_handler( cmdparams );
- }
return NS_SUCCESS;
}
cmd++;
@@ -98,22 +129,33 @@
return NS_SUCCESS;
}
+/** @brief ctcp_notice
+ *
+ * handle incoming CTCP NOTICE i.e. replies
+ * NeoStats core use only.
+ *
+ * @param cmdparams
+ *
+ * @return NS_SUCCESS if succeeds, NS_FAILURE if not
+ */
+
int ctcp_notice( CmdParams *cmdparams )
{
ctcp_cmd* cmd;
int len;
- if( cmdparams->param[0] == '\1' ) {
+ if( cmdparams->param[0] == '\1' )
+ {
strip_ctcp_codes( cmdparams->param );
cmd = ctcp_cmds;
- while( cmd->cmd ) {
+ while( cmd->cmd )
+ {
len = strlen( cmd->cmd );
if( ircstrncasecmp( cmd->cmd, cmdparams->param, len ) == 0 )
{
cmdparams->param += ( len + 1 );
- if( cmd->rpl_handler ) {
+ if( cmd->rpl_handler )
cmd->rpl_handler( cmdparams );
- }
return NS_SUCCESS;
}
cmd++;
@@ -123,155 +165,384 @@
return NS_SUCCESS;
}
+/** @brief ctcp_cprivate
+ *
+ * handle incoming CTCP channel PRIVMSG
+ * NeoStats core use only.
+ *
+ * @param cmdparams
+ *
+ * @return NS_SUCCESS if succeeds, NS_FAILURE if not
+ */
+
int ctcp_cprivate( CmdParams *cmdparams )
{
dlog( DEBUG5, "Channel CTCP requests currently not supported" );
return NS_SUCCESS;
}
+/** @brief ctcp_cnotice
+ *
+ * handle incoming CTCP channel NOTICE
+ * NeoStats core use only.
+ *
+ * @param cmdparams
+ *
+ * @return NS_SUCCESS if succeeds, NS_FAILURE if not
+ */
+
int ctcp_cnotice( CmdParams *cmdparams )
{
dlog( DEBUG5, "Channel CTCP replies currently not supported" );
return NS_SUCCESS;
}
-static int ctcp_req_version( CmdParams* cmdparams )
+/** @brief ctcp_req_version
+ *
+ * handle incoming CTCP VERSION request
+ * CTCP subsystem use only.
+ *
+ * @param cmdparams
+ *
+ * @return NS_SUCCESS if succeeds, NS_FAILURE if not
+ */
+
+static int ctcp_req_version( CmdParams *cmdparams )
{
dlog( DEBUG5, "RX: CTCP VERSION request from %s to %s", cmdparams->source->name, cmdparams->bot->name );
SendModuleEvent( EVENT_CTCPVERSIONREQ, cmdparams, cmdparams->bot->moduleptr );
return NS_SUCCESS;
}
-static int ctcp_rpl_version( CmdParams* cmdparams )
+/** @brief ctcp_rpl_version
+ *
+ * handle incoming CTCP VERSION reply
+ * CTCP subsystem use only.
+ *
+ * @param cmdparams
+ *
+ * @return NS_SUCCESS if succeeds, NS_FAILURE if not
+ */
+
+static int ctcp_rpl_version( CmdParams *cmdparams )
{
dlog( DEBUG5, "RX: CTCP VERSION reply from %s to %s", cmdparams->source->name, cmdparams->bot->name );
- /*SendAllModuleEvent( EVENT_CTCPVERSIONRPL, cmdparams);*/
+ SendAllModuleEvent( EVENT_CTCPVERSIONRPLBC, cmdparams );
SendModuleEvent( EVENT_CTCPVERSIONRPL, cmdparams, cmdparams->bot->moduleptr );
return NS_SUCCESS;
}
-int irc_ctcp_version_req( const Bot* botptr, const Client* target )
+/** @brief irc_ctcp_version_req
+ *
+ * Send a correctly formatted CTCP VERSION request
+ * Module call.
+ *
+ * @param botptr, pointer to bot sending request
+ * @param target, pointer to client to send to
+ *
+ * @return NS_SUCCESS if succeeds, NS_FAILURE if not
+ */
+
+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" );
return NS_SUCCESS;
}
-static int ctcp_req_finger( CmdParams* cmdparams )
+/** @brief ctcp_req_finger
+ *
+ * handle incoming CTCP FINGER request
+ * CTCP subsystem use only.
+ *
+ * @param cmdparams
+ *
+ * @return NS_SUCCESS if succeeds, NS_FAILURE if not
+ */
+
+static int ctcp_req_finger( CmdParams *cmdparams )
{
dlog( DEBUG5, "RX: CTCP FINGER request from %s to %s", cmdparams->source->name, cmdparams->bot->name );
SendModuleEvent( EVENT_CTCPFINGERREQ, cmdparams, cmdparams->bot->moduleptr );
return NS_SUCCESS;
}
-static int ctcp_rpl_finger( CmdParams* cmdparams )
+/** @brief ctcp_rpl_finger
+ *
+ * handle incoming CTCP FINGER reply
+ * CTCP subsystem use only.
+ *
+ * @param cmdparams
+ *
+ * @return NS_SUCCESS if succeeds, NS_FAILURE if not
+ */
+
+static int ctcp_rpl_finger( CmdParams *cmdparams )
{
dlog( DEBUG5, "RX: CTCP FINGER reply from %s to %s", cmdparams->source->name, cmdparams->bot->name );
- /*SendAllModuleEvent( EVENT_CTCPFINGERRPL, cmdparams);*/
+ SendAllModuleEvent( EVENT_CTCPFINGERRPLBC, cmdparams );
SendModuleEvent( EVENT_CTCPFINGERRPL, cmdparams, cmdparams->bot->moduleptr );
return NS_SUCCESS;
}
-int irc_ctcp_finger_req( const Bot* botptr, const Client* target )
+/** @brief irc_ctcp_finger_req
+ *
+ * Send a correctly formatted CTCP FINGER request
+ * Module call.
+ *
+ * @param botptr, pointer to bot sending request
+ * @param target, pointer to client to send to
+ *
+ * @return NS_SUCCESS if succeeds, NS_FAILURE if not
+ */
+
+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" );
return NS_SUCCESS;
}
-static int ctcp_req_action( CmdParams* cmdparams )
+/** @brief ctcp_req_action
+ *
+ * handle incoming CTCP ACTION request
+ * CTCP subsystem use only.
+ *
+ * @param cmdparams
+ *
+ * @return NS_SUCCESS if succeeds, NS_FAILURE if not
+ */
+
+static int ctcp_req_action( CmdParams *cmdparams )
{
dlog( DEBUG5, "RX: CTCP ACTION request from %s to %s", cmdparams->source->name, cmdparams->bot->name );
SendModuleEvent( EVENT_CTCPACTIONREQ, cmdparams, cmdparams->bot->moduleptr );
return NS_SUCCESS;
}
-int irc_ctcp_action_req( const Bot* botptr, const Client* target, const char *action )
+/** @brief irc_ctcp_action_req
+ *
+ * Send a correctly formatted CTCP ACTION request
+ * Module call.
+ *
+ * @param botptr, pointer to bot sending request
+ * @param target, pointer to client to send to
+ * @param action to send
+ *
+ * @return NS_SUCCESS if succeeds, NS_FAILURE if not
+ */
+
+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( const Bot* botptr, const Channel* channel, const char *action )
+/** @brief irc_ctcp_action_req_channel
+ *
+ * Send a correctly formatted CTCP ACTION request
+ * Module call.
+ *
+ * @param botptr, pointer to bot sending request
+ * @param channel to send to
+ * @param action to send
+ *
+ * @return NS_SUCCESS if succeeds, NS_FAILURE if not
+ */
+
+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 );
return NS_SUCCESS;
}
-static int ctcp_req_dcc( CmdParams* cmdparams )
+/** @brief ctcp_req_dcc
+ *
+ * handle incoming CTCP DCC request
+ * CTCP subsystem use only.
+ *
+ * @param cmdparams
+ *
+ * @return NS_SUCCESS if succeeds, NS_FAILURE if not
+ */
+
+static int ctcp_req_dcc( CmdParams *cmdparams )
{
dlog( DEBUG5, "RX: CTCP DCC request from %s to %s", cmdparams->source->name, cmdparams->bot->name );
dcc_req( cmdparams );
return NS_SUCCESS;
}
-static int ctcp_rpl_dcc( CmdParams* cmdparams )
+/** @brief ctcp_rpl_dcc
+ *
+ * handle incoming CTCP DCC reply
+ * CTCP subsystem use only.
+ *
+ * @param cmdparams
+ *
+ * @return NS_SUCCESS if succeeds, NS_FAILURE if not
+ */
+
+static int ctcp_rpl_dcc( CmdParams *cmdparams )
{
dlog( DEBUG5, "RX: CTCP DCC reply from %s to %s", cmdparams->source->name, cmdparams->bot->name );
dlog( DEBUG5, "CTCP DCC replies currently not supported" );
return NS_SUCCESS;
}
-static int ctcp_req_time( CmdParams* cmdparams )
+/** @brief ctcp_req_time
+ *
+ * handle incoming CTCP TIME request
+ * CTCP subsystem use only.
+ *
+ * @param cmdparams
+ *
+ * @return NS_SUCCESS if succeeds, NS_FAILURE if not
+ */
+
+static int ctcp_req_time( CmdParams *cmdparams )
{
dlog( DEBUG5, "RX: CTCP TIME request from %s to %s", cmdparams->source->name, cmdparams->bot->name );
SendModuleEvent( EVENT_CTCPTIMEREQ, cmdparams, cmdparams->bot->moduleptr );
return NS_SUCCESS;
}
-static int ctcp_rpl_time( CmdParams* cmdparams )
+/** @brief ctcp_rpl_time
+ *
+ * handle incoming CTCP TIME reply
+ * CTCP subsystem use only.
+ *
+ * @param cmdparams
+ *
+ * @return NS_SUCCESS if succeeds, NS_FAILURE if not
+ */
+
+static int ctcp_rpl_time( CmdParams *cmdparams )
{
dlog( DEBUG5, "RX: CTCP TIME reply from %s to %s", cmdparams->source->name, cmdparams->bot->name );
- /*SendAllModuleEvent( EVENT_CTCPTIMERPL, cmdparams);*/
+ SendAllModuleEvent( EVENT_CTCPTIMERPLBC, cmdparams );
SendModuleEvent( EVENT_CTCPTIMERPL, cmdparams, cmdparams->bot->moduleptr );
return NS_SUCCESS;
}
-int irc_ctcp_time_req( const Bot* botptr, const Client* target )
+/** @brief irc_ctcp_time_req
+ *
+ * Send a correctly formatted CTCP TIME request
+ * Module call.
+ *
+ * @param botptr, pointer to bot sending request
+ * @param target, pointer to client to send to
+ *
+ * @return NS_SUCCESS if succeeds, NS_FAILURE if not
+ */
+
+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" );
return NS_SUCCESS;
}
-static int ctcp_req_ping( CmdParams* cmdparams )
+/** @brief ctcp_req_ping
+ *
+ * handle incoming CTCP PING request
+ * CTCP subsystem use only.
+ *
+ * @param cmdparams
+ *
+ * @return NS_SUCCESS if succeeds, NS_FAILURE if not
+ */
+
+static int ctcp_req_ping( CmdParams *cmdparams )
{
dlog( DEBUG5, "RX: CTCP PING request from %s to %s", cmdparams->source->name, cmdparams->bot->name );
SendModuleEvent( EVENT_CTCPPINGREQ, cmdparams, cmdparams->bot->moduleptr );
return NS_SUCCESS;
}
-static int ctcp_rpl_ping( CmdParams* cmdparams )
+/** @brief ctcp_rpl_ping
+ *
+ * handle incoming CTCP PING reply
+ * CTCP subsystem use only.
+ *
+ * @param cmdparams
+ *
+ * @return NS_SUCCESS if succeeds, NS_FAILURE if not
+ */
+
+static int ctcp_rpl_ping( CmdParams *cmdparams )
{
dlog( DEBUG5, "RX: CTCP PING reply from %s to %s", cmdparams->source->name, cmdparams->bot->name );
- /*SendAllModuleEvent( EVENT_CTCPPINGRPL, cmdparams);*/
+ SendAllModuleEvent( EVENT_CTCPPINGRPLBC, cmdparams );
SendModuleEvent( EVENT_CTCPPINGRPL, cmdparams, cmdparams->bot->moduleptr );
return NS_SUCCESS;
}
-int irc_ctcp_ping_req( const Bot* botptr, const Client* target )
+/** @brief irc_ctcp_ping_req
+ *
+ * Send a correctly formatted CTCP PING request
+ * Module call.
+ *
+ * @param botptr, pointer to bot sending request
+ * @param target, pointer to client to send to
+ *
+ * @return NS_SUCCESS if succeeds, NS_FAILURE if not
+ */
+
+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" );
return NS_SUCCESS;
}
-static int ctcp_req_unhandled( CmdParams* cmdparams )
+/** @brief ctcp_req_unhandled
+ *
+ * handle incoming CTCP request that we have no specific handler for
+ * CTCP subsystem use only.
+ *
+ * @param cmdparams
+ *
+ * @return NS_SUCCESS if succeeds, NS_FAILURE if not
+ */
+
+static int ctcp_req_unhandled( CmdParams *cmdparams )
{
dlog( DEBUG5, "RX: CTCP UNHANDLED request from %s to %s", cmdparams->source->name, cmdparams->bot->name );
SendModuleEvent( EVENT_CTCPUNHANDLEDREQ, cmdparams, cmdparams->bot->moduleptr );
return NS_SUCCESS;
}
-static int ctcp_rpl_unhandled( CmdParams* cmdparams )
+/** @brief ctcp_rpl_unhandled
+ *
+ * handle incoming CTCP reply that we have no specific handler for
+ * CTCP subsystem use only.
+ *
+ * @param cmdparams
+ *
+ * @return NS_SUCCESS if succeeds, NS_FAILURE if not
+ */
+
+static int ctcp_rpl_unhandled( CmdParams *cmdparams )
{
dlog( DEBUG5, "RX: CTCP UNHANDLED reply from %s to %s", cmdparams->source->name, cmdparams->bot->name );
SendModuleEvent( EVENT_CTCPUNHANDLEDRPL, cmdparams, cmdparams->bot->moduleptr );
return NS_SUCCESS;
}
+/** @brief irc_ctcp_ping_req
+ *
+ * Send a correctly formatted CTCP request that we have no specific handler for
+ * Module call.
+ *
+ * @param botptr, pointer to bot sending request
+ * @param target, pointer to client to send to
+ *
+ * @return NS_SUCCESS if succeeds, NS_FAILURE if not
+ */
+
int irc_ctcp_unhandled_req( const Bot *botptr, const Client *target, const char *ctcp_command )
{
dlog( DEBUG5, "TX: CTCP UNHANDLED request from %s to %s: %s %s", botptr->name, target->name, ctcp_command );
@@ -279,10 +550,20 @@
return NS_SUCCESS;
}
+/** @brief irc_ctcp_unhandled_rpl
+ *
+ * Send a correctly formatted CTCP reply that we have no specific handler for
+ * Module call.
+ *
+ * @param botptr, pointer to bot sending reply
+ * @param target, pointer to client to send to
+ *
+ * @return NS_SUCCESS if succeeds, NS_FAILURE if not
+ */
+
int irc_ctcp_unhandled_rpl( const Bot *botptr, const Client *target, const char *ctcp_command, const char *ctcp_parameters )
{
- dlog( DEBUG5, "TX: CTCP UNHANDLED request from %s to %s: %s %s", botptr->name, target->name, ctcp_command, ctcp_parameters );
+ dlog( DEBUG5, "TX: CTCP UNHANDLED reply from %s to %s: %s %s", botptr->name, target->name, ctcp_command, ctcp_parameters );
irc_privmsg( botptr, target, "\1%s %s\1", ctcp_command, ctcp_parameters );
return NS_SUCCESS;
}
-
Modified: trunk/src/nsevents.c
==============================================================================
--- trunk/src/nsevents.c (original)
+++ trunk/src/nsevents.c Sat Sep 3 04:21:10 2005
@@ -77,16 +77,27 @@
"EVENT_CHATOPS",
"EVENT_WALLOPS",
"EVENT_CTCPVERSIONRPL",
+ "EVENT_CTCPVERSIONRPLBC",
"EVENT_CTCPVERSIONREQ",
+ "EVENT_CTCPVERSIONREQBC",
"EVENT_CTCPFINGERRPL",
+ "EVENT_CTCPFINGERRPLBC",
"EVENT_CTCPFINGERREQ",
+ "EVENT_CTCPFINGERREQBC",
"EVENT_CTCPACTIONREQ",
+ "EVENT_CTCPACTIONREQBC",
"EVENT_CTCPTIMERPL",
+ "EVENT_CTCPTIMERPLBC",
"EVENT_CTCPTIMEREQ",
+ "EVENT_CTCPTIMEREQBC",
"EVENT_CTCPPINGRPL",
+ "EVENT_CTCPPINGRPLBC",
"EVENT_CTCPPINGREQ",
+ "EVENT_CTCPPINGREQBC",
"EVENT_CTCPUNHANDLEDRPL",
+ "EVENT_CTCPUNHANDLEDRPLBC",
"EVENT_CTCPUNHANDLEDREQ",
+ "EVENT_CTCPUNHANDLEDREQBC",
"EVENT_DCCSEND",
"EVENT_DCCCHAT",
"EVENT_DCCCHATMSG",
Modified: trunk/src/servers.c
==============================================================================
--- trunk/src/servers.c (original)
+++ trunk/src/servers.c Sat Sep 3 04:21:10 2005
@@ -253,14 +253,14 @@
time_t uptime = s->server->uptime + ( me.now - me.ts_boot );
if( ircd_srv.protocol & PROTOCOL_B64SERVER )
- irc_chanalert( ns_botptr, _( "Server: %s (%s)" ), s->name, s->name64 );
+ irc_prefmsg( ns_botptr, cmdparams->source, _( "Server: %s (%s)" ), s->name, s->name64 );
else
- irc_chanalert( ns_botptr, _( "Server: %s" ), s->name );
- irc_chanalert( ns_botptr, _( "Version: %s" ), s->version );
- irc_chanalert( ns_botptr, _( "Uptime: %ld day%s, %02ld:%02ld:%02ld" ),( uptime / TS_ONE_DAY ),( uptime / TS_ONE_DAY == 1 ) ? "" : "s",( ( uptime / TS_ONE_HOUR ) % 24 ),( ( uptime / TS_ONE_MINUTE ) % TS_ONE_MINUTE ),( uptime % 60 ) );
- irc_chanalert( ns_botptr, _( "Flags: %x" ), s->flags );
- irc_chanalert( ns_botptr, _( "Uplink: %s" ), s->uplink ? s->uplink->name : "" );
- irc_chanalert( ns_botptr, "========================================" );
+ irc_prefmsg( ns_botptr, cmdparams->source, _( "Server: %s" ), s->name );
+ irc_prefmsg( ns_botptr, cmdparams->source, _( "Version: %s" ), s->version );
+ irc_prefmsg( ns_botptr, cmdparams->source, _( "Uptime: %ld day%s, %02ld:%02ld:%02ld" ),( uptime / TS_ONE_DAY ),( uptime / TS_ONE_DAY == 1 ) ? "" : "s",( ( uptime / TS_ONE_HOUR ) % 24 ),( ( uptime / TS_ONE_MINUTE ) % TS_ONE_MINUTE ),( uptime % 60 ) );
+ irc_prefmsg( ns_botptr, cmdparams->source, _( "Flags: %x" ), s->flags );
+ irc_prefmsg( ns_botptr, cmdparams->source, _( "Uplink: %s" ), s->uplink ? s->uplink->name : "" );
+ irc_prefmsg( ns_botptr, cmdparams->source, "========================================" );
return NS_FALSE;
}
@@ -274,9 +274,9 @@
* @return none
*/
-void ListServers( const char *name )
+void ListServers( CmdParams *cmdparams, const char *name )
{
- irc_chanalert( ns_botptr, _( "===============SERVERLIST===============" ) );
+ irc_prefmsg( ns_botptr, cmdparams->source, _( "===============SERVERLIST===============" ) );
if( name )
{
Client *s;
@@ -285,7 +285,7 @@
if( s )
dumpserver( s, NULL );
else
- irc_chanalert( ns_botptr, _( "ListServers: can't find server %s" ), name );
+ irc_prefmsg( ns_botptr, cmdparams->source, _( "ListServers: can't find server %s" ), name );
return;
}
ProcessServerList( dumpserver, NULL );
Modified: trunk/src/services.c
==============================================================================
--- trunk/src/services.c (original)
+++ trunk/src/services.c Sat Sep 3 04:21:10 2005
@@ -40,6 +40,7 @@
#include "services.h"
#include "bans.h"
+/* Command function prototypes */
static int ns_cmd_shutdown( CmdParams *cmdparams );
static int ns_cmd_reload( CmdParams *cmdparams );
static int ns_cmd_jupe( CmdParams *cmdparams );
@@ -95,7 +96,7 @@
};
/** Bot comand table */
-static bot_cmd ns_commands[]=
+static bot_cmd ns_commands[] =
{
{"LEVEL", ns_cmd_level, 0, 0, ns_help_level},
{"STATUS", ns_cmd_status, 0, 0, ns_help_status},
@@ -122,14 +123,14 @@
};
/** Bot setting table */
-static bot_setting ns_settings[]=
+static bot_setting ns_settings[] =
{
{"MSGSAMPLETIME", &nsconfig.msgsampletime, SET_TYPE_INT, 1, 100, NS_ULEVEL_ADMIN, NULL, ns_help_set_msgsampletime, NULL,( void * )10 },
{"MSGTHRESHOLD", &nsconfig.msgthreshold, SET_TYPE_INT, 1, 100, NS_ULEVEL_ADMIN, NULL, ns_help_set_msgthreshold, NULL,( void * )5 },
{"SPLITTIME", &nsconfig.splittime, SET_TYPE_INT, 0, 1000, NS_ULEVEL_ADMIN, NULL, ns_help_set_splittime, NULL,( void * )300 },
{"JOINSERVICESCHAN",&nsconfig.joinserviceschan, SET_TYPE_BOOLEAN, 0, 0, NS_ULEVEL_ADMIN, NULL, ns_help_set_joinserviceschan, NULL,( void* )1 },
{"PINGTIME", &nsconfig.pingtime, SET_TYPE_INT, 0, 0, NS_ULEVEL_ADMIN, NULL, ns_help_set_pingtime, NULL,( void* )120 },
- {"VERSIONSCAN", &me.versionscan, SET_TYPE_BOOLEAN, 0, 0, NS_ULEVEL_ADMIN, NULL, ns_help_set_versionscan, NULL,( void* )1 },
+ {"VERSIONSCAN", &me.versionscan, SET_TYPE_BOOLEAN, 0, 0, NS_ULEVEL_ADMIN, NULL, ns_help_set_versionscan, NULL,( void* )1 },
{"SERVICECMODE", me.servicescmode, SET_TYPE_STRING, 0, MODESIZE, NS_ULEVEL_ADMIN, NULL, ns_help_set_servicecmode, NULL, NULL },
{"SERVICEUMODE", me.servicesumode, SET_TYPE_STRING, 0, MODESIZE, NS_ULEVEL_ADMIN, NULL, ns_help_set_serviceumode, NULL, NULL },
{"CMDCHAR", nsconfig.cmdchar, SET_TYPE_STRING, 0, 2, NS_ULEVEL_ADMIN, NULL, ns_help_set_cmdchar, NULL,( void* )"!" },
@@ -140,7 +141,8 @@
NS_SETTING_END()
};
-static bot_setting ns_debugsettings[]=
+/** Bot debug setting table */
+static bot_setting ns_debugsettings[] =
{
#ifndef DEBUG
{"DEBUG", &nsconfig.debug, SET_TYPE_BOOLEAN, 0, 0, NS_ULEVEL_ADMIN, NULL, ns_help_set_debug, NULL,( void* )0 },
@@ -154,19 +156,23 @@
/** Bot pointer */
Bot* ns_botptr = NULL;
-BotInfo ns_botinfo = {
+/** Core bot info */
+BotInfo ns_botinfo =
+{
"NeoStats",
"NeoStats1",
"Neo",
BOT_COMMON_HOST,
- "",
+ "/msg NeoStats \2HELP\2",
/* 0x80000000 is a "hidden" flag to identify the core bot */
0x80000000|BOT_FLAG_ONLY_OPERS|BOT_FLAG_SERVICEBOT|BOT_FLAG_DEAF,
ns_commands,
ns_settings,
};
-ModuleEvent neostats_events[] = {
+/** Core event table */
+ModuleEvent neostats_events[] =
+{
{EVENT_CTCPVERSIONRPL, services_event_ctcpversion, EVENT_FLAG_IGNORE_SYNCH},
{EVENT_NULL, NULL}
};
@@ -175,13 +181,16 @@
*
* NeoStats CTCP VERSION reply event handler
*
- * @return none
+ * @param cmdparams structure with command information
+ *
+ * @return none
*/
+
static int services_event_ctcpversion( CmdParams *cmdparams )
{
dlog(DEBUG1, "Got Version reply event in services.c from %s: %s", cmdparams->source->name, cmdparams->param);
strlcpy( cmdparams->source->version, cmdparams->param, MAXHOST );
- SendAllModuleEvent( EVENT_CTCPVERSIONRPL, cmdparams );
+ SendAllModuleEvent( EVENT_CTCPVERSIONRPLBC, cmdparams );
return NS_SUCCESS;
}
@@ -189,8 +198,11 @@
*
* init NeoStats core
*
+ * @param none
+ *
* @return none
*/
+
void InitServices( void )
{
ModuleConfig( ns_settings );
@@ -200,8 +212,11 @@
*
* fini NeoStats core
*
+ * @param none
+ *
* @return none
*/
+
void FiniServices( void )
{
FreeEventList( &ns_module );
@@ -211,8 +226,11 @@
*
* init NeoStats bot
*
- * @return none
+ * @param none
+ *
+ * @return NS_SUCCESS if succeeds, NS_FAILURE if not
*/
+
int init_services_bot( void )
{
SET_SEGV_LOCATION();
@@ -232,13 +250,16 @@
return NS_SUCCESS;
}
-/** @brief SHUTDOWN command handler
+/** @brief ns_cmd_shutdown
*
+ * SHUTDOWN command handler
* Shutdown NeoStats
*
* @param cmdparams structure with command information
- * @returns none
+ *
+ * @return NS_SUCCESS if succeeds, NS_FAILURE if not
*/
+
static int ns_cmd_shutdown( CmdParams *cmdparams )
{
char *message;
@@ -255,13 +276,16 @@
return NS_SUCCESS;
}
-/** @brief RELOAD command handler
+/** @brief ns_cmd_reload
*
+ * RELOAD command handler
* Reload NeoStats
*
* @param cmdparams structure with command information
- * @returns none
+ *
+ * @return NS_SUCCESS if succeeds, NS_FAILURE if not
*/
+
static int ns_cmd_reload( CmdParams *cmdparams )
{
char *message;
@@ -278,13 +302,16 @@
return NS_SUCCESS;
}
-/** @brief JUPE command handler
+/** @brief ns_cmd_jupe
*
+ * JUPE command handler
* Jupiter a server
*
* @param cmdparams structure with command information
- * @returns none
+ *
+ * @return NS_SUCCESS if succeeds, NS_FAILURE if not
*/
+
static int ns_cmd_jupe( CmdParams *cmdparams )
{
static char infoline[255];
@@ -298,13 +325,16 @@
return NS_SUCCESS;
}
-/** @brief USERLIST command handler
+/** @brief ns_cmd_userlist
*
+ * USERLIST command handler
* Dump user list
*
* @param cmdparams structure with command information
- * @returns none
+ *
+ * @return NS_SUCCESS if succeeds, NS_FAILURE if not
*/
+
static int ns_cmd_userlist( CmdParams *cmdparams )
{
SET_SEGV_LOCATION();
@@ -312,17 +342,20 @@
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] );
+ ListUsers( cmdparams, ( cmdparams->ac < 1 ) ? NULL : cmdparams->av[0] );
return NS_SUCCESS;
}
-/** @brief SERVERLIST command handler
+/** @brief ns_cmd_serverlist
*
+ * SERVERLIST command handler
* Dump server list
*
* @param cmdparams structure with command information
- * @returns none
+ *
+ * @return NS_SUCCESS if succeeds, NS_FAILURE if not
*/
+
static int ns_cmd_serverlist( CmdParams *cmdparams )
{
SET_SEGV_LOCATION();
@@ -330,17 +363,20 @@
irc_prefmsg( ns_botptr, cmdparams->source, __( "\2Error:\2 debug mode disabled", cmdparams->source ) );
return NS_FAILURE;
}
- ListServers(( cmdparams->ac < 1 )? NULL : cmdparams->av[0] );
+ ListServers( cmdparams, ( cmdparams->ac < 1 ) ? NULL : cmdparams->av[0] );
return NS_SUCCESS;
}
-/** @brief CHANNELLIST command handler
+/** @brief ns_cmd_channellist
*
+ * CHANNELLIST command handler
* Dump channel list
*
* @param cmdparams structure with command information
- * @returns none
+ *
+ * @return NS_SUCCESS if succeeds, NS_FAILURE if not
*/
+
static int ns_cmd_channellist( CmdParams *cmdparams )
{
SET_SEGV_LOCATION();
@@ -348,17 +384,20 @@
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] );
+ ListChannels( cmdparams, ( cmdparams->ac < 1 ) ? NULL : cmdparams->av[0] );
return NS_SUCCESS;
}
-/** @brief USERLIST command handler
+/** @brief ns_cmd_banlist
*
- * Dump user list
+ * BANLIST command handler
+ * Dump ban list
*
* @param cmdparams structure with command information
- * @returns none
+ *
+ * @return NS_SUCCESS if succeeds, NS_FAILURE if not
*/
+
static int ns_cmd_banlist( CmdParams *cmdparams )
{
SET_SEGV_LOCATION();
@@ -370,13 +409,16 @@
return NS_SUCCESS;
}
-/** @brief STATUS command handler
+/** @brief ns_cmd_status
*
+ * STATUS command handler
* Display NeoStats status
*
* @param cmdparams structure with command information
- * @returns none
+ *
+ * @return NS_SUCCESS if succeeds, NS_FAILURE if not
*/
+
static int ns_cmd_status( CmdParams *cmdparams )
{
time_t uptime = me.now - me.ts_boot;
@@ -406,13 +448,16 @@
return NS_SUCCESS;
}
-/** @brief LEVEL command handler
+/** @brief ns_cmd_level
*
+ * LEVEL command handler
* Display user level
*
* @param cmdparams structure with command information
- * @returns none
+ *
+ * @return NS_SUCCESS if succeeds, NS_FAILURE if not
*/
+
static int ns_cmd_level( CmdParams *cmdparams )
{
SET_SEGV_LOCATION();
@@ -434,13 +479,16 @@
return NS_SUCCESS;
}
-/** @brief LOAD command handler
+/** @brief ns_cmd_load
*
+ * LOAD command handler
* Load module
*
* @param cmdparams structure with command information
- * @returns none
+ *
+ * @return NS_SUCCESS if succeeds, NS_FAILURE if not
*/
+
static int ns_cmd_load( CmdParams *cmdparams )
{
SET_SEGV_LOCATION();
@@ -451,13 +499,16 @@
return NS_SUCCESS;
}
-/** @brief UNLOAD command handler
+/** @brief ns_cmd_unload
*
+ * UNLOAD command handler
* Unload module
*
* @param cmdparams structure with command information
- * @returns none
+ *
+ * @return NS_SUCCESS if succeeds, NS_FAILURE if not
*/
+
static int ns_cmd_unload( CmdParams *cmdparams )
{
SET_SEGV_LOCATION();
@@ -467,13 +518,15 @@
}
#ifdef USE_RAW
-/** @brief RAW command handler
+/** @brief ns_cmd_raw
*
- * issue a RAW command
+ * RAW command handler
*
* @param cmdparams structure with command information
- * @returns none
+ *
+ * @return NS_SUCCESS if succeeds, NS_FAILURE if not
*/
+
static int ns_cmd_raw( CmdParams *cmdparams )
{
char *message;
Modified: trunk/src/users.c
==============================================================================
--- trunk/src/users.c (original)
+++ trunk/src/users.c Sat Sep 3 04:21:10 2005
@@ -647,10 +647,7 @@
{
strlcpy( u->user->vhost, vhost, MAXHOST );
ircsnprintf( u->user->uservhostmask, USERHOSTLEN, "%s!%s@%s", nick, u->user->username, vhost );
- /* sethost on Unreal doesn't send +xt, but /umode +x sends +x
- * so, we will never be 100% sure about +t
- */
- if( ircd_srv.features&FEATURE_UMODECLOAK )
+ if( ircd_srv.features & FEATURE_UMODECLOAK )
u->user->Umode |= UMODE_HIDE;
}
}