Commit Diff


commit - 4f759d811347a578624dde37462b9a056cca0720
commit + f199d637246fcd64ebf44b12ffa89fc1375e0665
blob - 61131b609a0e113dea468819b5caedbc0189ae87
blob + 8239c150cadba6f14a111cf2827b5c641b06730f
--- src/ngircd/irc-write.c
+++ src/ngircd/irc-write.c
@@ -39,7 +39,9 @@ static char UNUSED id[] = "$Id: irc-write.c,v 1.21 200
 #define SEND_TO_SERVER 2
 
 
-static char *Get_Prefix PARAMS(( CLIENT *Target, CLIENT *Client ));
+static char *Get_Prefix PARAMS((CLIENT *Target, CLIENT *Client));
+static void cb_writeStrServersPrefixFlag PARAMS((CLIENT *Client,
+					 CLIENT *Prefix, void *Buffer));
 
 
 #ifdef PROTOTYPES
@@ -187,7 +189,7 @@ va_dcl
 			else if( Client_Type( c ) == CLIENT_SERVER ) c = NULL;
 		}
 		if( c ) c = Client_NextHop( c );
-			
+
 		if( c && ( c != Client ))
 		{
 			/* Ok, anderer Client */
@@ -272,8 +274,8 @@ va_dcl
 
 	IRC_WriteStrServersPrefixFlag( ExceptOf, Prefix, '\0', "%s", buffer );
 } /* IRC_WriteStrServersPrefix */
-	
 
+
 #ifdef PROTOTYPES
 GLOBAL void
 IRC_WriteStrServersPrefixFlag( CLIENT *ExceptOf, CLIENT *Prefix, char Flag, char *Format, ... )
