* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* Please read the file COPYING, README and AUTHORS for more information.
- *
- * Sending IRC commands over the network
*/
-
#include "portab.h"
+/**
+ * @file
+ * Sending IRC commands over the network
+ */
+
#include "imp.h"
#include <assert.h>
#ifdef PROTOTYPES
static const char *Get_Prefix PARAMS((CLIENT *Target, CLIENT *Client));
static void cb_writeStrServersPrefixFlag PARAMS((CLIENT *Client,
CLIENT *Prefix, void *Buffer));
+static bool Send_Marked_Connections PARAMS((CLIENT *Prefix, const char *Buffer));
#ifdef PROTOTYPES
vsnprintf( buffer, 1000, Format, ap );
va_end( ap );
- return Conn_WriteStr( Client_Conn( Client_NextHop( Client )), ":%s %s", Get_Prefix( Client_NextHop( Client ), Prefix ), buffer );
+ return Conn_WriteStr(Client_Conn(Client_NextHop(Client)), ":%s %s",
+ Get_Prefix(Client_NextHop(Client), Prefix), buffer);
} /* IRC_WriteStrClientPrefix */
va_dcl
#endif
{
- bool ok = CONNECTED;
char buffer[1000];
CL2CHAN *cl2chan;
CONN_ID conn;
}
cl2chan = Channel_NextMember( Chan, cl2chan );
}
-
- conn = Conn_First( );
- while( conn != NONE )
- {
- /* 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;
-
- conn = Conn_Next( conn );
- }
-
- return ok;
+ return Send_Marked_Connections(Prefix, buffer);
} /* IRC_WriteStrChannelPrefix */
va_dcl
#endif
{
- bool ok = CONNECTED;
CL2CHAN *chan_cl2chan, *cl2chan;
char buffer[1000];
CHANNEL *chan;
chan_cl2chan = Channel_NextChannelOf( Client, chan_cl2chan );
}
-
- conn = Conn_First( );
- while( conn != NONE )
- {
- /* 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;
-
- conn = Conn_Next( conn );
- }
- return ok;
+ return Send_Marked_Connections(Prefix, buffer);
} /* IRC_WriteStrRelatedPrefix */
static const char *
-Get_Prefix( CLIENT *Target, CLIENT *Client )
+Get_Prefix(CLIENT *Target, CLIENT *Client)
{
- assert( Target != NULL );
- assert( Client != NULL );
+ assert (Target != NULL);
+ assert (Client != NULL);
- if( Client_Type( Target ) == CLIENT_SERVER ) return Client_ID( Client );
- else return Client_Mask( Client );
+ if (Client_Type(Target) == CLIENT_SERVER)
+ return Client_ID(Client);
+ else
+ return Client_MaskCloaked(Client);
} /* Get_Prefix */
} /* cb_writeStrServersPrefixFlag */
+static bool
+Send_Marked_Connections(CLIENT *Prefix, const char *Buffer)
+{
+ CONN_ID conn;
+ bool ok = CONNECTED;
+
+ assert(Prefix != NULL);
+ assert(Buffer != NULL);
+
+ conn = Conn_First();
+ while (conn != NONE) {
+ 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_MaskCloaked(Prefix), Buffer);
+ if (!ok)
+ break;
+ conn = Conn_Next( conn );
+ }
+ return ok;
+}
+
+
/* -eof- */