Commit Diff


commit - a02bf31d50743df9196310f4261fc09964347fbc
commit + 17f7c6d3edf26e644b98e2b11fd3b1959ac8c0e6
blob - 9a48194483ad1e543cecb20e403454eb8689bd50
blob + ac24dbf985f2c5b5f215e321099ceca158e66d01
--- src/ngircd/parse.c
+++ src/ngircd/parse.c
@@ -14,7 +14,7 @@
 
 #include "portab.h"
 
-static char UNUSED id[] = "$Id: parse.c,v 1.51 2002/12/12 12:24:18 alex Exp $";
+static char UNUSED id[] = "$Id: parse.c,v 1.52 2002/12/18 13:53:20 alex Exp $";
 
 #include "imp.h"
 #include <assert.h>
@@ -48,60 +48,51 @@ static char UNUSED id[] = "$Id: parse.c,v 1.51 2002/12
 #include "exp.h"
 
 
-typedef struct _COMMAND
-{
-	CHAR *name;		/* Name des Befehls */
-	BOOLEAN (*function)( CLIENT *Client, REQUEST *Request );
-	CLIENT_TYPE type;	/* Erlaubte Client-Typen (Bitmaske) */
-	LONG count;		/* Anzahl der Aufrufe */
-} COMMAND;
-
-
 COMMAND My_Commands[] =
 {
-	{ "ADMIN", IRC_ADMIN, CLIENT_USER|CLIENT_SERVER, 0 },
-	{ "AWAY", IRC_AWAY, CLIENT_USER, 0 },
-	{ "CONNECT", IRC_CONNECT, CLIENT_USER, 0 },
-	{ "DIE", IRC_DIE, CLIENT_USER, 0 },
-	{ "ERROR", IRC_ERROR, 0xFFFF, 0 },
-	{ "INVITE", IRC_INVITE, CLIENT_USER|CLIENT_SERVER, 0 },
-	{ "ISON", IRC_ISON, CLIENT_USER, 0 },
-	{ "JOIN", IRC_JOIN, CLIENT_USER|CLIENT_SERVER, 0 },
-	{ "KICK", IRC_KICK, CLIENT_USER|CLIENT_SERVER, 0 },
-	{ "KILL", IRC_KILL, CLIENT_USER|CLIENT_SERVER, 0 },
-	{ "LINKS", IRC_LINKS, CLIENT_USER|CLIENT_SERVER, 0 },
-	{ "LIST", IRC_LIST, CLIENT_USER|CLIENT_SERVER, 0 },
-	{ "LUSERS", IRC_LUSERS, CLIENT_USER|CLIENT_SERVER, 0 },
-	{ "MODE", IRC_MODE, CLIENT_USER|CLIENT_SERVER, 0 },
-	{ "MOTD", IRC_MOTD, CLIENT_USER|CLIENT_SERVER, 0 },
-	{ "NAMES", IRC_NAMES, CLIENT_USER|CLIENT_SERVER, 0 },
-	{ "NICK", IRC_NICK, 0xFFFF, 0 },
-	{ "NJOIN", IRC_NJOIN, CLIENT_SERVER, 0 },
-	{ "NOTICE", IRC_NOTICE, 0xFFFF, 0 },
-	{ "OPER", IRC_OPER, CLIENT_USER, 0 },
-	{ "PART", IRC_PART, CLIENT_USER|CLIENT_SERVER, 0 },
-	{ "PASS", IRC_PASS, 0xFFFF, 0 },
-	{ "PING", IRC_PING, CLIENT_USER|CLIENT_SERVER, 0 },
-	{ "PONG", IRC_PONG, CLIENT_USER|CLIENT_SERVER, 0 },
-	{ "PRIVMSG", IRC_PRIVMSG, CLIENT_USER|CLIENT_SERVER, 0 },
-	{ "QUIT", IRC_QUIT, 0xFFFF, 0 },
-	{ "REHASH", IRC_REHASH, CLIENT_USER, 0 },
-	{ "RESTART", IRC_RESTART, CLIENT_USER, 0 },
-	{ "SERVER", IRC_SERVER, 0xFFFF, 0 },
-	{ "SQUIT", IRC_SQUIT, CLIENT_SERVER, 0 },
-	{ "STATS", IRC_STATS, CLIENT_USER|CLIENT_SERVER, 0 },
-	{ "TIME", IRC_TIME, CLIENT_USER|CLIENT_SERVER, 0 },
-	{ "TOPIC", IRC_TOPIC, CLIENT_USER|CLIENT_SERVER, 0 },
-	{ "USER", IRC_USER, 0xFFFF, 0 },
-	{ "USERHOST", IRC_USERHOST, CLIENT_USER, 0 },
-	{ "VERSION", IRC_VERSION, CLIENT_USER|CLIENT_SERVER, 0 },
-	{ "WHO", IRC_WHO, CLIENT_USER, 0 },
-	{ "WHOIS", IRC_WHOIS, CLIENT_USER|CLIENT_SERVER, 0 },
-	{ "WHOWAS", IRC_WHOWAS, CLIENT_USER|CLIENT_SERVER, 0 },
-#ifdef IRCPLUS
-	{ "CHANINFO", IRC_CHANINFO, CLIENT_SERVER, 0 },
+	{ "ADMIN", IRC_ADMIN, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
+	{ "AWAY", IRC_AWAY, CLIENT_USER, 0, 0, 0 },
+	{ "CONNECT", IRC_CONNECT, CLIENT_USER, 0, 0, 0 },
+	{ "DIE", IRC_DIE, CLIENT_USER, 0, 0, 0 },
+	{ "ERROR", IRC_ERROR, 0xFFFF, 0, 0, 0 },
+	{ "INVITE", IRC_INVITE, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
+	{ "ISON", IRC_ISON, CLIENT_USER, 0, 0, 0 },
+	{ "JOIN", IRC_JOIN, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
+	{ "KICK", IRC_KICK, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
+	{ "KILL", IRC_KILL, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
+	{ "LINKS", IRC_LINKS, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
+	{ "LIST", IRC_LIST, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
+	{ "LUSERS", IRC_LUSERS, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
+	{ "MODE", IRC_MODE, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
+	{ "MOTD", IRC_MOTD, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
+	{ "NAMES", IRC_NAMES, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
+	{ "NICK", IRC_NICK, 0xFFFF, 0, 0, 0 },
+	{ "NJOIN", IRC_NJOIN, CLIENT_SERVER, 0, 0, 0 },
+	{ "NOTICE", IRC_NOTICE, 0xFFFF, 0, 0, 0 },
+	{ "OPER", IRC_OPER, CLIENT_USER, 0, 0, 0 },
+	{ "PART", IRC_PART, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
+	{ "PASS", IRC_PASS, 0xFFFF, 0, 0, 0 },
+	{ "PING", IRC_PING, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
+	{ "PONG", IRC_PONG, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
+	{ "PRIVMSG", IRC_PRIVMSG, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
+	{ "QUIT", IRC_QUIT, 0xFFFF, 0, 0, 0 },
+	{ "REHASH", IRC_REHASH, CLIENT_USER, 0, 0, 0 },
+	{ "RESTART", IRC_RESTART, CLIENT_USER, 0, 0, 0 },
+	{ "SERVER", IRC_SERVER, 0xFFFF, 0, 0, 0 },
+	{ "SQUIT", IRC_SQUIT, CLIENT_SERVER, 0, 0, 0 },
+	{ "STATS", IRC_STATS, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
+	{ "TIME", IRC_TIME, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
+	{ "TOPIC", IRC_TOPIC, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
+	{ "USER", IRC_USER, 0xFFFF, 0, 0, 0 },
+	{ "USERHOST", IRC_USERHOST, CLIENT_USER, 0, 0, 0 },
+	{ "VERSION", IRC_VERSION, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
+	{ "WHO", IRC_WHO, CLIENT_USER, 0, 0, 0 },
+	{ "WHOIS", IRC_WHOIS, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
+	{ "WHOWAS", IRC_WHOWAS, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
+#ifdef IRCPLUS
+	{ "CHANINFO", IRC_CHANINFO, CLIENT_SERVER, 0, 0, 0 },
 #endif
-	{ NULL, NULL, 0 } /* Ende-Marke */
+	{ NULL, NULL, 0x0, 0, 0, 0 } /* Ende-Marke */
 };
 
 
@@ -114,6 +105,13 @@ LOCAL BOOLEAN Validate_Args PARAMS(( CONN_ID Idx, REQU
 LOCAL BOOLEAN Handle_Request PARAMS(( CONN_ID Idx, REQUEST *Req ));
 
 
+GLOBAL COMMAND *
+Parse_GetCommandStruct( VOID )
+{
+	return My_Commands;
+} /* Parse_GetCommandStruct */
+
+
 GLOBAL BOOLEAN
 Parse_Request( CONN_ID Idx, CHAR *Request )
 {
@@ -317,6 +315,7 @@ Handle_Request( CONN_ID Idx, REQUEST *Req )
 
 	CLIENT *client, *target, *prefix;
 	CHAR str[LINE_LEN];
+	BOOLEAN result;
 	COMMAND *cmd;
 	INT i;
 
@@ -382,10 +381,16 @@ Handle_Request( CONN_ID Idx, REQUEST *Req )
 
 		if( Client_Type( client ) & cmd->type )
 		{
-			/* Der Befehl ist fuer diesen Client-Typ erlaubt.
-			 * Entsprechende Funktion zaehlen nun aufrufen: */
-			cmd->count++;
-			return (cmd->function)( client, Req );
+			/* Command is allowed for this client: call it and count produced bytes */
+			Conn_ResetWCounter( );
+			result = (cmd->function)( client, Req );
+			cmd->bytes += Conn_WCounter( );
+
+			/* Adjust counters */
+			if( Client_Type( client ) != CLIENT_SERVER ) cmd->lcount++;
+			else cmd->rcount++;
+
+			return result;
 		}
 		else
 		{
blob - 6c252b153caf2d7408bbfab9656c0c771eb9ddcd
blob + 0ace285631cb260430d561fd1e5b37d69facbefd
--- src/ngircd/parse.h
+++ src/ngircd/parse.h
@@ -8,7 +8,7 @@
  * (at your option) any later version.
  * Please read the file COPYING, README and AUTHORS for more information.
  *
- * $Id: parse.h,v 1.8 2002/12/12 12:23:43 alex Exp $
+ * $Id: parse.h,v 1.9 2002/12/18 13:53:20 alex Exp $
  *
  * IRC command parser and validator (header)
  */
@@ -27,9 +27,21 @@ typedef struct _REQUEST			/* vgl. RFC 2812, 2.3 */
 } REQUEST;
 
 
+typedef struct _COMMAND
+{
+	CHAR *name;		/* command name */
+	BOOLEAN (*function)( CLIENT *Client, REQUEST *Request );
+	CLIENT_TYPE type;	/* valid client types (bit mask) */
+	LONG lcount, rcount;	/* number of local and remote calls */
+	LONG bytes;		/* number of bytes created */
+} COMMAND;
+
+
 GLOBAL BOOLEAN Parse_Request PARAMS((CONN_ID Idx, CHAR *Request ));
 
+GLOBAL COMMAND *Parse_GetCommandStruct PARAMS(( VOID ));
 
+
 #endif