From dbe4d8defbfe9e7cb2332e771c8472e365bef7f4 Mon Sep 17 00:00:00 2001 From: Michael Poole Date: Sat, 2 Apr 2005 03:32:38 +0000 Subject: [PATCH] Allow flagging of pseudo-commands as "fast". git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/trunk@1348 c9e4aea6-c8fd-4c43-8297-357d70d61c8c --- ChangeLog | 14 ++++++++++++++ include/s_conf.h | 3 +++ ircd/ircd_lexer.l | 1 + ircd/ircd_parser.y | 7 ++++++- ircd/parse.c | 10 +++++----- 5 files changed, 29 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5460464..b847ef0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2005-04-01 Michael Poole + + * 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 * include/handlers.h (ms_privs): Declare. diff --git a/include/s_conf.h b/include/s_conf.h index e58d9fa..d2a3824 100644 --- a/include/s_conf.h +++ b/include/s_conf.h @@ -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. */ }; diff --git a/ircd/ircd_lexer.l b/ircd/ircd_lexer.l index 48419e9..bb41a59 100644 --- a/ircd/ircd_lexer.l +++ b/ircd/ircd_lexer.l @@ -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 }, diff --git a/ircd/ircd_parser.y b/ircd/ircd_parser.y index b867f28..a9876bf 100644 --- a/ircd/ircd_parser.y +++ b/ircd/ircd_parser.y @@ -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 '{' { diff --git a/ircd/parse.c b/ircd/parse.c index 16a062f..e8181e1 100644 --- a/ircd/parse.c +++ b/ircd/parse.c @@ -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 -- 2.20.1