mirror of
https://github.com/osmarks/ngircd.git
synced 2024-12-13 10:20:28 +00:00
Fix return code of some IRC_WriteXXX() functions
These functions usually write to more than one target, and therefore can't return value indicating success or failure in a sane way. And, even more omportant, these functions should send to as much as possible clients and not stop at the first client which isn't reachable any more!
This commit is contained in:
parent
8f5cbe51a7
commit
08d49a8fa0
@ -931,8 +931,9 @@ Channel_Write(CHANNEL *Chan, CLIENT *From, CLIENT *Client, const char *Command,
|
||||
if (Client_Conn(From) > NONE)
|
||||
Conn_UpdateIdle(Client_Conn(From));
|
||||
|
||||
return IRC_WriteStrChannelPrefix(Client, Chan, From, true,
|
||||
"%s %s :%s", Command, Channel_Name(Chan), Text);
|
||||
IRC_WriteStrChannelPrefix(Client, Chan, From, true, "%s %s :%s",
|
||||
Command, Channel_Name(Chan), Text);
|
||||
return CONNECTED;
|
||||
}
|
||||
|
||||
|
||||
|
@ -41,7 +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));
|
||||
static void Send_Marked_Connections PARAMS((CLIENT *Prefix, const char *Buffer));
|
||||
|
||||
|
||||
#ifdef PROTOTYPES
|
||||
@ -112,11 +112,11 @@ va_dcl
|
||||
|
||||
|
||||
#ifdef PROTOTYPES
|
||||
GLOBAL bool
|
||||
GLOBAL void
|
||||
IRC_WriteStrChannel(CLIENT *Client, CHANNEL *Chan, bool Remote,
|
||||
const char *Format, ...)
|
||||
#else
|
||||
GLOBAL bool
|
||||
GLOBAL void
|
||||
IRC_WriteStrChannel(Client, Chan, Remote, Format, va_alist)
|
||||
CLIENT *Client;
|
||||
CHANNEL *Chan;
|
||||
@ -139,21 +139,21 @@ va_dcl
|
||||
vsnprintf( buffer, 1000, Format, ap );
|
||||
va_end( ap );
|
||||
|
||||
return IRC_WriteStrChannelPrefix( Client, Chan, Client_ThisServer( ), Remote, "%s", buffer );
|
||||
IRC_WriteStrChannelPrefix(Client, Chan, Client_ThisServer(),
|
||||
Remote, "%s", buffer );
|
||||
} /* IRC_WriteStrChannel */
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* send message to all clients in the same channel, but only send message
|
||||
* once per remote server.
|
||||
*/
|
||||
#ifdef PROTOTYPES
|
||||
GLOBAL bool
|
||||
GLOBAL void
|
||||
IRC_WriteStrChannelPrefix(CLIENT *Client, CHANNEL *Chan, CLIENT *Prefix,
|
||||
bool Remote, const char *Format, ...)
|
||||
#else
|
||||
GLOBAL bool
|
||||
GLOBAL void
|
||||
IRC_WriteStrChannelPrefix(Client, Chan, Prefix, Remote, Format, va_alist)
|
||||
CLIENT *Client;
|
||||
CHANNEL *Chan;
|
||||
@ -204,7 +204,7 @@ va_dcl
|
||||
}
|
||||
cl2chan = Channel_NextMember( Chan, cl2chan );
|
||||
}
|
||||
return Send_Marked_Connections(Prefix, buffer);
|
||||
Send_Marked_Connections(Prefix, buffer);
|
||||
} /* IRC_WriteStrChannelPrefix */
|
||||
|
||||
|
||||
@ -324,11 +324,11 @@ IRC_WriteStrServersPrefixFlag_CB(CLIENT *ExceptOf, CLIENT *Prefix, char Flag,
|
||||
* only send message once per remote server.
|
||||
*/
|
||||
#ifdef PROTOTYPES
|
||||
GLOBAL bool
|
||||
GLOBAL void
|
||||
IRC_WriteStrRelatedPrefix(CLIENT *Client, CLIENT *Prefix, bool Remote,
|
||||
const char *Format, ...)
|
||||
#else
|
||||
GLOBAL bool
|
||||
GLOBAL void
|
||||
IRC_WriteStrRelatedPrefix(Client, Prefix, Remote, Format, va_alist)
|
||||
CLIENT *Client;
|
||||
CLIENT *Prefix;
|
||||
@ -384,7 +384,7 @@ va_dcl
|
||||
|
||||
chan_cl2chan = Channel_NextChannelOf( Client, chan_cl2chan );
|
||||
}
|
||||
return Send_Marked_Connections(Prefix, buffer);
|
||||
Send_Marked_Connections(Prefix, buffer);
|
||||
} /* IRC_WriteStrRelatedPrefix */
|
||||
|
||||
|
||||
@ -471,11 +471,10 @@ cb_writeStrServersPrefixFlag(CLIENT *Client, CLIENT *Prefix, void *Buffer)
|
||||
} /* cb_writeStrServersPrefixFlag */
|
||||
|
||||
|
||||
static bool
|
||||
static void
|
||||
Send_Marked_Connections(CLIENT *Prefix, const char *Buffer)
|
||||
{
|
||||
CONN_ID conn;
|
||||
bool ok = CONNECTED;
|
||||
|
||||
assert(Prefix != NULL);
|
||||
assert(Buffer != NULL);
|
||||
@ -483,16 +482,13 @@ Send_Marked_Connections(CLIENT *Prefix, const char *Buffer)
|
||||
conn = Conn_First();
|
||||
while (conn != NONE) {
|
||||
if (Conn_Flag(conn) == SEND_TO_SERVER)
|
||||
ok = Conn_WriteStr(conn, ":%s %s",
|
||||
Conn_WriteStr(conn, ":%s %s",
|
||||
Client_ID(Prefix), Buffer);
|
||||
else if (Conn_Flag(conn) == SEND_TO_USER)
|
||||
ok = Conn_WriteStr(conn, ":%s %s",
|
||||
Conn_WriteStr(conn, ":%s %s",
|
||||
Client_MaskCloaked(Prefix), Buffer);
|
||||
if (!ok)
|
||||
break;
|
||||
conn = Conn_Next( conn );
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* ngIRCd -- The Next Generation IRC Daemon
|
||||
* Copyright (c)2001-2008 Alexander Barton (alex@barton.de)
|
||||
* Copyright (c)2001-2013 Alexander Barton (alex@barton.de) and Contributors.
|
||||
*
|
||||
* 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
|
||||
@ -21,9 +21,9 @@ GLOBAL bool IRC_WriteStrClient PARAMS((CLIENT *Client, const char *Format, ...))
|
||||
GLOBAL bool IRC_WriteStrClientPrefix PARAMS((CLIENT *Client, CLIENT *Prefix,
|
||||
const char *Format, ...));
|
||||
|
||||
GLOBAL bool IRC_WriteStrChannel PARAMS((CLIENT *Client, CHANNEL *Chan,
|
||||
GLOBAL void IRC_WriteStrChannel PARAMS((CLIENT *Client, CHANNEL *Chan,
|
||||
bool Remote, const char *Format, ...));
|
||||
GLOBAL bool IRC_WriteStrChannelPrefix PARAMS((CLIENT *Client, CHANNEL *Chan,
|
||||
GLOBAL void IRC_WriteStrChannelPrefix PARAMS((CLIENT *Client, CHANNEL *Chan,
|
||||
CLIENT *Prefix, bool Remote, const char *Format, ...));
|
||||
|
||||
GLOBAL void IRC_WriteStrServers PARAMS((CLIENT *ExceptOf,
|
||||
@ -36,7 +36,7 @@ GLOBAL void IRC_WriteStrServersPrefixFlag_CB PARAMS((CLIENT *ExceptOf,
|
||||
CLIENT *Prefix, char Flag,
|
||||
void (*callback)(CLIENT *, CLIENT *, void *), void *cb_data));
|
||||
|
||||
GLOBAL bool IRC_WriteStrRelatedPrefix PARAMS((CLIENT *Client, CLIENT *Prefix,
|
||||
GLOBAL void IRC_WriteStrRelatedPrefix PARAMS((CLIENT *Client, CLIENT *Prefix,
|
||||
bool Remote, const char *Format, ...));
|
||||
|
||||
GLOBAL void IRC_SendWallops PARAMS((CLIENT *Client, CLIENT *From,
|
||||
|
Loading…
Reference in New Issue
Block a user