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 1793 by michael, Sun Mar 31 14:06:08 2013 UTC vs.
ircd-hybrid/branches/8.2.x/modules/m_accept.c (file contents), Revision 4546 by michael, Fri Aug 22 08:46:38 2014 UTC

# Line 1 | Line 1
1   /*
2 < *  ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
2 > *  ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3   *
4 < *  Copyright (C) 2002 by the past and present ircd coders, and others.
4 > *  Copyright (c) 2000-2014 ircd-hybrid development team
5   *
6   *  This program is free software; you can redistribute it and/or modify
7   *  it under the terms of the GNU General Public License as published by
# 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 47 | Line 46 | static void
46   list_accepts(struct Client *source_p)
47   {
48    int len = 0;
49 <  char nicks[IRCD_BUFSIZE] = { '\0' };
49 >  char nicks[IRCD_BUFSIZE] = "";
50    char *t = nicks;
51    const dlink_node *ptr = 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)
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 /* !@ */ ;
62 >                     strlen(accept_p->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(source_p, form_str(RPL_ACCEPTLIST),
67 <                 me.name, source_p->name, nicks);
67 >      sendto_one_numeric(source_p, &me, RPL_ACCEPTLIST, nicks);
68        t = nicks;
69      }
70  
# Line 73 | Line 73 | list_accepts(struct Client *source_p)
73                   accept_p->userptr, accept_p->hostptr);
74    }
75  
76 <  if (nicks[0] != '\0')
76 >  if (nicks[0])
77    {
78      *(t - 1) = '\0';
79 <    sendto_one(source_p, form_str(RPL_ACCEPTLIST),
80 <               me.name, source_p->name, nicks);
79 >    sendto_one_numeric(source_p, &me, RPL_ACCEPTLIST, nicks);
80    }
81  
82 <  sendto_one(source_p, form_str(RPL_ENDOFACCEPT),
84 <             me.name, source_p->name);
82 >  sendto_one_numeric(source_p, &me, RPL_ENDOFACCEPT);
83   }
84  
85   /*! \brief Allocates and adds a split_nuh_item holding a nick!user\@host
# Line 93 | 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 *accept_p = MyCalloc(sizeof(*accept_p));
95  
96    accept_p->nickptr = xstrdup(nuh->nickptr);
97    accept_p->userptr = xstrdup(nuh->userptr);
# Line 106 | Line 104 | add_accept(const struct split_nuh_item *
104  
105   /*! \brief ACCEPT command handler
106   *
109 * \param client_p Pointer to allocated Client struct with physical connection
110 *                 to this server, i.e. with an open socket connected.
107   * \param source_p Pointer to allocated Client struct from which the message
108   *                 originally comes from.  This can be a local or remote client.
109   * \param parc     Integer holding the number of supplied arguments.
110   * \param parv     Argument vector where parv[0] .. parv[parc-1] are non-NULL
111   *                 pointers.
112   * \note Valid arguments for this command are:
113 < *      - parv[0] = sender prefix
114 < *      - parv[1] = list of masks to be accepted or removed (optional)
113 > *      - parv[0] = command
114 > *      - parv[1] = comma-separated list of masks to be accepted or removed
115   */
116 < static void
117 < m_accept(struct Client *client_p, struct Client *source_p,
122 <         int parc, char *parv[])
116 > static int
117 > m_accept(struct Client *source_p, int parc, char *parv[])
118   {
119    char *mask = NULL;
120    char *p = NULL;
121 <  char nick[NICKLEN + 1];
122 <  char user[USERLEN + 1];
123 <  char host[HOSTLEN + 1];
121 >  char nick[NICKLEN + 1] = "";
122 >  char user[USERLEN + 1] = "";
123 >  char host[HOSTLEN + 1] = "";
124    struct split_nuh_item nuh;
125    struct split_nuh_item *accept_p = 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;
130 >    return 0;
131    }
132  
133 <  for (mask = strtoken(&p, parv[1], ","); mask != NULL;
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 151 | Line 146 | m_accept(struct Client *client_p, struct
146  
147        split_nuh(&nuh);
148  
149 <      if ((accept_p = find_accept(nick, user, host, source_p, 0)) == NULL)
149 >      if ((accept_p = find_accept(nick, user, host, source_p, irccmp)) == NULL)
150        {
151 <        sendto_one(source_p, form_str(ERR_ACCEPTNOT),
157 <                   me.name, source_p->name, nick, user, host);
151 >        sendto_one_numeric(source_p, &me, ERR_ACCEPTNOT, nick, user, host);
152          continue;
153        }
154  
155        del_accept(accept_p, 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)
160 >          ConfigGeneral.max_accept)
161        {
162 <        sendto_one(source_p, form_str(ERR_ACCEPTFULL),
163 <                   me.name, source_p->name);
170 <        return;
162 >        sendto_one_numeric(source_p, &me, ERR_ACCEPTFULL);
163 >        return 0;
164        }
165  
166        nuh.nuhmask  = mask;
# Line 181 | Line 174 | m_accept(struct Client *client_p, struct
174  
175        split_nuh(&nuh);
176  
177 <      if ((accept_p = find_accept(nick, user, host, source_p, 0)) != NULL)
177 >      if ((accept_p = find_accept(nick, user, host, source_p, irccmp)))
178        {
179 <        sendto_one(source_p, form_str(ERR_ACCEPTEXIST),
187 <                   me.name, source_p->name, nick, user, host);
179 >        sendto_one_numeric(source_p, &me, ERR_ACCEPTEXIST, nick, user, host);
180          continue;
181        }
182  
183        add_accept(&nuh, source_p);
184      }
185    }
186 +
187 +  return 0;
188   }
189  
190 < static struct Message accept_msgtab = {
191 <  "ACCEPT", 0, 0, 0, MAXPARA, MFLG_SLOW, 0,
190 > static struct Message accept_msgtab =
191 > {
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  
# Line 210 | Line 205 | module_exit(void)
205    mod_del_cmd(&accept_msgtab);
206   }
207  
208 < struct module module_entry = {
208 > struct module module_entry =
209 > {
210    .node    = { NULL, NULL, NULL },
211    .name    = NULL,
212    .version = "$Revision$",

Diff Legend

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