]> arthur.barton.de Git - ngircd-alex.git/commitdiff
implement /WALLOPS as described in RFC 2812, section 4.7.
authorFlorian Westphal <fw@strlen.de>
Thu, 2 Aug 2007 10:14:26 +0000 (10:14 +0000)
committerFlorian Westphal <fw@strlen.de>
Thu, 2 Aug 2007 10:14:26 +0000 (10:14 +0000)
src/ngircd/defines.h
src/ngircd/irc-mode.c
src/ngircd/irc-oper.c
src/ngircd/irc-oper.h
src/ngircd/parse.c

index b686f883a12d4577b9828641e7ca599f7254bbe7..251a6997dd3c1e084525cc29ede57c8219735cc2 100644 (file)
@@ -8,7 +8,7 @@
  * (at your option) any later version.
  * Please read the file COPYING, README and AUTHORS for more information.
  *
- * $Id: defines.h,v 1.60 2007/05/17 23:34:25 alex Exp $
+ * $Id: defines.h,v 1.61 2007/08/02 10:14:26 fw Exp $
  */
 
 
@@ -54,7 +54,7 @@
                                           see RFC 2812, section 1.2.1 */
 #define CLIENT_NAME_LEN 32             /* Max. length of "real names" */
 #define CLIENT_HOST_LEN 64             /* Max. host name length */
-#define CLIENT_MODE_LEN 8              /* Max. lenth of all client modes */
+#define CLIENT_MODE_LEN 9              /* Max. lenth of all client modes */
 #define CLIENT_INFO_LEN 64             /* Max. length of server info texts */
 #define CLIENT_AWAY_LEN 128            /* Max. length of away messages */
 #define CLIENT_FLAGS_LEN 100           /* Max. length of client flags */
index 75f99d9eb7b465a2a8ca907823500e563be658b1..4a6127ad95a0baa9e374fa3b36c3d764eb2fbeb1 100644 (file)
@@ -14,7 +14,7 @@
 
 #include "portab.h"
 
-static char UNUSED id[] = "$Id: irc-mode.c,v 1.48 2006/12/07 17:57:20 fw Exp $";
+static char UNUSED id[] = "$Id: irc-mode.c,v 1.49 2007/08/02 10:14:26 fw Exp $";
 
 #include "imp.h"
 #include <assert.h>
@@ -164,6 +164,7 @@ Client_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CLIENT *Target )
                {
                        case 'i': /* Invisible */
                        case 's': /* Server messages */
+                       case 'w': /* Wallops messages */
                                x[0] = *mode_ptr;
                                break;
 
index c80b8b051aecc89b78848254bf99d6f58ccab6f4..c9286d7015e4598d1d0c09ef7694160cb39bc22d 100644 (file)
@@ -14,7 +14,7 @@
 
 #include "portab.h"
 
-static char UNUSED id[] = "$Id: irc-oper.c,v 1.28 2007/06/28 05:15:18 fw Exp $";
+static char UNUSED id[] = "$Id: irc-oper.c,v 1.29 2007/08/02 10:14:26 fw Exp $";
 
 #include "imp.h"
 #include <assert.h>
@@ -263,4 +263,54 @@ IRC_DISCONNECT(CLIENT *Client, REQUEST *Req )
 } /* IRC_CONNECT */
 
 
+GLOBAL bool
+IRC_WALLOPS( CLIENT *Client, REQUEST *Req )
+{
+       CLIENT *to, *from;
+       int client_type;
+
+       assert( Client != NULL );
+       assert( Req != NULL );
+
+       if (Req->argc != 1)
+               return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG, Client_ID(Client), Req->command);
+
+       client_type = Client_Type(Client);
+       switch (client_type) {
+       case CLIENT_USER:
+               if (!Client_OperByMe(Client))
+                       return IRC_WriteStrClient(Client, ERR_NOPRIVILEGES_MSG, Client_ID(Client));
+               from = Client;
+               break;
+       case CLIENT_SERVER:
+               from = Client_Search(Req->prefix);
+               break;
+       default:
+               return CONNECTED;
+       }
+
+       if (!from)
+               return IRC_WriteStrClient(Client, ERR_NOSUCHNICK_MSG, Client_ID(Client), Req->prefix);
+
+       for (to=Client_First(); to != NULL; to=Client_Next(to)) {
+               if (Client_Conn(to) < 0) /* no local connection or WALLOPS origin */
+                       continue;
+
+               client_type = Client_Type(to);
+               switch (client_type) {
+               case CLIENT_USER:
+                       if (Client_HasMode(to, 'w'))
+                               IRC_WriteStrClientPrefix(to, from, "WALLOPS :%s", Req->argv[0]);
+                       break;
+               case CLIENT_SERVER:
+                       if (to != Client)
+                               IRC_WriteStrClientPrefix(to, from, "WALLOPS :%s", Req->argv[0]);
+                       break;
+               }
+       }
+       return CONNECTED;
+}
+
+
+
 /* -eof- */
index dd2faa24ef7a7df3e86beac762d750836c763d12..8b867c45ae486e9079bda580032a25f2e81735f3 100644 (file)
@@ -8,7 +8,7 @@
  * (at your option) any later version.
  * Please read the file COPYING, README and AUTHORS for more information.
  *
- * $Id: irc-oper.h,v 1.11 2005/03/19 18:43:48 fw Exp $
+ * $Id: irc-oper.h,v 1.12 2007/08/02 10:14:26 fw Exp $
  *
  * IRC operator commands (header)
  */
@@ -24,6 +24,7 @@ GLOBAL bool IRC_REHASH PARAMS((CLIENT *Client, REQUEST *Req ));
 GLOBAL bool IRC_RESTART PARAMS((CLIENT *Client, REQUEST *Req ));
 GLOBAL bool IRC_CONNECT PARAMS((CLIENT *Client, REQUEST *Req ));
 GLOBAL bool IRC_DISCONNECT PARAMS((CLIENT *Client, REQUEST *Req ));
+GLOBAL bool IRC_WALLOPS PARAMS(( CLIENT *Client, REQUEST *Req ));
 
 
 #endif
index 548c3729543aa9838ffccc2e85c9500e88436735..b5e64a331ffd0a2c57b503e0d0ca2097d84747ec 100644 (file)
@@ -12,7 +12,7 @@
 
 #include "portab.h"
 
-static char UNUSED id[] = "$Id: parse.c,v 1.67 2006/04/23 10:37:27 fw Exp $";
+static char UNUSED id[] = "$Id: parse.c,v 1.68 2007/08/02 10:14:26 fw Exp $";
 
 /**
  * @file
@@ -93,6 +93,7 @@ COMMAND My_Commands[] =
        { "USER", IRC_USER, 0xFFFF, 0, 0, 0 },
        { "USERHOST", IRC_USERHOST, CLIENT_USER, 0, 0, 0 },
        { "VERSION", IRC_VERSION, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
+       { "WALLOPS", IRC_WALLOPS, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
        { "WHO", IRC_WHO, CLIENT_USER, 0, 0, 0 },
        { "WHOIS", IRC_WHOIS, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
        { "WHOWAS", IRC_WHOWAS, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },