Refactor IRC_WriteStr{Channel|Related}Prefix(); support cloaking
Move common code to new local function Send_Marked_Connections() and respect hostname cloaking.
This commit is contained in:
parent
2a4bf67aac
commit
fd4dfccc30
|
@ -39,6 +39,7 @@
|
||||||
static const char *Get_Prefix PARAMS((CLIENT *Target, CLIENT *Client));
|
static const char *Get_Prefix PARAMS((CLIENT *Target, CLIENT *Client));
|
||||||
static void cb_writeStrServersPrefixFlag PARAMS((CLIENT *Client,
|
static void cb_writeStrServersPrefixFlag PARAMS((CLIENT *Client,
|
||||||
CLIENT *Prefix, void *Buffer));
|
CLIENT *Prefix, void *Buffer));
|
||||||
|
static bool Send_Marked_Connections PARAMS((CLIENT *Prefix, const char *Buffer));
|
||||||
|
|
||||||
|
|
||||||
#ifdef PROTOTYPES
|
#ifdef PROTOTYPES
|
||||||
|
@ -159,7 +160,6 @@ const char *Format;
|
||||||
va_dcl
|
va_dcl
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
bool ok = CONNECTED;
|
|
||||||
char buffer[1000];
|
char buffer[1000];
|
||||||
CL2CHAN *cl2chan;
|
CL2CHAN *cl2chan;
|
||||||
CONN_ID conn;
|
CONN_ID conn;
|
||||||
|
@ -201,19 +201,7 @@ va_dcl
|
||||||
}
|
}
|
||||||
cl2chan = Channel_NextMember( Chan, cl2chan );
|
cl2chan = Channel_NextMember( Chan, cl2chan );
|
||||||
}
|
}
|
||||||
|
return Send_Marked_Connections(Prefix, buffer);
|
||||||
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;
|
|
||||||
} /* IRC_WriteStrChannelPrefix */
|
} /* IRC_WriteStrChannelPrefix */
|
||||||
|
|
||||||
|
|
||||||
|
@ -346,7 +334,6 @@ const char *Format;
|
||||||
va_dcl
|
va_dcl
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
bool ok = CONNECTED;
|
|
||||||
CL2CHAN *chan_cl2chan, *cl2chan;
|
CL2CHAN *chan_cl2chan, *cl2chan;
|
||||||
char buffer[1000];
|
char buffer[1000];
|
||||||
CHANNEL *chan;
|
CHANNEL *chan;
|
||||||
|
@ -394,18 +381,7 @@ va_dcl
|
||||||
|
|
||||||
chan_cl2chan = Channel_NextChannelOf( Client, chan_cl2chan );
|
chan_cl2chan = Channel_NextChannelOf( Client, chan_cl2chan );
|
||||||
}
|
}
|
||||||
|
return Send_Marked_Connections(Prefix, buffer);
|
||||||
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;
|
|
||||||
} /* IRC_WriteStrRelatedPrefix */
|
} /* IRC_WriteStrRelatedPrefix */
|
||||||
|
|
||||||
|
|
||||||
|
@ -490,4 +466,29 @@ cb_writeStrServersPrefixFlag(CLIENT *Client, CLIENT *Prefix, void *Buffer)
|
||||||
} /* cb_writeStrServersPrefixFlag */
|
} /* 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- */
|
/* -eof- */
|
||||||
|
|
Loading…
Reference in New Issue