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 1001 by michael, Sat Aug 29 22:44:44 2009 UTC vs.
ircd-hybrid-8/src/send.c (file contents), Revision 1247 by michael, Sat Oct 1 07:54:24 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"
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"
39   #include "s_log.h"
40   #include "memory.h"
41   #include "hook.h"
45 #include "irc_getnameinfo.h"
42   #include "packet.h"
43  
48 #define LOG_BUFSIZE 2048
44  
45   struct Callback *iosend_cb = NULL;
46   struct Callback *iosendctrl_cb = NULL;
52
53 static void send_message(struct Client *, char *, int);
54 static void send_message_remote(struct Client *, struct Client *, char *, int);
55
47   static unsigned int current_serial = 0;
48  
49 +
50   /* send_format()
51   *
52   * inputs       - buffer to format into
# Line 87 | Line 79 | send_format(char *lsendbuf, int bufsize,
79  
80    lsendbuf[len++] = '\r';
81    lsendbuf[len++] = '\n';
82 <  return (len);
82 >  return len;
83   }
84  
85   /*
# Line 195 | Line 187 | send_message_remote(struct Client *to, s
187                    me.name, to->name, me.name, to->name,
188                    to->username, to->host, to->from->name);
189  
190 <    SetKilled(to);
190 >    AddFlag(to, FLAGS_KILLED);
191  
192      if (IsClient(from))
193        sendto_one(from, form_str(ERR_GHOSTEDCLIENT),
# Line 462 | Line 454 | sendto_channel_butone(struct Client *one
454    char remote_buf[IRCD_BUFSIZE];
455    char uid_buf[IRCD_BUFSIZE];
456    int local_len, remote_len, uid_len;
457 <  dlink_node *ptr;
466 <  dlink_node *ptr_next;
467 <  struct Client *target_p;
457 >  dlink_node *ptr = NULL, *ptr_next = NULL;
458  
459    if (IsServer(from))
460      local_len = ircsprintf(local_buf, ":%s %s %s ",
# Line 495 | Line 485 | sendto_channel_butone(struct Client *one
485  
486    DLINK_FOREACH_SAFE(ptr, ptr_next, chptr->members.head)
487    {
488 <    target_p = ((struct Membership *)ptr->data)->client_p;
489 <    assert(target_p != NULL);
488 >    struct Client *target_p = ((struct Membership *)ptr->data)->client_p;
489 >
490 >    assert(IsClient(target_p));
491  
492 <    if (IsDefunct(target_p) || IsDeaf(target_p) || target_p->from == one)
492 >    if (IsDefunct(target_p) || HasUMode(target_p, UMODE_DEAF) || target_p->from == one)
493        continue;
494  
495 <    if (MyClient(target_p))
495 >    if (MyConnect(target_p))
496      {
497 <      if (target_p->serial != current_serial)
497 >      if (target_p->localClient->serial != current_serial)
498        {
499          send_message(target_p, local_buf, local_len);
500 <        target_p->serial = current_serial;
500 >        target_p->localClient->serial = current_serial;
501        }
502      }
503      else
# Line 514 | Line 505 | sendto_channel_butone(struct Client *one
505        /* Now check whether a message has been sent to this
506         * remote link already
507         */
508 <      if (target_p->from->serial != current_serial)
508 >      if (target_p->from->localClient->serial != current_serial)
509        {
510          if (IsCapable(target_p->from, CAP_TS6))
511            send_message_remote(target_p->from, from, uid_buf, uid_len);
512          else
513            send_message_remote(target_p->from, from, remote_buf, remote_len);
514 <        target_p->from->serial = current_serial;
514 >        target_p->from->localClient->serial = current_serial;
515        }
516      }
517    }
# Line 545 | Line 536 | sendto_channel_butone(struct Client *one
536   * -davidt
537   */
538   void
539 < sendto_server(struct Client *one,
540 <              struct Channel *chptr, unsigned long caps,
541 <              unsigned long nocaps,
539 > sendto_server(struct Client *one, const struct Channel *chptr,
540 >              const unsigned int caps,
541 >              const unsigned int nocaps,
542                const char *format, ...)
543   {
544    va_list args;
# Line 623 | Line 614 | sendto_common_channels_local(struct Clie
614        assert(target_p != NULL);
615  
616        if (!MyConnect(target_p) || target_p == user || IsDefunct(target_p) ||
617 <          target_p->serial == current_serial)
617 >          target_p->localClient->serial == current_serial)
618          continue;
619  
620 <      target_p->serial = current_serial;
620 >      target_p->localClient->serial = current_serial;
621        send_message(target_p, buffer, len);
622      }
623    }
624  
625    if (touser && MyConnect(user) && !IsDead(user) &&
626 <      user->serial != current_serial)
626 >      user->localClient->serial != current_serial)
627      send_message(user, buffer, len);
628   }
629  
# Line 670 | Line 661 | sendto_channel_local(int type, int nodea
661        continue;
662  
663      if (!MyConnect(target_p) || IsDefunct(target_p) ||
664 <        (nodeaf && IsDeaf(target_p)))
664 >        (nodeaf && HasUMode(target_p, UMODE_DEAF)))
665        continue;
666  
667      send_message(target_p, buffer, len);
# Line 713 | Line 704 | sendto_channel_local_butone(struct Clien
704        continue;
705  
706      if (!MyConnect(target_p) || target_p == one ||
707 <        IsDefunct(target_p) || IsDeaf(target_p))
707 >        IsDefunct(target_p) || HasUMode(target_p, UMODE_DEAF))
708        continue;
709      send_message(target_p, buffer, len);
710    }
# Line 732 | Line 723 | sendto_channel_local_butone(struct Clien
723   *                remote to this server.
724   */
725   void
726 < sendto_channel_remote(struct Client *one, struct Client *from, int type, int caps,
727 <                      int nocaps, struct Channel *chptr, const char *pattern, ...)
726 > sendto_channel_remote(struct Client *one, struct Client *from, int type,
727 >                      const unsigned int caps, const unsigned int nocaps,
728 >                      struct Channel *chptr, const char *pattern, ...)
729   {
730    va_list args;
731    char buffer[IRCD_BUFSIZE];
# Line 764 | Line 756 | sendto_channel_remote(struct Client *one
756          ((target_p->from->localClient->caps & caps) != caps) ||
757          ((target_p->from->localClient->caps & nocaps) != 0))
758        continue;
759 <    if (target_p->from->serial != current_serial)
759 >    if (target_p->from->localClient->serial != current_serial)
760      {
761        send_message(target_p, buffer, len);
762 <      target_p->from->serial = current_serial;
762 >      target_p->from->localClient->serial = current_serial;
763      }
764    }
765   }
# Line 793 | Line 785 | static int
785   match_it(const struct Client *one, const char *mask, int what)
786   {
787    if (what == MATCH_HOST)
788 <    return(match(mask, one->host));
788 >    return match(mask, one->host);
789  
790 <  return(match(mask, one->servptr->name));
790 >  return match(mask, one->servptr->name);
791   }
792  
793   /* sendto_match_butone()
# Line 903 | Line 895 | sendto_match_servs(struct Client *source
895      if (IsMe(target_p) || target_p->from == source_p->from)
896        continue;
897  
898 <    if (target_p->from->serial == current_serial)
898 >    if (target_p->from->localClient->serial == current_serial)
899        continue;
900  
901      if (match(mask, target_p->name))
# Line 912 | Line 904 | sendto_match_servs(struct Client *source
904         * if we set the serial here, then we'll never do a
905         * match() again, if !IsCapable()
906         */
907 <      target_p->from->serial = current_serial;
907 >      target_p->from->localClient->serial = current_serial;
908        found++;
909  
910        if (!IsCapable(target_p->from, cap))
# Line 980 | Line 972 | sendto_anywhere(struct Client *to, struc
972   void
973   sendto_realops_flags(unsigned int flags, int level, const char *pattern, ...)
974   {
975 <  struct Client *client_p;
975 >  dlink_node *ptr = NULL;
976    char nbuf[IRCD_BUFSIZE];
985  dlink_node *ptr;
977    va_list args;
978  
979    va_start(args, pattern);
# Line 991 | Line 982 | sendto_realops_flags(unsigned int flags,
982  
983    DLINK_FOREACH(ptr, oper_list.head)
984    {
985 <    client_p = ptr->data;
986 <    assert(client_p->umodes & UMODE_OPER);
985 >    struct Client *client_p = ptr->data;
986 >    assert(HasUMode(client_p, UMODE_OPER));
987  
988      /* If we're sending it to opers and theyre an admin, skip.
989       * If we're sending it to admins, and theyre not, skip.
990       */
991 <    if (((level == L_ADMIN) && !IsAdmin(client_p)) ||
992 <        ((level == L_OPER) && IsAdmin(client_p)))
991 >    if (((level == L_ADMIN) && !HasUMode(client_p, UMODE_ADMIN)) ||
992 >        ((level == L_OPER) && HasUMode(client_p, UMODE_ADMIN)))
993        continue;
994  
995 <    if (client_p->umodes & flags)
995 >    if (HasUMode(client_p, flags))
996        sendto_one(client_p, ":%s NOTICE %s :*** Notice -- %s",
997                   me.name, client_p->name, nbuf);
998    }
999   }
1000  
1001 + void
1002 + sendto_globops_flags(unsigned int flags, int level, const char *pattern, ...)
1003 + {
1004 +  dlink_node *ptr = NULL;
1005 +  char nbuf[IRCD_BUFSIZE];
1006 +  va_list args;
1007 +
1008 +  va_start(args, pattern);
1009 +  vsnprintf(nbuf, IRCD_BUFSIZE, pattern, args);
1010 +  va_end(args);
1011 +
1012 +  DLINK_FOREACH(ptr, oper_list.head)
1013 +  {
1014 +    struct Client *client_p = ptr->data;
1015 +    assert(client_p->umodes & UMODE_OPER);
1016 +
1017 +    /* If we're sending it to opers and theyre an admin, skip.
1018 +     * If we're sending it to admins, and theyre not, skip.
1019 +     */
1020 +    if (((level == L_ADMIN) && !HasUMode(client_p, UMODE_ADMIN)) ||
1021 +        ((level == L_OPER) && HasUMode(client_p, UMODE_ADMIN)))
1022 +      continue;
1023 +
1024 +    if (HasUMode(client_p, flags))
1025 +      sendto_one(client_p, ":%s NOTICE %s :*** Global -- %s",
1026 +                 me.name, client_p->name, nbuf);
1027 +  }
1028 + }
1029 +
1030   /* sendto_wallops_flags()
1031   *
1032   * inputs       - flag types of messages to show to real opers
# Line 1019 | Line 1039 | void
1039   sendto_wallops_flags(unsigned int flags, struct Client *source_p,
1040                       const char *pattern, ...)
1041   {
1042 <  struct Client *client_p;
1023 <  dlink_node *ptr;
1042 >  dlink_node *ptr = NULL;
1043    va_list args;
1044    char buffer[IRCD_BUFSIZE];
1045    int len;
# Line 1037 | Line 1056 | sendto_wallops_flags(unsigned int flags,
1056  
1057    DLINK_FOREACH(ptr, oper_list.head)
1058    {
1059 <    client_p = ptr->data;
1059 >    struct Client *client_p = ptr->data;
1060      assert(client_p->umodes & UMODE_OPER);
1061  
1062 <    if ((client_p->umodes & flags) && !IsDefunct(client_p))
1062 >    if (HasUMode(client_p, flags) && !IsDefunct(client_p))
1063        send_message(client_p, buffer, len);
1064    }
1065   }
# Line 1056 | Line 1075 | void
1075   ts_warn(const char *pattern, ...)
1076   {
1077    va_list args;
1078 <  char buffer[LOG_BUFSIZE];
1078 >  char buffer[IRCD_BUFSIZE];
1079    static time_t last = 0;
1080    static int warnings = 0;
1081  
# Line 1079 | Line 1098 | ts_warn(const char *pattern, ...)
1098    }
1099  
1100    va_start(args, pattern);
1101 <  vsprintf_irc(buffer, pattern, args);
1101 >  vsnprintf(buffer, sizeof(buffer), pattern, args);
1102    va_end(args);
1103  
1104    sendto_realops_flags(UMODE_ALL, L_ALL, "%s", buffer);
1105 <  ilog(L_CRIT, "%s", buffer);
1105 >  ilog(LOG_TYPE_IRCD, "%s", buffer);
1106   }
1107  
1108   /* kill_client()
# Line 1137 | Line 1156 | kill_client_ll_serv_butone(struct Client
1156    char buf_uid[IRCD_BUFSIZE], buf_nick[IRCD_BUFSIZE];
1157    int len_uid = 0, len_nick = 0;
1158  
1159 <  if (HasID(source_p) && (me.id[0] != '\0'))
1159 >  if (HasID(source_p))
1160    {
1161      have_uid = 1;
1162      va_start(args, pattern);

Diff Legend

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