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

Comparing:
ircd-hybrid/src/send.c (file contents), Revision 32 by knight, Sun Oct 2 20:41:23 2005 UTC vs.
ircd-hybrid/trunk/src/send.c (file contents), Revision 2635 by michael, Tue Dec 10 17:46:37 2013 UTC

# Line 23 | Line 23
23   */
24  
25   #include "stdinc.h"
26 < #include "tools.h"
26 > #include "list.h"
27   #include "send.h"
28   #include "channel.h"
29   #include "client.h"
30 #include "common.h"
30   #include "dbuf.h"
31   #include "irc_string.h"
32   #include "ircd.h"
34 #include "handlers.h"
33   #include "numeric.h"
34   #include "fdlist.h"
35   #include "s_bsd.h"
36   #include "s_serv.h"
37 < #include "sprintf_irc.h"
38 < #include "s_conf.h"
41 < #include "list.h"
42 < #include "s_log.h"
37 > #include "conf.h"
38 > #include "log.h"
39   #include "memory.h"
44 #include "hook.h"
45 #include "irc_getnameinfo.h"
40   #include "packet.h"
41  
48 #define LOG_BUFSIZE 2048
42  
43 < struct Callback *iosend_cb = NULL;
51 < struct Callback *iosendctrl_cb = NULL;
43 > static unsigned int current_serial = 0;
44  
53 static void send_message(struct Client *, char *, int);
54 static void send_message_remote(struct Client *, struct Client *, char *, int);
55
56 static unsigned long current_serial = 0L;
45  
46   /* send_format()
47   *
# Line 87 | Line 75 | send_format(char *lsendbuf, int bufsize,
75  
76    lsendbuf[len++] = '\r';
77    lsendbuf[len++] = '\n';
78 <  return (len);
78 >  return len;
79   }
80  
81   /*
# Line 98 | Line 86 | send_format(char *lsendbuf, int bufsize,
86   static void
87   send_message(struct Client *to, char *buf, int len)
88   {
89 < #ifdef INVARIANTS
90 <  if (IsMe(to))
103 <  {
104 <    sendto_realops_flags(UMODE_ALL, L_ALL,
105 <                         "Trying to send message to myself!");
106 <    return;
107 <  }
108 < #endif
89 >  assert(!IsMe(to));
90 >  assert(to != &me);
91  
92 <  if (dbuf_length(&to->localClient->buf_sendq) + len > get_sendq(to))
92 >  if (dbuf_length(&to->localClient->buf_sendq) + len > get_sendq(&to->localClient->confs))
93    {
94      if (IsServer(to))
95 <      sendto_realops_flags(UMODE_ALL, L_ALL,
96 <                           "Max SendQ limit exceeded for %s: %lu > %lu",
95 >      sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
96 >                           "Max SendQ limit exceeded for %s: %lu > %u",
97                             get_client_name(to, HIDE_IP),
98                             (unsigned long)(dbuf_length(&to->localClient->buf_sendq) + len),
99 <                           get_sendq(to));
99 >                           get_sendq(&to->localClient->confs));
100      if (IsClient(to))
101        SetSendQExceeded(to);
102      dead_link_on_write(to, 0);
103      return;
104    }
105 <
105 >
106    dbuf_put(&to->localClient->buf_sendq, buf, len);
107  
108    /*
# Line 153 | Line 135 | send_message_remote(struct Client *to, s
135   {
136    if (!MyConnect(to))
137    {
138 <    sendto_realops_flags(UMODE_ALL, L_ALL,
138 >    sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
139                           "server send message to %s [%s] dropped from %s(Not local server)",
140                           to->name, to->from->name, from->name);
141      return;
142    }
143  
162  if (ServerInfo.hub && IsCapable(to, CAP_LL))
163  {
164    if (((from->lazyLinkClientExists &
165          to->localClient->serverMask) == 0))
166      client_burst_if_needed(to, from);
167  }
168
144    /* Optimize by checking if (from && to) before everything */
145    /* we set to->from up there.. */
146  
# Line 173 | Line 148 | send_message_remote(struct Client *to, s
148    {
149      if (IsServer(from))
150      {
151 <      sendto_realops_flags(UMODE_ALL, L_ALL,
151 >      sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
152                             "Send message to %s [%s] dropped from %s(Fake Dir)",
153                             to->name, to->from->name, from->name);
154        return;
155      }
156  
157 <    sendto_realops_flags(UMODE_ALL, L_ALL,
157 >    sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
158                           "Ghosted: %s[%s@%s] from %s[%s@%s] (%s)",
159                           to->name, to->username, to->host,
160                           from->name, from->username, from->host,
161                           to->from->name);
162  
163 <    sendto_server(NULL, to, NULL, CAP_TS6, NOCAPS, NOFLAGS,
163 >    sendto_server(NULL, CAP_TS6, NOCAPS,
164                    ":%s KILL %s :%s (%s[%s@%s] Ghosted %s)",
165                    me.id, to->name, me.name, to->name,
166                    to->username, to->host, to->from->name);
167 <    sendto_server(NULL, to, NULL, NOCAPS, CAP_TS6, NOFLAGS,
167 >    sendto_server(NULL, NOCAPS, CAP_TS6,
168                    ":%s KILL %s :%s (%s[%s@%s] Ghosted %s)",
169                    me.name, to->name, me.name, to->name,
170                    to->username, to->host, to->from->name);
171  
172 <    SetKilled(to);
172 >    AddFlag(to, FLAGS_KILLED);
173  
174      if (IsClient(from))
175        sendto_one(from, form_str(ERR_GHOSTEDCLIENT),
# Line 229 | Line 204 | sendq_unblocked(fde_t *fd, struct Client
204   }
205  
206   /*
232 ** slinkq_unblocked
233 **      Called when a server control socket is ready for writing.
234 */
235 static void
236 slinkq_unblocked(fde_t *fd, struct Client *client_p)
237 {
238  ClearSlinkqBlocked(client_p);
239  send_queued_slink_write(client_p);
240 }
241
242 /*
207   ** send_queued_write
208   **      This is called when there is a chance that some output would
209   **      be possible. This attempts to empty the send queue as far as
# Line 281 | Line 245 | send_queued_write(struct Client *to)
245                errno = EWOULDBLOCK;
246              case SSL_ERROR_SYSCALL:
247                break;
248 <
248 >            case SSL_ERROR_SSL:
249 >              if (errno == EAGAIN)
250 >                break;
251              default:
252                retlen = errno = 0;  /* either an SSL-specific error or EOF */
253            }
# Line 291 | Line 257 | send_queued_write(struct Client *to)
257          retlen = send(to->localClient->fd.fd, first->data, first->size, 0);
258  
259        if (retlen <= 0)
294      {
295 #ifdef _WIN32
296        errno = WSAGetLastError();
297 #endif
260          break;
299      }
261  
301      execute_callback(iosend_cb, to, retlen, first->data);
262        dbuf_delete(&to->localClient->buf_sendq, retlen);
263  
264        /* We have some data written .. update counters */
# Line 321 | Line 281 | send_queued_write(struct Client *to)
281    }
282   }
283  
324 /*
325 ** send_queued_slink_write
326 **      This is called when there is a chance the some output would
327 **      be possible. This attempts to empty the send queue as far as
328 **      possible, and then if any data is left, a write is rescheduled.
329 */
330 void
331 send_queued_slink_write(struct Client *to)
332 {
333  int retlen;
334
335  /*
336   ** Once socket is marked dead, we cannot start writing to it,
337   ** even if the error is removed...
338   */
339  if (IsDead(to) || IsSlinkqBlocked(to))
340    return;  /* no use calling send() now */
341
342  /* Next, lets try to write some data */
343  if (to->localClient->slinkq != NULL)
344  {
345    retlen = send(to->localClient->ctrlfd.fd,
346                   to->localClient->slinkq + to->localClient->slinkq_ofs,
347                   to->localClient->slinkq_len, 0);
348    if (retlen < 0)
349    {
350      /* If we have a fatal error */
351      if (!ignoreErrno(errno))
352      {
353        dead_link_on_write(to, errno);
354        return;
355      }
356    }
357    else if (retlen == 0)
358    {
359      /* 0 bytes is an EOF .. */
360      dead_link_on_write(to, 0);
361      return;
362    }
363    else
364    {
365      execute_callback(iosendctrl_cb, to, retlen,
366        to->localClient->slinkq + to->localClient->slinkq_ofs);
367      to->localClient->slinkq_len -= retlen;
368
369      assert(to->localClient->slinkq_len >= 0);
370      if (to->localClient->slinkq_len)
371        to->localClient->slinkq_ofs += retlen;
372      else
373      {
374        to->localClient->slinkq_ofs = 0;
375        MyFree(to->localClient->slinkq);
376        to->localClient->slinkq = NULL;
377      }
378    }
379
380    /* Finally, if we have any more data, reschedule a write */
381    if (to->localClient->slinkq_len)
382    {
383      SetSlinkqBlocked(to);
384      comm_setselect(&to->localClient->ctrlfd, COMM_SELECT_WRITE,
385                     (PF *)slinkq_unblocked, (void *)to, 0);
386    }
387  }
388 }
389
284   /* send_queued_all()
285   *
286   * input        - NONE
# Line 457 | Line 351 | sendto_one(struct Client *to, const char
351   */
352   void
353   sendto_channel_butone(struct Client *one, struct Client *from,
354 <                      struct Channel *chptr, const char *command,
354 >                      struct Channel *chptr, unsigned int type,
355                        const char *pattern, ...)
356   {
357 <  va_list args;
357 >  va_list alocal, aremote, auid;
358    char local_buf[IRCD_BUFSIZE];
359    char remote_buf[IRCD_BUFSIZE];
360    char uid_buf[IRCD_BUFSIZE];
361    int local_len, remote_len, uid_len;
362 <  dlink_node *ptr;
469 <  dlink_node *ptr_next;
470 <  struct Client *target_p;
362 >  dlink_node *ptr = NULL, *ptr_next = NULL;
363  
364    if (IsServer(from))
365 <    local_len = ircsprintf(local_buf, ":%s %s %s ",
366 <                           from->name, command, chptr->chname);
365 >    local_len = snprintf(local_buf, sizeof(local_buf), ":%s ",
366 >                        from->name);
367    else
368 <    local_len = ircsprintf(local_buf, ":%s!%s@%s %s %s ",
369 <                           from->name, from->username, from->host,
370 <                           command, chptr->chname);
371 <  remote_len = ircsprintf(remote_buf, ":%s %s %s ",
372 <                          from->name, command, chptr->chname);
373 <  uid_len = ircsprintf(uid_buf, ":%s %s %s ",
374 <                       ID(from), command, chptr->chname);
375 <
376 <  va_start(args, pattern);
368 >    local_len = snprintf(local_buf, sizeof(local_buf), ":%s!%s@%s ",
369 >                         from->name, from->username, from->host);
370 >  remote_len = snprintf(remote_buf, sizeof(remote_buf), ":%s ",
371 >                        from->name);
372 >  uid_len = snprintf(uid_buf, sizeof(uid_buf), ":%s ", ID(from));
373 >
374 >  va_start(alocal, pattern);
375 >  va_start(aremote, pattern);
376 >  va_start(auid, pattern);
377    local_len += send_format(&local_buf[local_len], IRCD_BUFSIZE - local_len,
378 <                           pattern, args);
378 >                           pattern, alocal);
379    remote_len += send_format(&remote_buf[remote_len], IRCD_BUFSIZE - remote_len,
380 <                            pattern, args);
380 >                            pattern, aremote);
381    uid_len += send_format(&uid_buf[uid_len], IRCD_BUFSIZE - uid_len, pattern,
382 <                         args);
383 <  va_end(args);
382 >                         auid);
383 >  va_end(auid);
384 >  va_end(aremote);
385 >  va_end(alocal);
386  
387    ++current_serial;
388  
389    DLINK_FOREACH_SAFE(ptr, ptr_next, chptr->members.head)
390    {
391 <    target_p = ((struct Membership *)ptr->data)->client_p;
392 <    assert(target_p != NULL);
391 >    struct Membership *ms = ptr->data;
392 >    struct Client *target_p = ms->client_p;
393 >
394 >    assert(IsClient(target_p));
395 >
396 >    if (IsDefunct(target_p) || HasUMode(target_p, UMODE_DEAF) || target_p->from == one)
397 >      continue;
398  
399 <    if (IsDefunct(target_p) || IsDeaf(target_p) || target_p->from == one)
399 >    if (type != 0 && (ms->flags & type) == 0)
400        continue;
401  
402 <    if (MyClient(target_p))
402 >    if (MyConnect(target_p))
403      {
404 <      if (target_p->serial != current_serial)
404 >      if (target_p->localClient->serial != current_serial)
405        {
406          send_message(target_p, local_buf, local_len);
407 <        target_p->serial = current_serial;
407 >        target_p->localClient->serial = current_serial;
408        }
409      }
410      else
# Line 513 | Line 412 | sendto_channel_butone(struct Client *one
412        /* Now check whether a message has been sent to this
413         * remote link already
414         */
415 <      if (target_p->from->serial != current_serial)
415 >      if (target_p->from->localClient->serial != current_serial)
416        {
417          if (IsCapable(target_p->from, CAP_TS6))
418            send_message_remote(target_p->from, from, uid_buf, uid_len);
419          else
420            send_message_remote(target_p->from, from, remote_buf, remote_len);
421 <        target_p->from->serial = current_serial;
421 >        target_p->from->localClient->serial = current_serial;
422        }
423      }
424    }
# Line 528 | Line 427 | sendto_channel_butone(struct Client *one
427   /* sendto_server()
428   *
429   * inputs       - pointer to client to NOT send to
430 < *              - pointer to source client required by LL (if any)
532 < *              - pointer to channel required by LL (if any)
430 > *              - pointer to channel
431   *              - caps or'd together which must ALL be present
432   *              - caps or'd together which must ALL NOT be present
535 *              - LL flags: LL_ICLIENT | LL_ICHAN
433   *              - printf style format string
434   *              - args to format string
435   * output       - NONE
436   * side effects - Send a message to all connected servers, except the
437   *                client 'one' (if non-NULL), as long as the servers
438   *                support ALL capabs in 'caps', and NO capabs in 'nocaps'.
542 *                If the server is a lazylink client, then it must know
543 *                about source_p if non-NULL (unless LL_ICLIENT is specified,
544 *                when source_p will be introduced where required) and
545 *                chptr if non-NULL (unless LL_ICHANNEL is specified, when
546 *                chptr will be introduced where required).
547 *                Note: nothing will be introduced to a LazyLeaf unless
548 *                the message is actually sent.
439   *            
440   * This function was written in an attempt to merge together the other
441   * billion sendto_*serv*() functions, which sprung up with capabs,
# Line 553 | Line 443 | sendto_channel_butone(struct Client *one
443   * -davidt
444   */
445   void
446 < sendto_server(struct Client *one, struct Client *source_p,
447 <              struct Channel *chptr, unsigned long caps,
448 <              unsigned long nocaps, unsigned long llflags,
446 > sendto_server(struct Client *one,
447 >              const unsigned int caps,
448 >              const unsigned int nocaps,
449                const char *format, ...)
450   {
451    va_list args;
452 <  struct Client *client_p;
563 <  dlink_node *ptr;
452 >  dlink_node *ptr = NULL;
453    char buffer[IRCD_BUFSIZE];
454 <  int len;
566 <
567 <  if (chptr != NULL)
568 <  {
569 <    if (chptr->chname[0] != '#')
570 <      return;
571 <  }
454 >  int len = 0;
455  
456    va_start(args, format);
457    len = send_format(buffer, IRCD_BUFSIZE, format, args);
# Line 576 | Line 459 | sendto_server(struct Client *one, struct
459  
460    DLINK_FOREACH(ptr, serv_list.head)
461    {
462 <    client_p = ptr->data;
462 >    struct Client *client_p = ptr->data;
463  
464      /* If dead already skip */
465      if (IsDead(client_p))
# Line 591 | Line 474 | sendto_server(struct Client *one, struct
474      if ((client_p->localClient->caps & nocaps) != 0)
475        continue;
476  
594    if (ServerInfo.hub && IsCapable(client_p, CAP_LL))
595    {
596      /* check LL channel */
597      if (chptr != NULL &&
598          ((chptr->lazyLinkChannelExists &
599            client_p->localClient->serverMask) == 0))
600      {
601        /* Only introduce the channel if we really will send this message */
602        if (!(llflags & LL_ICLIENT) && source_p &&
603            ((source_p->lazyLinkClientExists &
604              client_p->localClient->serverMask) == 0))
605          continue; /* we can't introduce the unknown source_p, skip */
606
607        if (llflags & LL_ICHAN)
608          burst_channel(client_p, chptr);
609        else
610          continue; /* we can't introduce the unknown chptr, skip */
611      }
612      /* check LL client */
613      if (source_p &&
614          ((source_p->lazyLinkClientExists &
615            client_p->localClient->serverMask) == 0))
616      {
617        if (llflags & LL_ICLIENT)
618          client_burst_if_needed(client_p,source_p);
619        else
620          continue; /* we can't introduce the unknown source_p, skip */
621      }
622    }
477      send_message(client_p, buffer, len);
478    }
479   }
# Line 634 | Line 488 | sendto_server(struct Client *one, struct
488   *                used by m_nick.c and exit_one_client.
489   */
490   void
491 < sendto_common_channels_local(struct Client *user, int touser,
491 > sendto_common_channels_local(struct Client *user, int touser, unsigned int cap,
492                               const char *pattern, ...)
493   {
494    va_list args;
# Line 657 | Line 511 | sendto_common_channels_local(struct Clie
511      chptr = ((struct Membership *) cptr->data)->chptr;
512      assert(chptr != NULL);
513  
514 <    DLINK_FOREACH(uptr, chptr->locmembers.head)
514 >    DLINK_FOREACH(uptr, chptr->members.head)
515      {
516        ms = uptr->data;
517        target_p = ms->client_p;
518        assert(target_p != NULL);
519  
520 <      if (target_p == user || IsDefunct(target_p) ||
521 <          target_p->serial == current_serial)
520 >      if (!MyConnect(target_p) || target_p == user || IsDefunct(target_p) ||
521 >          target_p->localClient->serial == current_serial)
522          continue;
523  
524 <      target_p->serial = current_serial;
524 >      if (HasCap(target_p, cap) != cap)
525 >        continue;
526 >
527 >      target_p->localClient->serial = current_serial;
528        send_message(target_p, buffer, len);
529      }
530    }
531  
532    if (touser && MyConnect(user) && !IsDead(user) &&
533 <      user->serial != current_serial)
534 <    send_message(user, buffer, len);
533 >      user->localClient->serial != current_serial)
534 >    if (HasCap(user, cap) == cap)
535 >      send_message(user, buffer, len);
536   }
537  
538   /* sendto_channel_local()
# Line 688 | Line 546 | sendto_common_channels_local(struct Clie
546   *                locally connected to this server.
547   */
548   void
549 < sendto_channel_local(int type, int nodeaf, struct Channel *chptr,
549 > sendto_channel_local(unsigned int type, int nodeaf, struct Channel *chptr,
550                       const char *pattern, ...)
551   {
552    va_list args;
# Line 702 | Line 560 | sendto_channel_local(int type, int nodea
560    len = send_format(buffer, IRCD_BUFSIZE, pattern, args);
561    va_end(args);
562  
563 <  DLINK_FOREACH(ptr, chptr->locmembers.head)
563 >  DLINK_FOREACH(ptr, chptr->members.head)
564    {
565      ms = ptr->data;
566      target_p = ms->client_p;
# Line 710 | Line 568 | sendto_channel_local(int type, int nodea
568      if (type != 0 && (ms->flags & type) == 0)
569        continue;
570  
571 <    if (IsDefunct(target_p) || (nodeaf && IsDeaf(target_p)))
571 >    if (!MyConnect(target_p) || IsDefunct(target_p) ||
572 >        (nodeaf && HasUMode(target_p, UMODE_DEAF)))
573        continue;
574  
575      send_message(target_p, buffer, len);
# Line 730 | Line 589 | sendto_channel_local(int type, int nodea
589   * WARNING - +D clients are omitted
590   */
591   void      
592 < sendto_channel_local_butone(struct Client *one, int type,
592 > sendto_channel_local_butone(struct Client *one, unsigned int type, unsigned int cap,
593                              struct Channel *chptr, const char *pattern, ...)
594   {
595    va_list args;
# Line 744 | Line 603 | sendto_channel_local_butone(struct Clien
603    len = send_format(buffer, IRCD_BUFSIZE, pattern, args);
604    va_end(args);
605  
606 <  DLINK_FOREACH(ptr, chptr->locmembers.head)      
606 >  DLINK_FOREACH(ptr, chptr->members.head)      
607    {  
608      ms = ptr->data;
609      target_p = ms->client_p;
# Line 752 | Line 611 | sendto_channel_local_butone(struct Clien
611      if (type != 0 && (ms->flags & type) == 0)
612        continue;
613  
614 <    if (target_p == one || IsDefunct(target_p) || IsDeaf(target_p))
614 >    if (!MyConnect(target_p) || target_p == one ||
615 >        IsDefunct(target_p) || HasUMode(target_p, UMODE_DEAF))
616        continue;
617 +
618 +    if (HasCap(target_p, cap) != cap)
619 +        continue;
620      send_message(target_p, buffer, len);
621    }
622   }
# Line 771 | Line 634 | sendto_channel_local_butone(struct Clien
634   *                remote to this server.
635   */
636   void
637 < sendto_channel_remote(struct Client *one, struct Client *from, int type, int caps,
638 <                      int nocaps, struct Channel *chptr, const char *pattern, ...)
637 > sendto_channel_remote(struct Client *one, struct Client *from, unsigned int type,
638 >                      const unsigned int caps, const unsigned int nocaps,
639 >                      struct Channel *chptr, const char *pattern, ...)
640   {
641    va_list args;
642    char buffer[IRCD_BUFSIZE];
# Line 785 | Line 649 | sendto_channel_remote(struct Client *one
649    len = send_format(buffer, IRCD_BUFSIZE, pattern, args);
650    va_end(args);
651  
652 +  ++current_serial;
653 +
654    DLINK_FOREACH(ptr, chptr->members.head)
655    {
656      ms = ptr->data;
# Line 801 | Line 667 | sendto_channel_remote(struct Client *one
667          ((target_p->from->localClient->caps & caps) != caps) ||
668          ((target_p->from->localClient->caps & nocaps) != 0))
669        continue;
670 <
671 <    send_message(target_p, buffer, len);
670 >    if (target_p->from->localClient->serial != current_serial)
671 >    {
672 >      send_message(target_p, buffer, len);
673 >      target_p->from->localClient->serial = current_serial;
674 >    }
675    }
676   }
677  
# Line 827 | Line 696 | static int
696   match_it(const struct Client *one, const char *mask, int what)
697   {
698    if (what == MATCH_HOST)
699 <    return(match(mask, one->host));
699 >    return !match(mask, one->host);
700  
701 <  return(match(mask, one->servptr->name));
701 >  return !match(mask, one->servptr->name);
702   }
703  
704   /* sendto_match_butone()
# Line 843 | Line 712 | void
712   sendto_match_butone(struct Client *one, struct Client *from, char *mask,
713                      int what, const char *pattern, ...)
714   {
715 <  va_list args;
715 >  va_list alocal, aremote;
716    struct Client *client_p;
717    dlink_node *ptr, *ptr_next;
718    char local_buf[IRCD_BUFSIZE], remote_buf[IRCD_BUFSIZE];
719 <  int local_len = ircsprintf(local_buf, ":%s!%s@%s ", from->name,
720 <                             from->username, from->host);
721 <  int remote_len = ircsprintf(remote_buf, ":%s ", from->name);
719 >  int local_len = snprintf(local_buf, sizeof(local_buf), ":%s!%s@%s ",
720 >                           from->name, from->username, from->host);
721 >  int remote_len = snprintf(remote_buf, sizeof(remote_buf), ":%s ",
722 >                            from->name);
723  
724 <  va_start(args, pattern);
724 >  va_start(alocal, pattern);
725 >  va_start(aremote, pattern);
726    local_len += send_format(&local_buf[local_len], IRCD_BUFSIZE - local_len,
727 <                           pattern, args);
727 >                           pattern, alocal);
728    remote_len += send_format(&remote_buf[remote_len], IRCD_BUFSIZE - remote_len,
729 <                            pattern, args);
730 <  va_end(args);
729 >                            pattern, aremote);
730 >  va_end(aremote);
731 >  va_end(alocal);
732  
733    /* scan the local clients */
734    DLINK_FOREACH(ptr, local_client_list.head)
# Line 912 | Line 784 | sendto_match_butone(struct Client *one,
784   * side effects - data sent to servers matching with capab
785   */
786   void
787 < sendto_match_servs(struct Client *source_p, const char *mask, int cap,
787 > sendto_match_servs(struct Client *source_p, const char *mask, unsigned int cap,
788                     const char *pattern, ...)
789   {
790    va_list args;
791    struct Client *target_p;
792    dlink_node *ptr;
793    char buffer[IRCD_BUFSIZE];
922  int found = 0;
794  
795    va_start(args, pattern);
796    vsnprintf(buffer, sizeof(buffer), pattern, args);
797    va_end(args);
798  
799 <  current_serial++;
799 >  ++current_serial;
800  
801    DLINK_FOREACH(ptr, global_serv_list.head)
802    {
# Line 935 | Line 806 | sendto_match_servs(struct Client *source
806      if (IsMe(target_p) || target_p->from == source_p->from)
807        continue;
808  
809 <    if (target_p->from->serial == current_serial)
809 >    if (target_p->from->localClient->serial == current_serial)
810        continue;
811  
812 <    if (match(mask, target_p->name))
812 >    if (!match(mask, target_p->name))
813      {
814        /*
815         * if we set the serial here, then we'll never do a
816         * match() again, if !IsCapable()
817         */
818 <      target_p->from->serial = current_serial;
948 <      found++;
818 >      target_p->from->localClient->serial = current_serial;
819  
820        if (!IsCapable(target_p->from, cap))
821          continue;
# Line 979 | Line 849 | sendto_anywhere(struct Client *to, struc
849    if (MyClient(to))
850    {
851      if (IsServer(from))
852 <    {
983 <      if (IsCapable(to, CAP_TS6) && HasID(from))
984 <        len = ircsprintf(buffer, ":%s ", from->id);
985 <      else
986 <        len = ircsprintf(buffer, ":%s ", from->name);
987 <    }
852 >      len = snprintf(buffer, sizeof(buffer), ":%s ", from->name);
853      else
854 <      len = ircsprintf(buffer, ":%s!%s@%s ",
855 <                       from->name, from->username, from->host);
854 >      len = snprintf(buffer, sizeof(buffer), ":%s!%s@%s ",
855 >                     from->name, from->username, from->host);
856    }
857 <  else len = ircsprintf(buffer, ":%s ", ID_or_name(from, send_to));
857 >  else
858 >    len = snprintf(buffer, sizeof(buffer), ":%s ", ID_or_name(from, send_to));
859  
860    va_start(args, pattern);
861    len += send_format(&buffer[len], IRCD_BUFSIZE - len, pattern, args);
862    va_end(args);
863  
864 <  if(MyClient(to))
864 >  if (MyClient(to))
865      send_message(send_to, buffer, len);
866    else
867      send_message_remote(send_to, from, buffer, len);
# Line 1010 | Line 876 | sendto_anywhere(struct Client *to, struc
876   * side effects - Send to *local* ops only but NOT +s nonopers.
877   */
878   void
879 < sendto_realops_flags(unsigned int flags, int level, const char *pattern, ...)
879 > sendto_realops_flags(unsigned int flags, int level, int type, const char *pattern, ...)
880   {
881 <  struct Client *client_p;
881 >  const char *ntype = NULL;
882 >  dlink_node *ptr = NULL;
883    char nbuf[IRCD_BUFSIZE];
1017  dlink_node *ptr;
884    va_list args;
885  
886    va_start(args, pattern);
887 <  vsnprintf(nbuf, IRCD_BUFSIZE, pattern, args);
887 >  vsnprintf(nbuf, sizeof(nbuf), pattern, args);
888    va_end(args);
889  
890 +  switch (type)
891 +  {
892 +    case SEND_NOTICE:
893 +      ntype = "Notice";
894 +      break;
895 +    case SEND_GLOBAL:
896 +      ntype = "Global";
897 +      break;
898 +    case SEND_LOCOPS:
899 +      ntype = "LocOps";
900 +      break;
901 +    default:
902 +      assert(0);
903 +  }
904 +
905    DLINK_FOREACH(ptr, oper_list.head)
906    {
907 <    client_p = ptr->data;
908 <    assert(client_p->umodes & UMODE_OPER);
907 >    struct Client *client_p = ptr->data;
908 >    assert(HasUMode(client_p, UMODE_OPER));
909  
910 <    /* If we're sending it to opers and theyre an admin, skip.
911 <     * If we're sending it to admins, and theyre not, skip.
910 >    /*
911 >     * If we're sending it to opers and they're an admin, skip.
912 >     * If we're sending it to admins, and they're not, skip.
913       */
914 <    if (((level == L_ADMIN) && !IsAdmin(client_p)) ||
915 <        ((level == L_OPER) && IsAdmin(client_p)))
914 >    if (((level == L_ADMIN) && !HasUMode(client_p, UMODE_ADMIN)) ||
915 >        ((level == L_OPER) && HasUMode(client_p, UMODE_ADMIN)))
916        continue;
917  
918 <    if (client_p->umodes & flags)
919 <      sendto_one(client_p, ":%s NOTICE %s :*** Notice -- %s",
920 <                 me.name, client_p->name, nbuf);
918 >    if (HasUMode(client_p, flags))
919 >      sendto_one(client_p, ":%s NOTICE %s :*** %s -- %s",
920 >                 me.name, client_p->name, ntype, nbuf);
921    }
922   }
923  
# Line 1051 | Line 933 | void
933   sendto_wallops_flags(unsigned int flags, struct Client *source_p,
934                       const char *pattern, ...)
935   {
936 <  struct Client *client_p;
1055 <  dlink_node *ptr;
936 >  dlink_node *ptr = NULL;
937    va_list args;
938    char buffer[IRCD_BUFSIZE];
939    int len;
940  
941    if (IsClient(source_p))
942 <    len = ircsprintf(buffer, ":%s!%s@%s WALLOPS :",
943 <                     source_p->name, source_p->username, source_p->host);
942 >    len = snprintf(buffer, sizeof(buffer), ":%s!%s@%s WALLOPS :",
943 >                   source_p->name, source_p->username,
944 >                   source_p->host);
945    else
946 <    len = ircsprintf(buffer, ":%s WALLOPS :", source_p->name);
946 >    len = snprintf(buffer, sizeof(buffer), ":%s WALLOPS :",
947 >                   source_p->name);
948  
949    va_start(args, pattern);
950    len += send_format(&buffer[len], IRCD_BUFSIZE - len, pattern, args);
# Line 1069 | Line 952 | sendto_wallops_flags(unsigned int flags,
952  
953    DLINK_FOREACH(ptr, oper_list.head)
954    {
955 <    client_p = ptr->data;
955 >    struct Client *client_p = ptr->data;
956      assert(client_p->umodes & UMODE_OPER);
957  
958 <    if ((client_p->umodes & flags) && !IsDefunct(client_p))
958 >    if (HasUMode(client_p, flags) && !IsDefunct(client_p))
959        send_message(client_p, buffer, len);
960    }
961   }
# Line 1088 | Line 971 | void
971   ts_warn(const char *pattern, ...)
972   {
973    va_list args;
974 <  char buffer[LOG_BUFSIZE];
974 >  char buffer[IRCD_BUFSIZE];
975    static time_t last = 0;
976    static int warnings = 0;
977  
# Line 1111 | Line 994 | ts_warn(const char *pattern, ...)
994    }
995  
996    va_start(args, pattern);
997 <  vsprintf_irc(buffer, pattern, args);
997 >  vsnprintf(buffer, sizeof(buffer), pattern, args);
998    va_end(args);
999  
1000 <  sendto_realops_flags(UMODE_ALL, L_ALL, "%s", buffer);
1001 <  ilog(L_CRIT, "%s", buffer);
1000 >  sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, "%s", buffer);
1001 >  ilog(LOG_TYPE_IRCD, "%s", buffer);
1002   }
1003  
1004   /* kill_client()
# Line 1139 | Line 1022 | kill_client(struct Client *client_p, str
1022    if (IsDead(client_p))
1023      return;
1024  
1025 <  len = ircsprintf(buffer, ":%s KILL %s :", ID_or_name(&me, client_p->from),
1026 <                   ID_or_name(diedie, client_p));
1025 >  len = snprintf(buffer, sizeof(buffer), ":%s KILL %s :",
1026 >                 ID_or_name(&me, client_p->from),
1027 >                 ID_or_name(diedie, client_p));
1028  
1029    va_start(args, pattern);
1030    len += send_format(&buffer[len], IRCD_BUFSIZE - len, pattern, args);
# Line 1160 | Line 1044 | kill_client(struct Client *client_p, str
1044   *                client being unknown to leaf, as in lazylink...
1045   */
1046   void
1047 < kill_client_ll_serv_butone(struct Client *one, struct Client *source_p,
1048 <                           const char *pattern, ...)
1047 > kill_client_serv_butone(struct Client *one, struct Client *source_p,
1048 >                        const char *pattern, ...)
1049   {
1050    va_list args;
1051    int have_uid = 0;
1052 <  struct Client *client_p;
1169 <  dlink_node *ptr;
1052 >  dlink_node *ptr = NULL;
1053    char buf_uid[IRCD_BUFSIZE], buf_nick[IRCD_BUFSIZE];
1054 <  int len_uid = 0, len_nick;
1054 >  int len_uid = 0, len_nick = 0;
1055  
1056 <  va_start(args, pattern);
1174 <  if (HasID(source_p) && (me.id[0] != '\0'))
1056 >  if (HasID(source_p))
1057    {
1058      have_uid = 1;
1059 <    len_uid = ircsprintf(buf_uid, ":%s KILL %s :", me.id, ID(source_p));
1059 >    va_start(args, pattern);
1060 >    len_uid = snprintf(buf_uid, sizeof(buf_uid), ":%s KILL %s :",
1061 >                       me.id, ID(source_p));
1062      len_uid += send_format(&buf_uid[len_uid], IRCD_BUFSIZE - len_uid, pattern,
1063                             args);
1064 +    va_end(args);
1065    }
1066 <  len_nick = ircsprintf(buf_nick, ":%s KILL %s :", me.name, source_p->name);
1066 >
1067 >  va_start(args, pattern);
1068 >  len_nick = snprintf(buf_nick, sizeof(buf_nick), ":%s KILL %s :",
1069 >                      me.name, source_p->name);
1070    len_nick += send_format(&buf_nick[len_nick], IRCD_BUFSIZE - len_nick, pattern,
1071                            args);
1072    va_end(args);
1073  
1074    DLINK_FOREACH(ptr, serv_list.head)
1075    {
1076 <    client_p = ptr->data;
1076 >    struct Client *client_p = ptr->data;
1077  
1078      if (one != NULL && (client_p == one->from))
1079        continue;
1080      if (IsDefunct(client_p))
1081        continue;
1082  
1083 <    /* XXX perhaps IsCapable should test for localClient itself ? -db */
1084 <    if (client_p->localClient == NULL || !IsCapable(client_p, CAP_LL) ||
1085 <        !ServerInfo.hub ||
1086 <        (source_p->lazyLinkClientExists & client_p->localClient->serverMask))
1199 <    {
1200 <      if (have_uid && IsCapable(client_p, CAP_TS6))
1201 <        send_message(client_p, buf_uid, len_uid);
1202 <      else
1203 <        send_message(client_p, buf_nick, len_nick);
1204 <    }
1083 >    if (have_uid && IsCapable(client_p, CAP_TS6))
1084 >      send_message(client_p, buf_uid, len_uid);
1085 >    else
1086 >      send_message(client_p, buf_nick, len_nick);
1087    }
1088   }

Comparing:
ircd-hybrid/src/send.c (property svn:keywords), Revision 32 by knight, Sun Oct 2 20:41:23 2005 UTC vs.
ircd-hybrid/trunk/src/send.c (property svn:keywords), Revision 2635 by michael, Tue Dec 10 17:46:37 2013 UTC

# Line 1 | Line 1
1 < Revision
1 > Id Revision

Diff Legend

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