[NeoStats-Devel] [Commits] r2714 - in trunk: . include modules/connectserv
[email protected] Sat, 13 Aug 2005 21:31:07 +1000
| Newsgroups | gmane.comp.neostats.devel |
|---|---|
| Message-ID | <[email protected]> |
Author: Fish
Date: Sat Aug 13 19:30:59 2005
New Revision: 2714
Modified:
trunk/ChangeLog
trunk/include/ircprotocol.h
trunk/modules/connectserv/cs.c
trunk/modules/connectserv/cs.h
trunk/modules/connectserv/cs_help.c
Log:
make connectserv colour logging configurable at runtime
Modified: trunk/ChangeLog
==============================================================================
--- trunk/ChangeLog (original)
+++ trunk/ChangeLog Sat Aug 13 19:30:59 2005
@@ -4,6 +4,7 @@
Fish (F), Mark (M), DeadNotBuried (D)
===============================================================================
* NeoStats * Version 3.0.a3-dev
+ - ConnectServ colour logging is now settable via IRC (F)
- First round of memory cleanups with Valgrind (F)
- Create a runvalgrind.sh file with NeoStats suppressions for memory
checking (F)
Modified: trunk/include/ircprotocol.h
==============================================================================
--- trunk/include/ircprotocol.h (original)
+++ trunk/include/ircprotocol.h Sat Aug 13 19:30:59 2005
@@ -24,6 +24,7 @@
#define _IRCPROTOCOL_H_
int InitIrcd( void );
+int FiniIrcd( void );
int irc_connect( const char *name, const int numeric, const char *infoline, const char *pass, const unsigned long tsboot, const unsigned long tslink );
int irc_nick( const char *nick, const char *user, const char *host, const char *realname, const char *modes );
int irc_server( const char *name, const int numeric, const char *infoline );
Modified: trunk/modules/connectserv/cs.c
==============================================================================
--- trunk/modules/connectserv/cs.c (original)
+++ trunk/modules/connectserv/cs.c Sat Aug 13 19:30:59 2005
@@ -46,36 +46,42 @@
int serv_watch;
int exclusions;
int logging;
+ int colour;
} cs_cfg;
-/** output message and format strings */
-#ifdef ENABLE_COLOUR_SUPPORT
-static char msg_nickchange[] = "\2\0037NICK\2 user: \2%s\2 (%s@%s) changed their nick to \2%s\2\003";
-static char msg_away[] = "\2AWAY\2 %s (%s@%s) is %s away %s";
-static char msg_signon[] = "\2\0034SIGNON\2 user: \2%s\2 (%s@%s %s) at \2%s\2\003";
-static char msg_signoff[] = "\2\0033SIGNOFF\2 user: %s (%s@%s %s) at %s %s\003";
-static char msg_localkill[] = "\2\00312LOCAL KILL\2 user: \2%s\2 (%s@%s) killed by \2%s\2 for \2%s\2\003";
-static char msg_globalkill[] = "\2\00312GLOBAL KILL\2 user: \2%s\2 (%s@%s) killed by \2%s\2 for \2%s\2\003";
-static char msg_serverkill[] = "\2\00312SERVER KILL\2 user: \2%s\2 (%s@%s) killed by \2%s\2 for \2%s\2\003";
-static char msg_mode[] = "\2\00313%s\2 is \2%s\2 a \2%s\2 (%c%c)\003";
-static char msg_mode_serv[] = "\2\00313%s\2 is \2%s\2 a \2%s\2 (%c%c) on \2%s\2\003";
-static char msg_bot[] = "\2\00313%s\2 is \2%s\2 a \2Bot\2 (%c%c)\003";
-static char msg_server[] = "\2SERVER\2 %s joined the network at %s";
-static char msg_squit[] = "\2SERVER\2 %s left the network at %s for %s";
-#else /* ENABLE_COLOUR_SUPPORT */
-static char msg_nickchange[] = "\2NICK\2 %s (%s@%s) changed their nick to %s";
-static char msg_away[] = "\2AWAY\2 %s (%s@%s) is %s away %s";
-static char msg_signon[] = "\2SIGNON\2 %s (%s@%s %s) signed on at %s";
-static char msg_signoff[] = "\2SIGNOFF\2 %s (%s@%s %s) signed off at %s %s";
-static char msg_localkill[] = "\2LOCAL KILL\2 %s (%s@%s) killed by %s for \2%s\2";
-static char msg_globalkill[] = "\2GLOBAL KILL\2 %s (%s@%s) killed by %s for \2%s\2";
-static char msg_serverkill[] = "\2SERVER KILL\2 %s (%s@%s) killed by %s for \2%s\2";
-static char msg_mode[] = "\2MODE\2 %s is %s a %s (%c%c)";
-static char msg_mode_serv[] = "\2MODE\2 %s is %s a %s (%c%c) on %s";
-static char msg_bot[] = "\2BOT\2 %s is %s a Bot (%c%c)";
-static char msg_server[] = "\2SERVER\2 %s joined the network at %s";
-static char msg_squit[] = "\2SERVER\2 %s left the network at %s for %s";
-#endif /* ENABLE_COLOUR_SUPPORT */
+
+typedef struct msg {
+ char colour[BUFSIZE];
+ char nocolour[BUFSIZE];
+} msg;
+
+
+static msg msg_nickchange ={"\2\0037NICK\2 user: \2%s\2 (%s@%s) changed their nick to \2%s\2\003",
+ "\2NICK\2 %s (%s@%s) changed their nick to %s" };
+static msg msg_away = {"\2AWAY\2 %s (%s@%s) is %s away %s",
+ "\2AWAY\2 %s (%s@%s) is %s away %s"};
+static msg msg_signon = {"\2\0034SIGNON\2 user: \2%s\2 (%s@%s %s) at \2%s\2\003",
+ "\2SIGNON\2 %s (%s@%s %s) signed on at %s"};
+static msg msg_signoff ={"\2\0033SIGNOFF\2 user: %s (%s@%s %s) at %s %s\003",
+ "\2SIGNOFF\2 %s (%s@%s %s) signed off at %s %s"};
+static msg msg_localkill = {"\2\00312LOCAL KILL\2 user: \2%s\2 (%s@%s) killed by \2%s\2 for \2%s\2\003",
+ "\2LOCAL KILL\2 %s (%s@%s) killed by %s for \2%s\2"};
+static msg msg_globalkill = {"\2\00312GLOBAL KILL\2 user: \2%s\2 (%s@%s) killed by \2%s\2 for \2%s\2\003",
+ "\2GLOBAL KILL\2 %s (%s@%s) killed by %s for \2%s\2"};
+static msg msg_serverkill = {"\2\00312SERVER KILL\2 user: \2%s\2 (%s@%s) killed by \2%s\2 for \2%s\2\003",
+ "\2SERVER KILL\2 %s (%s@%s) killed by %s for \2%s\2"};
+static msg msg_mode = {"\2\00313%s\2 is \2%s\2 a \2%s\2 (%c%c)\003",
+ "\2MODE\2 %s is %s a %s (%c%c)"};
+static msg msg_mode_serv = {"\2\00313%s\2 is \2%s\2 a \2%s\2 (%c%c) on \2%s\2\003",
+ "\2MODE\2 %s is %s a %s (%c%c) on %s"};
+static msg msg_bot = {"\2\00313BOT\2 %s is \2%s\2 a \2Bot\2 (%c%c)\003",
+ "\2BOT\2 %s is %s a Bot (%c%c)"};
+static msg msg_server = {"\2SERVER\2 %s joined the network at %s",
+ "\2SERVER\2 %s joined the network at %s"};
+static msg msg_squit = {"\2SERVER\2 %s left the network at %s for %s",
+ "\2SERVER\2 %s left the network at %s for %s"};
+
+#define GET_MSG(x) (cs_cfg.colour == 1 ? x.colour : x.nocolour)
/** Bot event function prototypes */
static int cs_event_signon( CmdParams *cmdparams );
@@ -136,7 +142,8 @@
{"AWAYWATCH", &cs_cfg.away_watch, SET_TYPE_BOOLEAN, 0, 0, NS_ULEVEL_ADMIN, NULL, cs_help_set_awaywatch, cs_set_away_watch_cb,( void* )1 },
{"SERVWATCH", &cs_cfg.serv_watch, SET_TYPE_BOOLEAN, 0, 0, NS_ULEVEL_ADMIN, NULL, cs_help_set_servwatch, cs_set_serv_watch_cb,( void* )1 },
{"EXCLUSIONS", &cs_cfg.exclusions, SET_TYPE_BOOLEAN, 0, 0, NS_ULEVEL_ADMIN, NULL, cs_help_set_exclusions, cs_set_exclusions_cb,( void* )1 },
- {"LOGGING", &cs_cfg.logging, SET_TYPE_BOOLEAN, 0, 0, NS_ULEVEL_ADMIN, NULL, cs_help_set_logging, NULL,( void* )1 },
+ {"LOGGING", &cs_cfg.logging, SET_TYPE_BOOLEAN, 0, 0, NS_ULEVEL_ADMIN, NULL, cs_help_set_logging, NULL,( void* )1 },
+ {"COLOUR", &cs_cfg.colour, SET_TYPE_BOOLEAN, 0, 0, NS_ULEVEL_ADMIN, NULL, cs_help_set_colour, NULL,( void* )1 },
{NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL },
};
@@ -260,7 +267,7 @@
{
SET_SEGV_LOCATION();
/* Print Connection Notice */
- cs_report( msg_signon, cmdparams->source->name,
+ cs_report( GET_MSG(msg_signon), cmdparams->source->name,
cmdparams->source->user->username, cmdparams->source->user->hostname,
cmdparams->source->info, cmdparams->source->uplink->name );
return NS_SUCCESS;
@@ -280,7 +287,7 @@
{
SET_SEGV_LOCATION();
/* Print Disconnection Notice */
- cs_report( msg_signoff, cmdparams->source->name,
+ cs_report( GET_MSG(msg_signoff), cmdparams->source->name,
cmdparams->source->user->username, cmdparams->source->user->hostname,
cmdparams->source->info, cmdparams->source->uplink->name,
cmdparams->param );
@@ -300,7 +307,7 @@
static int cs_event_localkill( CmdParams *cmdparams )
{
SET_SEGV_LOCATION();
- cs_report( msg_localkill, cmdparams->target->name,
+ cs_report( GET_MSG(msg_localkill), cmdparams->target->name,
cmdparams->target->user->username, cmdparams->target->user->hostname,
cmdparams->source->name, cmdparams->param );
return NS_SUCCESS;
@@ -319,7 +326,7 @@
static int cs_event_globalkill( CmdParams *cmdparams )
{
SET_SEGV_LOCATION();
- cs_report( msg_globalkill, cmdparams->target->name,
+ cs_report( GET_MSG(msg_globalkill), cmdparams->target->name,
cmdparams->target->user->username, cmdparams->target->user->hostname,
cmdparams->source->name, cmdparams->param );
return NS_SUCCESS;
@@ -338,7 +345,7 @@
static int cs_event_serverkill( CmdParams *cmdparams )
{
SET_SEGV_LOCATION();
- cs_report( msg_serverkill, cmdparams->target->name,
+ cs_report( GET_MSG(msg_serverkill), cmdparams->target->name,
cmdparams->target->user->username, cmdparams->target->user->hostname,
cmdparams->source->name, cmdparams->param );
return NS_SUCCESS;
@@ -357,7 +364,7 @@
{
if( serverflag )
{
- cs_report( msg_mode_serv, u->name,
+ cs_report( GET_MSG(msg_mode_serv), u->name,
add ? "now" : "no longer",
modedesc,
add ? '+' : '-',
@@ -365,7 +372,7 @@
}
else
{
- cs_report( msg_mode, u->name,
+ cs_report( GET_MSG(msg_mode), u->name,
add ? "now" : "no longer",
modedesc,
add ? '+' : '-',
@@ -414,7 +421,7 @@
default:
mask = UmodeCharToMask( *modes );
if( mask & UMODE_BOT )
- cs_report( msg_bot, cmdparams->source->name, add ? "now" : "no longer", add ? '+' : '-', *modes );
+ cs_report( GET_MSG(msg_bot), cmdparams->source->name, add ? "now" : "no longer", add ? '+' : '-', *modes );
else if( OperUmodes & mask )
cs_report_mode( GetUmodeDesc( mask ), IsServerOperMode( mask ), cmdparams->source, mask, add, *modes );
break;
@@ -484,7 +491,7 @@
static int cs_event_nick( CmdParams *cmdparams )
{
SET_SEGV_LOCATION();
- cs_report( msg_nickchange, cmdparams->param,
+ cs_report( GET_MSG(msg_nickchange), cmdparams->param,
cmdparams->source->user->username, cmdparams->source->user->hostname,
cmdparams->source->name );
return NS_SUCCESS;
@@ -503,7 +510,7 @@
static int cs_event_away( CmdParams *cmdparams )
{
SET_SEGV_LOCATION();
- cs_report( msg_away, cmdparams->source->name,
+ cs_report( GET_MSG(msg_away), cmdparams->source->name,
cmdparams->source->user->username, cmdparams->source->user->hostname,
IsAway( cmdparams->source ) ? "now" : "no longer", cmdparams->source->user->awaymsg );
return NS_SUCCESS;
@@ -522,7 +529,7 @@
static int cs_event_server( CmdParams *cmdparams )
{
SET_SEGV_LOCATION();
- cs_report( msg_server, cmdparams->source->name, cmdparams->source->uplink->name );
+ cs_report( GET_MSG(msg_server), cmdparams->source->name, cmdparams->source->uplink->name );
return NS_SUCCESS;
}
@@ -539,7 +546,7 @@
static int cs_event_squit( CmdParams *cmdparams )
{
SET_SEGV_LOCATION();
- cs_report( msg_squit, cmdparams->source->name, cmdparams->source->uplink->name,
+ cs_report( GET_MSG(msg_squit), cmdparams->source->name, cmdparams->source->uplink->name,
cmdparams->param ? cmdparams->param : "reason unknown" );
return NS_SUCCESS;
}
Modified: trunk/modules/connectserv/cs.h
==============================================================================
--- trunk/modules/connectserv/cs.h (original)
+++ trunk/modules/connectserv/cs.h Sat Aug 13 19:30:59 2005
@@ -32,3 +32,4 @@
extern const char *cs_help_set_nickwatch[];
extern const char *cs_help_set_awaywatch[];
extern const char *cs_help_set_servwatch[];
+extern const char *cs_help_set_colour[];
Modified: trunk/modules/connectserv/cs_help.c
==============================================================================
--- trunk/modules/connectserv/cs_help.c (original)
+++ trunk/modules/connectserv/cs_help.c Sat Aug 13 19:30:59 2005
@@ -89,3 +89,10 @@
"Report server joins and quits.",
NULL
};
+
+const char *cs_help_set_colour[] =
+{
+ "COLOUR <ON|OFF>",
+ "Turn on or off Colour reporting.",
+ NULL
+};