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 4556 by michael, Sat Aug 23 17:21:17 2014 UTC vs.
Revision 6161 by michael, Thu Jun 18 10:55:29 2015 UTC

# Line 1 | Line 1
1   /*
2   *  ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3   *
4 < *  Copyright (c) 1997-2014 ircd-hybrid development team
4 > *  Copyright (c) 1997-2015 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 15 | Line 15
15   *
16   *  You should have received a copy of the GNU General Public License
17   *  along with this program; if not, write to the Free Software
18 < *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
18 > *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19   *  USA
20   */
21  
# Line 29 | Line 29
29   #include "parse.h"
30   #include "channel.h"
31   #include "hash.h"
32 + #include "id.h"
33   #include "irc_string.h"
34   #include "ircd.h"
35   #include "numeric.h"
# Line 130 | Line 131 | parse_remove_unknown(struct Client *clie
131                 me.id, lsender, me.name);
132   }
133  
133 – /* cancel_clients()
134 – *
135 – * inputs       -
136 – * output       -
137 – * side effects -
138 – */
139 – static void
140 – parse_cancel_clients(struct Client *client_p, struct Client *source_p, char *cmd)
141 – {
142 –  if (IsServer(source_p) || IsMe(source_p))
143 –  {
144 –    sendto_realops_flags(UMODE_DEBUG, L_ADMIN, SEND_NOTICE,
145 –                         "Message for %s[%s] from %s",
146 –                         source_p->name, source_p->from->name,
147 –                         get_client_name(client_p, SHOW_IP));
148 –    sendto_realops_flags(UMODE_DEBUG, L_OPER, SEND_NOTICE,
149 –                         "Message for %s[%s] from %s",
150 –                         source_p->name, source_p->from->name,
151 –                         get_client_name(client_p, MASK_IP));
152 –    sendto_realops_flags(UMODE_DEBUG, L_ALL, SEND_NOTICE,
153 –                         "Not dropping server %s (%s) for Fake Direction",
154 –                         client_p->name, source_p->name);
155 –    return;
156 –  }
157 –
158 –  sendto_realops_flags(UMODE_DEBUG, L_ADMIN, SEND_NOTICE,
159 –                       "Message for %s[%s@%s!%s] from %s (TS, ignored)",
160 –                       source_p->name, source_p->username, source_p->host,
161 –                       source_p->from->name, get_client_name(client_p, SHOW_IP));
162 –  sendto_realops_flags(UMODE_DEBUG, L_OPER, SEND_NOTICE,
163 –                       "Message for %s[%s@%s!%s] from %s (TS, ignored)",
164 –                       source_p->name, source_p->username, source_p->host,
165 –                       source_p->from->name, get_client_name(client_p, MASK_IP));
166 – }
167 –
134   /*
135   *
136   *      parc    number of arguments ('sender' counted as one!)
# Line 210 | Line 176 | parse_handle_numeric(unsigned int numeri
176    else
177      target_p = find_person(source_p, parv[1]);
178  
179 <  if (((!target_p) || (target_p->from == source_p->from)) && !chptr)
179 >  if ((!target_p || target_p->from == source_p->from) && !chptr)
180      return;
181  
182    /*
# Line 230 | Line 196 | parse_handle_numeric(unsigned int numeri
196      /* Fake it for server hiding, if it's our client */
197      if ((ConfigServerHide.hide_servers || IsHidden(source_p)) && MyConnect(target_p) &&
198          !HasUMode(target_p, UMODE_OPER))
199 <      sendto_one_numeric(target_p, &me, numeric|SND_EXPLICIT, "%s", parv[2]);
199 >      sendto_one_numeric(target_p, &me, numeric | SND_EXPLICIT, "%s", parv[2]);
200      else
201 <      sendto_one_numeric(target_p, source_p, numeric|SND_EXPLICIT, "%s", parv[2]);
201 >      sendto_one_numeric(target_p, source_p, numeric | SND_EXPLICIT, "%s", parv[2]);
202    }
203    else
204      sendto_channel_butone(source_p, source_p, chptr, 0, "%u %s %s",
205 <                          numeric, chptr->chname, parv[2]);
205 >                          numeric, chptr->name, parv[2]);
206   }
207  
208   /* handle_command()
# Line 250 | Line 216 | parse_handle_numeric(unsigned int numeri
216   * side effects -
217   */
218   static void
219 < parse_handle_command(struct Message *mptr, struct Client *source_p,
219 > parse_handle_command(struct Message *message, struct Client *source_p,
220                       unsigned int i, char *para[])
221   {
222    if (IsServer(source_p->from))
223 <    ++mptr->rcount;
223 >    ++message->rcount;
224  
225 <  ++mptr->count;
225 >  ++message->count;
226  
227    /* Check right amount of parameters is passed... --is */
228 <  if (i < mptr->args_min)
229 <    sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, mptr->cmd);
228 >  if (i < message->args_min)
229 >    sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, message->cmd);
230    else
231 <    mptr->handlers[source_p->from->handler](source_p, i, para);
231 >    message->handlers[source_p->from->handler](source_p, i, para);
232   }
233  
234   /*
# Line 274 | Line 240 | void
240   parse(struct Client *client_p, char *pbuffer, char *bufend)
241   {
242    struct Client *from = client_p;
243 <  struct Message *msg_ptr = NULL;
243 >  struct Message *message = NULL;
244    char *para[MAXPARA + 2];  /* <command> + <parameters> + NULL */
245    char *ch = NULL;
246    char *s = NULL;
# Line 285 | Line 251 | parse(struct Client *client_p, char *pbu
251    if (IsDefunct(client_p))
252      return;
253  
254 <  assert(client_p->localClient->fd.flags.open);
254 >  assert(client_p->connection->fd.flags.open);
255    assert((bufend - pbuffer) < IRCD_BUFSIZE);
256  
257    for (ch = pbuffer; *ch == ' '; ++ch)  /* Skip spaces */
# Line 297 | Line 263 | parse(struct Client *client_p, char *pbu
263       * Copy the prefix to 'sender' assuming it terminates
264       * with SPACE (or NULL, which is an error, though).
265       */
266 <    const char *sender = ++ch;
266 >    const char *const sender = ++ch;
267  
268      if ((s = strchr(ch, ' ')))
269      {
# Line 325 | Line 291 | parse(struct Client *client_p, char *pbu
291        if (from->from != client_p)
292        {
293          ++ServerStats.is_wrdi;
294 <        parse_cancel_clients(client_p, from, pbuffer);
294 >        sendto_realops_flags(UMODE_DEBUG, L_ADMIN, SEND_NOTICE,
295 >                             "Fake direction: dropped message from %s[%s] via %s",
296 >                             from->name, from->from->name,
297 >                             get_client_name(client_p, SHOW_IP));
298 >        sendto_realops_flags(UMODE_DEBUG, L_OPER, SEND_NOTICE,
299 >                             "Fake direction: dropped message from %s[%s] via %s",
300 >                             from->name, from->from->name,
301 >                             get_client_name(client_p, MASK_IP));
302          return;
303        }
304      }
# Line 360 | Line 333 | parse(struct Client *client_p, char *pbu
333    }
334    else
335    {
336 <    unsigned int ii = 0;
336 >    unsigned int length = 0;
337  
338      if ((s = strchr(ch, ' ')))
339        *s++ = '\0';
340  
341 <    if ((msg_ptr = find_command(ch)) == NULL)
341 >    if ((message = find_command(ch)) == NULL)
342      {
343        /*
344         * Note: Give error message *only* to recognized
# Line 386 | Line 359 | parse(struct Client *client_p, char *pbu
359        return;
360      }
361  
362 <    assert(msg_ptr->cmd);
362 >    assert(message->cmd);
363  
364 <    paramcount = msg_ptr->args_max;
365 <    ii = bufend - ((s) ? s : ch);
366 <    msg_ptr->bytes += ii;
364 >    paramcount = message->args_max;
365 >    length = bufend - ((s) ? s : ch);
366 >    message->bytes += length;
367    }
368  
369    /*
# Line 404 | Line 377 | parse(struct Client *client_p, char *pbu
377  
378    para[parc] = ch;
379  
380 <  if (msg_ptr && (msg_ptr->flags & MFLG_EXTRA))
380 >  if (message && (message->flags & MFLG_EXTRA))
381    {
382      /*
383       * XXX: This will have to go away after the command handler rewrite
384       */
385 <    para[++parc] = msg_ptr->extra;
385 >    para[++parc] = message->extra;
386    }
387  
388    if (s)
# Line 427 | Line 400 | parse(struct Client *client_p, char *pbu
400  
401         if (*s == ':')
402         {
403 <         /* The rest is a single parameter */
403 >         /* The rest is single parameter--can include blanks also. */
404           para[++parc] = s + (!numeric);  /* Keep the colon if it's a numeric */
405           break;
406         }
# Line 444 | Line 417 | parse(struct Client *client_p, char *pbu
417  
418    para[++parc] = NULL;
419  
420 <  if (msg_ptr)
421 <    parse_handle_command(msg_ptr, from, parc, para);
420 >  if (message)
421 >    parse_handle_command(message, from, parc, para);
422    else
423      parse_handle_numeric(numeric, from, parc, para);
424   }
# Line 567 | Line 540 | msg_tree_parse(const char *cmd)
540   {
541    struct MessageTree *mtree = &msg_tree;
542  
543 <  assert(cmd && *cmd);
543 >  assert(!EmptyString(cmd));
544  
545    while (IsAlpha(*cmd) && (mtree = mtree->pointers[*cmd & (MAXPTRLEN - 1)]))
546      if (*++cmd == '\0')
# Line 646 | Line 619 | recurse_report_messages(struct Client *s
619   void
620   report_messages(struct Client *source_p)
621   {
622 <  const struct MessageTree *mtree = &msg_tree;
622 >  const struct MessageTree *const mtree = &msg_tree;
623  
624    for (unsigned int i = 0; i < MAXPTRLEN; ++i)
625      if (mtree->pointers[i])

Diff Legend

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