]> arthur.barton.de Git - ngircd-alex.git/commitdiff
Allow DIE to send a message to all locally connected clients. Closes bug #48.
authorAlexander Barton <alex@barton.de>
Sun, 23 Jul 2006 15:43:18 +0000 (15:43 +0000)
committerAlexander Barton <alex@barton.de>
Sun, 23 Jul 2006 15:43:18 +0000 (15:43 +0000)
src/ngircd/irc-oper.c

index c9241b345b2d726df041302680abbe60e29bcef7..1b3011761ceab4e4d0b646057144d75d10b2c9ce 100644 (file)
@@ -14,7 +14,7 @@
 
 #include "portab.h"
 
 
 #include "portab.h"
 
-static char UNUSED id[] = "$Id: irc-oper.c,v 1.26 2006/05/10 21:24:01 alex Exp $";
+static char UNUSED id[] = "$Id: irc-oper.c,v 1.27 2006/07/23 15:43:18 alex Exp $";
 
 #include "imp.h"
 #include <assert.h>
 
 #include "imp.h"
 #include <assert.h>
@@ -23,7 +23,7 @@ static char UNUSED id[] = "$Id: irc-oper.c,v 1.26 2006/05/10 21:24:01 alex Exp $
 
 #include "ngircd.h"
 #include "resolve.h"
 
 #include "ngircd.h"
 #include "resolve.h"
-#include "conn.h"
+#include "conn-func.h"
 #include "conf.h"
 #include "client.h"
 #include "channel.h"
 #include "conf.h"
 #include "client.h"
 #include "channel.h"
@@ -90,21 +90,46 @@ IRC_OPER( CLIENT *Client, REQUEST *Req )
 
 
 GLOBAL bool
 
 
 GLOBAL bool
-IRC_DIE( CLIENT *Client, REQUEST *Req )
+IRC_DIE(CLIENT * Client, REQUEST * Req)
 {
        /* Shut down server */
 
 {
        /* Shut down server */
 
-       assert( Client != NULL );
-       assert( Req != NULL );
+       CONN_ID c;
+       CLIENT *cl;
+
+       assert(Client != NULL);
+       assert(Req != NULL);
 
        /* Not a local IRC operator? */
 
        /* Not a local IRC operator? */
-       if(( ! Client_HasMode( Client, 'o' )) || ( ! Client_OperByMe( Client ))) return IRC_WriteStrClient( Client, ERR_NOPRIVILEGES_MSG, Client_ID( Client ));
-       
+       if ((!Client_HasMode(Client, 'o')) || (!Client_OperByMe(Client)))
+               return IRC_WriteStrClient(Client, ERR_NOPRIVILEGES_MSG,
+                                         Client_ID(Client));
+
        /* Bad number of parameters? */
        /* Bad number of parameters? */
-       if( Req->argc != 0 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
+#ifdef STRICT_RFC
+       if (Req->argc != 0)
+#else
+       if (Req->argc > 1)
+#endif
+               return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
+                                         Client_ID(Client), Req->command);
+
+       /* Is a message given? */
+       if (Req->argc > 0) {
+               c = Conn_First();
+               while (c != NONE) {
+                       cl = Conn_GetClient(c);
+                       if (Client_Type(cl) == CLIENT_USER)
+                               IRC_WriteStrClient(cl, "NOTICE %s :%s",
+                                               Client_ID(cl), Req->argv[0]);
+                       c = Conn_Next(c);
+               }
+       }
 
 
-       Log( LOG_NOTICE|LOG_snotice, "Got DIE command from \"%s\" ...", Client_Mask( Client ));
+       Log(LOG_NOTICE | LOG_snotice, "Got DIE command from \"%s\" ...",
+           Client_Mask(Client));
        NGIRCd_SignalQuit = true;
        NGIRCd_SignalQuit = true;
+
        return CONNECTED;
 } /* IRC_DIE */
 
        return CONNECTED;
 } /* IRC_DIE */