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 3100 by michael, Wed Mar 5 20:19:15 2014 UTC vs.
Revision 3235 by michael, Sat Mar 29 19:34:16 2014 UTC

# Line 104 | Line 104 | static char *para[MAXPARA + 2]; /* <comm
104  
105   static int cancel_clients(struct Client *, struct Client *, char *);
106   static void remove_unknown(struct Client *, char *, char *);
107 < static void handle_numeric(char[], struct Client *, struct Client *, int, char *[]);
108 < static void handle_command(struct Message *, struct Client *, struct Client *, unsigned int, char *[]);
107 > static void handle_numeric(char[], struct Client *, int, char *[]);
108 > static void handle_command(struct Message *, struct Client *, unsigned int, char *[]);
109  
110  
111   /*
# Line 141 | Line 141 | parse(struct Client *client_p, char *pbu
141       */
142      char *sender = ++ch;
143  
144 <    if ((s = strchr(ch, ' ')) != NULL)
144 >    if ((s = strchr(ch, ' ')))
145      {
146        *s = '\0';
147        ch = ++s;
# Line 204 | Line 204 | parse(struct Client *client_p, char *pbu
204    {
205      unsigned int ii = 0;
206  
207 <    if ((s = strchr(ch, ' ')) != NULL)
207 >    if ((s = strchr(ch, ' ')))
208        *s++ = '\0';
209  
210      if ((msg_ptr = find_command(ch)) == NULL)
# Line 223 | Line 223 | parse(struct Client *client_p, char *pbu
223        if (*pbuffer != '\0')
224        {
225          if (IsClient(from))
226 <          sendto_one(from, form_str(ERR_UNKNOWNCOMMAND),
227 <                     me.name, from->name, ch);
226 >          sendto_one_numeric(from, &me, ERR_UNKNOWNCOMMAND, ch);
227        }
228  
229        ++ServerStats.is_unco;
230        return;
231      }
232  
233 <    assert(msg_ptr->cmd != NULL);
233 >    assert(msg_ptr->cmd);
234  
235      paramcount = msg_ptr->args_max;
236      ii = bufend - ((s) ? s : ch);
# Line 281 | Line 280 | parse(struct Client *client_p, char *pbu
280  
281    para[++parc] = NULL;
282  
283 <  if (msg_ptr != NULL)
284 <    handle_command(msg_ptr, client_p, from, parc, para);
283 >  if (msg_ptr)
284 >    handle_command(msg_ptr, from, parc, para);
285    else
286 <    handle_numeric(numeric, client_p, from, parc, para);
286 >    handle_numeric(numeric, from, parc, para);
287   }
288  
289   /* handle_command()
# Line 298 | Line 297 | parse(struct Client *client_p, char *pbu
297   * side effects -
298   */
299   static void
300 < handle_command(struct Message *mptr, struct Client *client_p,
301 <               struct Client *from, unsigned int i, char *hpara[])
300 > handle_command(struct Message *mptr, struct Client *source_p,
301 >               unsigned int i, char *hpara[])
302   {
303 <  MessageHandler handler = 0;
305 <
306 <  if (IsServer(client_p))
303 >  if (IsServer(source_p->from))
304      mptr->rcount++;
305  
306    mptr->count++;
307  
311 –  handler = mptr->handlers[client_p->handler];
312 –
308    /* check right amount of params is passed... --is */
309    if (i < mptr->args_min)
310 <  {
316 <    if (!IsServer(client_p))
317 <    {
318 <      sendto_one(client_p, form_str(ERR_NEEDMOREPARAMS), me.name,
319 <                 client_p->name[0] ? client_p->name : "*", 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 <  }
310 >    sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, mptr->cmd);
311    else
312 <    (*handler)(client_p, from, i, hpara);
312 >    mptr->handlers[source_p->from->handler](source_p, i, hpara);
313   }
314  
315   /* add_msg_element()
# Line 418 | Line 396 | del_msg_element(struct MessageTree *mtre
396     * check that there is a msg pointer here, else links-- goes -ve
397     * -db
398     */
399 <  if ((*cmd == '\0') && (mtree_p->msg != NULL))
399 >  if (*cmd == '\0' && mtree_p->msg)
400    {
401      mtree_p->msg = NULL;
402      mtree_p->links--;
403    }
404    else
405    {
406 <    if ((ntree_p = mtree_p->pointers[*cmd & (MAXPTRLEN - 1)]) != NULL)
406 >    if ((ntree_p = mtree_p->pointers[*cmd & (MAXPTRLEN - 1)]))
407      {
408        del_msg_element(ntree_p, cmd + 1);
409  
# Line 509 | Line 487 | find_command(const char *cmd)
487   static void
488   recurse_report_messages(struct Client *source_p, const struct MessageTree *mtree)
489   {
490 <  unsigned int i;
490 >  if (mtree->msg)
491 >    sendto_one_numeric(source_p, &me, RPL_STATSCOMMANDS,
492 >                       mtree->msg->cmd,
493 >                       mtree->msg->count, mtree->msg->bytes,
494 >                       mtree->msg->rcount);
495  
496 <  if (mtree->msg != NULL)
497 <    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)
496 >  for (unsigned int i = 0; i < MAXPTRLEN; ++i)
497 >    if (mtree->pointers[i])
498        recurse_report_messages(source_p, mtree->pointers[i]);
499   }
500  
# Line 532 | Line 508 | void
508   report_messages(struct Client *source_p)
509   {
510    const struct MessageTree *mtree = &msg_tree;
535 –  unsigned int i;
511  
512 <  for (i = 0; i < MAXPTRLEN; ++i)
513 <    if (mtree->pointers[i] != NULL)
512 >  for (unsigned int i = 0; i < MAXPTRLEN; ++i)
513 >    if (mtree->pointers[i])
514        recurse_report_messages(source_p, mtree->pointers[i]);
515   }
516  
# Line 607 | Line 582 | cancel_clients(struct Client *client_p,
582                         "Message for %s[%s@%s!%s] from %s (TS, ignored)",
583                         source_p->name, source_p->username, source_p->host,
584                         source_p->from->name, get_client_name(client_p, MASK_IP));
610 –
585    return 0;
586   }
587  
# Line 631 | Line 605 | remove_unknown(struct Client *client_p,
605     * 'no.dot.at.start' is a server   (SQUIT)
606     */
607    if ((IsDigit(*lsender) && strlen(lsender) <= IRC_MAXSID) ||
608 <      strchr(lsender, '.') != NULL)
608 >      strchr(lsender, '.'))
609    {
610      sendto_realops_flags(UMODE_DEBUG, L_ADMIN, SEND_NOTICE,
611                           "Unknown prefix (%s) from %s, Squitting %s",
# Line 669 | 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,
673 <               int parc, char *parv[])
646 > handle_numeric(char numeric[], struct Client *source_p, int parc, char *parv[])
647   {
648    struct Client *target_p = NULL;
649    struct Channel *chptr = NULL;
# Line 691 | Line 664 | handle_numeric(char numeric[], struct Cl
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    /*
# Line 719 | Line 692 | handle_numeric(char numeric[], struct Cl
692                   numeric, ID_or_name(target_p, target_p), parv[2]);
693    }
694    else
695 <    sendto_channel_local(ALL_MEMBERS, 0, chptr, ":%s %s %s %s",
696 <                         source_p->name, numeric, chptr->chname, parv[2]);
695 >    sendto_channel_butone(source_p, source_p, chptr, 0, "%s %s %s",
696 >                          numeric, chptr->chname, parv[2]);
697   }
698  
699   /* m_not_oper()
# Line 729 | Line 702 | handle_numeric(char numeric[], struct Cl
702   * side effects - just returns a nastyogram to given user
703   */
704   int
705 < m_not_oper(struct Client *client_p, struct Client *source_p,
733 <           int parc, char *parv[])
705 > m_not_oper(struct Client *source_p, int parc, char *parv[])
706   {
707 <  sendto_one(source_p, form_str(ERR_NOPRIVILEGES),
736 <             me.name, source_p->name);
707 >  sendto_one_numeric(source_p, &me, ERR_NOPRIVILEGES);
708    return 0;
709   }
710  
711   int
712 < m_unregistered(struct Client *client_p, struct Client *source_p,
742 <               int parc, char *parv[])
712 > m_unregistered(struct Client *source_p, int parc, char *parv[])
713   {
714 <  sendto_one(source_p, form_str(ERR_NOTREGISTERED), me.name,
745 <             source_p->name[0] ? source_p->name : "*");
714 >  sendto_one_numeric(source_p, &me, ERR_NOTREGISTERED);
715    return 0;
716   }
717  
718   int
719 < m_registered(struct Client *client_p, struct Client *source_p,
751 <             int parc, char *parv[])
719 > m_registered(struct Client *source_p, int parc, char *parv[])
720   {
721 <  sendto_one(source_p, form_str(ERR_ALREADYREGISTRED),
754 <             me.name, source_p->name);
721 >  sendto_one_numeric(source_p, &me, ERR_ALREADYREGISTRED);
722    return 0;
723   }
724  
725   int
726 < m_ignore(struct Client *client_p, struct Client *source_p,
760 <         int parc, char *parv[])
726 > m_ignore(struct Client *source_p, int parc, char *parv[])
727   {
728    return 0;
729   }

Diff Legend

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