diff options
| author | Alexander Barton <alex@barton.de> | 2008-08-17 14:59:36 +0200 |
|---|---|---|
| committer | Alexander Barton <alex@barton.de> | 2008-09-23 11:53:15 +0200 |
| commit | 3913de3cffaa4a3641075d4b4df4aea388bc3717 (patch) | |
| tree | e41ce45f3c99fb02b55765372f55fa8b119781cb | |
| parent | 91e87a37051018c100cff6c72eb7aaf823efe894 (diff) | |
| download | ngircd-3913de3cffaa4a3641075d4b4df4aea388bc3717.tar.gz ngircd-3913de3cffaa4a3641075d4b4df4aea388bc3717.zip | |
Fix PRIVMSG/NOTICE handler (II): keep command when forwarding to channels.
- new function ngt_UpperStr(). - change Channel_Write() to take command name and error flag. - remove now unneeded function Channel_Notice().
| -rw-r--r-- | src/ngircd/channel.c | 31 | ||||
| -rw-r--r-- | src/ngircd/channel.h | 9 | ||||
| -rw-r--r-- | src/ngircd/irc.c | 7 |
3 files changed, 19 insertions, 28 deletions
diff --git a/src/ngircd/channel.c b/src/ngircd/channel.c index aec6aa2d..d774e576 100644 --- a/src/ngircd/channel.c +++ b/src/ngircd/channel.c @@ -1,6 +1,6 @@ /* * ngIRCd -- The Next Generation IRC Daemon - * Copyright (c)2001-2005 by Alexander Barton (alex@barton.de) + * Copyright (c)2001-2008 by Alexander Barton (alex@barton.de) * * 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 @@ -17,8 +17,6 @@ #include "portab.h" -static char UNUSED id[] = "$Id: channel.c,v 1.65 2008/02/05 16:31:35 fw Exp $"; - #include "imp.h" #include <assert.h> #include <stdlib.h> @@ -770,30 +768,21 @@ Can_Send_To_Channel(CHANNEL *Chan, CLIENT *From) GLOBAL bool -Channel_Write(CHANNEL *Chan, CLIENT *From, CLIENT *Client, const char *Text) -{ - if (!Can_Send_To_Channel(Chan, From)) - return IRC_WriteStrClient(From, ERR_CANNOTSENDTOCHAN_MSG, Client_ID(From), Channel_Name(Chan)); - - if (Client_Conn(From) > NONE) - Conn_UpdateIdle(Client_Conn(From)); - - return IRC_WriteStrChannelPrefix(Client, Chan, From, true, - "PRIVMSG %s :%s", Channel_Name(Chan), Text); -} - - -GLOBAL bool -Channel_Notice(CHANNEL *Chan, CLIENT *From, CLIENT *Client, const char *Text) +Channel_Write(CHANNEL *Chan, CLIENT *From, CLIENT *Client, const char *Command, + bool SendErrors, const char *Text) { - if (!Can_Send_To_Channel(Chan, From)) - return true; /* no error, see RFC 2812 */ + if (!Can_Send_To_Channel(Chan, From)) { + if (! SendErrors) + return CONNECTED; /* no error, see RFC 2812 */ + return IRC_WriteStrClient(From, ERR_CANNOTSENDTOCHAN_MSG, + Client_ID(From), Channel_Name(Chan)); + } if (Client_Conn(From) > NONE) Conn_UpdateIdle(Client_Conn(From)); return IRC_WriteStrChannelPrefix(Client, Chan, From, true, - "NOTICE %s :%s", Channel_Name(Chan), Text); + "%s %s :%s", Command, Channel_Name(Chan), Text); } diff --git a/src/ngircd/channel.h b/src/ngircd/channel.h index 1f78bf87..a562645c 100644 --- a/src/ngircd/channel.h +++ b/src/ngircd/channel.h @@ -1,6 +1,6 @@ /* * ngIRCd -- The Next Generation IRC Daemon - * Copyright (c)2001,2002 by Alexander Barton (alex@barton.de) + * Copyright (c)2001-2008 by Alexander Barton (alex@barton.de) * * 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 @@ -8,8 +8,6 @@ * (at your option) any later version. * Please read the file COPYING, README and AUTHORS for more information. * - * $Id: channel.h,v 1.35 2008/02/05 16:31:35 fw Exp $ - * * Channel management (header) */ @@ -109,8 +107,9 @@ GLOBAL char *Channel_UserModes PARAMS(( CHANNEL *Chan, CLIENT *Client )); GLOBAL bool Channel_IsMemberOf PARAMS(( CHANNEL *Chan, CLIENT *Client )); -GLOBAL bool Channel_Write PARAMS(( CHANNEL *Chan, CLIENT *From, CLIENT *Client, const char *Text )); -GLOBAL bool Channel_Notice PARAMS(( CHANNEL *Chan, CLIENT *From, CLIENT *Client, const char *Text)); +GLOBAL bool Channel_Write PARAMS((CHANNEL *Chan, CLIENT *From, CLIENT *Client, + const char *Command, bool SendErrors, + const char *Text)); GLOBAL CHANNEL *Channel_Create PARAMS(( char *Name )); diff --git a/src/ngircd/irc.c b/src/ngircd/irc.c index 3a2a9aff..8d2291fe 100644 --- a/src/ngircd/irc.c +++ b/src/ngircd/irc.c @@ -33,6 +33,7 @@ static char UNUSED id[] = "$Id: irc.c,v 1.132 2008/01/15 22:28:14 fw Exp $"; #include "match.h" #include "messages.h" #include "parse.h" +#include "tool.h" #include "exp.h" #include "irc.h" @@ -349,6 +350,7 @@ Send_Message(CLIENT * Client, REQUEST * Req, int ForceType, bool SendErrors) /* handle msgtarget = msgto *("," msgto) */ currentTarget = strtok_r(currentTarget, ",", &lastCurrentTarget); + ngt_UpperStr(Req->command); while (currentTarget) { /* Check for and handle valid <msgto> of form: @@ -460,8 +462,9 @@ Send_Message(CLIENT * Client, REQUEST * Req, int ForceType, bool SendErrors) return DISCONNECTED; } else if ((chan = Channel_Search(currentTarget))) { /* channel */ - if (!Channel_Write(chan, from, Client, Req->argv[1])) - return DISCONNECTED; + if (!Channel_Write(chan, from, Client, Req->command, + SendErrors, Req->argv[1])) + return DISCONNECTED; } else { if (!SendErrors) return CONNECTED; |