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-8/modules/m_accept.c (file contents), Revision 1243 by michael, Fri Sep 30 10:47:53 2011 UTC vs.
ircd-hybrid/trunk/modules/m_accept.c (file contents), Revision 3246 by michael, Sun Mar 30 17:37:13 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 27 | Line 27
27   #include "stdinc.h"
28   #include "client.h"
29   #include "irc_string.h"
30 #include "sprintf_irc.h"
30   #include "ircd.h"
31   #include "list.h"
32   #include "numeric.h"
33 < #include "s_conf.h"
33 > #include "conf.h"
34   #include "s_serv.h"
35   #include "send.h"
36   #include "parse.h"
37   #include "modules.h"
38 + #include "memory.h"
39  
40  
41   /*! \brief Creates and sends a list of nick!user\@host masks a Client
# Line 47 | Line 47 | static void
47   list_accepts(struct Client *source_p)
48   {
49    int len = 0;
50 <  char nicks[IRCD_BUFSIZE] = { '\0' };
50 >  char nicks[IRCD_BUFSIZE] = "";
51    char *t = nicks;
52    const dlink_node *ptr = NULL;
53  
# Line 63 | Line 63 | list_accepts(struct Client *source_p)
63      if ((t - nicks) + masklen + len  > IRCD_BUFSIZE)
64      {
65        *(t - 1) = '\0';
66 <      sendto_one(source_p, form_str(RPL_ACCEPTLIST),
67 <                 me.name, source_p->name, nicks);
66 >      sendto_one_numeric(source_p, &me, RPL_ACCEPTLIST, nicks);
67        t = nicks;
68      }
69  
70 <    t += ircsprintf(t, "%s!%s@%s ",
71 <                    accept_p->nickptr,
72 <                    accept_p->userptr, accept_p->hostptr);
70 >    t += sprintf(t, "%s!%s@%s ",
71 >                 accept_p->nickptr,
72 >                 accept_p->userptr, accept_p->hostptr);
73    }
74  
75 <  if (nicks[0] != '\0')
75 >  if (nicks[0])
76    {
77      *(t - 1) = '\0';
78 <    sendto_one(source_p, form_str(RPL_ACCEPTLIST),
80 <               me.name, source_p->name, nicks);
78 >    sendto_one_numeric(source_p, &me, RPL_ACCEPTLIST, nicks);
79    }
80  
81 <  sendto_one(source_p, form_str(RPL_ENDOFACCEPT),
84 <             me.name, source_p->name);
81 >  sendto_one_numeric(source_p, &me, RPL_ENDOFACCEPT);
82   }
83  
84   /*! \brief Allocates and adds a split_nuh_item holding a nick!user\@host
# Line 95 | Line 92 | add_accept(const struct split_nuh_item *
92   {
93    struct split_nuh_item *accept_p = MyMalloc(sizeof(*accept_p));
94  
95 <  DupString(accept_p->nickptr, nuh->nickptr);
96 <  DupString(accept_p->userptr, nuh->userptr);
97 <  DupString(accept_p->hostptr, nuh->hostptr);
95 >  accept_p->nickptr = xstrdup(nuh->nickptr);
96 >  accept_p->userptr = xstrdup(nuh->userptr);
97 >  accept_p->hostptr = xstrdup(nuh->hostptr);
98  
99    dlinkAdd(accept_p, &accept_p->node, &source_p->localClient->acceptlist);
100  
# Line 106 | Line 103 | add_accept(const struct split_nuh_item *
103  
104   /*! \brief ACCEPT command handler
105   *
109 * \param client_p Pointer to allocated Client struct with physical connection
110 *                 to this server, i.e. with an open socket connected.
106   * \param source_p Pointer to allocated Client struct from which the message
107   *                 originally comes from.  This can be a local or remote client.
108   * \param parc     Integer holding the number of supplied arguments.
109   * \param parv     Argument vector where parv[0] .. parv[parc-1] are non-NULL
110   *                 pointers.
111   * \note Valid arguments for this command are:
112 < *      - parv[0] = sender prefix
112 > *      - parv[0] = command
113   *      - parv[1] = list of masks to be accepted or removed (optional)
114   */
115 < static void
116 < m_accept(struct Client *client_p, struct Client *source_p,
122 <         int parc, char *parv[])
115 > static int
116 > m_accept(struct Client *source_p, int parc, char *parv[])
117   {
118    char *mask = NULL;
119    char *p = NULL;
120 <  char nick[NICKLEN + 1];
121 <  char user[USERLEN + 1];
122 <  char host[HOSTLEN + 1];
120 >  char nick[NICKLEN + 1] = "";
121 >  char user[USERLEN + 1] = "";
122 >  char host[HOSTLEN + 1] = "";
123    struct split_nuh_item nuh;
124    struct split_nuh_item *accept_p = NULL;
125  
126    if (EmptyString(parv[1]) || !irccmp(parv[1], "*"))
127    {
128      list_accepts(source_p);
129 <    return;
129 >    return 0;
130    }
131  
132 <  for (mask = strtoken(&p, parv[1], ","); mask != NULL;
132 >  for (mask = strtoken(&p, parv[1], ","); mask;
133         mask = strtoken(&p,    NULL, ","))
134    {
135      if (*mask == '-' && *++mask != '\0')
# Line 151 | Line 145 | m_accept(struct Client *client_p, struct
145  
146        split_nuh(&nuh);
147  
148 <      if ((accept_p = find_accept(nick, user, host, source_p, 0)) == NULL)
148 >      if ((accept_p = find_accept(nick, user, host, source_p, irccmp)) == NULL)
149        {
150 <        sendto_one(source_p, form_str(ERR_ACCEPTNOT),
157 <                   me.name, source_p->name, nick, user, host);
150 >        sendto_one_numeric(source_p, &me, ERR_ACCEPTNOT, nick, user, host);
151          continue;
152        }
153  
# Line 165 | Line 158 | m_accept(struct Client *client_p, struct
158        if (dlink_list_length(&source_p->localClient->acceptlist) >=
159            ConfigFileEntry.max_accept)
160        {
161 <        sendto_one(source_p, form_str(ERR_ACCEPTFULL),
162 <                   me.name, source_p->name);
170 <        return;
161 >        sendto_one_numeric(source_p, &me, ERR_ACCEPTFULL);
162 >        return 0;
163        }
164  
165        nuh.nuhmask  = mask;
# Line 181 | Line 173 | m_accept(struct Client *client_p, struct
173  
174        split_nuh(&nuh);
175  
176 <      if ((accept_p = find_accept(nick, user, host, source_p, 0)) != NULL)
176 >      if ((accept_p = find_accept(nick, user, host, source_p, irccmp)))
177        {
178 <        sendto_one(source_p, form_str(ERR_ACCEPTEXIST),
187 <                   me.name, source_p->name, nick, user, host);
178 >        sendto_one_numeric(source_p, &me, ERR_ACCEPTEXIST, nick, user, host);
179          continue;
180        }
181  
182        add_accept(&nuh, source_p);
183      }
184    }
185 +
186 +  return 0;
187   }
188  
189 < static struct Message accept_msgtab = {
189 > static struct Message accept_msgtab =
190 > {
191    "ACCEPT", 0, 0, 0, MAXPARA, MFLG_SLOW, 0,
192    { m_unregistered, m_accept, m_ignore, m_ignore, m_accept, m_ignore }
193   };
# Line 210 | Line 204 | module_exit(void)
204    mod_del_cmd(&accept_msgtab);
205   }
206  
207 < struct module module_entry = {
207 > struct module module_entry =
208 > {
209    .node    = { NULL, NULL, NULL },
210    .name    = NULL,
211    .version = "$Revision$",

Diff Legend

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