Allow flagging of pseudo-commands as "fast".
authorMichael Poole <mdpoole@troilus.org>
Sat, 2 Apr 2005 03:32:38 +0000 (03:32 +0000)
committerMichael Poole <mdpoole@troilus.org>
Sat, 2 Apr 2005 03:32:38 +0000 (03:32 +0000)
git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/trunk@1348 c9e4aea6-c8fd-4c43-8297-357d70d61c8c

ChangeLog
include/s_conf.h
ircd/ircd_lexer.l
ircd/ircd_parser.y
ircd/parse.c

index 54604645eb486430aae9078ad0855963aed0051b..b847ef0c2fbcba76017dc313337ee93e3813d63a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2005-04-01  Michael Poole <mdpoole@troilus.org>
+
+       * include/s_conf.h (SMAP_FAST): Define.
+       (s_map): Add 'flags' field.
+
+       * ircd/ircd_lexer.l: Recognize 'FAST' token.
+
+       * ircd/ircd_parser.y (FAST): New token.
+       (pseudoitem): Add pseudoflags alternative.
+       (pseudoflags): New production, recognizing FAST token.
+
+       * ircd/parse.c (register_mapping): Set MFLG_SLOW conditionally.
+       Remove outdated comment.
+
 2005-04-01  Michael Poole <mdpoole@troilus.org>
 
        * include/handlers.h (ms_privs): Declare.
index e58d9faf188b0f7143375b2d3c2324c678adcb2d..d2a38245149dc3782f80b6f4e2601ff7ab94aabe 100644 (file)
@@ -134,6 +134,8 @@ struct nick_host {
   char nick[1];           /**< start of nick\@server string */
 };
 
+#define SMAP_FAST 1           /**< Command does not have MFLG_SLOW. */
+
 /** Target set for a service pseudo-command. */
 struct s_map {
   struct s_map *next;         /**< Next element in #GlobalServiceMapList. */
@@ -141,6 +143,7 @@ struct s_map {
   char *name;                 /**< Text name of the mapping. */
   char *command;              /**< Command name to use. */
   char *prepend;              /**< Extra text to prepend to user's text. */
+  unsigned int flags;         /**< Bitwise map of SMAP_* flags. */
   struct nick_host *services; /**< Linked list of possible targets. */
 };
 
index 48419e95a92bb4f795818e25bcebb9d037245a0e..bb41a592b1c643147885d44a38a89eb07fbf8bf7 100644 (file)
@@ -98,6 +98,7 @@ static struct lexer_token {
   TOKEN(PSEUDO),
   TOKEN(PREPEND),
   TOKEN(USERMODE),
+  TOKEN(FAST),
 #undef TOKEN
   { "administrator", ADMIN },
   { "apass_opmode", TPRIV_APASS_OPMODE },
index b867f28d870ecff62f43ce5d9040a2675ede0e05..a9876bf15e1235ff2dd851eb0b7e94be2b0785c7 100644 (file)
@@ -156,6 +156,7 @@ static void parse_error(char *pattern,...) {
 %token USERMODE
 %token IAUTH
 %token TIMEOUT
+%token FAST
 /* and now a lot of privileges... */
 %token TPRIV_CHAN_LIMIT TPRIV_MODE_LCHAN TPRIV_DEOP_LCHAN TPRIV_WALK_LCHAN
 %token TPRIV_LOCAL_KILL TPRIV_REHASH TPRIV_RESTART TPRIV_DIE
@@ -943,7 +944,7 @@ pseudoitems '}' ';'
 };
 
 pseudoitems: pseudoitem pseudoitems | pseudoitem;
-pseudoitem: pseudoname | pseudoprepend | pseudonick | error;
+pseudoitem: pseudoname | pseudoprepend | pseudonick | pseudoflags | error;
 pseudoname: NAME '=' QSTRING ';'
 {
   DupString(smap->name, $3);
@@ -965,6 +966,10 @@ pseudonick: NICK '=' QSTRING ';'
     smap->services = nh;
   }
 };
+pseudoflags: FAST ';'
+{
+  smap->flags |= SMAP_FAST;
+};
 
 iauthblock: IAUTH '{'
 {
index 16a062f89b5e78cb3d6b9b71f12f4b0f36f7656f..e8181e1867eaacf98dee4f193c8cfec824f53102 100644 (file)
@@ -741,18 +741,18 @@ int register_mapping(struct s_map *map)
   msg->tok = map->command;
   msg->count = 0;
   msg->parameters = 2;
-  msg->flags = MFLG_SLOW | MFLG_EXTRA;
+  msg->flags = MFLG_EXTRA;
+  if (!(map->flags & SMAP_FAST))
+    msg->flags |= MFLG_SLOW;
   msg->bytes = 0;
   msg->extra = map;
 
   msg->handlers[UNREGISTERED_HANDLER] = m_ignore;
   msg->handlers[CLIENT_HANDLER] = m_pseudo;
   msg->handlers[SERVER_HANDLER] = m_ignore;
-  msg->handlers[OPER_HANDLER] = m_pseudo;
+  msg->handlers[OPER_HANDLER]   = m_pseudo;
   msg->handlers[SERVICE_HANDLER] = m_ignore;
 
-  /* Service mappings are only applicable to clients; insert the
-     pseudocommand into the command tree only. */
   add_msg_element(&msg_tree, msg, msg->cmd);
   map->msg = msg;
 
@@ -856,7 +856,7 @@ parse_client(struct Client *cptr, char *buffer, char *bufend)
   paramcount = mptr->parameters;
   i = bufend - ((s) ? s : ch);
   mptr->bytes += i;
-  if ((mptr->flags & MFLG_SLOW))
+  if ((mptr->flags & MFLG_SLOW) || !IsAnOper(cptr))
     cli_since(cptr) += (2 + i / 120);
   /*
    * Allow only 1 msg per 2 seconds