/*
* ngIRCd -- The Next Generation IRC Daemon
- * Copyright (c)2001-2005 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
#include "portab.h"
-static char UNUSED id[] = "$Id: irc-write.c,v 1.21 2006/08/12 11:56:24 fw Exp $";
-
#include "imp.h"
#include <assert.h>
#ifdef PROTOTYPES
vsnprintf( buffer, 1000, Format, ap );
va_end( ap );
- /* an den Client selber */
+ /* to the client itself */
ok = IRC_WriteStrClientPrefix( Client, Client_ThisServer( ), "%s", buffer );
return ok;
va_dcl
#endif
{
- /* Text an Clients, lokal bzw. remote, senden. */
+ /* send text to local and remote clients */
char buffer[1000];
va_list ap;
} /* IRC_WriteStrChannel */
+
+/**
+ * send message to all clients in the same channel, but only send message
+ * once per remote server.
+ */
#ifdef PROTOTYPES
GLOBAL bool
IRC_WriteStrChannelPrefix( CLIENT *Client, CHANNEL *Chan, CLIENT *Prefix, bool Remote, char *Format, ... )
Conn_ClearFlags( );
- /* An alle Clients, die in den selben Channels sind.
- * Dabei aber nur einmal je Remote-Server */
cl2chan = Channel_FirstMember( Chan );
while( cl2chan )
{
if( c && ( c != Client ))
{
- /* Ok, anderer Client */
+ /* Ok, another Client */
conn = Client_Conn( c );
if( Client_Type( c ) == CLIENT_SERVER ) Conn_SetFlag( conn, SEND_TO_SERVER );
else Conn_SetFlag( conn, SEND_TO_USER );
cl2chan = Channel_NextMember( Chan, cl2chan );
}
- /* Senden: alle Verbindungen durchgehen ... */
conn = Conn_First( );
while( conn != NONE )
{
- /* muessen Daten ueber diese Verbindung verschickt werden? */
+ /* do we need to send data via this connection? */
if( Conn_Flag( conn ) == SEND_TO_SERVER) ok = Conn_WriteStr( conn, ":%s %s", Client_ID( Prefix ), buffer );
else if( Conn_Flag( conn ) == SEND_TO_USER ) ok = Conn_WriteStr( conn, ":%s %s", Client_Mask( Prefix ), buffer );
if( ! ok ) break;
- /* naechste Verbindung testen */
conn = Conn_Next( conn );
}
vsnprintf( buffer, 1000, Format, ap );
va_end( ap );
- /* an den Client selber */
IRC_WriteStrServersPrefix( ExceptOf, Client_ThisServer( ), "%s", buffer );
} /* IRC_WriteStrServers */
} /* IRC_WriteStrServersPrefixFlag */
+/**
+ * send message to all clients that are in the same channels as the client sending this message.
+ * only send message once per reote server.
+ */
#ifdef PROTOTYPES
GLOBAL bool
IRC_WriteStrRelatedPrefix( CLIENT *Client, CLIENT *Prefix, bool Remote, char *Format, ... )
vsnprintf( buffer, 1000, Format, ap );
va_end( ap );
- /* initialisieren */
Conn_ClearFlags( );
- /* An alle Clients, die in einem Channel mit dem "Ausloeser" sind,
- * den Text schicken. An Remote-Server aber jeweils nur einmal. */
chan_cl2chan = Channel_FirstChannelOf( Client );
while( chan_cl2chan )
{
- /* Channel des Users durchsuchen */
chan = Channel_GetChannel( chan_cl2chan );
cl2chan = Channel_FirstMember( chan );
while( cl2chan )
if( c && ( c != Client ))
{
- /* Ok, anderer Client */
conn = Client_Conn( c );
if( Client_Type( c ) == CLIENT_SERVER ) Conn_SetFlag( conn, SEND_TO_SERVER );
else Conn_SetFlag( conn, SEND_TO_USER );
cl2chan = Channel_NextMember( chan, cl2chan );
}
- /* naechsten Channel */
chan_cl2chan = Channel_NextChannelOf( Client, chan_cl2chan );
}
- /* Senden: alle Verbindungen durchgehen ... */
conn = Conn_First( );
while( conn != NONE )
{
- /* muessen ueber diese Verbindung Daten gesendet werden? */
+ /* send data via this connection? */
if( Conn_Flag( conn ) == SEND_TO_SERVER ) ok = Conn_WriteStr( conn, ":%s %s", Client_ID( Prefix ), buffer );
else if( Conn_Flag( conn ) == SEND_TO_USER ) ok = Conn_WriteStr( conn, ":%s %s", Client_Mask( Prefix ), buffer );
if( ! ok ) break;
- /* naechste Verbindung testen */
conn = Conn_Next( conn );
}
return ok;
} /* IRC_WriteStrRelatedPrefix */
+/**
+ * Send WALLOPS message.
+ */
+#ifdef PROTOTYPES
+GLOBAL void
+IRC_SendWallops(CLIENT *Client, CLIENT *From, const char *Format, ...)
+#else
+GLOBAL void
+IRC_SendWallops(Client, From, Format, va_alist )
+CLIENT *Client;
+CLIENT *From;
+char *Format;
+va_dcl
+#endif
+{
+ va_list ap;
+ char msg[1000];
+ CLIENT *to;
+
+#ifdef PROTOTYPES
+ va_start(ap, Format);
+#else
+ va_start(ap);
+#endif
+ vsnprintf(msg, 1000, Format, ap);
+ va_end(ap);
+
+ for (to=Client_First(); to != NULL; to=Client_Next(to)) {
+ if (Client_Conn(to) == NONE) /* no local connection */
+ continue;
+
+ switch (Client_Type(to)) {
+ case CLIENT_USER:
+ if (Client_HasMode(to, 'w'))
+ IRC_WriteStrClientPrefix(to, From,
+ "WALLOPS :%s", msg);
+ break;
+ case CLIENT_SERVER:
+ if (to != Client)
+ IRC_WriteStrClientPrefix(to, From,
+ "WALLOPS :%s", msg);
+ break;
+ }
+ }
+} /* IRC_SendWallops */
+
+
GLOBAL void
IRC_SetPenalty( CLIENT *Client, time_t Seconds )
{