1 |
|
/* |
2 |
|
* ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). |
3 |
– |
* m_accept.c: Allows a user to talk to a +g user. |
3 |
|
* |
4 |
|
* Copyright (C) 2002 by the past and present ircd coders, and others. |
5 |
|
* |
17 |
|
* along with this program; if not, write to the Free Software |
18 |
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
19 |
|
* USA |
20 |
< |
* |
21 |
< |
* $Id$ |
20 |
> |
*/ |
21 |
> |
|
22 |
> |
/*! \file m_accept.c |
23 |
> |
* \brief Includes required functions for processing the ACCEPT command. |
24 |
> |
* \version $Id$ |
25 |
|
*/ |
26 |
|
|
27 |
|
#include "stdinc.h" |
29 |
|
#include "client.h" |
30 |
|
#include "irc_string.h" |
31 |
|
#include "sprintf_irc.h" |
30 |
– |
#include "hash.h" /* for find_client() */ |
32 |
|
#include "ircd.h" |
33 |
|
#include "list.h" |
34 |
|
#include "numeric.h" |
37 |
|
#include "send.h" |
38 |
|
#include "msg.h" |
39 |
|
#include "parse.h" |
39 |
– |
#include "s_user.h" |
40 |
|
#include "modules.h" |
41 |
|
|
42 |
|
static void m_accept(struct Client *, struct Client *, int, char *[]); |
43 |
– |
static void list_accepts(struct Client *); |
43 |
|
|
44 |
|
struct Message accept_msgtab = { |
45 |
|
"ACCEPT", 0, 0, 0, 0, MFLG_SLOW, 0, |
63 |
|
#endif |
64 |
|
|
65 |
|
|
66 |
< |
/* add_accept() |
66 |
> |
/*! \brief Creates and sends a list of nick!user\@host masks a Client |
67 |
> |
* has on its acceptlist. |
68 |
|
* |
69 |
< |
* input - pointer to preallocated nick |
70 |
< |
* - pointer to preallocated username |
71 |
< |
* - pointer to preallocated host |
72 |
< |
* - pointer to client to add to acceptlist |
73 |
< |
* output - none |
74 |
< |
* side effects - target is added to clients list |
69 |
> |
* \param source_p The actual Client the list will be sent to. |
70 |
> |
*/ |
71 |
> |
static void |
72 |
> |
list_accepts(struct Client *source_p) |
73 |
> |
{ |
74 |
> |
int len = 0; |
75 |
> |
char nicks[IRCD_BUFSIZE] = { '\0' }; |
76 |
> |
char *t = nicks; |
77 |
> |
const dlink_node *ptr = NULL; |
78 |
> |
|
79 |
> |
len = strlen(me.name) + strlen(source_p->name) + 12; |
80 |
> |
|
81 |
> |
DLINK_FOREACH(ptr, source_p->localClient->acceptlist.head) |
82 |
> |
{ |
83 |
> |
const struct split_nuh_item *accept_p = ptr->data; |
84 |
> |
size_t masklen = strlen(accept_p->nickptr) + |
85 |
> |
strlen(accept_p->userptr) + |
86 |
> |
strlen(accept_p->hostptr) + 2 /* !@ */ ; |
87 |
> |
|
88 |
> |
if ((t - nicks) + masklen + len > IRCD_BUFSIZE) |
89 |
> |
{ |
90 |
> |
*(t - 1) = '\0'; |
91 |
> |
sendto_one(source_p, form_str(RPL_ACCEPTLIST), |
92 |
> |
me.name, source_p->name, nicks); |
93 |
> |
t = nicks; |
94 |
> |
} |
95 |
> |
|
96 |
> |
t += ircsprintf(t, "%s!%s@%s ", |
97 |
> |
accept_p->nickptr, |
98 |
> |
accept_p->userptr, accept_p->hostptr); |
99 |
> |
} |
100 |
> |
|
101 |
> |
if (nicks[0] != '\0') |
102 |
> |
{ |
103 |
> |
*(t - 1) = '\0'; |
104 |
> |
sendto_one(source_p, form_str(RPL_ACCEPTLIST), |
105 |
> |
me.name, source_p->name, nicks); |
106 |
> |
} |
107 |
> |
|
108 |
> |
sendto_one(source_p, form_str(RPL_ENDOFACCEPT), |
109 |
> |
me.name, source_p->name); |
110 |
> |
} |
111 |
> |
|
112 |
> |
/*! \brief Allocates and adds a split_nuh_item holding a nick!user\@host |
113 |
> |
* mask to a Client's acceptlist. |
114 |
> |
* |
115 |
> |
* \param nuh A split_nuh_item already prepared with required masks. |
116 |
> |
* \param source_p The actual Client the new accept is added to. |
117 |
|
*/ |
118 |
|
static void |
119 |
|
add_accept(const struct split_nuh_item *nuh, struct Client *source_p) |
217 |
|
} |
218 |
|
} |
219 |
|
} |
178 |
– |
|
179 |
– |
/* list_accepts() |
180 |
– |
* |
181 |
– |
* input - pointer to client |
182 |
– |
* output - none |
183 |
– |
* side effects - print accept list to client |
184 |
– |
*/ |
185 |
– |
static void |
186 |
– |
list_accepts(struct Client *source_p) |
187 |
– |
{ |
188 |
– |
int len = 0; |
189 |
– |
char nicks[IRCD_BUFSIZE] = { '\0' }; |
190 |
– |
char *t = nicks; |
191 |
– |
const dlink_node *ptr = NULL; |
192 |
– |
|
193 |
– |
len = strlen(me.name) + strlen(source_p->name) + 12; |
194 |
– |
|
195 |
– |
DLINK_FOREACH(ptr, source_p->localClient->acceptlist.head) |
196 |
– |
{ |
197 |
– |
const struct split_nuh_item *accept_p = ptr->data; |
198 |
– |
size_t masklen = strlen(accept_p->nickptr) + |
199 |
– |
strlen(accept_p->userptr) + |
200 |
– |
strlen(accept_p->hostptr) + 2 /* !@ */ ; |
201 |
– |
|
202 |
– |
if ((t - nicks) + masklen + len > IRCD_BUFSIZE) |
203 |
– |
{ |
204 |
– |
*(t - 1) = '\0'; |
205 |
– |
sendto_one(source_p, form_str(RPL_ACCEPTLIST), |
206 |
– |
me.name, source_p->name, nicks); |
207 |
– |
t = nicks; |
208 |
– |
} |
209 |
– |
|
210 |
– |
t += ircsprintf(t, "%s!%s@%s ", |
211 |
– |
accept_p->nickptr, |
212 |
– |
accept_p->userptr, accept_p->hostptr); |
213 |
– |
} |
214 |
– |
|
215 |
– |
if (nicks[0] != '\0') |
216 |
– |
{ |
217 |
– |
*(t - 1) = '\0'; |
218 |
– |
sendto_one(source_p, form_str(RPL_ACCEPTLIST), |
219 |
– |
me.name, source_p->name, nicks); |
220 |
– |
} |
221 |
– |
|
222 |
– |
sendto_one(source_p, form_str(RPL_ENDOFACCEPT), |
223 |
– |
me.name, source_p->name); |
224 |
– |
} |