IRC_SendWallops(): support format string and variable parameter lists.
This commit is contained in:
parent
30b584c2e8
commit
7d6de7c352
|
@ -207,8 +207,6 @@ IRC_RESTART( CLIENT *Client, REQUEST *Req )
|
||||||
GLOBAL bool
|
GLOBAL bool
|
||||||
IRC_CONNECT(CLIENT * Client, REQUEST * Req)
|
IRC_CONNECT(CLIENT * Client, REQUEST * Req)
|
||||||
{
|
{
|
||||||
char msg[LINE_LEN + 64];
|
|
||||||
|
|
||||||
assert(Client != NULL);
|
assert(Client != NULL);
|
||||||
assert(Req != NULL);
|
assert(Req != NULL);
|
||||||
|
|
||||||
|
@ -225,9 +223,9 @@ IRC_CONNECT(CLIENT * Client, REQUEST * Req)
|
||||||
return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
|
return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
|
||||||
Client_ID(Client), Req->command);
|
Client_ID(Client), Req->command);
|
||||||
|
|
||||||
snprintf(msg, sizeof(msg), "Received CONNECT %s from %s",
|
IRC_SendWallops(Client_ThisServer(), Client_ThisServer(),
|
||||||
|
"Received CONNECT %s from %s",
|
||||||
Req->argv[0], Client_ID(Client));
|
Req->argv[0], Client_ID(Client));
|
||||||
IRC_SendWallops(Client_ThisServer(), Client_ThisServer(), msg);
|
|
||||||
|
|
||||||
Log(LOG_NOTICE | LOG_snotice,
|
Log(LOG_NOTICE | LOG_snotice,
|
||||||
"Got CONNECT command from \"%s\" for \"%s\".", Client_Mask(Client),
|
"Got CONNECT command from \"%s\" for \"%s\".", Client_Mask(Client),
|
||||||
|
@ -269,7 +267,6 @@ GLOBAL bool
|
||||||
IRC_DISCONNECT(CLIENT * Client, REQUEST * Req)
|
IRC_DISCONNECT(CLIENT * Client, REQUEST * Req)
|
||||||
{
|
{
|
||||||
CONN_ID my_conn;
|
CONN_ID my_conn;
|
||||||
char msg[LINE_LEN + 64];
|
|
||||||
|
|
||||||
assert(Client != NULL);
|
assert(Client != NULL);
|
||||||
assert(Req != NULL);
|
assert(Req != NULL);
|
||||||
|
@ -282,9 +279,9 @@ IRC_DISCONNECT(CLIENT * Client, REQUEST * Req)
|
||||||
return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
|
return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
|
||||||
Client_ID(Client), Req->command);
|
Client_ID(Client), Req->command);
|
||||||
|
|
||||||
snprintf(msg, sizeof(msg), "Received DISCONNECT %s from %s",
|
IRC_SendWallops(Client_ThisServer(), Client_ThisServer(),
|
||||||
|
"Received DISCONNECT %s from %s",
|
||||||
Req->argv[0], Client_ID(Client));
|
Req->argv[0], Client_ID(Client));
|
||||||
IRC_SendWallops(Client_ThisServer(), Client_ThisServer(), msg);
|
|
||||||
|
|
||||||
Log(LOG_NOTICE | LOG_snotice,
|
Log(LOG_NOTICE | LOG_snotice,
|
||||||
"Got DISCONNECT command from \"%s\" for \"%s\".",
|
"Got DISCONNECT command from \"%s\" for \"%s\".",
|
||||||
|
@ -333,7 +330,7 @@ IRC_WALLOPS( CLIENT *Client, REQUEST *Req )
|
||||||
if (!from)
|
if (!from)
|
||||||
return IRC_WriteStrClient(Client, ERR_NOSUCHNICK_MSG, Client_ID(Client), Req->prefix);
|
return IRC_WriteStrClient(Client, ERR_NOSUCHNICK_MSG, Client_ID(Client), Req->prefix);
|
||||||
|
|
||||||
IRC_SendWallops(Client, from, Req->argv[0]);
|
IRC_SendWallops(Client, from, "%s", Req->argv[0]);
|
||||||
return CONNECTED;
|
return CONNECTED;
|
||||||
} /* IRC_WALLOPS */
|
} /* IRC_WALLOPS */
|
||||||
|
|
||||||
|
|
|
@ -408,11 +408,30 @@ va_dcl
|
||||||
/**
|
/**
|
||||||
* Send WALLOPS message.
|
* Send WALLOPS message.
|
||||||
*/
|
*/
|
||||||
|
#ifdef PROTOTYPES
|
||||||
GLOBAL void
|
GLOBAL void
|
||||||
IRC_SendWallops(CLIENT *Client, CLIENT *From, const char *Message)
|
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;
|
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)) {
|
for (to=Client_First(); to != NULL; to=Client_Next(to)) {
|
||||||
if (Client_Conn(to) == NONE) /* no local connection */
|
if (Client_Conn(to) == NONE) /* no local connection */
|
||||||
continue;
|
continue;
|
||||||
|
@ -421,12 +440,12 @@ IRC_SendWallops(CLIENT *Client, CLIENT *From, const char *Message)
|
||||||
case CLIENT_USER:
|
case CLIENT_USER:
|
||||||
if (Client_HasMode(to, 'w'))
|
if (Client_HasMode(to, 'w'))
|
||||||
IRC_WriteStrClientPrefix(to, From,
|
IRC_WriteStrClientPrefix(to, From,
|
||||||
"WALLOPS :%s", Message);
|
"WALLOPS :%s", msg);
|
||||||
break;
|
break;
|
||||||
case CLIENT_SERVER:
|
case CLIENT_SERVER:
|
||||||
if (to != Client)
|
if (to != Client)
|
||||||
IRC_WriteStrClientPrefix(to, From,
|
IRC_WriteStrClientPrefix(to, From,
|
||||||
"WALLOPS :%s", Message);
|
"WALLOPS :%s", msg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ GLOBAL bool IRC_WriteStrRelatedPrefix PARAMS((CLIENT *Client, CLIENT *Prefix,
|
||||||
bool Remote, char *Format, ...));
|
bool Remote, char *Format, ...));
|
||||||
|
|
||||||
GLOBAL void IRC_SendWallops PARAMS((CLIENT *Client, CLIENT *From,
|
GLOBAL void IRC_SendWallops PARAMS((CLIENT *Client, CLIENT *From,
|
||||||
const char *Message));
|
const char *Format, ...));
|
||||||
|
|
||||||
GLOBAL void IRC_SetPenalty PARAMS((CLIENT *Client, time_t Seconds));
|
GLOBAL void IRC_SetPenalty PARAMS((CLIENT *Client, time_t Seconds));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue