ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/parse.c
(Generate patch)

Comparing ircd-hybrid/trunk/src/parse.c (file contents):
Revision 2182 by michael, Tue Jun 4 12:19:04 2013 UTC vs.
Revision 3638 by michael, Fri May 23 19:54:30 2014 UTC

# Line 1 | Line 1
1   /*
2 < *  ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3 < *  parse.c: The message parser.
2 > *  ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3   *
4 < *  Copyright (C) 2002 by the past and present ircd coders, and others.
4 > *  Copyright (c) 1997-2014 ircd-hybrid development team
5   *
6   *  This program is free software; you can redistribute it and/or modify
7   *  it under the terms of the GNU General Public License as published by
# Line 18 | Line 17
17   *  along with this program; if not, write to the Free Software
18   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
19   *  USA
20 < *
21 < *  $Id$
20 > */
21 >
22 > /*! \file parse.c
23 > * \brief The message parser.
24 > * \version $Id$
25   */
26  
27   #include "stdinc.h"
# Line 34 | Line 36
36   #include "send.h"
37   #include "conf.h"
38   #include "memory.h"
39 < #include "s_user.h"
40 < #include "s_serv.h"
39 > #include "user.h"
40 > #include "server.h"
41 >
42  
43   /*
44   * (based on orabidoo's parser code)
# Line 51 | Line 54
54   * 't' points -> [MessageTree *] 'r' -> [MessageTree *] -> 'i'
55   *   -> [MessageTree *] -> [MessageTree *] -> 'e' and matches
56   *
57 < *                               'i' -> [MessageTree *] -> 'e' and matches
57 > *                               'i' -> [MessageTree *] -> 'e' and matches
58   *
59   * BUGS (Limitations!)
60 < *
60 > *
61   * I designed this trie to parse ircd commands. Hence it currently
62   * casefolds. This is trivial to fix by increasing MAXPTRLEN.
63   * This trie also "folds" '{' etc. down. This means, the input to this
# Line 64 | Line 67
67   * MAXPTRLEN 128.
68   *
69   * This is also not a patricia trie. On short ircd tokens, this is
70 < * not likely going to matter.
70 > * not likely going to matter.
71   *
72   * Diane Bruce (Dianora), June 6 2003
73   */
# Line 88 | Line 91
91  
92   struct MessageTree
93   {
94 <  int links; /* Count of all pointers (including msg) at this node
94 >  int links; /* Count of all pointers (including msg) at this node
95                * used as reference count for deletion of _this_ node.
96                */
97    struct Message *msg;
# Line 97 | Line 100 | struct MessageTree
100  
101   static struct MessageTree msg_tree;
102  
100 – /*
101 – * NOTE: parse() should not be called recursively by other functions!
102 – */
103 – static char *sender;
104 – static char *para[MAXPARA + 2]; /* <prefix> + <params> + NULL */
105 –
103   static int cancel_clients(struct Client *, struct Client *, char *);
104   static void remove_unknown(struct Client *, char *, char *);
105 < static void handle_numeric(char[], struct Client *, struct Client *, int, char *[]);
106 < static void handle_command(struct Message *, struct Client *, struct Client *, unsigned int, char *[]);
105 > static void handle_numeric(unsigned int, struct Client *, int, char *[]);
106 > static void handle_command(struct Message *, struct Client *, unsigned int, char *[]);
107  
108  
109   /*
# Line 119 | Line 116 | parse(struct Client *client_p, char *pbu
116   {
117    struct Client *from = client_p;
118    struct Message *msg_ptr = NULL;
119 +  char *para[MAXPARA + 2];  /* <command> + <parameters> + NULL */
120    char *ch = NULL;
121    char *s = NULL;
122 <  char *numeric = NULL;
122 >  unsigned int numeric = 0;
123    unsigned int parc = 0;
124    unsigned int paramcount;
125  
# Line 129 | Line 127 | parse(struct Client *client_p, char *pbu
127      return;
128  
129    assert(client_p->localClient->fd.flags.open);
130 <  assert((bufend - pbuffer) < 512);
130 >  assert((bufend - pbuffer) < IRCD_BUFSIZE);
131  
132 <  for (ch = pbuffer; *ch == ' '; ++ch) /* skip spaces */
133 <    /* null statement */ ;
132 >  for (ch = pbuffer; *ch == ' '; ++ch)  /* Skip spaces */
133 >    ;
134  
135    if (*ch == ':')
136    {
# Line 140 | Line 138 | parse(struct Client *client_p, char *pbu
138       * Copy the prefix to 'sender' assuming it terminates
139       * with SPACE (or NULL, which is an error, though).
140       */
141 <    sender = ++ch;
141 >    char *sender = ++ch;
142  
143 <    if ((s = strchr(ch, ' ')) != NULL)
143 >    if ((s = strchr(ch, ' ')))
144      {
145        *s = '\0';
146        ch = ++s;
# Line 153 | Line 151 | parse(struct Client *client_p, char *pbu
151        if ((from = find_person(client_p, sender)) == NULL)
152          from = hash_find_server(sender);
153  
154 <      /* Hmm! If the client corresponding to the
155 <       * prefix is not found--what is the correct
156 <       * action??? Now, I will ignore the message
157 <       * (old IRC just let it through as if the
160 <       * prefix just wasn't there...) --msa
154 >      /*
155 >       * Hmm! If the client corresponding to the prefix is not found--what is
156 >       * the correct action??? Now, I will ignore the message (old IRC just
157 >       * let it through as if the prefix just wasn't there...) --msa
158         */
159        if (from == NULL)
160        {
# Line 184 | Line 181 | parse(struct Client *client_p, char *pbu
181      return;
182    }
183  
184 <  /* Extract the command code from the packet.  Point s to the end
184 >  /*
185 >   * Extract the command code from the packet. Point s to the end
186     * of the command code and calculate the length using pointer
187 <   * arithmetic.  Note: only need length for numerics and *all*
187 >   * arithmetic. Note: only need length for numerics and *all*
188     * numerics must have parameters and thus a space after the command
189     * code. -avalon
190     */
191  
192 <  /* EOB is 3 chars long but is not a numeric */
193 <  if (*(ch + 3) == ' ' && /* ok, lets see if its a possible numeric.. */
192 >  /* EOB is 3 characters long but is not a numeric */
193 >  if (*(ch + 3) == ' ' &&  /* Ok, lets see if its a possible numeric.. */
194        IsDigit(*ch) && IsDigit(*(ch + 1)) && IsDigit(*(ch + 2)))
195    {
196 <    numeric = ch;
197 <    paramcount = 2; /* destination, and the rest of it */
196 >    numeric = (*ch - '0') * 100 + (*(ch + 1) - '0') * 10 + (*(ch + 2) - '0');
197 >    paramcount = 2;  /* Destination, and the rest of it */
198      ++ServerStats.is_num;
199 <    s = ch + 3;  /* I know this is ' ' from above if            */
200 <    *s++ = '\0'; /* blow away the ' ', and point s to next part */
199 >    s = ch + 3;  /* I know this is ' ' from above if */
200 >    *s++ = '\0';  /* Blow away the ' ', and point s to next part */
201    }
202    else
203 <  {
203 >  {
204      unsigned int ii = 0;
205  
206 <    if ((s = strchr(ch, ' ')) != NULL)
206 >    if ((s = strchr(ch, ' ')))
207        *s++ = '\0';
208  
209      if ((msg_ptr = find_command(ch)) == NULL)
210      {
211 <      /* Note: Give error message *only* to recognized
211 >      /*
212 >       * Note: Give error message *only* to recognized
213         * persons. It's a nightmare situation to have
214         * two programs sending "Unknown command"'s or
215         * equivalent to each other at full blast....
# Line 220 | Line 219 | parse(struct Client *client_p, char *pbu
219         * Hm, when is the buffer empty -- if a command
220         * code has been found ?? -Armin
221         */
222 <      if (*pbuffer != '\0')
224 <      {
222 >      if (*pbuffer)
223          if (IsClient(from))
224 <          sendto_one(from, form_str(ERR_UNKNOWNCOMMAND),
227 <                     me.name, from->name, ch);
228 <      }
224 >          sendto_one_numeric(from, &me, ERR_UNKNOWNCOMMAND, ch);
225  
226        ++ServerStats.is_unco;
227        return;
228      }
229  
230 <    assert(msg_ptr->cmd != NULL);
230 >    assert(msg_ptr->cmd);
231  
232      paramcount = msg_ptr->args_max;
233      ii = bufend - ((s) ? s : ch);
# Line 245 | Line 241 | parse(struct Client *client_p, char *pbu
241     * this last parameter (about same effect as ":" has...) --msa
242     */
243  
244 <  /* Note initially true: s==NULL || *(s-1) == '\0' !! */
244 >  /* Note initially true: s == NULL || *(s - 1) == '\0' !! */
245  
246 <  para[parc] = from->name;
246 >  para[parc] = ch;
247  
248    if (s)
249    {
# Line 265 | Line 261 | parse(struct Client *client_p, char *pbu
261         if (*s == ':')
262         {
263           /* The rest is a single parameter */
264 <         para[++parc] = s + (!numeric); /* keep the colon if it's a numeric */
264 >         para[++parc] = s + (!numeric);  /* Keep the colon if it's a numeric */
265           break;
266         }
267  
# Line 281 | Line 277 | parse(struct Client *client_p, char *pbu
277  
278    para[++parc] = NULL;
279  
280 <  if (msg_ptr != NULL)
281 <    handle_command(msg_ptr, client_p, from, parc, para);
280 >  if (msg_ptr)
281 >    handle_command(msg_ptr, from, parc, para);
282    else
283 <    handle_numeric(numeric, client_p, from, parc, para);
283 >    handle_numeric(numeric, from, parc, para);
284   }
285  
286   /* handle_command()
# Line 298 | Line 294 | parse(struct Client *client_p, char *pbu
294   * side effects -
295   */
296   static void
297 < handle_command(struct Message *mptr, struct Client *client_p,
298 <               struct Client *from, unsigned int i, char *hpara[])
297 > handle_command(struct Message *mptr, struct Client *source_p,
298 >               unsigned int i, char *para[])
299   {
300 <  MessageHandler handler = 0;
300 >  if (IsServer(source_p->from))
301 >    ++mptr->rcount;
302  
303 <  if (IsServer(client_p))
307 <    mptr->rcount++;
303 >  ++mptr->count;
304  
305 <  mptr->count++;
310 <
311 <  handler = mptr->handlers[client_p->handler];
312 <
313 <  /* check right amount of params is passed... --is */
305 >  /* Check right amount of parameters is passed... --is */
306    if (i < mptr->args_min)
307 <  {
316 <    if (!IsServer(client_p))
317 <    {
318 <      sendto_one(client_p, form_str(ERR_NEEDMOREPARAMS), me.name,
319 <                 EmptyString(hpara[0]) ? "*" : hpara[0], mptr->cmd);
320 <    }
321 <    else
322 <    {
323 <      sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
324 <                           "Dropping server %s due to (invalid) command '%s' "
325 <                           "with only %d arguments (expecting %d).",
326 <                           client_p->name, mptr->cmd, i, mptr->args_min);
327 <      ilog(LOG_TYPE_IRCD, "Insufficient parameters (%d) for command '%s' from %s.",
328 <           i, mptr->cmd, client_p->name);
329 <      exit_client(client_p, client_p,
330 <                  "Not enough arguments to server command.");
331 <    }
332 <  }
307 >    sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, mptr->cmd);
308    else
309 <    (*handler)(client_p, from, i, hpara);
309 >    mptr->handlers[source_p->from->handler](source_p, i, para);
310   }
311  
312   /* add_msg_element()
# Line 358 | Line 333 | static void
333   add_msg_element(struct MessageTree *mtree_p, struct Message *msg_p,
334                  const char *cmd)
335   {
336 <  struct MessageTree *ntree_p;
336 >  struct MessageTree *ntree_p = NULL;
337  
338    if (*cmd == '\0')
339    {
# Line 367 | Line 342 | add_msg_element(struct MessageTree *mtre
342    }
343    else
344    {
345 <    /* *cmd & (MAXPTRLEN-1)
345 >    /*
346 >     * *cmd & (MAXPTRLEN-1)
347       * convert the char pointed to at *cmd from ASCII to an integer
348       * between 0 and MAXPTRLEN.
349       * Thus 'A' -> 0x1 'B' -> 0x2 'c' -> 0x3 etc.
350       */
375 –
351      if ((ntree_p = mtree_p->pointers[*cmd & (MAXPTRLEN - 1)]) == NULL)
352      {
353 <      ntree_p = MyMalloc(sizeof(struct MessageTree));
353 >      ntree_p = MyCalloc(sizeof(struct MessageTree));
354        mtree_p->pointers[*cmd & (MAXPTRLEN - 1)] = ntree_p;
355  
356        mtree_p->links++;  /* Have new pointer, so up ref count */
# Line 411 | Line 386 | add_msg_element(struct MessageTree *mtre
386   static void
387   del_msg_element(struct MessageTree *mtree_p, const char *cmd)
388   {
389 <  struct MessageTree *ntree_p;
389 >  struct MessageTree *ntree_p = NULL;
390  
391    /*
392     * In case this is called for a nonexistent command
393     * check that there is a msg pointer here, else links-- goes -ve
394     * -db
395     */
396 <  if ((*cmd == '\0') && (mtree_p->msg != NULL))
396 >  if (*cmd == '\0' && mtree_p->msg)
397    {
398      mtree_p->msg = NULL;
399      mtree_p->links--;
400    }
401    else
402    {
403 <    if ((ntree_p = mtree_p->pointers[*cmd & (MAXPTRLEN - 1)]) != NULL)
403 >    if ((ntree_p = mtree_p->pointers[*cmd & (MAXPTRLEN - 1)]))
404      {
405        del_msg_element(ntree_p, cmd + 1);
406  
# Line 450 | Line 425 | static struct Message *
425   msg_tree_parse(const char *cmd)
426   {
427    struct MessageTree *mtree = &msg_tree;
428 +
429    assert(cmd && *cmd);
430  
431    while (IsAlpha(*cmd) && (mtree = mtree->pointers[*cmd & (MAXPTRLEN - 1)]))
# Line 472 | Line 448 | mod_add_cmd(struct Message *msg)
448   {
449    assert(msg && msg->cmd);
450  
451 <  /* command already added? */
451 >  /* Command already added? */
452    if (msg_tree_parse(msg->cmd))
453      return;
454  
# Line 491 | Line 467 | mod_del_cmd(struct Message *msg)
467   {
468    assert(msg && msg->cmd);
469  
470 +  if (!msg_tree_parse(msg->cmd))
471 +    return;
472 +
473    del_msg_element(&msg_tree, msg->cmd);
474   }
475  
# Line 509 | Line 488 | find_command(const char *cmd)
488   static void
489   recurse_report_messages(struct Client *source_p, const struct MessageTree *mtree)
490   {
491 <  unsigned int i;
491 >  if (mtree->msg)
492 >    sendto_one_numeric(source_p, &me, RPL_STATSCOMMANDS,
493 >                       mtree->msg->cmd,
494 >                       mtree->msg->count, mtree->msg->bytes,
495 >                       mtree->msg->rcount);
496  
497 <  if (mtree->msg != NULL)
498 <    sendto_one(source_p, form_str(RPL_STATSCOMMANDS),
516 <               me.name, source_p->name, mtree->msg->cmd,
517 <               mtree->msg->count, mtree->msg->bytes,
518 <               mtree->msg->rcount);
519 <
520 <  for (i = 0; i < MAXPTRLEN; ++i)
521 <    if (mtree->pointers[i] != NULL)
497 >  for (unsigned int i = 0; i < MAXPTRLEN; ++i)
498 >    if (mtree->pointers[i])
499        recurse_report_messages(source_p, mtree->pointers[i]);
500   }
501  
# Line 532 | Line 509 | void
509   report_messages(struct Client *source_p)
510   {
511    const struct MessageTree *mtree = &msg_tree;
535 –  unsigned int i;
512  
513 <  for (i = 0; i < MAXPTRLEN; ++i)
514 <    if (mtree->pointers[i] != NULL)
513 >  for (unsigned int i = 0; i < MAXPTRLEN; ++i)
514 >    if (mtree->pointers[i])
515        recurse_report_messages(source_p, mtree->pointers[i]);
516   }
517  
518   /* cancel_clients()
519   *
520 < * inputs       -
521 < * output       -
522 < * side effects -
520 > * inputs       -
521 > * output       -
522 > * side effects -
523   */
524   static int
525   cancel_clients(struct Client *client_p, struct Client *source_p, char *cmd)
526   {
527 <  /* kill all possible points that are causing confusion here,
527 >  /*
528 >   * Kill all possible points that are causing confusion here,
529     * I'm not sure I've got this all right...
530     * - avalon
531     *
532 <   * knowing avalon, probably not.
532 >   * Knowing avalon, probably not.
533     */
534  
535 <  /* with TS, fake prefixes are a common thing, during the
535 >  /*
536 >   * With TS, fake prefixes are a common thing, during the
537     * connect burst when there's a nick collision, and they
538     * must be ignored rather than killed because one of the
539     * two is surviving.. so we don't bother sending them to
# Line 564 | Line 542 | cancel_clients(struct Client *client_p,
542     * servers to be dropped though, as well as the ones from
543     * non-TS servers -orabidoo
544     */
545 <  /* Incorrect prefix for a server from some connection.  If it is a
545 >  /*
546 >   * Incorrect prefix for a server from some connection. If it is a
547     * client trying to be annoying, just QUIT them, if it is a server
548     * then the same deal.
549     */
# Line 585 | Line 564 | cancel_clients(struct Client *client_p,
564      /* return exit_client(client_p, client_p, &me, "Fake Direction");*/
565    }
566  
567 <  /* Ok, someone is trying to impose as a client and things are
568 <   * confused.  If we got the wrong prefix from a server, send out a
567 >  /*
568 >   * Ok, someone is trying to impose as a client and things are
569 >   * confused. If we got the wrong prefix from a server, send out a
570     * kill, else just exit the lame client.
571     */
572 <  /* If the fake prefix is coming from a TS server, discard it
572 >  /*
573 >   * If the fake prefix is coming from a TS server, discard it
574     * silently -orabidoo
575     *
576     * all servers must be TS these days --is
# Line 602 | Line 583 | cancel_clients(struct Client *client_p,
583                         "Message for %s[%s@%s!%s] from %s (TS, ignored)",
584                         source_p->name, source_p->username, source_p->host,
585                         source_p->from->name, get_client_name(client_p, MASK_IP));
605 –
586    return 0;
587   }
588  
589   /* remove_unknown()
590   *
591 < * inputs       -
592 < * output       -
593 < * side effects -
591 > * inputs       -
592 > * output       -
593 > * side effects -
594   */
595   static void
596   remove_unknown(struct Client *client_p, char *lsender, char *lbuffer)
597   {
598 <  /* Do kill if it came from a server because it means there is a ghost
598 >  /*
599 >   * Do kill if it came from a server because it means there is a ghost
600     * user on the other server which needs to be removed. -avalon
601     * Tell opers about this. -Taner
602     */
603 <  /* '[0-9]something'  is an ID      (KILL/SQUIT depending on its length)
603 >  /*
604 >   * '[0-9]something'  is an ID      (KILL/SQUIT depending on its length)
605     * 'nodots'          is a nickname (KILL)
606     * 'no.dot.at.start' is a server   (SQUIT)
607     */
608 <  if ((IsDigit(*lsender) && strlen(lsender) <= IRC_MAXSID) ||
627 <      strchr(lsender, '.') != NULL)
608 >  if ((IsDigit(*lsender) && strlen(lsender) <= IRC_MAXSID) || strchr(lsender, '.'))
609    {
610      sendto_realops_flags(UMODE_DEBUG, L_ADMIN, SEND_NOTICE,
611                           "Unknown prefix (%s) from %s, Squitting %s",
# Line 633 | Line 614 | remove_unknown(struct Client *client_p,
614                           "Unknown prefix (%s) from %s, Squitting %s",
615                           lbuffer, client_p->name, lsender);
616      sendto_one(client_p, ":%s SQUIT %s :(Unknown prefix (%s) from %s)",
617 <               me.name, lsender, lbuffer, client_p->name);
617 >               me.id, lsender, lbuffer, client_p->name);
618    }
619    else
620      sendto_one(client_p, ":%s KILL %s :%s (Unknown Client)",
621 <               me.name, lsender, me.name);
621 >               me.id, lsender, me.name);
622   }
623  
624   /*
# Line 662 | Line 643 | remove_unknown(struct Client *client_p,
643   * the savvy approach is NEVER generate an error in response to an... error :)
644   */
645   static void
646 < handle_numeric(char numeric[], struct Client *client_p, struct Client *source_p,
666 <               int parc, char *parv[])
646 > handle_numeric(unsigned int numeric, struct Client *source_p, int parc, char *parv[])
647   {
648    struct Client *target_p = NULL;
649    struct Channel *chptr = NULL;
650  
651 <  /* Avoid trash, we need it to come from a server and have a target  */
651 >  /*
652 >   * Avoid trash, we need it to come from a server and have a target
653 >   */
654    if (parc < 2 || !IsServer(source_p))
655      return;
656  
657    /*
658     * Who should receive this message ? Will we do something with it ?
659 <   *  Note that we use findUser functions, so the target can't be neither
660 <   *  a server, nor a channel (?) nor a list of targets (?) .. u2.10
661 <   *  should never generate numeric replies to non-users anyway
662 <   *  Ahem... it can be a channel actually, csc bots use it :\ --Nem
659 >   * Note that we use findUser functions, so the target can't be neither
660 >   * a server, nor a channel (?) nor a list of targets (?) .. u2.10
661 >   * should never generate numeric replies to non-users anyway
662 >   * Ahem... it can be a channel actually, csc bots use it :\ --Nem
663     */
664    if (IsChanPrefix(*parv[1]))
665      chptr = hash_find_channel(parv[1]);
666    else
667 <    target_p = find_person(client_p, parv[1]);
667 >    target_p = find_person(source_p, parv[1]);
668  
669 <  if (((!target_p) || (target_p->from == client_p)) && !chptr)
669 >  if (((!target_p) || (target_p->from == source_p->from)) && !chptr)
670      return;
671  
672    /*
673     * Remap low number numerics, not that I understand WHY.. --Nemesi
674     */
675    /*
676 <   * numerics below 100 talk about the current 'connection', you're not
676 >   * Numerics below 100 talk about the current 'connection', you're not
677     * connected to a remote server so it doesn't make sense to send them
678     * remotely - but the information they contain may be useful, so we
679 <   * remap them up.  Weird, but true.  -- Isomer
679 >   * remap them up. Weird, but true.  -- Isomer
680     */
681 <  if (numeric[0] == '0')
682 <    numeric[0] = '1';
681 >  if (numeric < 100)
682 >    numeric += 100;
683  
684    if (target_p)
685    {
686 <    /* Fake it for server hiding, if its our client */
687 <    if (ConfigServerHide.hide_servers && MyClient(target_p) &&
686 >    /* Fake it for server hiding, if it's our client */
687 >    if (ConfigServerHide.hide_servers && MyConnect(target_p) &&
688          !HasUMode(target_p, UMODE_OPER))
689 <      sendto_one(target_p, ":%s %s %s %s", me.name, numeric, target_p->name, parv[2]);
689 >      sendto_one_numeric(target_p, &me, numeric|SND_EXPLICIT, "%s", parv[2]);
690      else
691 <      sendto_one(target_p, ":%s %s %s %s", ID_or_name(source_p, target_p->from),
710 <                 numeric, ID_or_name(target_p, target_p->from), parv[2]);
691 >      sendto_one_numeric(target_p, source_p, numeric|SND_EXPLICIT, "%s", parv[2]);
692    }
693    else
694 <    sendto_channel_local(ALL_MEMBERS, 0, chptr, ":%s %s %s %s",
695 <                         source_p->name, numeric, chptr->chname, parv[2]);
694 >    sendto_channel_butone(source_p, source_p, chptr, 0, "%u %s %s",
695 >                          numeric, chptr->chname, parv[2]);
696   }
697  
698   /* m_not_oper()
699 < * inputs       -
699 > * inputs       -
700   * output       -
701   * side effects - just returns a nastyogram to given user
702   */
703 < void
704 < m_not_oper(struct Client *client_p, struct Client *source_p,
724 <           int parc, char *parv[])
703 > int
704 > m_not_oper(struct Client *source_p, int parc, char *parv[])
705   {
706 <  sendto_one(source_p, form_str(ERR_NOPRIVILEGES),
707 <             me.name, source_p->name);
706 >  sendto_one_numeric(source_p, &me, ERR_NOPRIVILEGES);
707 >  return 0;
708   }
709  
710 < void
711 < m_unregistered(struct Client *client_p, struct Client *source_p,
732 <               int parc, char *parv[])
710 > int
711 > m_unregistered(struct Client *source_p, int parc, char *parv[])
712   {
713 <  sendto_one(source_p, form_str(ERR_NOTREGISTERED), me.name,
714 <             source_p->name[0] ? source_p->name : "*");
736 < }
737 <
738 < void
739 < m_registered(struct Client *client_p, struct Client *source_p,
740 <             int parc, char *parv[])
741 < {
742 <  sendto_one(source_p, form_str(ERR_ALREADYREGISTRED),  
743 <             me.name, source_p->name);
713 >  sendto_one_numeric(source_p, &me, ERR_NOTREGISTERED);
714 >  return 0;
715   }
716  
717 < void
718 < m_ignore(struct Client *client_p, struct Client *source_p,
748 <         int parc, char *parv[])
717 > int
718 > m_registered(struct Client *source_p, int parc, char *parv[])
719   {
720 <  return;
720 >  sendto_one_numeric(source_p, &me, ERR_ALREADYREGISTRED);
721 >  return 0;
722   }
723  
724 < void
725 < rfc1459_command_send_error(struct Client *client_p, struct Client *source_p,
755 <                           int parc, char *parv[])
724 > int
725 > m_ignore(struct Client *source_p, int parc, char *parv[])
726   {
727 <  const char *in_para;
758 <
759 <  in_para = (parc > 1 && *parv[1] != '\0') ? parv[1] : "<>";
760 <
761 <  ilog(LOG_TYPE_IRCD, "Received ERROR message from %s: %s",
762 <       source_p->name, in_para);
763 <
764 <  if (client_p == source_p)
765 <  {
766 <    sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE,
767 <                         "ERROR :from %s -- %s",
768 <                         get_client_name(client_p, HIDE_IP), in_para);
769 <    sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE,
770 <                         "ERROR :from %s -- %s",
771 <                         get_client_name(client_p, MASK_IP), in_para);
772 <  }
773 <  else
774 <  {
775 <    sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE,
776 <                         "ERROR :from %s via %s -- %s",
777 <                         source_p->name, get_client_name(client_p, HIDE_IP), in_para);
778 <    sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE,
779 <                         "ERROR :from %s via %s -- %s",
780 <                         source_p->name, get_client_name(client_p, MASK_IP), in_para);
781 <  }
782 <
783 <  if (MyClient(source_p))
784 <    exit_client(source_p, source_p, "ERROR");
727 >  return 0;
728   }

Diff Legend

– Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)