@@ -288,9 +290,8 @@ va_dcl
 #endif
 {
 	char buffer[1000];
-	CLIENT *c;
 	va_list ap;
-	
+
 	assert( Format != NULL );
 	assert( Prefix != NULL );
 
@@ -301,16 +302,27 @@ va_dcl
 #endif
 	vsnprintf( buffer, 1000, Format, ap );
 	va_end( ap );
-	
-	c = Client_First( );
-	while( c )
-	{
-		if(( Client_Type( c ) == CLIENT_SERVER ) && ( Client_Conn( c ) > NONE ) && ( c != Client_ThisServer( )) && ( c != ExceptOf ))
-		{
-			/* Ziel-Server gefunden. Nun noch pruefen, ob Flags stimmen */
-			if(( Flag == '\0' ) || ( strchr( Client_Flags( c ), Flag ) != NULL )) IRC_WriteStrClientPrefix( c, Prefix, "%s", buffer );
+
+	IRC_WriteStrServersPrefixFlag_CB(ExceptOf, Prefix, Flag,
+					 cb_writeStrServersPrefixFlag, buffer);
+} /* IRC_WriteStrServersPrefixFlag */
+
+
+GLOBAL void
+IRC_WriteStrServersPrefixFlag_CB(CLIENT *ExceptOf, CLIENT *Prefix, char Flag,
+		void (*callback)(CLIENT *, CLIENT *, void *), void *cb_data)
+{
+	CLIENT *c;
+
+	c = Client_First();
+	while(c) {
+		if (Client_Type(c) == CLIENT_SERVER && Client_Conn(c) > NONE &&
+		    c != Client_ThisServer() && c != ExceptOf) {
+			/* Found a target server, do the flags match? */
+			if (Flag == '\0' || strchr(Client_Flags(c), Flag))
+				callback(c, Prefix, cb_data);
 		}
-		c = Client_Next( c );
+		c = Client_Next(c);
 	}
 } /* IRC_WriteStrServersPrefixFlag */
 
@@ -426,4 +438,11 @@ Get_Prefix( CLIENT *Target, CLIENT *Client )
 } /* Get_Prefix */
 
 
+static void
+cb_writeStrServersPrefixFlag(CLIENT *Client, CLIENT *Prefix, void *Buffer)
+{
+	IRC_WriteStrClientPrefix(Client, Prefix, "%s", Buffer);
+} /* cb_writeStrServersPrefixFlag */
+
+
 /* -eof- */
blob - 40169b19117b67011878ecb5bda6cc753806034b
blob + 51c8f0c2b72fff27f371101d7792f4d19468fbc8
--- src/ngircd/irc-write.h
+++ src/ngircd/irc-write.h
@@ -1,6 +1,6 @@
 /*
  * ngIRCd -- The Next Generation IRC Daemon
- * Copyright (c)2001,2002 by Alexander Barton (alex@barton.de)
+ * Copyright (c)2001-2008 Alexander Barton (alex@barton.de)
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -8,32 +8,35 @@
  * (at your option) any later version.
  * Please read the file COPYING, README and AUTHORS for more information.
  *
- * $Id: irc-write.h,v 1.8 2006/05/10 21:24:01 alex Exp $
- *
  * Sending IRC commands over the network (header)
  */
 
-
 #ifndef __irc_write_h__
 #define __irc_write_h__
 
+GLOBAL bool IRC_WriteStrClient PARAMS((CLIENT *Client, char *Format, ...));
+GLOBAL bool IRC_WriteStrClientPrefix PARAMS((CLIENT *Client, CLIENT *Prefix,
+		char *Format, ...));
 
-GLOBAL bool IRC_WriteStrClient PARAMS(( CLIENT *Client, char *Format, ... ));
-GLOBAL bool IRC_WriteStrClientPrefix PARAMS(( CLIENT *Client, CLIENT *Prefix, char *Format, ... ));
+GLOBAL bool IRC_WriteStrChannel PARAMS((CLIENT *Client, CHANNEL *Chan,
+		bool Remote, char *Format, ...));
+GLOBAL bool IRC_WriteStrChannelPrefix PARAMS((CLIENT *Client, CHANNEL *Chan,
+		CLIENT *Prefix, bool Remote, char *Format, ...));
 
-GLOBAL bool IRC_WriteStrChannel PARAMS(( CLIENT *Client, CHANNEL *Chan, bool Remote, char *Format, ... ));
-GLOBAL bool IRC_WriteStrChannelPrefix PARAMS(( CLIENT *Client, CHANNEL *Chan, CLIENT *Prefix, bool Remote, char *Format, ... ));
+GLOBAL void IRC_WriteStrServers PARAMS((CLIENT *ExceptOf, char *Format, ...));
+GLOBAL void IRC_WriteStrServersPrefix PARAMS((CLIENT *ExceptOf, CLIENT *Prefix,
+		char *Format, ...));
+GLOBAL void IRC_WriteStrServersPrefixFlag PARAMS((CLIENT *ExceptOf,
+		CLIENT *Prefix, char Flag, char *Format, ...));
+GLOBAL void IRC_WriteStrServersPrefixFlag_CB PARAMS((CLIENT *ExceptOf,
+		CLIENT *Prefix, char Flag,
+		void (*callback)(CLIENT *, CLIENT *, void *), void *cb_data));
 
-GLOBAL void IRC_WriteStrServers PARAMS(( CLIENT *ExceptOf, char *Format, ... ));
-GLOBAL void IRC_WriteStrServersPrefix PARAMS(( CLIENT *ExceptOf, CLIENT *Prefix, char *Format, ... ));
-GLOBAL void IRC_WriteStrServersPrefixFlag PARAMS(( CLIENT *ExceptOf, CLIENT *Prefix, char Flag, char *Format, ... ));
+GLOBAL bool IRC_WriteStrRelatedPrefix PARAMS((CLIENT *Client, CLIENT *Prefix,
+		bool Remote, char *Format, ...));
 
-GLOBAL bool IRC_WriteStrRelatedPrefix PARAMS(( CLIENT *Client, CLIENT *Prefix, bool Remote, char *Format, ... ));
+GLOBAL void IRC_SetPenalty PARAMS((CLIENT *Client, time_t Seconds));
 
-GLOBAL void IRC_SetPenalty PARAMS(( CLIENT *Client, time_t Seconds ));
-
-
 #endif
 
-
 /* -eof- */