ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/modules/m_accept.c
Revision: 239
Committed: Sat Nov 5 17:54:04 2005 UTC (20 years, 9 months ago) by michael
Content type: text/x-csrc
File size: 5159 byte(s)
Log Message:
- Got rid of build_nuh_list()
- Readd ability of showing ACCEPT list via "ACCEPT *" as described in umodeg.txt

File Contents

# User Rev Content
1 adx 30 /*
2     * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3     * m_accept.c: Allows a user to talk to a +g user.
4     *
5     * Copyright (C) 2002 by the past and present ircd coders, and others.
6     *
7     * This program is free software; you can redistribute it and/or modify
8     * it under the terms of the GNU General Public License as published by
9     * the Free Software Foundation; either version 2 of the License, or
10     * (at your option) any later version.
11     *
12     * This program is distributed in the hope that it will be useful,
13     * but WITHOUT ANY WARRANTY; without even the implied warranty of
14     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15     * GNU General Public License for more details.
16     *
17     * You should have received a copy of the GNU General Public License
18     * along with this program; if not, write to the Free Software
19     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20     * USA
21     *
22 knight 31 * $Id$
23 adx 30 */
24    
25     #include "stdinc.h"
26     #include "handlers.h"
27     #include "client.h"
28     #include "ircd.h"
29     #include "numeric.h"
30     #include "s_conf.h"
31     #include "s_serv.h"
32     #include "send.h"
33     #include "msg.h"
34     #include "parse.h"
35     #include "s_user.h"
36     #include "modules.h"
37    
38     static void m_accept(struct Client *, struct Client *, int, char *[]);
39 michael 235 static void add_accept(const char *, const char *, const char *, struct Client *);
40 adx 30 static void list_accepts(struct Client *);
41    
42     struct Message accept_msgtab = {
43 michael 235 "ACCEPT", 0, 0, 0, 0, MFLG_SLOW, 0,
44     { m_unregistered, m_accept, m_ignore, m_ignore, m_accept, m_ignore }
45 adx 30 };
46    
47     #ifndef STATIC_MODULES
48     void
49     _modinit(void)
50     {
51     mod_add_cmd(&accept_msgtab);
52     }
53    
54     void
55     _moddeinit(void)
56     {
57     mod_del_cmd(&accept_msgtab);
58     }
59    
60 knight 31 const char *_version = "$Revision$";
61 adx 30 #endif
62    
63     /*
64     * m_accept - ACCEPT command handler
65     * parv[0] = sender prefix
66 michael 239 * parv[1] = list of masks to be accepted or removed
67 adx 30 */
68     static void
69     m_accept(struct Client *client_p, struct Client *source_p,
70     int parc, char *parv[])
71     {
72 michael 235 struct Accept *accept = NULL;
73 db 232 char *mask, *nick, *user, *host;
74 adx 30 char *p = NULL;
75 michael 239 unsigned int accept_num = 0;
76 adx 30
77 michael 239 if (parc < 2 || !irccmp(parv[1], "*"))
78 adx 30 {
79     list_accepts(source_p);
80     return;
81     }
82    
83     /* parse the delete list */
84 michael 239 for (mask = strtoken(&p, parv[1], ","); mask != NULL;
85     mask = strtoken(&p, NULL, ","))
86 adx 30 {
87 michael 239 if (*mask == '-' && *++mask != '\0')
88 adx 30 {
89 michael 239 split_nuh(mask, &nick, &user, &host);
90 adx 30
91 michael 239 if ((accept = find_accept(nick, user, host, source_p, 0)) == NULL)
92     {
93     sendto_one(source_p, form_str(ERR_ACCEPTNOT),
94     me.name, source_p->name, nick, user, host);
95     MyFree(nick);
96     MyFree(user);
97     MyFree(host);
98     continue;
99     }
100 michael 235
101 michael 239 del_accept(accept, source_p);
102 adx 30
103 michael 235 MyFree(nick);
104     MyFree(user);
105     MyFree(host);
106 adx 30 }
107 michael 239 else if (*mask != '\0')
108     {
109     split_nuh(mask, &nick, &user, &host);
110 adx 30
111 michael 239 if ((accept = find_accept(nick, user, host, source_p, 0)) != NULL)
112     {
113     sendto_one(source_p, form_str(ERR_ACCEPTEXIST),
114     me.name, source_p->name, nick, user, host);
115     MyFree(nick);
116     MyFree(user);
117     MyFree(host);
118     continue;
119     }
120    
121     if (dlink_list_length(&source_p->localClient->acceptlist) >=
122     ConfigFileEntry.max_accept)
123     {
124     sendto_one(source_p, form_str(ERR_ACCEPTFULL),
125     me.name, source_p->name);
126     MyFree(nick);
127     MyFree(user);
128     MyFree(host);
129     return;
130     }
131    
132     add_accept(nick, user, host, source_p);
133 michael 235 MyFree(nick);
134     MyFree(user);
135     MyFree(host);
136 michael 239 ++accept_num;
137 adx 30 }
138     }
139     }
140    
141     /* add_accept()
142     *
143 db 232 * input - nick
144     * - username
145     * - host
146     * - pointer to client to add to acceptlist
147 adx 30 * output - none
148     * side effects - target is added to clients list
149     */
150     static void
151 michael 235 add_accept(const char *nick, const char *user,
152     const char *host, struct Client *source_p)
153 adx 30 {
154 michael 235 struct Accept *accept = MyMalloc(sizeof(*accept));
155    
156     DupString(accept->nick, nick);
157     DupString(accept->user, user);
158 db 232 DupString(accept->host, host);
159 michael 235
160 db 232 dlinkAdd(accept, &accept->node, &source_p->localClient->acceptlist);
161    
162 adx 30 list_accepts(source_p);
163     }
164    
165     /* list_accepts()
166     *
167     * input - pointer to client
168     * output - none
169     * side effects - print accept list to client
170     */
171     static void
172     list_accepts(struct Client *source_p)
173     {
174 db 232 struct Accept *accept;
175 adx 30 int len = 0;
176 db 232 char nuh_list[IRCD_BUFSIZE] = { '\0' };
177     char *t = nuh_list;
178 adx 30 const dlink_node *ptr = NULL;
179    
180     len = strlen(me.name) + strlen(source_p->name) + 12;
181    
182 db 232 DLINK_FOREACH(ptr, source_p->localClient->acceptlist.head)
183 adx 30 {
184 db 232 accept = ptr->data;
185 adx 30
186 db 232 if ((t - nuh_list) + strlen(source_p->name) + len > IRCD_BUFSIZE)
187 adx 30 {
188     *(t - 1) = '\0';
189     sendto_one(source_p, form_str(RPL_ACCEPTLIST),
190 db 232 me.name, source_p->name, nuh_list);
191     t = nuh_list;
192 adx 30 }
193    
194 db 232 t += ircsprintf(t, "%s!%s@%s ",
195 michael 235 accept->nick, accept->user, accept->host);
196 adx 30 }
197    
198 db 232 if (nuh_list[0] != '\0')
199 adx 30 {
200     *(t - 1) = '\0';
201     sendto_one(source_p, form_str(RPL_ACCEPTLIST),
202 db 232 me.name, source_p->name, nuh_list);
203 adx 30 }
204    
205     sendto_one(source_p, form_str(RPL_ENDOFACCEPT),
206     me.name, source_p->name);
207     }

Properties

Name Value
svn:eol-style native
svn:keywords Id Revision