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-7.2/src/send.c (file contents), Revision 885 by michael, Wed Oct 31 18:09:24 2007 UTC vs.
ircd-hybrid-8/src/send.c (file contents), Revision 1206 by michael, Wed Aug 24 21:41:23 2011 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"
# Line 38 | Line 38
38   #include "s_serv.h"
39   #include "sprintf_irc.h"
40   #include "s_conf.h"
41 #include "list.h"
41   #include "s_log.h"
42   #include "memory.h"
43   #include "hook.h"
45 #include "irc_getnameinfo.h"
44   #include "packet.h"
45  
48 #define LOG_BUFSIZE 2048
46  
47   struct Callback *iosend_cb = NULL;
48   struct Callback *iosendctrl_cb = NULL;
49 + static unsigned int current_serial = 0;
50  
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;
51  
52   /* send_format()
53   *
# Line 87 | Line 81 | send_format(char *lsendbuf, int bufsize,
81  
82    lsendbuf[len++] = '\r';
83    lsendbuf[len++] = '\n';
84 <  return (len);
84 >  return len;
85   }
86  
87   /*
# Line 294 | Line 288 | send_queued_write(struct Client *to)
288          retlen = send(to->localClient->fd.fd, first->data, first->size, 0);
289  
290        if (retlen <= 0)
297      {
298 #ifdef _WIN32
299        errno = WSAGetLastError();
300 #endif
291          break;
302      }
292  
293        dbuf_delete(&to->localClient->buf_sendq, retlen);
294  
# Line 467 | Line 456 | sendto_channel_butone(struct Client *one
456    char remote_buf[IRCD_BUFSIZE];
457    char uid_buf[IRCD_BUFSIZE];
458    int local_len, remote_len, uid_len;
459 <  dlink_node *ptr;
471 <  dlink_node *ptr_next;
472 <  struct Client *target_p;
459 >  dlink_node *ptr = NULL, *ptr_next = NULL;
460  
461    if (IsServer(from))
462      local_len = ircsprintf(local_buf, ":%s %s %s ",
# Line 500 | Line 487 | sendto_channel_butone(struct Client *one
487  
488    DLINK_FOREACH_SAFE(ptr, ptr_next, chptr->members.head)
489    {
490 <    target_p = ((struct Membership *)ptr->data)->client_p;
491 <    assert(target_p != NULL);
490 >    struct Client *target_p = ((struct Membership *)ptr->data)->client_p;
491 >
492 >    assert(IsClient(target_p));
493  
494      if (IsDefunct(target_p) || IsDeaf(target_p) || target_p->from == one)
495        continue;
496  
497 <    if (MyClient(target_p))
497 >    if (MyConnect(target_p))
498      {
499 <      if (target_p->serial != current_serial)
499 >      if (target_p->localClient->serial != current_serial)
500        {
501          send_message(target_p, local_buf, local_len);
502 <        target_p->serial = current_serial;
502 >        target_p->localClient->serial = current_serial;
503        }
504      }
505      else
# Line 519 | Line 507 | sendto_channel_butone(struct Client *one
507        /* Now check whether a message has been sent to this
508         * remote link already
509         */
510 <      if (target_p->from->serial != current_serial)
510 >      if (target_p->from->localClient->serial != current_serial)
511        {
512          if (IsCapable(target_p->from, CAP_TS6))
513            send_message_remote(target_p->from, from, uid_buf, uid_len);
514          else
515            send_message_remote(target_p->from, from, remote_buf, remote_len);
516 <        target_p->from->serial = current_serial;
516 >        target_p->from->localClient->serial = current_serial;
517        }
518      }
519    }
# Line 534 | Line 522 | sendto_channel_butone(struct Client *one
522   /* sendto_server()
523   *
524   * inputs       - pointer to client to NOT send to
525 < *              - pointer to source client required by LL (if any)
538 < *              - pointer to channel required by LL (if any)
525 > *              - pointer to channel
526   *              - caps or'd together which must ALL be present
527   *              - caps or'd together which must ALL NOT be present
528   *              - printf style format string
# Line 551 | Line 538 | sendto_channel_butone(struct Client *one
538   * -davidt
539   */
540   void
541 < sendto_server(struct Client *one,
542 <              struct Channel *chptr, unsigned long caps,
543 <              unsigned long nocaps,
541 > sendto_server(struct Client *one, const struct Channel *chptr,
542 >              const unsigned int caps,
543 >              const unsigned int nocaps,
544                const char *format, ...)
545   {
546    va_list args;
# Line 629 | Line 616 | sendto_common_channels_local(struct Clie
616        assert(target_p != NULL);
617  
618        if (!MyConnect(target_p) || target_p == user || IsDefunct(target_p) ||
619 <          target_p->serial == current_serial)
619 >          target_p->localClient->serial == current_serial)
620          continue;
621  
622 <      target_p->serial = current_serial;
622 >      target_p->localClient->serial = current_serial;
623        send_message(target_p, buffer, len);
624      }
625    }
626  
627    if (touser && MyConnect(user) && !IsDead(user) &&
628 <      user->serial != current_serial)
628 >      user->localClient->serial != current_serial)
629      send_message(user, buffer, len);
630   }
631  
# Line 738 | Line 725 | sendto_channel_local_butone(struct Clien
725   *                remote to this server.
726   */
727   void
728 < sendto_channel_remote(struct Client *one, struct Client *from, int type, int caps,
729 <                      int nocaps, struct Channel *chptr, const char *pattern, ...)
728 > sendto_channel_remote(struct Client *one, struct Client *from, int type,
729 >                      const unsigned int caps, const unsigned int nocaps,
730 >                      struct Channel *chptr, const char *pattern, ...)
731   {
732    va_list args;
733    char buffer[IRCD_BUFSIZE];
# Line 770 | Line 758 | sendto_channel_remote(struct Client *one
758          ((target_p->from->localClient->caps & caps) != caps) ||
759          ((target_p->from->localClient->caps & nocaps) != 0))
760        continue;
761 <    if (target_p->from->serial != current_serial)
761 >    if (target_p->from->localClient->serial != current_serial)
762      {
763        send_message(target_p, buffer, len);
764 <      target_p->from->serial = current_serial;
764 >      target_p->from->localClient->serial = current_serial;
765      }
766    }
767   }
# Line 799 | Line 787 | static int
787   match_it(const struct Client *one, const char *mask, int what)
788   {
789    if (what == MATCH_HOST)
790 <    return(match(mask, one->host));
790 >    return match(mask, one->host);
791  
792 <  return(match(mask, one->servptr->name));
792 >  return match(mask, one->servptr->name);
793   }
794  
795   /* sendto_match_butone()
# Line 899 | Line 887 | sendto_match_servs(struct Client *source
887    vsnprintf(buffer, sizeof(buffer), pattern, args);
888    va_end(args);
889  
890 <  current_serial++;
890 >  ++current_serial;
891  
892    DLINK_FOREACH(ptr, global_serv_list.head)
893    {
# Line 909 | Line 897 | sendto_match_servs(struct Client *source
897      if (IsMe(target_p) || target_p->from == source_p->from)
898        continue;
899  
900 <    if (target_p->from->serial == current_serial)
900 >    if (target_p->from->localClient->serial == current_serial)
901        continue;
902  
903      if (match(mask, target_p->name))
# Line 918 | Line 906 | sendto_match_servs(struct Client *source
906         * if we set the serial here, then we'll never do a
907         * match() again, if !IsCapable()
908         */
909 <      target_p->from->serial = current_serial;
909 >      target_p->from->localClient->serial = current_serial;
910        found++;
911  
912        if (!IsCapable(target_p->from, cap))
# Line 986 | Line 974 | sendto_anywhere(struct Client *to, struc
974   void
975   sendto_realops_flags(unsigned int flags, int level, const char *pattern, ...)
976   {
977 <  struct Client *client_p;
977 >  dlink_node *ptr = NULL;
978    char nbuf[IRCD_BUFSIZE];
991  dlink_node *ptr;
979    va_list args;
980  
981    va_start(args, pattern);
# Line 997 | Line 984 | sendto_realops_flags(unsigned int flags,
984  
985    DLINK_FOREACH(ptr, oper_list.head)
986    {
987 <    client_p = ptr->data;
987 >    struct Client *client_p = ptr->data;
988      assert(client_p->umodes & UMODE_OPER);
989  
990      /* If we're sending it to opers and theyre an admin, skip.
# Line 1013 | Line 1000 | sendto_realops_flags(unsigned int flags,
1000    }
1001   }
1002  
1003 + void
1004 + sendto_globops_flags(unsigned int flags, int level, const char *pattern, ...)
1005 + {
1006 +  dlink_node *ptr = NULL;
1007 +  char nbuf[IRCD_BUFSIZE];
1008 +  va_list args;
1009 +
1010 +  va_start(args, pattern);
1011 +  vsnprintf(nbuf, IRCD_BUFSIZE, pattern, args);
1012 +  va_end(args);
1013 +
1014 +  DLINK_FOREACH(ptr, oper_list.head)
1015 +  {
1016 +    struct Client *client_p = ptr->data;
1017 +    assert(client_p->umodes & UMODE_OPER);
1018 +
1019 +    /* If we're sending it to opers and theyre an admin, skip.
1020 +     * If we're sending it to admins, and theyre not, skip.
1021 +     */
1022 +    if (((level == L_ADMIN) && !IsAdmin(client_p)) ||
1023 +        ((level == L_OPER) && IsAdmin(client_p)))
1024 +      continue;
1025 +
1026 +    if (client_p->umodes & flags)
1027 +      sendto_one(client_p, ":%s NOTICE %s :*** Global -- %s",
1028 +                 me.name, client_p->name, nbuf);
1029 +  }
1030 + }
1031 +
1032   /* sendto_wallops_flags()
1033   *
1034   * inputs       - flag types of messages to show to real opers
# Line 1025 | Line 1041 | void
1041   sendto_wallops_flags(unsigned int flags, struct Client *source_p,
1042                       const char *pattern, ...)
1043   {
1044 <  struct Client *client_p;
1029 <  dlink_node *ptr;
1044 >  dlink_node *ptr = NULL;
1045    va_list args;
1046    char buffer[IRCD_BUFSIZE];
1047    int len;
# Line 1043 | Line 1058 | sendto_wallops_flags(unsigned int flags,
1058  
1059    DLINK_FOREACH(ptr, oper_list.head)
1060    {
1061 <    client_p = ptr->data;
1061 >    struct Client *client_p = ptr->data;
1062      assert(client_p->umodes & UMODE_OPER);
1063  
1064      if ((client_p->umodes & flags) && !IsDefunct(client_p))
# Line 1062 | Line 1077 | void
1077   ts_warn(const char *pattern, ...)
1078   {
1079    va_list args;
1080 <  char buffer[LOG_BUFSIZE];
1080 >  char buffer[IRCD_BUFSIZE];
1081    static time_t last = 0;
1082    static int warnings = 0;
1083  
# Line 1085 | Line 1100 | ts_warn(const char *pattern, ...)
1100    }
1101  
1102    va_start(args, pattern);
1103 <  vsprintf_irc(buffer, pattern, args);
1103 >  vsnprintf(buffer, sizeof(buffer), pattern, args);
1104    va_end(args);
1105  
1106    sendto_realops_flags(UMODE_ALL, L_ALL, "%s", buffer);
# Line 1143 | Line 1158 | kill_client_ll_serv_butone(struct Client
1158    char buf_uid[IRCD_BUFSIZE], buf_nick[IRCD_BUFSIZE];
1159    int len_uid = 0, len_nick = 0;
1160  
1161 <  if (HasID(source_p) && (me.id[0] != '\0'))
1161 >  if (HasID(source_p))
1162    {
1163      have_uid = 1;
1164      va_start(args, pattern);

Diff Legend

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