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

# 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 240
76 michael 239 if (parc < 2 || !irccmp(parv[1], "*"))
77 adx 30 {
78     list_accepts(source_p);
79     return;
80     }
81    
82 michael 239 for (mask = strtoken(&p, parv[1], ","); mask != NULL;
83     mask = strtoken(&p, NULL, ","))
84 adx 30 {
85 michael 239 if (*mask == '-' && *++mask != '\0')
86 adx 30 {
87 michael 239 split_nuh(mask, &nick, &user, &host);
88 adx 30
89 michael 239 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 michael 235
99 michael 239 del_accept(accept, source_p);
100 adx 30
101 michael 235 MyFree(nick);
102     MyFree(user);
103     MyFree(host);
104 adx 30 }
105 michael 239 else if (*mask != '\0')
106     {
107     split_nuh(mask, &nick, &user, &host);
108 adx 30
109 michael 239 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 michael 240
132 michael 235 MyFree(nick);
133     MyFree(user);
134     MyFree(host);
135 adx 30 }
136     }
137     }
138    
139     /* add_accept()
140     *
141 db 232 * input - nick
142     * - username
143     * - host
144     * - pointer to client to add to acceptlist
145 adx 30 * output - none
146     * side effects - target is added to clients list
147     */
148     static void
149 michael 235 add_accept(const char *nick, const char *user,
150     const char *host, struct Client *source_p)
151 adx 30 {
152 michael 235 struct Accept *accept = MyMalloc(sizeof(*accept));
153    
154     DupString(accept->nick, nick);
155     DupString(accept->user, user);
156 db 232 DupString(accept->host, host);
157 michael 235
158 db 232 dlinkAdd(accept, &accept->node, &source_p->localClient->acceptlist);
159    
160 adx 30 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 db 232 struct Accept *accept;
173 adx 30 int len = 0;
174 db 232 char nuh_list[IRCD_BUFSIZE] = { '\0' };
175     char *t = nuh_list;
176 adx 30 const dlink_node *ptr = NULL;
177    
178     len = strlen(me.name) + strlen(source_p->name) + 12;
179    
180 db 232 DLINK_FOREACH(ptr, source_p->localClient->acceptlist.head)
181 adx 30 {
182 db 232 accept = ptr->data;
183 adx 30
184 db 232 if ((t - nuh_list) + strlen(source_p->name) + len > IRCD_BUFSIZE)
185 adx 30 {
186     *(t - 1) = '\0';
187     sendto_one(source_p, form_str(RPL_ACCEPTLIST),
188 db 232 me.name, source_p->name, nuh_list);
189     t = nuh_list;
190 adx 30 }
191    
192 db 232 t += ircsprintf(t, "%s!%s@%s ",
193 michael 235 accept->nick, accept->user, accept->host);
194 adx 30 }
195    
196 db 232 if (nuh_list[0] != '\0')
197 adx 30 {
198     *(t - 1) = '\0';
199     sendto_one(source_p, form_str(RPL_ACCEPTLIST),
200 db 232 me.name, source_p->name, nuh_list);
201 adx 30 }
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