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-7.3/src/channel.c (file contents), Revision 1146 by michael, Thu Jul 28 20:00:19 2011 UTC vs.
ircd-hybrid-8/src/channel.c (file contents), Revision 1330 by michael, Sun Apr 1 12:12:00 2012 UTC

# Line 29 | Line 29
29   #include "channel.h"
30   #include "channel_mode.h"
31   #include "client.h"
32 #include "common.h"
32   #include "hash.h"
33   #include "hostmask.h"
34   #include "irc_string.h"
# Line 39 | Line 38
38   #include "s_serv.h"             /* captab */
39   #include "s_user.h"
40   #include "send.h"
41 < #include "s_conf.h"             /* ConfigFileEntry, ConfigChannel */
41 > #include "conf.h"             /* ConfigFileEntry, ConfigChannel */
42   #include "event.h"
43   #include "memory.h"
44   #include "balloc.h"
# Line 48 | Line 47 | struct config_channel_entry ConfigChanne
47   dlink_list global_channel_list = { NULL, NULL, 0 };
48   BlockHeap *ban_heap;    /*! \todo ban_heap shouldn't be a global var */
49  
51 static BlockHeap *topic_heap = NULL;
50   static BlockHeap *member_heap = NULL;
51   static BlockHeap *channel_heap = NULL;
52  
# Line 68 | Line 66 | init_channels(void)
66  
67    channel_heap = BlockHeapCreate("channel", sizeof(struct Channel), CHANNEL_HEAP_SIZE);
68    ban_heap = BlockHeapCreate("ban", sizeof(struct Ban), BAN_HEAP_SIZE);
71  topic_heap = BlockHeapCreate("topic", TOPICLEN+1 + USERHOST_REPLYLEN, TOPIC_HEAP_SIZE);
69    member_heap = BlockHeapCreate("member", sizeof(struct Membership), CHANNEL_HEAP_SIZE*2);
70   }
71  
# Line 183 | Line 180 | send_members(struct Client *client_p, st
180      /* space will be converted into CR, but we also need space for LF..
181       * That's why we use '- 1' here
182       * -adx */
183 <    if (t + tlen - buf > sizeof(buf) - 1)
183 >    if (t + tlen - buf > IRCD_BUFSIZE - 1)
184      {
185        *(t - 1) = '\0';  /* kill the space and terminate the string */
186        sendto_one(client_p, "%s", buf);
# Line 407 | Line 404 | destroy_channel(struct Channel *chptr)
404    free_channel_list(&chptr->exceptlist);
405    free_channel_list(&chptr->invexlist);
406  
410  /* Free the topic */
411  free_topic(chptr);
412
407    dlinkDelete(&chptr->node, &global_channel_list);
408    hash_del_channel(chptr);
409  
# Line 462 | Line 456 | channel_member_names(struct Client *sour
456        ms       = ptr->data;
457        target_p = ms->client_p;
458  
459 <      if (IsInvisible(target_p) && !is_member)
459 >      if (HasUMode(target_p, UMODE_INVISIBLE) && !is_member)
460          continue;
461  
462        tlen = strlen(target_p->name) + 1;  /* nick + space */
# Line 661 | Line 655 | can_join(struct Client *source_p, struct
655    if (is_banned(chptr, source_p))
656      return ERR_BANNEDFROMCHAN;
657  
658 + #ifdef HAVE_LIBCRYPTO
659 +  if ((chptr->mode.mode & MODE_SSLONLY) && !source_p->localClient->fd.ssl)
660 +    return ERR_SSLONLYCHAN;
661 + #endif
662 +
663 +  if ((chptr->mode.mode & MODE_REGONLY) && !HasUMode(source_p, UMODE_REGISTERED))
664 +    return ERR_NEEDREGGEDNICK;
665 +
666 +  if ((chptr->mode.mode & MODE_OPERONLY) && !HasUMode(source_p, UMODE_OPER))
667 +    return ERR_OPERONLYCHAN;
668 +
669    if (chptr->mode.mode & MODE_INVITEONLY)
670      if (!dlinkFind(&source_p->localClient->invited, chptr))
671        if (!ConfigChannel.use_invex || !find_bmask(source_p, &chptr->invexlist))
# Line 705 | Line 710 | find_channel_link(struct Client *client_
710   * \param ms       pointer to Membership struct (can be NULL)
711   * \return CAN_SEND_OPV if op or voiced on channel\n
712   *         CAN_SEND_NONOP if can send to channel but is not an op\n
713 < *         CAN_SEND_NO if they cannot send to channel\n
713 > *         ERR_CANNOTSENDTOCHAN or ERR_NEEDREGGEDNICK if they cannot send to channel\n
714   */
715   int
716   can_send(struct Channel *chptr, struct Client *source_p, struct Membership *ms)
717   {
718 <  if (IsServer(source_p))
718 >  if (IsServer(source_p) || HasFlag(source_p, FLAGS_SERVICE))
719      return CAN_SEND_OPV;
720  
721    if (MyClient(source_p) && !IsExemptResv(source_p))
722 <    if (!(IsOper(source_p) && ConfigFileEntry.oper_pass_resv))
722 >    if (!(HasUMode(source_p, UMODE_OPER) && ConfigFileEntry.oper_pass_resv))
723        if (!hash_find_resv(chptr->chname) == ConfigChannel.restrict_channels)
724 <        return CAN_SEND_NO;
724 >        return ERR_CANNOTSENDTOCHAN;
725  
726    if (ms != NULL || (ms = find_channel_link(source_p, chptr)))
727    {
# Line 727 | Line 732 | can_send(struct Channel *chptr, struct C
732      if (ConfigChannel.quiet_on_ban && MyClient(source_p))
733      {
734        if (ms->flags & CHFL_BAN_SILENCED)
735 <        return CAN_SEND_NO;
735 >        return ERR_CANNOTSENDTOCHAN;
736  
737        if (!(ms->flags & CHFL_BAN_CHECKED))
738        {
739          if (is_banned(chptr, source_p))
740          {
741            ms->flags |= (CHFL_BAN_CHECKED|CHFL_BAN_SILENCED);
742 <          return CAN_SEND_NO;
742 >          return ERR_CANNOTSENDTOCHAN;
743          }
744  
745          ms->flags |= CHFL_BAN_CHECKED;
# Line 742 | Line 747 | can_send(struct Channel *chptr, struct C
747      }
748    }
749    else if (chptr->mode.mode & MODE_NOPRIVMSGS)
750 <    return CAN_SEND_NO;
750 >    return ERR_CANNOTSENDTOCHAN;
751  
752    if (chptr->mode.mode & MODE_MODERATED)
753 <    return CAN_SEND_NO;
753 >    return ERR_CANNOTSENDTOCHAN;
754  
755    return CAN_SEND_NONOP;
756   }
# Line 846 | Line 851 | check_splitmode(void *unused)
851    }
852   }
853  
849 /*! \brief Allocates a new topic
850 * \param chptr Channel to allocate a new topic for
851 */
852 static void
853 allocate_topic(struct Channel *chptr)
854 {
855  void *ptr = NULL;
856
857  if (chptr == NULL)
858    return;
859
860  ptr = BlockHeapAlloc(topic_heap);  
861
862  /* Basically we allocate one large block for the topic and
863   * the topic info.  We then split it up into two and shove it
864   * in the chptr
865   */
866  chptr->topic       = ptr;
867  chptr->topic_info  = (char *)ptr + TOPICLEN+1;
868  *chptr->topic      = '\0';
869  *chptr->topic_info = '\0';
870 }
871
872 void
873 free_topic(struct Channel *chptr)
874 {
875  void *ptr = NULL;
876  assert(chptr);
877  if (chptr->topic == NULL)
878    return;
879
880  /*
881   * If you change allocate_topic you MUST change this as well
882   */
883  ptr = chptr->topic;
884  BlockHeapFree(topic_heap, ptr);    
885  chptr->topic      = NULL;
886  chptr->topic_info = NULL;
887 }
888
854   /*! \brief Sets the channel topic for chptr
855   * \param chptr      Pointer to struct Channel
856   * \param topic      The topic string
# Line 896 | Line 861 | void
861   set_channel_topic(struct Channel *chptr, const char *topic,
862                    const char *topic_info, time_t topicts)
863   {
864 <  if (!EmptyString(topic))
865 <  {
866 <    if (chptr->topic == NULL)
902 <      allocate_topic(chptr);
903 <
904 <    strlcpy(chptr->topic, topic, TOPICLEN+1);
905 <    strlcpy(chptr->topic_info, topic_info, USERHOST_REPLYLEN);
906 <    chptr->topic_time = topicts;
907 <  }
908 <  else
909 <  {
910 <    /*
911 <     * Do not reset chptr->topic_time here, it's required for
912 <     * bursting topics properly.
913 <     */
914 <    if (chptr->topic != NULL)
915 <      free_topic(chptr);
916 <  }
864 >  strlcpy(chptr->topic, topic, sizeof(chptr->topic));
865 >  strlcpy(chptr->topic_info, topic_info, sizeof(chptr->topic_info));
866 >  chptr->topic_time = topicts;
867   }

Diff Legend

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