X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fngircd%2Firc-write.c;h=25cecaff8e90c13e350189dad7e39db2883c0932;hb=4ab688c5e82281c4d9ad2a4498523b1722c1f738;hp=93753564770f3dbdeb32f768d01c0c991959f237;hpb=0a3d8d60d3c3ac66d09346aa02c10c9649b62e99;p=ngircd-alex.git diff --git a/src/ngircd/irc-write.c b/src/ngircd/irc-write.c index 93753564..25cecaff 100644 --- a/src/ngircd/irc-write.c +++ b/src/ngircd/irc-write.c @@ -41,6 +41,43 @@ static void cb_writeStrServersPrefixFlag PARAMS((CLIENT *Client, CLIENT *Prefix, void *Buffer)); static void Send_Marked_Connections PARAMS((CLIENT *Prefix, const char *Buffer)); +/** + * Send an error message to a client and enforce a penalty time. + * + * @param Client The target client. + * @param Format Format string. + * @return CONNECTED or DISCONNECTED. + */ +#ifdef PROTOTYPES +GLOBAL bool +IRC_WriteErrClient( CLIENT *Client, const char *Format, ... ) +#else +GLOBAL bool +IRC_WriteErrClient( Client, Format, va_alist ) +CLIENT *Client; +const char *Format; +va_dcl +#endif +{ + char buffer[1000]; + va_list ap; + + assert(Client != NULL); + assert(Format != NULL); + +#ifdef PROTOTYPES + va_start(ap, Format); +#else + va_start(ap); +#endif + vsnprintf(buffer, 1000, Format, ap); + va_end(ap); + + IRC_SetPenalty(Client, 2); + return IRC_WriteStrClientPrefix(Client, Client_ThisServer(), + "%s", buffer); +} + /** * Send a message to a client. * @@ -501,24 +538,27 @@ va_dcl /** * Set a "penalty time" for an IRC client. * - * Note: penalty times are never set for server links! + * Note: penalty times are never set for server links or remote clients! * * @param Client The client. * @param Seconds The additional "penalty time" to enforce. */ GLOBAL void -IRC_SetPenalty( CLIENT *Client, time_t Seconds ) +IRC_SetPenalty(CLIENT *Client, time_t Seconds) { CONN_ID c; - assert( Client != NULL ); - assert( Seconds > 0 ); + assert(Client != NULL); + assert(Seconds > 0); + + if (Client_Type(Client) == CLIENT_SERVER) + return; - if( Client_Type( Client ) == CLIENT_SERVER ) return; + c = Client_Conn(Client); + if (c <= NONE) + return; - c = Client_Conn( Client ); - if (c > NONE) - Conn_SetPenalty(c, Seconds); + Conn_SetPenalty(c, Seconds); } /* IRC_SetPenalty */ static const char *