added gnutls backend and moved backend code into new files
[ircu2.10.12-pk.git] / ircd / parse.c
index 84dc1be9ee0bc92e4ad89bd9ae0d2b8e2ae5f733..b79ebb8ace48f6f52a9e50dce8812c4ddb2c82c2 100644 (file)
@@ -342,7 +342,7 @@ struct Message msgtab[] = {
     TOK_NAMES,
     0, MAXPARA, MFLG_SLOW, 0, NULL,
     /* UNREG, CLIENT, SERVER, OPER, SERVICE */
-    { m_unregistered, m_names, ms_names, m_names, m_ignore }
+    { m_unregistered, m_names, m_names, m_names, m_ignore }
   },
   {
     MSG_USERHOST,
@@ -391,7 +391,7 @@ struct Message msgtab[] = {
     TOK_SETTIME,
     0, MAXPARA, MFLG_SLOW, 0, NULL,
     /* UNREG, CLIENT, SERVER, OPER, SERVICE */
-    { m_unregistered, m_ignore, ms_settime, mo_settime, m_ignore }
+    { m_unregistered, m_not_oper, ms_settime, mo_settime, m_ignore }
   },
   {
     MSG_RPING,
@@ -617,6 +617,20 @@ struct Message msgtab[] = {
     /* UNREG, CLIENT, SERVER, OPER, SERVICE */
     { m_ignore, m_not_oper, ms_asll, mo_asll, m_ignore }
    },
+  {
+    MSG_XQUERY,
+    TOK_XQUERY,
+    0, MAXPARA, MFLG_SLOW, 0, NULL,
+    /* UNREG, CLIENT, SERVER, OPER, SERVICE */
+    { m_ignore, m_ignore, ms_xquery, mo_xquery, m_ignore }
+  },
+  {
+    MSG_XREPLY,
+    TOK_XREPLY,
+    0, MAXPARA, MFLG_SLOW, 0, NULL,
+    /* UNREG, CLIENT, SERVER, OPER, SERVICE */
+    { m_ignore, m_ignore, ms_xreply, m_ignore, m_ignore }
+  },
 #if WE_HAVE_A_REAL_CAPABILITY_NOW
   {
     MSG_CAP,
@@ -678,20 +692,28 @@ add_msg_element(struct MessageTree *mtree_p, struct Message *msg_p, char *cmd)
  * @param[in,out] mtree_p Trie node to remove command from.
  * @param[in] cmd Text of command to remove.
  */
-void
+struct MessageTree *
 del_msg_element(struct MessageTree *mtree_p, char *cmd)
 {
-  struct MessageTree *ntree_p;
+  int slot = *cmd & (MAXPTRLEN-1);
 
+  /* Either remove leaf message or from appropriate child. */
   if (*cmd == '\0')
-    return;
-
-  if ((ntree_p = mtree_p->pointers[*cmd & (MAXPTRLEN-1)]) != NULL)
-  {
-    del_msg_element(ntree_p, cmd+1);
-    MyFree(ntree_p);
-    mtree_p->pointers[*cmd & (MAXPTRLEN-1)] = NULL;
-  }
+    mtree_p->msg = NULL;
+  else
+    mtree_p->pointers[slot] = del_msg_element(mtree_p->pointers[slot], cmd + 1);
+
+  /* If current message or any child still exists, keep this node. */
+  if (mtree_p->msg)
+    return mtree_p;
+  for (slot = 0; slot < MAXPTRLEN; ++slot)
+    if (mtree_p->pointers[slot])
+      return mtree_p;
+
+  /* Otherwise, if we're not a root node, free it and return null. */
+  if (mtree_p != &msg_tree && mtree_p != &tok_tree)
+    MyFree(mtree_p);
+  return NULL;
 }
 
 /** Initialize the message lookup trie with all known commands. */
@@ -802,7 +824,6 @@ parse_client(struct Client *cptr, char *buffer, char *bufend)
   char*           s;
   int             i;
   int             paramcount;
-  int             noprefix = 0;
   struct Message* mptr;
   MessageHandler  handler = 0;
 
@@ -820,8 +841,6 @@ parse_client(struct Client *cptr, char *buffer, char *bufend)
     while (*ch == ' ')
       ch++;                     /* Advance to command */
   }
-  else
-    noprefix = 1;
   if (*ch == '\0')
   {
     ServerStats->is_empt++;