/[svn]/ircd-hybrid/src/channel.c
ViewVC logotype

Diff of /ircd-hybrid/src/channel.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 490 by db, Sun Feb 12 22:22:50 2006 UTC revision 491 by michael, Wed Mar 1 14:51:05 2006 UTC
# Line 307  send_channel_modes(struct Client *client Line 307  send_channel_modes(struct Client *client
307    
308  /*! \brief check channel name for invalid characters  /*! \brief check channel name for invalid characters
309   * \param name pointer to channel name string   * \param name pointer to channel name string
310   * \return TRUE (1) if name ok, FALSE (0) otherwise   * \param local indicates whether it's a local or remote creation
311     * \return 0 if invalid, 1 otherwise
312   */   */
313  int  int
314  check_channel_name(const char *name)  check_channel_name(const char *name, int local)
315  {  {
316    const unsigned char *p = (const unsigned char *)name;    const unsigned char *p = (const unsigned char *)name;
317      int max_length = local ? LOCAL_CHANNELLEN : CHANNELLEN;
318    assert(name != NULL);    assert(name != NULL);
319    
320      if (!IsChanPrefix(*p))
321        return 0;
322    
323    for (; *p; ++p)    for (; *p; ++p)
324      if (!IsChanChar(*p))      if (!IsChanChar(*p))
325        return 0;        return 0;
326    
327    return 1;    return p - name <= max_length;
328  }  }
329    
330  void  void
# Line 354  free_channel_list(dlink_list *list) Line 359  free_channel_list(dlink_list *list)
359    
360  /*! \brief Get Channel block for chname (and allocate a new channel  /*! \brief Get Channel block for chname (and allocate a new channel
361   *         block, if it didn't exist before)   *         block, if it didn't exist before)
362   * \param client_p client pointer   * \param chname channel name
363   * \param chname   channel name   * \return channel block
  * \param isnew    pointer to int flag whether channel was newly created or not  
  * \return channel block or NULL if illegal name  
364   */   */
365  struct Channel *  struct Channel *
366  get_or_create_channel(struct Client *client_p, const char *chname, int *isnew)  make_channel(const char *chname)
367  {  {
368    struct Channel *chptr = NULL;    struct Channel *chptr = NULL;
   int len;  
   
   if (EmptyString(chname))  
     return NULL;  
   
   if ((len = strlen(chname)) > CHANNELLEN)  
   {  
     if (IsServer(client_p))  
       sendto_realops_flags(UMODE_DEBUG, L_ALL,  
                            "*** Long channel name from %s (%d > %d): %s",  
                            client_p->name, len, CHANNELLEN, chname);  
     return NULL;  
   }  
   
   if ((chptr = hash_find_channel(chname)) != NULL)  
   {  
     if (isnew != NULL)  
       *isnew = 0;  
369    
370      return chptr;    assert(!EmptyString(chname));
   }  
   
   if (isnew != NULL)  
     *isnew = 1;  
371    
372    chptr = BlockHeapAlloc(channel_heap);    chptr = BlockHeapAlloc(channel_heap);
373    
374    /* doesn't hurt to set it here */    /* doesn't hurt to set it here */
375    chptr->channelts = chptr->last_join_time = CurrentTime;    chptr->channelts = CurrentTime;
376      chptr->last_join_time = CurrentTime;
377    
378    strlcpy(chptr->chname, chname, sizeof(chptr->chname));    strlcpy(chptr->chname, chname, sizeof(chptr->chname));
379    dlinkAdd(chptr, &chptr->node, &global_channel_list);    dlinkAdd(chptr, &chptr->node, &global_channel_list);

Legend:
Removed from v.490  
changed lines
  Added in v.491

svnadmin@ircd-hybrid.org
ViewVC Help
Powered by ViewVC 1.1.28