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 4588 by michael, Tue Aug 26 15:59:07 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 107 | Line 107 | add_user_to_channel(struct Channel *chpt
107          sendto_realops_flags(UMODE_BOTS, L_ALL, SEND_NOTICE,
108                               "Possible Join Flooder %s on %s target: %s",
109                               get_client_name(who, HIDE_IP),
110 <                             who->servptr->name, chptr->chname);
110 >                             who->servptr->name, chptr->name);
111        }
112      }
113  
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 157 | Line 157 | remove_user_from_channel(struct Membersh
157   * side effects -
158   */
159   static void
160 < send_members(struct Client *client_p, struct Channel *chptr,
160 > send_members(struct Client *client_p, const struct Channel *chptr,
161               char *modebuf, char *parabuf)
162   {
163    char buf[IRCD_BUFSIZE] = "";
164 <  const dlink_node *ptr = NULL;
164 >  const dlink_node *node = NULL;
165    int tlen;              /* length of text to append */
166    char *t, *start;       /* temp char pointer */
167  
168    start = t = buf + snprintf(buf, sizeof(buf), ":%s SJOIN %lu %s %s %s:",
169                               me.id, (unsigned long)chptr->channelts,
170 <                             chptr->chname, modebuf, parabuf);
170 >                             chptr->name, modebuf, parabuf);
171  
172 <  DLINK_FOREACH(ptr, chptr->members.head)
172 >  DLINK_FOREACH(node, chptr->members.head)
173    {
174 <    const struct Membership *ms = ptr->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, st
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 220 | Line 220 | send_members(struct Client *client_p, st
220   * \param flag     Char flag flagging type of mode. Currently this can be 'b', e' or 'I'
221   */
222   static void
223 < send_mode_list(struct Client *client_p, struct Channel *chptr,
223 > send_mode_list(struct Client *client_p, const struct Channel *chptr,
224                 const dlink_list *list, const char flag)
225   {
226 <  const dlink_node *ptr = NULL;
226 >  const dlink_node *node = NULL;
227    char mbuf[IRCD_BUFSIZE] = "";
228    char pbuf[IRCD_BUFSIZE] = "";
229    int tlen, mlen, cur_len;
# Line 233 | Line 233 | send_mode_list(struct Client *client_p,
233      return;
234  
235    mlen = snprintf(mbuf, sizeof(mbuf), ":%s BMASK %lu %s %c :", me.id,
236 <                  (unsigned long)chptr->channelts, chptr->chname, flag);
236 >                  (unsigned long)chptr->channelts, chptr->name, flag);
237    cur_len = mlen;
238  
239 <  DLINK_FOREACH(ptr, list->head)
239 >  DLINK_FOREACH(node, list->head)
240    {
241 <    const struct Ban *banptr = ptr->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 334 | Line 333 | remove_ban(struct Ban *bptr, dlink_list
333   void
334   free_channel_list(dlink_list *list)
335   {
336 <  dlink_node *ptr = NULL, *ptr_next = NULL;
336 >  dlink_node *node = NULL, *node_next = NULL;
337  
338 <  DLINK_FOREACH_SAFE(ptr, ptr_next, list->head)
339 <    remove_ban(ptr->data, list);
338 >  DLINK_FOREACH_SAFE(node, node_next, list->head)
339 >    remove_ban(node->data, list);
340  
341    assert(list->tail == NULL && list->head == NULL);
342   }
343  
344 < /*! \brief Get Channel block for chname (and allocate a new channel
344 > /*! \brief Get Channel block for name (and allocate a new channel
345   *         block, if it didn't exist before)
346 < * \param chname Channel name
346 > * \param name Channel name
347   * \return Channel block
348   */
349   struct Channel *
350 < make_channel(const char *chname)
350 > make_channel(const char *name)
351   {
352    struct Channel *chptr = NULL;
353  
354 <  assert(!EmptyString(chname));
354 >  assert(!EmptyString(name));
355  
356    chptr = mp_pool_get(channel_pool);
357  
# Line 360 | Line 359 | make_channel(const char *chname)
359    chptr->channelts = CurrentTime;
360    chptr->last_join_time = CurrentTime;
361  
362 <  strlcpy(chptr->chname, chname, sizeof(chptr->chname));
362 >  strlcpy(chptr->name, name, sizeof(chptr->name));
363    dlinkAdd(chptr, &chptr->node, &channel_list);
364  
365    hash_add_channel(chptr);
# Line 374 | Line 373 | make_channel(const char *chname)
373   void
374   destroy_channel(struct Channel *chptr)
375   {
376 <  dlink_node *ptr = NULL, *ptr_next = NULL;
378 <
379 <  DLINK_FOREACH_SAFE(ptr, ptr_next, chptr->invites.head)
380 <    del_invite(chptr, ptr->data);
376 >  clear_invites(chptr);
377  
378    /* Free ban/exception/invex lists */
379    free_channel_list(&chptr->banlist);
# Line 414 | Line 410 | void
410   channel_member_names(struct Client *source_p, struct Channel *chptr,
411                       int show_eon)
412   {
413 <  const dlink_node *ptr = NULL;
413 >  const dlink_node *node = NULL;
414    char buf[IRCD_BUFSIZE + 1] = "";
415    char *t = NULL, *start = NULL;
416    int tlen = 0;
# Line 426 | Line 422 | channel_member_names(struct Client *sour
422    {
423      t = buf + snprintf(buf, sizeof(buf), numeric_form(RPL_NAMREPLY),
424                         me.name, source_p->name,
425 <                       channel_pub_or_secret(chptr), chptr->chname);
425 >                       channel_pub_or_secret(chptr), chptr->name);
426      start = t;
427  
428 <    DLINK_FOREACH(ptr, chptr->members.head)
428 >    DLINK_FOREACH(node, chptr->members.head)
429      {
430 <      const struct Membership *ms = ptr->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 465 | 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 481 | Line 477 | channel_member_names(struct Client *sour
477    }
478  
479    if (show_eon)
480 <    sendto_one_numeric(source_p, &me, RPL_ENDOFNAMES, chptr->chname);
480 >    sendto_one_numeric(source_p, &me, RPL_ENDOFNAMES, chptr->name);
481   }
482  
483   /*! \brief Adds client to invite list
# Line 515 | Line 511 | add_invite(struct Channel *chptr, struct
511   void
512   del_invite(struct Channel *chptr, struct Client *who)
513   {
514 <  dlink_node *ptr = NULL;
514 >  dlink_node *node = NULL;
515 >
516 >  if ((node = dlinkFindDelete(&who->connection->invited, chptr)))
517 >    free_dlink_node(node);
518 >
519 >  if ((node = dlinkFindDelete(&chptr->invites, who)))
520 >    free_dlink_node(node);
521 > }
522  
523 <  if ((ptr = dlinkFindDelete(&who->connection->invited, chptr)))
524 <    free_dlink_node(ptr);
523 > /*! \brief Removes all invites of a specific channel
524 > * \param chptr Pointer to Channel struct
525 > */
526 > void
527 > clear_invites(struct Channel *chptr)
528 > {
529 >  dlink_node *node = NULL, *node_next = NULL;
530  
531 <  if ((ptr = dlinkFindDelete(&chptr->invites, who)))
532 <    free_dlink_node(ptr);
531 >  DLINK_FOREACH_SAFE(node, node_next, chptr->invites.head)
532 >    del_invite(chptr, node->data);
533   }
534  
535   /* get_member_status()
# Line 536 | Line 544 | del_invite(struct Channel *chptr, struct
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 571 | Line 579 | get_member_status(const struct Membershi
579   static int
580   find_bmask(const struct Client *who, const dlink_list *const list)
581   {
582 <  const dlink_node *ptr = NULL;
582 >  const dlink_node *node = NULL;
583  
584 <  DLINK_FOREACH(ptr, list->head)
584 >  DLINK_FOREACH(node, list->head)
585    {
586 <    const struct Ban *bp = ptr->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 627 | Line 635 | is_banned(const struct Channel *chptr, c
635   *         or 0 if allowed to join.
636   */
637   int
638 < can_join(struct Client *source_p, struct Channel *chptr, const char *key)
638 > can_join(struct Client *source_p, const struct Channel *chptr, const char *key)
639   {
640    if ((chptr->mode.mode & MODE_SSLONLY) && !HasUMode(source_p, UMODE_SSL))
641      return ERR_SSLONLYCHAN;
# Line 657 | Line 665 | can_join(struct Client *source_p, struct
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 *
674   find_channel_link(struct Client *client_p, struct Channel *chptr)
675   {
676 <  dlink_node *ptr = NULL;
676 >  dlink_node *node = NULL;
677  
678    if (!IsClient(client_p))
679      return NULL;
680  
681    if (dlink_list_length(&chptr->members) < dlink_list_length(&client_p->channel))
682    {
683 <    DLINK_FOREACH(ptr, chptr->members.head)
684 <      if (((struct Membership *)ptr->data)->client_p == client_p)
685 <        return ptr->data;
683 >    DLINK_FOREACH(node, chptr->members.head)
684 >      if (((struct Membership *)node->data)->client_p == client_p)
685 >        return node->data;
686    }
687    else
688    {
689 <    DLINK_FOREACH(ptr, client_p->channel.head)
690 <      if (((struct Membership *)ptr->data)->chptr == chptr)
691 <        return ptr->data;
689 >    DLINK_FOREACH(node, client_p->channel.head)
690 >      if (((struct Membership *)node->data)->chptr == chptr)
691 >        return node->data;
692    }
693  
694    return NULL;
695   }
696  
697 < /*! Tests if a client can send to a channel
697 > /*! Checks if a message contains control codes
698   * \param message The actual message string the client wants to send
699   * \return 1 if the message does contain any control codes, 0 otherwise
700   */
# Line 714 | Line 722 | msg_has_ctrls(const char *message)
722      return 1;  /* Control code */
723    }
724  
725 <  return 0;
725 >  return 0;  /* No control code found */
726   }
727  
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 728 | 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 <  struct MaskItem *conf = NULL;
741 >  const struct MaskItem *conf = NULL;
742  
743    if (IsServer(source_p) || HasFlag(source_p, FLAGS_SERVICE))
744      return CAN_SEND_OPV;
745  
746    if (MyClient(source_p) && !IsExemptResv(source_p))
747      if (!(HasUMode(source_p, UMODE_OPER) && ConfigGeneral.oper_pass_resv))
748 <      if ((conf = match_find_resv(chptr->chname)) && !resv_find_exempt(source_p, conf))
748 >      if ((conf = match_find_resv(chptr->name)) && !resv_find_exempt(source_p, conf))
749          return ERR_CANNOTSENDTOCHAN;
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 755 | 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 903 | Line 911 | channel_set_topic(struct Channel *chptr,
911   void
912   channel_do_join_0(struct Client *source_p)
913   {
914 <  dlink_node *ptr = NULL, *ptr_next = NULL;
914 >  dlink_node *node = NULL, *node_next = NULL;
915  
916    if (source_p->channel.head)
917      if (MyConnect(source_p) && !HasUMode(source_p, UMODE_OPER))
918        check_spambot_warning(source_p, NULL);
919  
920 <  DLINK_FOREACH_SAFE(ptr, ptr_next, source_p->channel.head)
920 >  DLINK_FOREACH_SAFE(node, node_next, source_p->channel.head)
921    {
922 <    struct Channel *chptr = ((struct Membership *)ptr->data)->chptr;
922 >    struct Channel *chptr = ((struct Membership *)node->data)->chptr;
923  
924      sendto_server(source_p, NOCAPS, NOCAPS, ":%s PART %s",
925 <                  source_p->id, chptr->chname);
926 <    sendto_channel_local(ALL_MEMBERS, 0, chptr, ":%s!%s@%s PART %s",
925 >                  source_p->id, chptr->name);
926 >    sendto_channel_local(0, chptr, ":%s!%s@%s PART %s",
927                           source_p->name, source_p->username,
928 <                         source_p->host, chptr->chname);
928 >                         source_p->host, chptr->name);
929  
930 <    remove_user_from_channel(ptr->data);
930 >    remove_user_from_channel(node->data);
931    }
932   }
933  
# Line 932 | Line 940 | channel_find_last0(struct Client *source
940    {
941      if (*p == '0' && (*(p + 1) == ',' || *(p + 1) == '\0'))
942      {
943 <      if ((*p + 1) == ',')
943 >      if (*(p + 1) == ',')
944          ++p;
945  
946        chanlist = p + 1;
# Line 962 | Line 970 | channel_do_join(struct Client *source_p,
970    char *chan_list = NULL;
971    struct Channel *chptr = NULL;
972    struct MaskItem *conf = NULL;
973 <  const struct ClassItem *class = get_class_ptr(&source_p->connection->confs);
973 >  const struct ClassItem *const class = get_class_ptr(&source_p->connection->confs);
974    int i = 0;
975    unsigned int flags = 0;
976  
# Line 1015 | Line 1023 | channel_do_join(struct Client *source_p,
1023        if (splitmode && !HasUMode(source_p, UMODE_OPER) &&
1024            ConfigChannel.no_join_on_split)
1025        {
1026 <        sendto_one_numeric(source_p, &me, ERR_UNAVAILRESOURCE, chptr->chname);
1026 >        sendto_one_numeric(source_p, &me, ERR_UNAVAILRESOURCE, chptr->name);
1027          continue;
1028        }
1029  
# Line 1024 | Line 1032 | channel_do_join(struct Client *source_p,
1032         */
1033        if ((i = can_join(source_p, chptr, key)))
1034        {
1035 <        sendto_one_numeric(source_p, &me, i, chptr->chname);
1035 >        sendto_one_numeric(source_p, &me, i, chptr->name);
1036          continue;
1037        }
1038  
# Line 1051 | Line 1059 | channel_do_join(struct Client *source_p,
1059      }
1060  
1061      if (!HasUMode(source_p, UMODE_OPER))
1062 <      check_spambot_warning(source_p, chptr->chname);
1062 >      check_spambot_warning(source_p, chptr->name);
1063  
1064      add_user_to_channel(chptr, source_p, flags, 1);
1065  
# Line 1066 | Line 1074 | channel_do_join(struct Client *source_p,
1074  
1075        sendto_server(source_p, NOCAPS, NOCAPS, ":%s SJOIN %lu %s +nt :@%s",
1076                      me.id, (unsigned long)chptr->channelts,
1077 <                    chptr->chname, source_p->id);
1077 >                    chptr->name, source_p->id);
1078  
1079        /*
1080         * Notify all other users on the new channel
1081         */
1082 <      sendto_channel_local(ALL_MEMBERS, 0, chptr, ":%s!%s@%s JOIN :%s",
1083 <                           source_p->name, source_p->username,
1084 <                           source_p->host, chptr->chname);
1085 <      sendto_channel_local(ALL_MEMBERS, 0, chptr, ":%s MODE %s +nt",
1086 <                           me.name, chptr->chname);
1082 >      sendto_channel_local_butone(NULL, CAP_EXTENDED_JOIN, 0, chptr, ":%s!%s@%s JOIN %s %s :%s",
1083 >                                  source_p->name, source_p->username,
1084 >                                  source_p->host, chptr->name,
1085 >                                  (!IsDigit(source_p->svid[0]) && source_p->svid[0] != '*') ? source_p->svid : "*",
1086 >                                  source_p->info);
1087 >      sendto_channel_local_butone(NULL, 0, CAP_EXTENDED_JOIN, chptr, ":%s!%s@%s JOIN :%s",
1088 >                                  source_p->name, source_p->username,
1089 >                                  source_p->host, chptr->name);
1090 >      sendto_channel_local(0, chptr, ":%s MODE %s +nt",
1091 >                           me.name, chptr->name);
1092  
1093        if (source_p->away[0])
1094 <        sendto_channel_local_butone(source_p, 0, CAP_AWAY_NOTIFY, chptr,
1094 >        sendto_channel_local_butone(source_p, CAP_AWAY_NOTIFY, 0, chptr,
1095                                      ":%s!%s@%s AWAY :%s",
1096                                      source_p->name, source_p->username,
1097                                      source_p->host, source_p->away);
# Line 1087 | Line 1100 | channel_do_join(struct Client *source_p,
1100      {
1101        sendto_server(source_p, NOCAPS, NOCAPS, ":%s JOIN %lu %s +",
1102                      source_p->id, (unsigned long)chptr->channelts,
1103 <                    chptr->chname);
1104 <      sendto_channel_local(ALL_MEMBERS, 0, chptr, ":%s!%s@%s JOIN :%s",
1105 <                           source_p->name, source_p->username,
1106 <                           source_p->host, chptr->chname);
1103 >                    chptr->name);
1104 >
1105 >      sendto_channel_local_butone(NULL, CAP_EXTENDED_JOIN, 0, chptr, ":%s!%s@%s JOIN %s %s :%s",
1106 >                                  source_p->name, source_p->username,
1107 >                                  source_p->host, chptr->name,
1108 >                                  (!IsDigit(source_p->svid[0]) && source_p->svid[0] != '*') ? source_p->svid : "*",
1109 >                                  source_p->info);
1110 >      sendto_channel_local_butone(NULL, 0, CAP_EXTENDED_JOIN, chptr, ":%s!%s@%s JOIN :%s",
1111 >                                  source_p->name, source_p->username,
1112 >                                  source_p->host, chptr->name);
1113  
1114        if (source_p->away[0])
1115 <        sendto_channel_local_butone(source_p, 0, CAP_AWAY_NOTIFY, chptr,
1115 >        sendto_channel_local_butone(source_p, CAP_AWAY_NOTIFY, 0, chptr,
1116                                      ":%s!%s@%s AWAY :%s",
1117                                      source_p->name, source_p->username,
1118                                      source_p->host, source_p->away);
# Line 1103 | Line 1122 | channel_do_join(struct Client *source_p,
1122  
1123      if (chptr->topic[0])
1124      {
1125 <      sendto_one_numeric(source_p, &me, RPL_TOPIC, chptr->chname, chptr->topic);
1126 <      sendto_one_numeric(source_p, &me, RPL_TOPICWHOTIME, chptr->chname,
1125 >      sendto_one_numeric(source_p, &me, RPL_TOPIC, chptr->name, chptr->topic);
1126 >      sendto_one_numeric(source_p, &me, RPL_TOPICWHOTIME, chptr->name,
1127                           chptr->topic_info, chptr->topic_time);
1128      }
1129  
# Line 1123 | 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 1131 | 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->chname);
1155 >    sendto_one_numeric(source_p, &me, ERR_NOTONCHANNEL, chptr->name);
1156      return;
1157    }
1158  
# Line 1145 | 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    {
1171      sendto_server(source_p, NOCAPS, NOCAPS, ":%s PART %s :%s",
1172 <                  source_p->id, chptr->chname, reason);
1173 <    sendto_channel_local(ALL_MEMBERS, 0, chptr, ":%s!%s@%s PART %s :%s",
1172 >                  source_p->id, chptr->name, reason);
1173 >    sendto_channel_local(0, chptr, ":%s!%s@%s PART %s :%s",
1174                           source_p->name, source_p->username,
1175 <                         source_p->host, chptr->chname, reason);
1175 >                         source_p->host, chptr->name, reason);
1176    }
1177    else
1178    {
1179      sendto_server(source_p, NOCAPS, NOCAPS, ":%s PART %s",
1180 <                  source_p->id, chptr->chname);
1181 <    sendto_channel_local(ALL_MEMBERS, 0, chptr, ":%s!%s@%s PART %s",
1180 >                  source_p->id, chptr->name);
1181 >    sendto_channel_local(0, chptr, ":%s!%s@%s PART %s",
1182                           source_p->name, source_p->username,
1183 <                         source_p->host, chptr->chname);
1183 >                         source_p->host, chptr->name);
1184    }
1185  
1186 <  remove_user_from_channel(ms);
1186 >  remove_user_from_channel(member);
1187   }
1188  
1189   void
1190 < channel_do_part(struct Client *source_p, char *channel, char *reason)
1190 > channel_do_part(struct Client *source_p, char *channel, const char *reason)
1191   {
1192    char *p = NULL, *name = NULL;
1193 <  char reasonbuf[KICKLEN + 1] = "";
1193 >  char buf[KICKLEN + 1] = "";
1194  
1195    if (!EmptyString(reason))
1196 <    strlcpy(reasonbuf, reason, sizeof(reasonbuf));
1196 >    strlcpy(buf, reason, sizeof(buf));
1197  
1198    for (name = strtoken(&p, channel, ","); name;
1199         name = strtoken(&p,    NULL, ","))
1200 <    channel_part_one_client(source_p, name, reasonbuf);
1200 >    channel_part_one_client(source_p, name, buf);
1201   }

Diff Legend

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