ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/modules/m_accept.c
Revision: 240
Committed: Sat Nov 5 18:03:59 2005 UTC (20 years, 9 months ago) by michael
Content type: text/x-csrc
File size: 5077 byte(s)
Log Message:
- Forgot to remove accept_num, we dont need it anymore.

File Contents

# Content
1 /*
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 * $Id$
23 */
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 static void add_accept(const char *, const char *, const char *, struct Client *);
40 static void list_accepts(struct Client *);
41
42 struct Message accept_msgtab = {
43 "ACCEPT", 0, 0, 0, 0, MFLG_SLOW, 0,
44 { m_unregistered, m_accept, m_ignore, m_ignore, m_accept, m_ignore }
45 };
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 const char *_version = "$Revision$";
61 #endif
62
63 /*
64 * m_accept - ACCEPT command handler
65 * parv[0] = sender prefix
66 * parv[1] = list of masks to be accepted or removed
67 */
68 static void
69 m_accept(struct Client *client_p, struct Client *source_p,
70 int parc, char *parv[])
71 {
72 struct Accept *accept = NULL;
73 char *mask, *nick, *user, *host;
74 char *p = NULL;
75
76 if (parc < 2 || !irccmp(parv[1], "*"))
77 {
78 list_accepts(source_p);
79 return;
80 }
81
82 for (mask = strtoken(&p, parv[1], ","); mask != NULL;
83 mask = strtoken(&p, NULL, ","))
84 {
85 if (*mask == '-' && *++mask != '\0')
86 {
87 split_nuh(mask, &nick, &user, &host);
88
89 if ((accept = find_accept(nick, user, host, source_p, 0)) == NULL)
90 {
91 sendto_one(source_p, form_str(ERR_ACCEPTNOT),
92 me.name, source_p->name, nick, user, host);
93 MyFree(nick);
94 MyFree(user);
95 MyFree(host);
96 continue;
97 }
98
99 del_accept(accept, source_p);
100
101 MyFree(nick);
102 MyFree(user);
103 MyFree(host);
104 }
105 else if (*mask != '\0')
106 {
107 split_nuh(mask, &nick, &user, &host);
108
109 if ((accept = find_accept(nick, user, host, source_p, 0)) != NULL)
110 {
111 sendto_one(source_p, form_str(ERR_ACCEPTEXIST),
112 me.name, source_p->name, nick, user, host);
113 MyFree(nick);
114 MyFree(user);
115 MyFree(host);
116 continue;
117 }
118
119 if (dlink_list_length(&source_p->localClient->acceptlist) >=
120 ConfigFileEntry.max_accept)
121 {
122 sendto_one(source_p, form_str(ERR_ACCEPTFULL),
123 me.name, source_p->name);
124 MyFree(nick);
125 MyFree(user);
126 MyFree(host);
127 return;
128 }
129
130 add_accept(nick, user, host, source_p);
131
132 MyFree(nick);
133 MyFree(user);
134 MyFree(host);
135 }
136 }
137 }
138
139 /* add_accept()
140 *
141 * input - nick
142 * - username
143 * - host
144 * - pointer to client to add to acceptlist
145 * output - none
146 * side effects - target is added to clients list
147 */
148 static void
149 add_accept(const char *nick, const char *user,
150 const char *host, struct Client *source_p)
151 {
152 struct Accept *accept = MyMalloc(sizeof(*accept));
153
154 DupString(accept->nick, nick);
155 DupString(accept->user, user);
156 DupString(accept->host, host);
157
158 dlinkAdd(accept, &accept->node, &source_p->localClient->acceptlist);
159
160 list_accepts(source_p);
161 }
162
163 /* list_accepts()
164 *
165 * input - pointer to client
166 * output - none
167 * side effects - print accept list to client
168 */
169 static void
170 list_accepts(struct Client *source_p)
171 {
172 struct Accept *accept;
173 int len = 0;
174 char nuh_list[IRCD_BUFSIZE] = { '\0' };
175 char *t = nuh_list;
176 const dlink_node *ptr = NULL;
177
178 len = strlen(me.name) + strlen(source_p->name) + 12;
179
180 DLINK_FOREACH(ptr, source_p->localClient->acceptlist.head)
181 {
182 accept = ptr->data;
183
184 if ((t - nuh_list) + strlen(source_p->name) + len > IRCD_BUFSIZE)
185 {
186 *(t - 1) = '\0';
187 sendto_one(source_p, form_str(RPL_ACCEPTLIST),
188 me.name, source_p->name, nuh_list);
189 t = nuh_list;
190 }
191
192 t += ircsprintf(t, "%s!%s@%s ",
193 accept->nick, accept->user, accept->host);
194 }
195
196 if (nuh_list[0] != '\0')
197 {
198 *(t - 1) = '\0';
199 sendto_one(source_p, form_str(RPL_ACCEPTLIST),
200 me.name, source_p->name, nuh_list);
201 }
202
203 sendto_one(source_p, form_str(RPL_ENDOFACCEPT),
204 me.name, source_p->name);
205 }

Properties

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