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 30 by adx, Sun Oct 2 20:03:27 2005 UTC vs.
ircd-hybrid/trunk/src/send.c (file contents), Revision 2565 by michael, Sun Nov 17 18:40:26 2013 UTC

# Line 19 | Line 19
19   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
20   *  USA
21   *
22 < *  $Id: send.c,v 7.307 2005/10/02 12:45:07 adx Exp $
22 > *  $Id$
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 <    if (IsDefunct(target_p) || IsDeaf(target_p) || target_p->from == one)
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 (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 >      if (HasCap(target_p, cap) != cap)
525          continue;
526  
527 <      target_p->serial = current_serial;
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;
# Line 925 | Line 797 | sendto_match_servs(struct Client *source
797    vsnprintf(buffer, sizeof(buffer), pattern, args);
798    va_end(args);
799  
800 <  current_serial++;
800 >  ++current_serial;
801  
802    DLINK_FOREACH(ptr, global_serv_list.head)
803    {
# Line 935 | Line 807 | sendto_match_servs(struct Client *source
807      if (IsMe(target_p) || target_p->from == source_p->from)
808        continue;
809  
810 <    if (target_p->from->serial == current_serial)
810 >    if (target_p->from->localClient->serial == current_serial)
811        continue;
812  
813 <    if (match(mask, target_p->name))
813 >    if (!match(mask, target_p->name))
814      {
815        /*
816         * if we set the serial here, then we'll never do a
817         * match() again, if !IsCapable()
818         */
819 <      target_p->from->serial = current_serial;
819 >      target_p->from->localClient->serial = current_serial;
820        found++;
821  
822        if (!IsCapable(target_p->from, cap))
# Line 981 | Line 853 | sendto_anywhere(struct Client *to, struc
853      if (IsServer(from))
854      {
855        if (IsCapable(to, CAP_TS6) && HasID(from))
856 <        len = ircsprintf(buffer, ":%s ", from->id);
856 >        len = snprintf(buffer, sizeof(buffer), ":%s ", from->id);
857        else
858 <        len = ircsprintf(buffer, ":%s ", from->name);
858 >        len = snprintf(buffer, sizeof(buffer), ":%s ", from->name);
859      }
860      else
861 <      len = ircsprintf(buffer, ":%s!%s@%s ",
862 <                       from->name, from->username, from->host);
861 >      len = snprintf(buffer, sizeof(buffer), ":%s!%s@%s ",
862 >                     from->name, from->username, from->host);
863    }
864 <  else len = ircsprintf(buffer, ":%s ", ID_or_name(from, send_to));
864 >  else len = snprintf(buffer, sizeof(buffer), ":%s ", ID_or_name(from, send_to));
865  
866    va_start(args, pattern);
867    len += send_format(&buffer[len], IRCD_BUFSIZE - len, pattern, args);
868    va_end(args);
869  
870 <  if(MyClient(to))
870 >  if (MyClient(to))
871      send_message(send_to, buffer, len);
872    else
873      send_message_remote(send_to, from, buffer, len);
# Line 1010 | Line 882 | sendto_anywhere(struct Client *to, struc
882   * side effects - Send to *local* ops only but NOT +s nonopers.
883   */
884   void
885 < sendto_realops_flags(unsigned int flags, int level, const char *pattern, ...)
885 > sendto_realops_flags(unsigned int flags, int level, int type, const char *pattern, ...)
886   {
887 <  struct Client *client_p;
887 >  const char *ntype = NULL;
888 >  dlink_node *ptr = NULL;
889    char nbuf[IRCD_BUFSIZE];
1017  dlink_node *ptr;
890    va_list args;
891  
892    va_start(args, pattern);
893 <  vsnprintf(nbuf, IRCD_BUFSIZE, pattern, args);
893 >  vsnprintf(nbuf, sizeof(nbuf), pattern, args);
894    va_end(args);
895  
896 +  switch (type)
897 +  {
898 +    case SEND_NOTICE:
899 +      ntype = "Notice";
900 +      break;
901 +    case SEND_GLOBAL:
902 +      ntype = "Global";
903 +      break;
904 +    case SEND_LOCOPS:
905 +      ntype = "LocOps";
906 +      break;
907 +    default:
908 +      assert(0);
909 +  }
910 +
911    DLINK_FOREACH(ptr, oper_list.head)
912    {
913 <    client_p = ptr->data;
914 <    assert(client_p->umodes & UMODE_OPER);
913 >    struct Client *client_p = ptr->data;
914 >    assert(HasUMode(client_p, UMODE_OPER));
915  
916 <    /* If we're sending it to opers and theyre an admin, skip.
917 <     * If we're sending it to admins, and theyre not, skip.
916 >    /*
917 >     * If we're sending it to opers and they're an admin, skip.
918 >     * If we're sending it to admins, and they're not, skip.
919       */
920 <    if (((level == L_ADMIN) && !IsAdmin(client_p)) ||
921 <        ((level == L_OPER) && IsAdmin(client_p)))
920 >    if (((level == L_ADMIN) && !HasUMode(client_p, UMODE_ADMIN)) ||
921 >        ((level == L_OPER) && HasUMode(client_p, UMODE_ADMIN)))
922        continue;
923  
924 <    if (client_p->umodes & flags)
925 <      sendto_one(client_p, ":%s NOTICE %s :*** Notice -- %s",
926 <                 me.name, client_p->name, nbuf);
924 >    if (HasUMode(client_p, flags))
925 >      sendto_one(client_p, ":%s NOTICE %s :*** %s -- %s",
926 >                 me.name, client_p->name, ntype, nbuf);
927    }
928   }
929  
# Line 1051 | Line 939 | void
939   sendto_wallops_flags(unsigned int flags, struct Client *source_p,
940                       const char *pattern, ...)
941   {
942 <  struct Client *client_p;
1055 <  dlink_node *ptr;
942 >  dlink_node *ptr = NULL;
943    va_list args;
944    char buffer[IRCD_BUFSIZE];
945    int len;
946  
947    if (IsClient(source_p))
948 <    len = ircsprintf(buffer, ":%s!%s@%s WALLOPS :",
949 <                     source_p->name, source_p->username, source_p->host);
948 >    len = snprintf(buffer, sizeof(buffer), ":%s!%s@%s WALLOPS :",
949 >                   source_p->name, source_p->username,
950 >                   source_p->host);
951    else
952 <    len = ircsprintf(buffer, ":%s WALLOPS :", source_p->name);
952 >    len = snprintf(buffer, sizeof(buffer), ":%s WALLOPS :",
953 >                   source_p->name);
954  
955    va_start(args, pattern);
956    len += send_format(&buffer[len], IRCD_BUFSIZE - len, pattern, args);
# Line 1069 | Line 958 | sendto_wallops_flags(unsigned int flags,
958  
959    DLINK_FOREACH(ptr, oper_list.head)
960    {
961 <    client_p = ptr->data;
961 >    struct Client *client_p = ptr->data;
962      assert(client_p->umodes & UMODE_OPER);
963  
964 <    if ((client_p->umodes & flags) && !IsDefunct(client_p))
964 >    if (HasUMode(client_p, flags) && !IsDefunct(client_p))
965        send_message(client_p, buffer, len);
966    }
967   }
# Line 1088 | Line 977 | void
977   ts_warn(const char *pattern, ...)
978   {
979    va_list args;
980 <  char buffer[LOG_BUFSIZE];
980 >  char buffer[IRCD_BUFSIZE];
981    static time_t last = 0;
982    static int warnings = 0;
983  
# Line 1111 | Line 1000 | ts_warn(const char *pattern, ...)
1000    }
1001  
1002    va_start(args, pattern);
1003 <  vsprintf_irc(buffer, pattern, args);
1003 >  vsnprintf(buffer, sizeof(buffer), pattern, args);
1004    va_end(args);
1005  
1006 <  sendto_realops_flags(UMODE_ALL, L_ALL, "%s", buffer);
1007 <  ilog(L_CRIT, "%s", buffer);
1006 >  sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, "%s", buffer);
1007 >  ilog(LOG_TYPE_IRCD, "%s", buffer);
1008   }
1009  
1010   /* kill_client()
# Line 1139 | Line 1028 | kill_client(struct Client *client_p, str
1028    if (IsDead(client_p))
1029      return;
1030  
1031 <  len = ircsprintf(buffer, ":%s KILL %s :", ID_or_name(&me, client_p->from),
1032 <                   ID_or_name(diedie, client_p));
1031 >  len = snprintf(buffer, sizeof(buffer), ":%s KILL %s :",
1032 >                 ID_or_name(&me, client_p->from),
1033 >                 ID_or_name(diedie, client_p));
1034  
1035    va_start(args, pattern);
1036    len += send_format(&buffer[len], IRCD_BUFSIZE - len, pattern, args);
# Line 1160 | Line 1050 | kill_client(struct Client *client_p, str
1050   *                client being unknown to leaf, as in lazylink...
1051   */
1052   void
1053 < kill_client_ll_serv_butone(struct Client *one, struct Client *source_p,
1054 <                           const char *pattern, ...)
1053 > kill_client_serv_butone(struct Client *one, struct Client *source_p,
1054 >                        const char *pattern, ...)
1055   {
1056    va_list args;
1057    int have_uid = 0;
1058 <  struct Client *client_p;
1169 <  dlink_node *ptr;
1058 >  dlink_node *ptr = NULL;
1059    char buf_uid[IRCD_BUFSIZE], buf_nick[IRCD_BUFSIZE];
1060 <  int len_uid = 0, len_nick;
1060 >  int len_uid = 0, len_nick = 0;
1061  
1062 <  va_start(args, pattern);
1174 <  if (HasID(source_p) && (me.id[0] != '\0'))
1062 >  if (HasID(source_p))
1063    {
1064      have_uid = 1;
1065 <    len_uid = ircsprintf(buf_uid, ":%s KILL %s :", me.id, ID(source_p));
1065 >    va_start(args, pattern);
1066 >    len_uid = snprintf(buf_uid, sizeof(buf_uid), ":%s KILL %s :",
1067 >                       me.id, ID(source_p));
1068      len_uid += send_format(&buf_uid[len_uid], IRCD_BUFSIZE - len_uid, pattern,
1069                             args);
1070 +    va_end(args);
1071    }
1072 <  len_nick = ircsprintf(buf_nick, ":%s KILL %s :", me.name, source_p->name);
1072 >
1073 >  va_start(args, pattern);
1074 >  len_nick = snprintf(buf_nick, sizeof(buf_nick), ":%s KILL %s :",
1075 >                      me.name, source_p->name);
1076    len_nick += send_format(&buf_nick[len_nick], IRCD_BUFSIZE - len_nick, pattern,
1077                            args);
1078    va_end(args);
1079  
1080    DLINK_FOREACH(ptr, serv_list.head)
1081    {
1082 <    client_p = ptr->data;
1082 >    struct Client *client_p = ptr->data;
1083  
1084      if (one != NULL && (client_p == one->from))
1085        continue;
1086      if (IsDefunct(client_p))
1087        continue;
1088  
1089 <    /* XXX perhaps IsCapable should test for localClient itself ? -db */
1090 <    if (client_p->localClient == NULL || !IsCapable(client_p, CAP_LL) ||
1091 <        !ServerInfo.hub ||
1092 <        (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 <    }
1089 >    if (have_uid && IsCapable(client_p, CAP_TS6))
1090 >      send_message(client_p, buf_uid, len_uid);
1091 >    else
1092 >      send_message(client_p, buf_nick, len_nick);
1093    }
1094   }

Comparing:
ircd-hybrid/src/send.c (property svn:keywords), Revision 30 by adx, Sun Oct 2 20:03:27 2005 UTC vs.
ircd-hybrid/trunk/src/send.c (property svn:keywords), Revision 2565 by michael, Sun Nov 17 18:40:26 2013 UTC

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

Diff Legend

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