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

Diff of /ircd-hybrid-7.2/modules/m_accept.c

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

revision 1006 by michael, Thu Nov 1 11:54:48 2007 UTC revision 1007 by michael, Tue Sep 1 15:25:26 2009 UTC
# Line 1  Line 1 
1  /*  /*
2   *  ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).   *  ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
  *  m_accept.c: Allows a user to talk to a +g user.  
3   *   *
4   *  Copyright (C) 2002 by the past and present ircd coders, and others.   *  Copyright (C) 2002 by the past and present ircd coders, and others.
5   *   *
# Line 18  Line 17 
17   *  along with this program; if not, write to the Free Software   *  along with this program; if not, write to the Free Software
18   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
19   *  USA   *  USA
20   *   */
21   *  $Id$  
22    /*! \file m_accept.c
23     * \brief Includes required functions for processing the ACCEPT command.
24     * \version $Id$
25   */   */
26    
27  #include "stdinc.h"  #include "stdinc.h"
# Line 27  Line 29 
29  #include "client.h"  #include "client.h"
30  #include "irc_string.h"  #include "irc_string.h"
31  #include "sprintf_irc.h"  #include "sprintf_irc.h"
 #include "hash.h"       /* for find_client() */  
32  #include "ircd.h"  #include "ircd.h"
33  #include "list.h"  #include "list.h"
34  #include "numeric.h"  #include "numeric.h"
# Line 36  Line 37 
37  #include "send.h"  #include "send.h"
38  #include "msg.h"  #include "msg.h"
39  #include "parse.h"  #include "parse.h"
 #include "s_user.h"  
40  #include "modules.h"  #include "modules.h"
41    
42  static void m_accept(struct Client *, struct Client *, int, char *[]);  static void m_accept(struct Client *, struct Client *, int, char *[]);
 static void list_accepts(struct Client *);  
43    
44  struct Message accept_msgtab = {  struct Message accept_msgtab = {
45    "ACCEPT", 0, 0, 0, 0, MFLG_SLOW, 0,    "ACCEPT", 0, 0, 0, 0, MFLG_SLOW, 0,
# Line 64  const char *_version = "$Revision$"; Line 63  const char *_version = "$Revision$";
63  #endif  #endif
64    
65    
66  /* add_accept()  /*! \brief Creates and sends a list of nick!user\@host masks a Client
67     *         has on its acceptlist.
68   *   *
69   * input        - pointer to preallocated nick   * \param source_p The actual Client the list will be sent to.
70   *              - pointer to preallocated username   */
71   *              - pointer to preallocated host  static void
72   *              - pointer to client to add to acceptlist  list_accepts(struct Client *source_p)
73   * output       - none  {
74   * side effects - target is added to clients list    int len = 0;
75      char nicks[IRCD_BUFSIZE] = { '\0' };
76      char *t = nicks;
77      const dlink_node *ptr = NULL;
78    
79      len = strlen(me.name) + strlen(source_p->name) + 12;
80    
81      DLINK_FOREACH(ptr, source_p->localClient->acceptlist.head)
82      {
83        const struct split_nuh_item *accept_p = ptr->data;
84        size_t masklen = strlen(accept_p->nickptr) +
85                         strlen(accept_p->userptr) +
86                         strlen(accept_p->hostptr) + 2 /* !@ */ ;
87    
88        if ((t - nicks) + masklen + len  > IRCD_BUFSIZE)
89        {
90          *(t - 1) = '\0';
91          sendto_one(source_p, form_str(RPL_ACCEPTLIST),
92                     me.name, source_p->name, nicks);
93          t = nicks;
94        }
95    
96        t += ircsprintf(t, "%s!%s@%s ",
97                        accept_p->nickptr,
98                        accept_p->userptr, accept_p->hostptr);
99      }
100    
101      if (nicks[0] != '\0')
102      {
103        *(t - 1) = '\0';
104        sendto_one(source_p, form_str(RPL_ACCEPTLIST),
105                   me.name, source_p->name, nicks);
106      }
107    
108      sendto_one(source_p, form_str(RPL_ENDOFACCEPT),
109                 me.name, source_p->name);
110    }
111    
112    /*! \brief Allocates and adds a split_nuh_item holding a nick!user\@host
113     *         mask to a Client's acceptlist.
114     *
115     * \param nuh      A split_nuh_item already prepared with required masks.
116     * \param source_p The actual Client the new accept is added to.
117   */   */
118  static void  static void
119  add_accept(const struct split_nuh_item *nuh, struct Client *source_p)  add_accept(const struct split_nuh_item *nuh, struct Client *source_p)
# Line 175  m_accept(struct Client *client_p, struct Line 217  m_accept(struct Client *client_p, struct
217      }      }
218    }    }
219  }  }
   
 /* list_accepts()  
  *  
  * input        - pointer to client  
  * output       - none  
  * side effects - print accept list to client  
  */  
 static void  
 list_accepts(struct Client *source_p)  
 {  
   int len = 0;  
   char nicks[IRCD_BUFSIZE] = { '\0' };  
   char *t = nicks;  
   const dlink_node *ptr = NULL;  
   
   len = strlen(me.name) + strlen(source_p->name) + 12;  
   
   DLINK_FOREACH(ptr, source_p->localClient->acceptlist.head)  
   {  
     const struct split_nuh_item *accept_p = ptr->data;  
     size_t masklen = strlen(accept_p->nickptr) +  
                      strlen(accept_p->userptr) +  
                      strlen(accept_p->hostptr) + 2 /* !@ */ ;  
   
     if ((t - nicks) + masklen + len  > IRCD_BUFSIZE)  
     {  
       *(t - 1) = '\0';  
       sendto_one(source_p, form_str(RPL_ACCEPTLIST),  
                  me.name, source_p->name, nicks);  
       t = nicks;  
     }  
   
     t += ircsprintf(t, "%s!%s@%s ",  
                     accept_p->nickptr,  
                     accept_p->userptr, accept_p->hostptr);  
   }  
   
   if (nicks[0] != '\0')  
   {  
     *(t - 1) = '\0';  
     sendto_one(source_p, form_str(RPL_ACCEPTLIST),  
                me.name, source_p->name, nicks);  
   }  
   
   sendto_one(source_p, form_str(RPL_ENDOFACCEPT),  
              me.name, source_p->name);  
 }  

Legend:
Removed from v.1006  
changed lines
  Added in v.1007

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