/[svn]/ircd-hybrid/modules/m_cap.c
ViewVC logotype

Diff of /ircd-hybrid/modules/m_cap.c

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

revision 503 by michael, Fri Mar 3 19:49:25 2006 UTC revision 504 by michael, Fri Mar 3 20:11:54 2006 UTC
# Line 36  Line 36 
36  #include "s_conf.h"  #include "s_conf.h"
37  #include "s_stats.h"  #include "s_stats.h"
38  #include "s_user.h"  #include "s_user.h"
 #include "whowas.h"  
39  #include "s_serv.h"  #include "s_serv.h"
40  #include "send.h"  #include "send.h"
41  #include "channel.h"  #include "channel.h"
# Line 102  capab_search(const char *key, const stru Line 101  capab_search(const char *key, const stru
101      else    /* OK, let's move on... */      else    /* OK, let's move on... */
102        rb++;        rb++;
103    
104    /* If the character they differ on happens to be a space, and it happens    /*
105       * If the character they differ on happens to be a space, and it happens
106     * to be the same length as the capability name, then we've found a     * to be the same length as the capability name, then we've found a
107     * match; otherwise, return the difference of the two.     * match; otherwise, return the difference of the two.
108     */     */
# Line 118  find_cap(const char **caplist_p, int *ne Line 118  find_cap(const char **caplist_p, int *ne
118    
119    *neg_p = 0;    /* clear negative flag... */    *neg_p = 0;    /* clear negative flag... */
120    
121    if (!inited++)    if (!inited)
122      {
123      /* First, let's sort the array... */      /* First, let's sort the array... */
124      qsort(capab_list, CAPAB_LIST_LEN, sizeof(struct capabilities), (bqcmp)capab_sort);      qsort(capab_list, CAPAB_LIST_LEN, sizeof(struct capabilities), (bqcmp)capab_sort);
125        inited = 1;
126      }
127    
128    /* Next, find first non-whitespace character... */    /* Next, find first non-whitespace character... */
129    while (*caplist && IsSpace(*caplist))    while (*caplist && IsSpace(*caplist))
# Line 157  find_cap(const char **caplist_p, int *ne Line 160  find_cap(const char **caplist_p, int *ne
160  /** Send a CAP \a subcmd list of capability changes to \a sptr.  /** Send a CAP \a subcmd list of capability changes to \a sptr.
161   * If more than one line is necessary, each line before the last has   * If more than one line is necessary, each line before the last has
162   * an added "*" parameter before that line's capability list.   * an added "*" parameter before that line's capability list.
163   * @param[in] sptr Client receiving capability list.   * \param sptr   Client receiving capability list.
164   * @param[in] set Capabilities to show as set (with ack and sticky modifiers).   * \param set    Capabilities to show as set (with ack and sticky modifiers).
165   * @param[in] rem Capabalities to show as removed (with no other modifier).   * \param rem    Capabalities to show as removed (with no other modifier).
166   * @param[in] subcmd Name of capability subcommand.   * \param subcmd Name of capability subcommand.
167   */   */
168  static int  static int
169  send_caplist(struct Client *sptr, unsigned int set,  send_caplist(struct Client *sptr, unsigned int set,
# Line 171  send_caplist(struct Client *sptr, unsign Line 174  send_caplist(struct Client *sptr, unsign
174    int i, loc, len, flags, pfx_len, clen;    int i, loc, len, flags, pfx_len, clen;
175    
176    /* set up the buffer for the final LS message... */    /* set up the buffer for the final LS message... */
177    clen = snprintf(cmdbuf, sizeof(capbuf), ":%s CAP %s %s ", me.name,    clen = snprintf(cmdbuf, sizeof(cmdbuf), ":%s CAP %s %s ", me.name,
178                    sptr->name[0] ? sptr->name : "*", subcmd);                    sptr->name[0] ? sptr->name : "*", subcmd);
179    
180    for (i = 0, loc = 0; i < CAPAB_LIST_LEN; ++i)    for (i = 0, loc = 0; i < CAPAB_LIST_LEN; ++i)
# Line 227  send_caplist(struct Client *sptr, unsign Line 230  send_caplist(struct Client *sptr, unsign
230  static int  static int
231  cap_ls(struct Client *sptr, const char *caplist)  cap_ls(struct Client *sptr, const char *caplist)
232  {  {
233    if (IsUnknown(sptr)) /* registration hasn't completed; suspend it... */    if (IsUnknown(sptr))
234        /* registration hasn't completed; suspend it... */
235      sptr->localClient->registration |= REG_NEED_CAP;      sptr->localClient->registration |= REG_NEED_CAP;
236    
237    return send_caplist(sptr, 0, 0, "LS"); /* send list of capabilities */    return send_caplist(sptr, 0, 0, "LS"); /* send list of capabilities */
# Line 246  cap_req(struct Client *sptr, const char Line 250  cap_req(struct Client *sptr, const char
250    if (IsUnknown(sptr)) /* registration hasn't completed; suspend it... */    if (IsUnknown(sptr)) /* registration hasn't completed; suspend it... */
251      sptr->localClient->registration |= REG_NEED_CAP;      sptr->localClient->registration |= REG_NEED_CAP;
252    
253    while (cl) { /* walk through the capabilities list... */    while (cl)
254      {
255        /* walk through the capabilities list... */
256      if (!(cap = find_cap(&cl, &neg)) /* look up capability... */      if (!(cap = find_cap(&cl, &neg)) /* look up capability... */
257          || (!neg && (cap->flags & CAPFL_PROHIBIT)) /* is it prohibited? */          || (!neg && (cap->flags & CAPFL_PROHIBIT))    /* is it prohibited? */
258          || (neg && (cap->flags & CAPFL_STICKY))) { /* is it sticky? */          || (neg && (cap->flags & CAPFL_STICKY)))    /* is it sticky? */
259        {
260        sendto_one(sptr, ":%s CAP %s NAK :%s", me.name,        sendto_one(sptr, ":%s CAP %s NAK :%s", me.name,
261                   sptr->name[0] ? sptr->name : "*", caplist);                   sptr->name[0] ? sptr->name : "*", caplist);
262        return 0; /* can't complete requested op... */        return 0; /* can't complete requested op... */

Legend:
Removed from v.503  
changed lines
  Added in v.504

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