X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fngircd%2Firc-write.c;h=16aac9a081859aa27904e116252d009ba02d3176;hb=6a308fcb42eae1de168699ed432b49b610073ede;hp=afefefba4b2db9a87e7be1b87dcb8107e5e25365;hpb=0c0d4af55ae6d098ccfabc258508a6b85b8c7449;p=ngircd-alex.git diff --git a/src/ngircd/irc-write.c b/src/ngircd/irc-write.c index afefefba..16aac9a0 100644 --- a/src/ngircd/irc-write.c +++ b/src/ngircd/irc-write.c @@ -7,13 +7,15 @@ * 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 #ifdef PROTOTYPES @@ -26,7 +28,6 @@ #include "defines.h" #include "conn-func.h" -#include "client.h" #include "channel.h" #include "exp.h" @@ -40,6 +41,7 @@ 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 @@ -104,7 +106,8 @@ va_dcl 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 */ @@ -160,7 +163,6 @@ const char *Format; va_dcl #endif { - bool ok = CONNECTED; char buffer[1000]; CL2CHAN *cl2chan; CONN_ID conn; @@ -202,19 +204,7 @@ va_dcl } 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 */ @@ -347,7 +337,6 @@ const char *Format; va_dcl #endif { - bool ok = CONNECTED; CL2CHAN *chan_cl2chan, *cl2chan; char buffer[1000]; CHANNEL *chan; @@ -395,18 +384,7 @@ va_dcl 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 */ @@ -474,13 +452,15 @@ IRC_SetPenalty( CLIENT *Client, time_t Seconds ) 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 */ @@ -491,4 +471,29 @@ cb_writeStrServersPrefixFlag(CLIENT *Client, CLIENT *Prefix, void *Buffer) } /* 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- */