ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/branches/8.2.x/modules/m_accept.c
(Generate patch)

Comparing:
ircd-hybrid/trunk/modules/m_accept.c (file contents), Revision 3246 by michael, Sun Mar 30 17:37:13 2014 UTC vs.
ircd-hybrid/branches/8.2.x/modules/m_accept.c (file contents), Revision 4954 by michael, Sun Nov 30 13:01:28 2014 UTC

# Line 15 | Line 15
15   *
16   *  You should have received a copy of the GNU General Public License
17   *  along with this program; if not, write to the Free Software
18 < *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
18 > *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19   *  USA
20   */
21  
# Line 31 | Line 31
31   #include "list.h"
32   #include "numeric.h"
33   #include "conf.h"
34 #include "s_serv.h"
34   #include "send.h"
35   #include "parse.h"
36   #include "modules.h"
# Line 49 | Line 48 | list_accepts(struct Client *source_p)
48    int len = 0;
49    char nicks[IRCD_BUFSIZE] = "";
50    char *t = nicks;
51 <  const dlink_node *ptr = NULL;
51 >  const dlink_node *node = NULL;
52  
53 <  len = strlen(me.name) + strlen(source_p->name) + 12;
53 >  /* :me.name 281 source_p->name :n1!u1@h1 n2!u2@h2 ...\r\n */
54 >  /* 1       23456              78                     9 10 */
55 >  len = strlen(me.name) + strlen(source_p->name) + 10;
56  
57 <  DLINK_FOREACH(ptr, source_p->localClient->acceptlist.head)
57 >  DLINK_FOREACH(node, source_p->connection->acceptlist.head)
58    {
59 <    const struct split_nuh_item *accept_p = ptr->data;
60 <    size_t masklen = strlen(accept_p->nickptr) +
61 <                     strlen(accept_p->userptr) +
62 <                     strlen(accept_p->hostptr) + 2 /* !@ */ ;
59 >    const struct split_nuh_item *accept = node->data;
60 >    size_t masklen = strlen(accept->nickptr) +
61 >                     strlen(accept->userptr) +
62 >                     strlen(accept->hostptr) + 3;  /* +3 for ! + @ + space */
63  
64 <    if ((t - nicks) + masklen + len  > IRCD_BUFSIZE)
64 >    if ((t - nicks) + masklen + len > IRCD_BUFSIZE)
65      {
66        *(t - 1) = '\0';
67        sendto_one_numeric(source_p, &me, RPL_ACCEPTLIST, nicks);
# Line 68 | Line 69 | list_accepts(struct Client *source_p)
69      }
70  
71      t += sprintf(t, "%s!%s@%s ",
72 <                 accept_p->nickptr,
73 <                 accept_p->userptr, accept_p->hostptr);
72 >                 accept->nickptr,
73 >                 accept->userptr, accept->hostptr);
74    }
75  
76    if (nicks[0])
# Line 90 | Line 91 | list_accepts(struct Client *source_p)
91   static void
92   add_accept(const struct split_nuh_item *nuh, struct Client *source_p)
93   {
94 <  struct split_nuh_item *accept_p = MyMalloc(sizeof(*accept_p));
94 >  struct split_nuh_item *const accept = MyCalloc(sizeof(*accept));
95  
96 <  accept_p->nickptr = xstrdup(nuh->nickptr);
97 <  accept_p->userptr = xstrdup(nuh->userptr);
98 <  accept_p->hostptr = xstrdup(nuh->hostptr);
96 >  accept->nickptr = xstrdup(nuh->nickptr);
97 >  accept->userptr = xstrdup(nuh->userptr);
98 >  accept->hostptr = xstrdup(nuh->hostptr);
99  
100 <  dlinkAdd(accept_p, &accept_p->node, &source_p->localClient->acceptlist);
100 >  dlinkAdd(accept, &accept->node, &source_p->connection->acceptlist);
101  
102    list_accepts(source_p);
103   }
# Line 110 | Line 111 | add_accept(const struct split_nuh_item *
111   *                 pointers.
112   * \note Valid arguments for this command are:
113   *      - parv[0] = command
114 < *      - parv[1] = list of masks to be accepted or removed (optional)
114 > *      - parv[1] = comma-separated list of masks to be accepted or removed
115   */
116   static int
117   m_accept(struct Client *source_p, int parc, char *parv[])
# Line 121 | Line 122 | m_accept(struct Client *source_p, int pa
122    char user[USERLEN + 1] = "";
123    char host[HOSTLEN + 1] = "";
124    struct split_nuh_item nuh;
125 <  struct split_nuh_item *accept_p = NULL;
125 >  struct split_nuh_item *accept = NULL;
126  
127 <  if (EmptyString(parv[1]) || !irccmp(parv[1], "*"))
127 >  if (EmptyString(parv[1]) || !strcmp(parv[1], "*"))
128    {
129      list_accepts(source_p);
130      return 0;
# Line 132 | Line 133 | m_accept(struct Client *source_p, int pa
133    for (mask = strtoken(&p, parv[1], ","); mask;
134         mask = strtoken(&p,    NULL, ","))
135    {
136 <    if (*mask == '-' && *++mask != '\0')
136 >    if (*mask == '-' && *++mask)
137      {
138        nuh.nuhmask  = mask;
139        nuh.nickptr  = nick;
# Line 145 | Line 146 | m_accept(struct Client *source_p, int pa
146  
147        split_nuh(&nuh);
148  
149 <      if ((accept_p = find_accept(nick, user, host, source_p, irccmp)) == NULL)
149 >      if ((accept = find_accept(nick, user, host, source_p, irccmp)) == NULL)
150        {
151          sendto_one_numeric(source_p, &me, ERR_ACCEPTNOT, nick, user, host);
152          continue;
153        }
154  
155 <      del_accept(accept_p, source_p);
155 >      del_accept(accept, source_p);
156      }
157 <    else if (*mask != '\0')
157 >    else if (*mask)
158      {
159 <      if (dlink_list_length(&source_p->localClient->acceptlist) >=
160 <          ConfigFileEntry.max_accept)
159 >      if (dlink_list_length(&source_p->connection->acceptlist) >=
160 >          ConfigGeneral.max_accept)
161        {
162          sendto_one_numeric(source_p, &me, ERR_ACCEPTFULL);
163          return 0;
# Line 173 | Line 174 | m_accept(struct Client *source_p, int pa
174  
175        split_nuh(&nuh);
176  
177 <      if ((accept_p = find_accept(nick, user, host, source_p, irccmp)))
177 >      if ((accept = find_accept(nick, user, host, source_p, irccmp)))
178        {
179          sendto_one_numeric(source_p, &me, ERR_ACCEPTEXIST, nick, user, host);
180          continue;
# Line 188 | Line 189 | m_accept(struct Client *source_p, int pa
189  
190   static struct Message accept_msgtab =
191   {
192 <  "ACCEPT", 0, 0, 0, MAXPARA, MFLG_SLOW, 0,
192 >  "ACCEPT", NULL, 0, 0, 0, MAXPARA, MFLG_SLOW, 0,
193    { m_unregistered, m_accept, m_ignore, m_ignore, m_accept, m_ignore }
194   };
195  

Diff Legend

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