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

Comparing ircd-hybrid/trunk/src/channel.c (file contents):
Revision 4811 by michael, Sat Nov 1 11:56:53 2014 UTC vs.
Revision 4815 by michael, Sat Nov 1 15:28:42 2014 UTC

# Line 81 | Line 81 | void
81   add_user_to_channel(struct Channel *chptr, struct Client *who,
82                      unsigned int flags, int flood_ctrl)
83   {
84 <  struct Membership *ms = NULL;
84 >  struct Membership *member = NULL;
85  
86    if (GlobalSetOptions.joinfloodtime > 0)
87    {
# Line 114 | Line 114 | add_user_to_channel(struct Channel *chpt
114      chptr->last_join_time = CurrentTime;
115    }
116  
117 <  ms = mp_pool_get(member_pool);
118 <  ms->client_p = who;
119 <  ms->chptr = chptr;
120 <  ms->flags = flags;
117 >  member = mp_pool_get(member_pool);
118 >  member->client_p = who;
119 >  member->chptr = chptr;
120 >  member->flags = flags;
121  
122 <  dlinkAdd(ms, &ms->channode, &chptr->members);
122 >  dlinkAdd(member, &member->channode, &chptr->members);
123  
124    if (MyConnect(who))
125 <    dlinkAdd(ms, &ms->locchannode, &chptr->locmembers);
125 >    dlinkAdd(member, &member->locchannode, &chptr->locmembers);
126  
127 <  dlinkAdd(ms, &ms->usernode, &who->channel);
127 >  dlinkAdd(member, &member->usernode, &who->channel);
128   }
129  
130   /*! \brief Deletes an user from a channel by removing a link in the
# Line 171 | Line 171 | send_members(struct Client *client_p, co
171  
172    DLINK_FOREACH(node, chptr->members.head)
173    {
174 <    const struct Membership *ms = node->data;
174 >    const struct Membership *member = node->data;
175  
176 <    tlen = strlen(ms->client_p->id) + 1;  /* +1 for space */
176 >    tlen = strlen(member->client_p->id) + 1;  /* +1 for space */
177  
178 <    if (ms->flags & CHFL_CHANOP)
178 >    if (member->flags & CHFL_CHANOP)
179        ++tlen;
180 <    if (ms->flags & CHFL_HALFOP)
180 >    if (member->flags & CHFL_HALFOP)
181        ++tlen;
182 <    if (ms->flags & CHFL_VOICE)
182 >    if (member->flags & CHFL_VOICE)
183        ++tlen;
184  
185      /*
# Line 193 | Line 193 | send_members(struct Client *client_p, co
193        t = start;
194      }
195  
196 <    if (ms->flags & CHFL_CHANOP)
196 >    if (member->flags & CHFL_CHANOP)
197        *t++ = '@';
198 <    if (ms->flags & CHFL_HALFOP)
198 >    if (member->flags & CHFL_HALFOP)
199        *t++ = '%';
200 <    if (ms->flags & CHFL_VOICE)
200 >    if (member->flags & CHFL_VOICE)
201        *t++ = '+';
202  
203 <    strcpy(t, ms->client_p->id);
203 >    strcpy(t, member->client_p->id);
204  
205      t += strlen(t);
206      *t++ = ' ';
# Line 238 | Line 238 | send_mode_list(struct Client *client_p,
238  
239    DLINK_FOREACH(node, list->head)
240    {
241 <    const struct Ban *banptr = node->data;
241 >    const struct Ban *ban = node->data;
242  
243 <    tlen = banptr->len + 3;  /* +3 for ! + @ + space */
243 >    tlen = ban->len + 3;  /* +3 for ! + @ + space */
244  
245      /*
246       * Send buffer and start over if we cannot fit another ban
# Line 254 | Line 254 | send_mode_list(struct Client *client_p,
254        pp = pbuf;
255      }
256  
257 <    pp += sprintf(pp, "%s!%s@%s ", banptr->name, banptr->user,
258 <                  banptr->host);
257 >    pp += sprintf(pp, "%s!%s@%s ", ban->name, ban->user, ban->host);
258      cur_len += tlen;
259    }
260  
# Line 313 | Line 312 | check_channel_name(const char *name, con
312   }
313  
314   void
315 < remove_ban(struct Ban *bptr, dlink_list *list)
315 > remove_ban(struct Ban *ban, dlink_list *list)
316   {
317 <  dlinkDelete(&bptr->node, list);
317 >  dlinkDelete(&ban->node, list);
318  
319 <  MyFree(bptr->name);
320 <  MyFree(bptr->user);
321 <  MyFree(bptr->host);
322 <  MyFree(bptr->who);
319 >  MyFree(ban->name);
320 >  MyFree(ban->user);
321 >  MyFree(ban->host);
322 >  MyFree(ban->who);
323  
324 <  mp_pool_release(bptr);
324 >  mp_pool_release(ban);
325   }
326  
327   /* free_channel_list()
# Line 428 | Line 427 | channel_member_names(struct Client *sour
427  
428      DLINK_FOREACH(node, chptr->members.head)
429      {
430 <      const struct Membership *ms = node->data;
430 >      const struct Membership *member = node->data;
431  
432 <      if (HasUMode(ms->client_p, UMODE_INVISIBLE) && !is_member)
432 >      if (HasUMode(member->client_p, UMODE_INVISIBLE) && !is_member)
433          continue;
434  
435        if (!uhnames)
436 <        tlen = strlen(ms->client_p->name) + 1;  /* +1 for space */
436 >        tlen = strlen(member->client_p->name) + 1;  /* +1 for space */
437        else
438 <        tlen = strlen(ms->client_p->name) + strlen(ms->client_p->username) +
439 <               strlen(ms->client_p->host) + 3;  /* +3 for ! + @ + space */
438 >        tlen = strlen(member->client_p->name) + strlen(member->client_p->username) +
439 >               strlen(member->client_p->host) + 3;  /* +3 for ! + @ + space */
440  
441        if (!multi_prefix)
442        {
443 <        if (ms->flags & (CHFL_CHANOP | CHFL_HALFOP | CHFL_VOICE))
443 >        if (member->flags & (CHFL_CHANOP | CHFL_HALFOP | CHFL_VOICE))
444            ++tlen;
445        }
446        else
447        {
448 <        if (ms->flags & CHFL_CHANOP)
448 >        if (member->flags & CHFL_CHANOP)
449            ++tlen;
450 <        if (ms->flags & CHFL_HALFOP)
450 >        if (member->flags & CHFL_HALFOP)
451            ++tlen;
452 <        if (ms->flags & CHFL_VOICE)
452 >        if (member->flags & CHFL_VOICE)
453            ++tlen;
454        }
455  
# Line 462 | Line 461 | channel_member_names(struct Client *sour
461        }
462  
463        if (!uhnames)
464 <        t += sprintf(t, "%s%s ", get_member_status(ms, multi_prefix),
465 <                     ms->client_p->name);
464 >        t += sprintf(t, "%s%s ", get_member_status(member, multi_prefix),
465 >                     member->client_p->name);
466        else
467 <        t += sprintf(t, "%s%s!%s@%s ", get_member_status(ms, multi_prefix),
468 <                     ms->client_p->name, ms->client_p->username,
469 <                     ms->client_p->host);
467 >        t += sprintf(t, "%s%s!%s@%s ", get_member_status(member, multi_prefix),
468 >                     member->client_p->name, member->client_p->username,
469 >                     member->client_p->host);
470      }
471  
472      if (tlen)
# Line 545 | Line 544 | clear_invites(struct Channel *chptr)
544   * (like in get_client_name)
545   */
546   const char *
547 < get_member_status(const struct Membership *ms, const int combine)
547 > get_member_status(const struct Membership *member, const int combine)
548   {
549    static char buffer[4];  /* 4 for @%+\0 */
550    char *p = buffer;
551  
552 <  if (ms->flags & CHFL_CHANOP)
552 >  if (member->flags & CHFL_CHANOP)
553    {
554      if (!combine)
555        return "@";
556      *p++ = '@';
557    }
558  
559 <  if (ms->flags & CHFL_HALFOP)
559 >  if (member->flags & CHFL_HALFOP)
560    {
561      if (!combine)
562        return "%";
563      *p++ = '%';
564    }
565  
566 <  if (ms->flags & CHFL_VOICE)
566 >  if (member->flags & CHFL_VOICE)
567      *p++ = '+';
568    *p = '\0';
569  
# Line 584 | Line 583 | find_bmask(const struct Client *who, con
583  
584    DLINK_FOREACH(node, list->head)
585    {
586 <    const struct Ban *bp = node->data;
586 >    const struct Ban *ban = node->data;
587  
588 <    if (!match(bp->name, who->name) && !match(bp->user, who->username))
588 >    if (!match(ban->name, who->name) && !match(ban->user, who->username))
589      {
590 <      switch (bp->type)
590 >      switch (ban->type)
591        {
592          case HM_HOST:
593 <          if (!match(bp->host, who->host) || !match(bp->host, who->sockhost))
593 >          if (!match(ban->host, who->host) || !match(ban->host, who->sockhost))
594              return 1;
595            break;
596          case HM_IPV4:
597            if (who->connection->aftype == AF_INET)
598 <            if (match_ipv4(&who->connection->ip, &bp->addr, bp->bits))
598 >            if (match_ipv4(&who->connection->ip, &ban->addr, ban->bits))
599                return 1;
600            break;
601          case HM_IPV6:
602            if (who->connection->aftype == AF_INET6)
603 <            if (match_ipv6(&who->connection->ip, &bp->addr, bp->bits))
603 >            if (match_ipv6(&who->connection->ip, &ban->addr, ban->bits))
604                return 1;
605            break;
606          default:
# Line 666 | Line 665 | can_join(struct Client *source_p, const
665   }
666  
667   int
668 < has_member_flags(const struct Membership *ms, const unsigned int flags)
668 > has_member_flags(const struct Membership *member, const unsigned int flags)
669   {
670 <  return ms && (ms->flags & flags);
670 >  return member && (member->flags & flags);
671   }
672  
673   struct Membership *
# Line 729 | Line 728 | msg_has_ctrls(const char *message)
728   /*! Tests if a client can send to a channel
729   * \param chptr    Pointer to Channel struct
730   * \param source_p Pointer to Client struct
731 < * \param ms       Pointer to Membership struct (can be NULL)
731 > * \param member   Pointer to Membership struct (can be NULL)
732   * \param message  The actual message string the client wants to send
733   * \return CAN_SEND_OPV if op or voiced on channel\n
734   *         CAN_SEND_NONOP if can send to channel but is not an op\n
# Line 737 | Line 736 | msg_has_ctrls(const char *message)
736   */
737   int
738   can_send(struct Channel *chptr, struct Client *source_p,
739 <         struct Membership *ms, const char *message)
739 >         struct Membership *member, const char *message)
740   {
741    const struct MaskItem *conf = NULL;
742  
# Line 751 | Line 750 | can_send(struct Channel *chptr, struct C
750  
751    if ((chptr->mode.mode & MODE_NOCTRL) && msg_has_ctrls(message))
752      return ERR_NOCTRLSONCHAN;
753 <  if (ms || (ms = find_channel_link(source_p, chptr)))
754 <    if (ms->flags & (CHFL_CHANOP|CHFL_HALFOP|CHFL_VOICE))
753 >  if (member || (member = find_channel_link(source_p, chptr)))
754 >    if (member->flags & (CHFL_CHANOP|CHFL_HALFOP|CHFL_VOICE))
755        return CAN_SEND_OPV;
756 <  if (!ms && (chptr->mode.mode & MODE_NOPRIVMSGS))
756 >  if (!member && (chptr->mode.mode & MODE_NOPRIVMSGS))
757      return ERR_CANNOTSENDTOCHAN;
758    if (chptr->mode.mode & MODE_MODERATED)
759      return ERR_CANNOTSENDTOCHAN;
# Line 764 | Line 763 | can_send(struct Channel *chptr, struct C
763    /* Cache can send if banned */
764    if (MyClient(source_p))
765    {
766 <    if (ms)
766 >    if (member)
767      {
768 <      if (ms->flags & CHFL_BAN_SILENCED)
768 >      if (member->flags & CHFL_BAN_SILENCED)
769          return ERR_CANNOTSENDTOCHAN;
770  
771 <      if (!(ms->flags & CHFL_BAN_CHECKED))
771 >      if (!(member->flags & CHFL_BAN_CHECKED))
772        {
773          if (is_banned(chptr, source_p))
774          {
775 <          ms->flags |= (CHFL_BAN_CHECKED|CHFL_BAN_SILENCED);
775 >          member->flags |= (CHFL_BAN_CHECKED|CHFL_BAN_SILENCED);
776            return ERR_CANNOTSENDTOCHAN;
777          }
778  
779 <        ms->flags |= CHFL_BAN_CHECKED;
779 >        member->flags |= CHFL_BAN_CHECKED;
780        }
781      }
782      else if (is_banned(chptr, source_p))
# Line 1143 | Line 1142 | static void
1142   channel_part_one_client(struct Client *source_p, const char *name, const char *reason)
1143   {
1144    struct Channel *chptr = NULL;
1145 <  struct Membership *ms = NULL;
1145 >  struct Membership *member = NULL;
1146  
1147    if ((chptr = hash_find_channel(name)) == NULL)
1148    {
# Line 1151 | Line 1150 | channel_part_one_client(struct Client *s
1150      return;
1151    }
1152  
1153 <  if ((ms = find_channel_link(source_p, chptr)) == NULL)
1153 >  if ((member = find_channel_link(source_p, chptr)) == NULL)
1154    {
1155      sendto_one_numeric(source_p, &me, ERR_NOTONCHANNEL, chptr->name);
1156      return;
# Line 1165 | Line 1164 | channel_part_one_client(struct Client *s
1164     * only allow /part reasons in -m chans
1165     */
1166    if (*reason && (!MyConnect(source_p) ||
1167 <      ((can_send(chptr, source_p, ms, reason) &&
1167 >      ((can_send(chptr, source_p, member, reason) &&
1168         (source_p->connection->firsttime + ConfigGeneral.anti_spam_exit_message_time)
1169          < CurrentTime))))
1170    {
# Line 1184 | Line 1183 | channel_part_one_client(struct Client *s
1183                           source_p->host, chptr->name);
1184    }
1185  
1186 <  remove_user_from_channel(ms);
1186 >  remove_user_from_channel(member);
1187   }
1188  
1189   void

Diff Legend

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