]> jfr.im git - solanum.git/blobdiff - ircd/parse.c
Change struct Dictionary(*) to rb_dictionary(_\1).
[solanum.git] / ircd / parse.c
index 1289baa181e2d6034f5e05de414cd6616995b108..76a3585de14b5d10019063cbe7e9901d9f4d69d0 100644 (file)
 #include "packet.h"
 #include "s_assert.h"
 
-struct Dictionary *cmd_dict = NULL;
-struct Dictionary *alias_dict = NULL;
-
-/* parv[0] is not used, and parv[LAST] == NULL */
-static char *para[MAXPARA + 2];
+rb_dictionary *cmd_dict = NULL;
+rb_dictionary *alias_dict = NULL;
 
 static void cancel_clients(struct Client *, struct Client *);
 static void remove_unknown(struct Client *, const char *, char *);
@@ -82,7 +79,7 @@ parse(struct Client *client_p, char *pbuffer, char *bufend)
 {
        struct Client *from = client_p;
        char *end;
-       int i = 1, res;
+       int res;
        int numeric = 0;
        struct Message *mptr;
        struct MsgBuf msgbuf;
@@ -107,7 +104,7 @@ parse(struct Client *client_p, char *pbuffer, char *bufend)
                return;
        }
 
-       if (msgbuf.origin != NULL)
+       if (msgbuf.origin != NULL && IsServer(client_p))
        {
                from = find_client(msgbuf.origin);
 
@@ -136,16 +133,25 @@ parse(struct Client *client_p, char *pbuffer, char *bufend)
        }
        else
        {
-               mptr = irc_dictionary_retrieve(cmd_dict, msgbuf.cmd);
+               mptr = rb_dictionary_retrieve(cmd_dict, msgbuf.cmd);
 
                /* no command or its encap only, error */
                if(!mptr || !mptr->cmd)
                {
                        if (IsPerson(client_p))
                        {
-                               struct alias_entry *aptr = irc_dictionary_retrieve(alias_dict, msgbuf.cmd);
+                               struct alias_entry *aptr = rb_dictionary_retrieve(alias_dict, msgbuf.cmd);
                                if (aptr != NULL)
                                {
+                                       if (msgbuf.n_para < 2)
+                                       {
+                                               sendto_one(client_p, form_str(ERR_NEEDMOREPARAMS),
+                                                          me.name,
+                                                          EmptyString(client_p->name) ? "*" : client_p->name,
+                                                          msgbuf.cmd);
+                                               return;
+                                       }
+
                                        do_alias(aptr, client_p, reconstruct_parv(msgbuf.n_para - 1, msgbuf.para + 1));
                                        return;
                                }
@@ -177,7 +183,7 @@ parse(struct Client *client_p, char *pbuffer, char *bufend)
                        /* Its expected this nasty code can be removed
                         * or rewritten later if still needed.
                         */
-                       if((unsigned long) (p + 8) > (unsigned long) end)
+                       if((p + 8) > end)
                        {
                                for (; p <= end; p++)
                                {
@@ -240,13 +246,13 @@ handle_command(struct Message *mptr, struct MsgBuf *msgbuf_p, struct Client *cli
 
                sendto_realops_snomask(SNO_GENERAL, L_ALL,
                                     "Dropping server %s due to (invalid) command '%s'"
-                                    " with only %zu arguments (expecting %d).",
+                                    " with only %zu arguments (expecting %zu).",
                                     client_p->name, mptr->cmd, msgbuf_p->n_para, ehandler.min_para);
                ilog(L_SERVER,
-                    "Insufficient parameters (%zu < %d) for command '%s' from %s.",
+                    "Insufficient parameters (%zu < %zu) for command '%s' from %s.",
                     msgbuf_p->n_para, ehandler.min_para, mptr->cmd, client_p->name);
                snprintf(squitreason, sizeof squitreason,
-                               "Insufficient parameters (%zu < %d) for command '%s'",
+                               "Insufficient parameters (%zu < %zu) for command '%s'",
                                msgbuf_p->n_para, ehandler.min_para, mptr->cmd);
                exit_client(client_p, client_p, client_p, squitreason);
                return (-1);
@@ -264,7 +270,7 @@ handle_encap(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *so
        struct MessageEntry ehandler;
        MessageHandler handler = 0;
 
-       mptr = irc_dictionary_retrieve(cmd_dict, command);
+       mptr = rb_dictionary_retrieve(cmd_dict, command);
 
        if(mptr == NULL || mptr->cmd == NULL)
                return;
@@ -272,7 +278,7 @@ handle_encap(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *so
        ehandler = mptr->handlers[ENCAP_HANDLER];
        handler = ehandler.handler;
 
-       if(parc < ehandler.min_para ||
+       if((size_t)parc < ehandler.min_para ||
           (ehandler.min_para && EmptyString(parv[ehandler.min_para - 1])))
                return;
 
@@ -290,7 +296,7 @@ handle_encap(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *so
 void
 clear_hash_parse()
 {
-       cmd_dict = irc_dictionary_create("command", strcasecmp);
+       cmd_dict = rb_dictionary_create("command", strcasecmp);
 }
 
 /* mod_add_cmd
@@ -309,14 +315,14 @@ mod_add_cmd(struct Message *msg)
        if(msg == NULL)
                return;
 
-       if (irc_dictionary_find(cmd_dict, msg->cmd) != NULL)
+       if (rb_dictionary_find(cmd_dict, msg->cmd) != NULL)
                return;
 
        msg->count = 0;
        msg->rcount = 0;
        msg->bytes = 0;
 
-       irc_dictionary_add(cmd_dict, msg->cmd, msg);
+       rb_dictionary_add(cmd_dict, msg->cmd, msg);
 }
 
 /* mod_del_cmd
@@ -332,7 +338,7 @@ mod_del_cmd(struct Message *msg)
        if(msg == NULL)
                return;
 
-       irc_dictionary_delete(cmd_dict, msg->cmd);
+       rb_dictionary_delete(cmd_dict, msg->cmd);
 }
 
 /* cancel_clients()
@@ -567,14 +573,13 @@ static void do_alias(struct alias_entry *aptr, struct Client *source_p, char *te
                        text);
 }
 
-int
+void
 m_not_oper(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
 {
        sendto_one_numeric(source_p, ERR_NOPRIVILEGES, form_str(ERR_NOPRIVILEGES));
-       return 0;
 }
 
-int
+void
 m_unregistered(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
 {
        /* bit of a hack.
@@ -587,19 +592,16 @@ m_unregistered(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *
                sendto_one(client_p, form_str(ERR_NOTREGISTERED), me.name);
                client_p->localClient->number_of_nick_changes++;
        }
-
-       return 0;
 }
 
-int
+void
 m_registered(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
 {
        sendto_one(client_p, form_str(ERR_ALREADYREGISTRED), me.name, source_p->name);
-       return 0;
 }
 
-int
+void
 m_ignore(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
 {
-       return 0;
+       /* Does nothing */
 }