Blame


1 c23199d9 2002-02-27 alex /*
2 c23199d9 2002-02-27 alex * ngIRCd -- The Next Generation IRC Daemon
3 8579b2a1 2005-02-27 alex * Copyright (c)2001-2005 Alexander Barton (alex@barton.de)
4 c23199d9 2002-02-27 alex *
5 490f28ff 2002-12-12 alex * This program is free software; you can redistribute it and/or modify
6 490f28ff 2002-12-12 alex * it under the terms of the GNU General Public License as published by
7 490f28ff 2002-12-12 alex * the Free Software Foundation; either version 2 of the License, or
8 490f28ff 2002-12-12 alex * (at your option) any later version.
9 490f28ff 2002-12-12 alex * Please read the file COPYING, README and AUTHORS for more information.
10 c23199d9 2002-02-27 alex *
11 490f28ff 2002-12-12 alex * IRC commands for mode changes (MODE, AWAY, ...)
12 c23199d9 2002-02-27 alex */
13 c23199d9 2002-02-27 alex
14 c23199d9 2002-02-27 alex
15 ca33cbda 2002-03-12 alex #include "portab.h"
16 490f28ff 2002-12-12 alex
17 ca33cbda 2002-03-12 alex #include "imp.h"
18 c23199d9 2002-02-27 alex #include <assert.h>
19 69ad0e38 2002-12-16 alex #include <stdio.h>
20 69ad0e38 2002-12-16 alex #include <stdlib.h>
21 c23199d9 2002-02-27 alex #include <string.h>
22 c23199d9 2002-02-27 alex
23 aa25cd7d 2005-04-27 alex #include "defines.h"
24 c2f60abe 2002-05-27 alex #include "conn.h"
25 c2f60abe 2002-05-27 alex #include "client.h"
26 c23199d9 2002-02-27 alex #include "channel.h"
27 c23199d9 2002-02-27 alex #include "irc-write.h"
28 19ac723e 2002-09-08 alex #include "lists.h"
29 c23199d9 2002-02-27 alex #include "log.h"
30 c2f60abe 2002-05-27 alex #include "parse.h"
31 c23199d9 2002-02-27 alex #include "messages.h"
32 7e1b3b91 2002-09-02 alex #include "resolve.h"
33 7e1b3b91 2002-09-02 alex #include "conf.h"
34 c23199d9 2002-02-27 alex
35 ca33cbda 2002-03-12 alex #include "exp.h"
36 c23199d9 2002-02-27 alex #include "irc-mode.h"
37 c23199d9 2002-02-27 alex
38 c23199d9 2002-02-27 alex
39 77f54693 2005-07-31 alex static bool Client_Mode PARAMS(( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CLIENT *Target ));
40 77f54693 2005-07-31 alex static bool Channel_Mode PARAMS(( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel ));
41 80c6dc86 2002-12-15 alex
42 6b0c0948 2008-04-19 fw static bool Add_Ban_Invite PARAMS((int what, CLIENT *Prefix, CLIENT *Client, CHANNEL *Channel, const char *Pattern));
43 6b0c0948 2008-04-19 fw static bool Del_Ban_Invite PARAMS((int what, CLIENT *Prefix, CLIENT *Client, CHANNEL *Channel, const char *Pattern));
44 19ac723e 2002-09-08 alex
45 2dd51a98 2008-04-19 fw static bool Send_ListChange PARAMS(( char *Mode, CLIENT *Prefix, CLIENT *Client, CHANNEL *Channel, const char *Mask ));
46 19ac723e 2002-09-08 alex
47 296ddebe 2002-09-08 alex
48 8adff592 2005-03-19 fw GLOBAL bool
49 c2f60abe 2002-05-27 alex IRC_MODE( CLIENT *Client, REQUEST *Req )
50 c23199d9 2002-02-27 alex {
51 80c6dc86 2002-12-15 alex CLIENT *cl, *origin;
52 c23199d9 2002-02-27 alex CHANNEL *chan;
53 80c6dc86 2002-12-15 alex
54 c23199d9 2002-02-27 alex assert( Client != NULL );
55 c23199d9 2002-02-27 alex assert( Req != NULL );
56 c23199d9 2002-02-27 alex
57 80c6dc86 2002-12-15 alex /* No parameters? */
58 c23199d9 2002-02-27 alex if( Req->argc < 1 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
59 c23199d9 2002-02-27 alex
60 80c6dc86 2002-12-15 alex /* Origin for answers */
61 80c6dc86 2002-12-15 alex if( Client_Type( Client ) == CLIENT_SERVER )
62 80c6dc86 2002-12-15 alex {
63 80c6dc86 2002-12-15 alex origin = Client_Search( Req->prefix );
64 80c6dc86 2002-12-15 alex if( ! origin ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix );
65 80c6dc86 2002-12-15 alex }
66 80c6dc86 2002-12-15 alex else origin = Client;
67 0eccdbc1 2006-08-12 fw
68 80c6dc86 2002-12-15 alex /* Channel or user mode? */
69 dd3a3bc6 2006-05-10 alex cl = NULL; chan = NULL;
70 dd3a3bc6 2006-05-10 alex if (Client_IsValidNick(Req->argv[0]))
71 dd3a3bc6 2006-05-10 alex cl = Client_Search(Req->argv[0]);
72 dd3a3bc6 2006-05-10 alex if (Channel_IsValidName(Req->argv[0]))
73 dd3a3bc6 2006-05-10 alex chan = Channel_Search(Req->argv[0]);
74 c23199d9 2002-02-27 alex
75 dd3a3bc6 2006-05-10 alex if (cl)
76 dd3a3bc6 2006-05-10 alex return Client_Mode(Client, Req, origin, cl);
77 dd3a3bc6 2006-05-10 alex if (chan)
78 dd3a3bc6 2006-05-10 alex return Channel_Mode(Client, Req, origin, chan);
79 c23199d9 2002-02-27 alex
80 80c6dc86 2002-12-15 alex /* No target found! */
81 dd3a3bc6 2006-05-10 alex return IRC_WriteStrClient(Client, ERR_NOSUCHNICK_MSG,
82 dd3a3bc6 2006-05-10 alex Client_ID(Client), Req->argv[0]);
83 80c6dc86 2002-12-15 alex } /* IRC_MODE */
84 c23199d9 2002-02-27 alex
85 19ac723e 2002-09-08 alex
86 77f54693 2005-07-31 alex static bool
87 80c6dc86 2002-12-15 alex Client_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CLIENT *Target )
88 80c6dc86 2002-12-15 alex {
89 80c6dc86 2002-12-15 alex /* Handle client mode requests */
90 80c6dc86 2002-12-15 alex
91 8adff592 2005-03-19 fw char the_modes[COMMAND_LEN], x[2], *mode_ptr;
92 8adff592 2005-03-19 fw bool ok, set;
93 8adff592 2005-03-19 fw int mode_arg;
94 e6180411 2005-03-05 alex size_t len;
95 80c6dc86 2002-12-15 alex
96 80c6dc86 2002-12-15 alex /* Is the client allowed to request or change the modes? */
97 80c6dc86 2002-12-15 alex if( Client_Type( Client ) == CLIENT_USER )
98 19ac723e 2002-09-08 alex {
99 80c6dc86 2002-12-15 alex /* Users are only allowed to manipulate their own modes! */
100 80c6dc86 2002-12-15 alex if( Target != Client ) return IRC_WriteStrClient( Client, ERR_USERSDONTMATCH_MSG, Client_ID( Client ));
101 19ac723e 2002-09-08 alex }
102 19ac723e 2002-09-08 alex
103 80c6dc86 2002-12-15 alex /* Mode request: let's answer it :-) */
104 80c6dc86 2002-12-15 alex if( Req->argc == 1 ) return IRC_WriteStrClient( Origin, RPL_UMODEIS_MSG, Client_ID( Origin ), Client_Modes( Target ));
105 80c6dc86 2002-12-15 alex
106 80c6dc86 2002-12-15 alex mode_arg = 1;
107 80c6dc86 2002-12-15 alex mode_ptr = Req->argv[mode_arg];
108 80c6dc86 2002-12-15 alex
109 80c6dc86 2002-12-15 alex /* Initial state: set or unset modes? */
110 8adff592 2005-03-19 fw if( *mode_ptr == '+' ) set = true;
111 8adff592 2005-03-19 fw else if( *mode_ptr == '-' ) set = false;
112 80c6dc86 2002-12-15 alex else return IRC_WriteStrClient( Origin, ERR_UMODEUNKNOWNFLAG_MSG, Client_ID( Origin ));
113 80c6dc86 2002-12-15 alex
114 80c6dc86 2002-12-15 alex /* Prepare reply string */
115 80c6dc86 2002-12-15 alex if( set ) strcpy( the_modes, "+" );
116 80c6dc86 2002-12-15 alex else strcpy( the_modes, "-" );
117 80c6dc86 2002-12-15 alex
118 80c6dc86 2002-12-15 alex x[1] = '\0';
119 80c6dc86 2002-12-15 alex ok = CONNECTED;
120 80c6dc86 2002-12-15 alex while( mode_ptr )
121 80c6dc86 2002-12-15 alex {
122 80c6dc86 2002-12-15 alex mode_ptr++;
123 80c6dc86 2002-12-15 alex if( ! *mode_ptr )
124 19ac723e 2002-09-08 alex {
125 80c6dc86 2002-12-15 alex /* Try next argument if there's any */
126 80c6dc86 2002-12-15 alex mode_arg++;
127 80c6dc86 2002-12-15 alex if( mode_arg < Req->argc ) mode_ptr = Req->argv[mode_arg];
128 80c6dc86 2002-12-15 alex else break;
129 19ac723e 2002-09-08 alex }
130 80c6dc86 2002-12-15 alex
131 80c6dc86 2002-12-15 alex switch( *mode_ptr )
132 19ac723e 2002-09-08 alex {
133 80c6dc86 2002-12-15 alex case '+':
134 80c6dc86 2002-12-15 alex case '-':
135 80c6dc86 2002-12-15 alex if((( *mode_ptr == '+' ) && ( ! set )) || (( *mode_ptr == '-' ) && ( set )))
136 c2aefbb3 2002-09-08 alex {
137 80c6dc86 2002-12-15 alex /* Action modifier ("+"/"-") must be changed ... */
138 e6180411 2005-03-05 alex len = strlen( the_modes ) - 1;
139 e6180411 2005-03-05 alex if(( the_modes[len] == '+' ) || ( the_modes[len] == '-' ))
140 80c6dc86 2002-12-15 alex {
141 80c6dc86 2002-12-15 alex /* Adjust last action modifier in result */
142 e6180411 2005-03-05 alex the_modes[len] = *mode_ptr;
143 80c6dc86 2002-12-15 alex }
144 80c6dc86 2002-12-15 alex else
145 80c6dc86 2002-12-15 alex {
146 80c6dc86 2002-12-15 alex /* Append modifier character to result string */
147 6626395c 2002-12-26 alex x[0] = *mode_ptr;
148 6626395c 2002-12-26 alex strlcat( the_modes, x, sizeof( the_modes ));
149 80c6dc86 2002-12-15 alex }
150 8adff592 2005-03-19 fw if( *mode_ptr == '+' ) set = true;
151 8adff592 2005-03-19 fw else set = false;
152 c2aefbb3 2002-09-08 alex }
153 80c6dc86 2002-12-15 alex continue;
154 80c6dc86 2002-12-15 alex }
155 80c6dc86 2002-12-15 alex
156 7f61f413 2002-12-16 alex /* Validate modes */
157 80c6dc86 2002-12-15 alex x[0] = '\0';
158 7f61f413 2002-12-16 alex switch( *mode_ptr )
159 80c6dc86 2002-12-15 alex {
160 8579b2a1 2005-02-27 alex case 'i': /* Invisible */
161 8579b2a1 2005-02-27 alex case 's': /* Server messages */
162 4b9e52eb 2007-08-02 fw case 'w': /* Wallops messages */
163 8579b2a1 2005-02-27 alex x[0] = *mode_ptr;
164 8579b2a1 2005-02-27 alex break;
165 8579b2a1 2005-02-27 alex
166 8579b2a1 2005-02-27 alex case 'a': /* Away */
167 8c1df9ef 2003-01-02 alex if( Client_Type( Client ) == CLIENT_SERVER )
168 8c1df9ef 2003-01-02 alex {
169 8c1df9ef 2003-01-02 alex x[0] = 'a';
170 dd9b4bc9 2005-05-14 alex Client_SetAway( Origin, DEFAULT_AWAY_MSG );
171 8c1df9ef 2003-01-02 alex }
172 8841d873 2002-12-18 alex else ok = IRC_WriteStrClient( Origin, ERR_NOPRIVILEGES_MSG, Client_ID( Origin ));
173 8841d873 2002-12-18 alex break;
174 8579b2a1 2005-02-27 alex
175 8579b2a1 2005-02-27 alex case 'o': /* IRC operator (only unsettable!) */
176 8841d873 2002-12-18 alex if(( ! set ) || ( Client_Type( Client ) == CLIENT_SERVER ))
177 7f61f413 2002-12-16 alex {
178 8adff592 2005-03-19 fw Client_SetOperByMe( Target, false );
179 7f61f413 2002-12-16 alex x[0] = 'o';
180 7f61f413 2002-12-16 alex }
181 7f61f413 2002-12-16 alex else ok = IRC_WriteStrClient( Origin, ERR_NOPRIVILEGES_MSG, Client_ID( Origin ));
182 7f61f413 2002-12-16 alex break;
183 8579b2a1 2005-02-27 alex
184 8579b2a1 2005-02-27 alex case 'r': /* Restricted (only settable) */
185 8841d873 2002-12-18 alex if(( set ) || ( Client_Type( Client ) == CLIENT_SERVER )) x[0] = 'r';
186 7f61f413 2002-12-16 alex else ok = IRC_WriteStrClient( Origin, ERR_RESTRICTED_MSG, Client_ID( Origin ));
187 7f61f413 2002-12-16 alex break;
188 8579b2a1 2005-02-27 alex
189 7f61f413 2002-12-16 alex default:
190 7f61f413 2002-12-16 alex Log( LOG_DEBUG, "Unknown mode \"%c%c\" from \"%s\"!?", set ? '+' : '-', *mode_ptr, Client_ID( Origin ));
191 7f61f413 2002-12-16 alex if( Client_Type( Client ) != CLIENT_SERVER ) ok = IRC_WriteStrClient( Origin, ERR_UMODEUNKNOWNFLAG2_MSG, Client_ID( Origin ), set ? '+' : '-', *mode_ptr );
192 7f61f413 2002-12-16 alex x[0] = '\0';
193 69ad0e38 2002-12-16 alex goto client_exit;
194 19ac723e 2002-09-08 alex }
195 80c6dc86 2002-12-15 alex if( ! ok ) break;
196 80c6dc86 2002-12-15 alex
197 80c6dc86 2002-12-15 alex /* Is there a valid mode change? */
198 80c6dc86 2002-12-15 alex if( ! x[0] ) continue;
199 80c6dc86 2002-12-15 alex
200 80c6dc86 2002-12-15 alex if( set )
201 80c6dc86 2002-12-15 alex {
202 80c6dc86 2002-12-15 alex /* Set mode */
203 6626395c 2002-12-26 alex if( Client_ModeAdd( Target, x[0] )) strlcat( the_modes, x, sizeof( the_modes ));
204 80c6dc86 2002-12-15 alex
205 80c6dc86 2002-12-15 alex }
206 80c6dc86 2002-12-15 alex else
207 80c6dc86 2002-12-15 alex {
208 80c6dc86 2002-12-15 alex /* Unset mode */
209 6626395c 2002-12-26 alex if( Client_ModeDel( Target, x[0] )) strlcat( the_modes, x, sizeof( the_modes ));
210 80c6dc86 2002-12-15 alex }
211 19ac723e 2002-09-08 alex }
212 69ad0e38 2002-12-16 alex client_exit:
213 69ad0e38 2002-12-16 alex
214 80c6dc86 2002-12-15 alex /* Are there changed modes? */
215 80c6dc86 2002-12-15 alex if( the_modes[1] )
216 c23199d9 2002-02-27 alex {
217 80c6dc86 2002-12-15 alex /* Remoce needless action modifier characters */
218 e6180411 2005-03-05 alex len = strlen( the_modes ) - 1;
219 e6180411 2005-03-05 alex if(( the_modes[len] == '+' ) || ( the_modes[len] == '-' )) the_modes[len] = '\0';
220 80c6dc86 2002-12-15 alex
221 80c6dc86 2002-12-15 alex if( Client_Type( Client ) == CLIENT_SERVER )
222 c23199d9 2002-02-27 alex {
223 80c6dc86 2002-12-15 alex /* Forward modes to other servers */
224 80c6dc86 2002-12-15 alex IRC_WriteStrServersPrefix( Client, Origin, "MODE %s :%s", Client_ID( Target ), the_modes );
225 c23199d9 2002-02-27 alex }
226 80c6dc86 2002-12-15 alex else
227 c23199d9 2002-02-27 alex {
228 80c6dc86 2002-12-15 alex /* Send reply to client and inform other servers */
229 56227abc 2004-02-29 alex ok = IRC_WriteStrClientPrefix( Client, Origin, "MODE %s :%s", Client_ID( Target ), the_modes );
230 80c6dc86 2002-12-15 alex IRC_WriteStrServersPrefix( Client, Origin, "MODE %s :%s", Client_ID( Target ), the_modes );
231 c23199d9 2002-02-27 alex }
232 d93030ad 2008-09-23 alex LogDebug("%s \"%s\": Mode change, now \"%s\".",
233 d93030ad 2008-09-23 alex Client_TypeText(Target), Client_Mask(Target),
234 d93030ad 2008-09-23 alex Client_Modes(Target));
235 c23199d9 2002-02-27 alex }
236 7b6e2662 2003-11-05 alex
237 7b6e2662 2003-11-05 alex IRC_SetPenalty( Client, 1 );
238 80c6dc86 2002-12-15 alex return ok;
239 80c6dc86 2002-12-15 alex } /* Client_Mode */
240 e710e8ae 2008-02-26 fw
241 e710e8ae 2008-02-26 fw
242 e710e8ae 2008-02-26 fw static bool
243 e710e8ae 2008-02-26 fw Channel_Mode_Answer_Request(CLIENT *Origin, CHANNEL *Channel)
244 e710e8ae 2008-02-26 fw {
245 e710e8ae 2008-02-26 fw char the_modes[COMMAND_LEN], the_args[COMMAND_LEN], argadd[CLIENT_PASS_LEN];
246 e710e8ae 2008-02-26 fw const char *mode_ptr;
247 e710e8ae 2008-02-26 fw
248 e710e8ae 2008-02-26 fw /* Member or not? -- That's the question! */
249 e710e8ae 2008-02-26 fw if (!Channel_IsMemberOf(Channel, Origin))
250 e710e8ae 2008-02-26 fw return IRC_WriteStrClient(Origin, RPL_CHANNELMODEIS_MSG,
251 e710e8ae 2008-02-26 fw Client_ID(Origin), Channel_Name(Channel), Channel_Modes(Channel));
252 e710e8ae 2008-02-26 fw
253 e710e8ae 2008-02-26 fw /* The sender is a member: generate extended reply */
254 e710e8ae 2008-02-26 fw strlcpy(the_modes, Channel_Modes(Channel), sizeof(the_modes));
255 e710e8ae 2008-02-26 fw mode_ptr = the_modes;
256 e710e8ae 2008-02-26 fw the_args[0] = '\0';
257 e710e8ae 2008-02-26 fw
258 e710e8ae 2008-02-26 fw while(*mode_ptr) {
259 e710e8ae 2008-02-26 fw switch(*mode_ptr) {
260 e710e8ae 2008-02-26 fw case 'l':
261 e710e8ae 2008-02-26 fw snprintf(argadd, sizeof(argadd), " %lu", Channel_MaxUsers(Channel));
262 e710e8ae 2008-02-26 fw strlcat(the_args, argadd, sizeof(the_args));
263 e710e8ae 2008-02-26 fw break;
264 e710e8ae 2008-02-26 fw case 'k':
265 e710e8ae 2008-02-26 fw strlcat(the_args, " ", sizeof(the_args));
266 e710e8ae 2008-02-26 fw strlcat(the_args, Channel_Key(Channel), sizeof(the_args));
267 e710e8ae 2008-02-26 fw break;
268 e710e8ae 2008-02-26 fw }
269 e710e8ae 2008-02-26 fw mode_ptr++;
270 e710e8ae 2008-02-26 fw }
271 e710e8ae 2008-02-26 fw if (the_args[0])
272 e710e8ae 2008-02-26 fw strlcat(the_modes, the_args, sizeof(the_modes));
273 c23199d9 2002-02-27 alex
274 e710e8ae 2008-02-26 fw return IRC_WriteStrClient(Origin, RPL_CHANNELMODEIS_MSG,
275 e710e8ae 2008-02-26 fw Client_ID(Origin), Channel_Name(Channel), the_modes);
276 e710e8ae 2008-02-26 fw }
277 c23199d9 2002-02-27 alex
278 e710e8ae 2008-02-26 fw
279 77f54693 2005-07-31 alex static bool
280 80c6dc86 2002-12-15 alex Channel_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel )
281 80c6dc86 2002-12-15 alex {
282 80c6dc86 2002-12-15 alex /* Handle channel and channel-user modes */
283 c23199d9 2002-02-27 alex
284 8adff592 2005-03-19 fw char the_modes[COMMAND_LEN], the_args[COMMAND_LEN], x[2], argadd[CLIENT_PASS_LEN], *mode_ptr;
285 8df44531 2008-04-19 fw bool ok, set, modeok = true, skiponce, use_servermode = false, retval;
286 8adff592 2005-03-19 fw int mode_arg, arg_arg;
287 80c6dc86 2002-12-15 alex CLIENT *client;
288 8adff592 2005-03-19 fw long l;
289 e6180411 2005-03-05 alex size_t len;
290 80c6dc86 2002-12-15 alex
291 530112b1 2008-05-01 alex /* Are modes allowed on channel? */
292 530112b1 2008-05-01 alex if (Channel_Name(Channel)[0] == '+')
293 530112b1 2008-05-01 alex return IRC_WriteStrClient(Client, ERR_NOCHANMODES_MSG,
294 530112b1 2008-05-01 alex Client_ID(Client), Channel_Name(Channel));
295 f7c2e822 2008-05-01 alex
296 80c6dc86 2002-12-15 alex /* Mode request: let's answer it :-) */
297 e710e8ae 2008-02-26 fw if (Req->argc <= 1)
298 e710e8ae 2008-02-26 fw return Channel_Mode_Answer_Request(Origin, Channel);
299 df00b38a 2003-01-08 alex
300 80c6dc86 2002-12-15 alex /* Is the user allowed to change modes? */
301 e710e8ae 2008-02-26 fw if (Client_Type(Client) == CLIENT_USER) {
302 e07542a1 2003-01-17 alex /* Is the originating user on that channel? */
303 e710e8ae 2008-02-26 fw if (!Channel_IsMemberOf(Channel, Origin))
304 e710e8ae 2008-02-26 fw return IRC_WriteStrClient(Origin, ERR_NOTONCHANNEL_MSG,
305 e710e8ae 2008-02-26 fw Client_ID(Origin), Channel_Name(Channel));
306 e710e8ae 2008-02-26 fw modeok = false;
307 e710e8ae 2008-02-26 fw /* channel operator? */
308 e710e8ae 2008-02-26 fw if (strchr(Channel_UserModes(Channel, Origin), 'o'))
309 e710e8ae 2008-02-26 fw modeok = true;
310 e710e8ae 2008-02-26 fw else if(Conf_OperCanMode) {
311 1d08d51e 2005-03-15 alex /* IRC-Operators can use MODE as well */
312 e710e8ae 2008-02-26 fw if (Client_OperByMe(Origin)) {
313 8adff592 2005-03-19 fw modeok = true;
314 e710e8ae 2008-02-26 fw if (Conf_OperServerMode)
315 e710e8ae 2008-02-26 fw use_servermode = true; /* Change Origin to Server */
316 1d08d51e 2005-03-15 alex }
317 80c6dc86 2002-12-15 alex }
318 c23199d9 2002-02-27 alex }
319 c23199d9 2002-02-27 alex
320 80c6dc86 2002-12-15 alex mode_arg = 1;
321 80c6dc86 2002-12-15 alex mode_ptr = Req->argv[mode_arg];
322 e710e8ae 2008-02-26 fw if (Req->argc > mode_arg + 1)
323 e710e8ae 2008-02-26 fw arg_arg = mode_arg + 1;
324 e710e8ae 2008-02-26 fw else
325 e710e8ae 2008-02-26 fw arg_arg = -1;
326 80c6dc86 2002-12-15 alex
327 80c6dc86 2002-12-15 alex /* Initial state: set or unset modes? */
328 8adff592 2005-03-19 fw skiponce = false;
329 e710e8ae 2008-02-26 fw switch (*mode_ptr) {
330 e710e8ae 2008-02-26 fw case '-': set = false; break;
331 e710e8ae 2008-02-26 fw case '+': set = true; break;
332 e710e8ae 2008-02-26 fw default:
333 e710e8ae 2008-02-26 fw set = true;
334 e710e8ae 2008-02-26 fw skiponce = true;
335 e710e8ae 2008-02-26 fw }
336 80c6dc86 2002-12-15 alex
337 80c6dc86 2002-12-15 alex /* Prepare reply string */
338 e710e8ae 2008-02-26 fw strcpy(the_modes, set ? "+" : "-");
339 1784180b 2008-02-26 fw the_args[0] = '\0';
340 c23199d9 2002-02-27 alex
341 c23199d9 2002-02-27 alex x[1] = '\0';
342 80c6dc86 2002-12-15 alex ok = CONNECTED;
343 e710e8ae 2008-02-26 fw while (mode_ptr) {
344 e710e8ae 2008-02-26 fw if (! skiponce)
345 e710e8ae 2008-02-26 fw mode_ptr++;
346 e710e8ae 2008-02-26 fw if (!*mode_ptr) {
347 80c6dc86 2002-12-15 alex /* Try next argument if there's any */
348 e710e8ae 2008-02-26 fw if (arg_arg > mode_arg)
349 e710e8ae 2008-02-26 fw mode_arg = arg_arg;
350 e710e8ae 2008-02-26 fw else
351 e710e8ae 2008-02-26 fw mode_arg++;
352 e710e8ae 2008-02-26 fw
353 e710e8ae 2008-02-26 fw if (mode_arg >= Req->argc)
354 e710e8ae 2008-02-26 fw break;
355 e710e8ae 2008-02-26 fw mode_ptr = Req->argv[mode_arg];
356 e710e8ae 2008-02-26 fw
357 e710e8ae 2008-02-26 fw if (Req->argc > mode_arg + 1)
358 e710e8ae 2008-02-26 fw arg_arg = mode_arg + 1;
359 e710e8ae 2008-02-26 fw else
360 e710e8ae 2008-02-26 fw arg_arg = -1;
361 80c6dc86 2002-12-15 alex }
362 8adff592 2005-03-19 fw skiponce = false;
363 80c6dc86 2002-12-15 alex
364 e710e8ae 2008-02-26 fw switch (*mode_ptr) {
365 e710e8ae 2008-02-26 fw case '+':
366 e710e8ae 2008-02-26 fw case '-':
367 e710e8ae 2008-02-26 fw if (((*mode_ptr == '+') && !set) || ((*mode_ptr == '-') && set)) {
368 e710e8ae 2008-02-26 fw /* Action modifier ("+"/"-") must be changed ... */
369 e710e8ae 2008-02-26 fw len = strlen( the_modes ) - 1;
370 e710e8ae 2008-02-26 fw if ((the_modes[len] == '+') || (the_modes[len] == '-')) {
371 e710e8ae 2008-02-26 fw /* Adjust last action modifier in result */
372 e710e8ae 2008-02-26 fw the_modes[len] = *mode_ptr;
373 e710e8ae 2008-02-26 fw } else {
374 e710e8ae 2008-02-26 fw /* Append modifier character to result string */
375 e710e8ae 2008-02-26 fw x[0] = *mode_ptr;
376 e710e8ae 2008-02-26 fw strlcat(the_modes, x, sizeof(the_modes));
377 80c6dc86 2002-12-15 alex }
378 e710e8ae 2008-02-26 fw set = *mode_ptr == '+';
379 e710e8ae 2008-02-26 fw }
380 e710e8ae 2008-02-26 fw continue;
381 80c6dc86 2002-12-15 alex }
382 80c6dc86 2002-12-15 alex
383 80c6dc86 2002-12-15 alex /* Are there arguments left? */
384 80c6dc86 2002-12-15 alex if( arg_arg >= Req->argc ) arg_arg = -1;
385 80c6dc86 2002-12-15 alex
386 7f61f413 2002-12-16 alex /* Validate modes */
387 c23199d9 2002-02-27 alex x[0] = '\0';
388 69ad0e38 2002-12-16 alex argadd[0] = '\0';
389 80c6dc86 2002-12-15 alex client = NULL;
390 55381155 2008-04-19 fw switch (*mode_ptr) {
391 55381155 2008-04-19 fw /* --- Channel modes --- */
392 55381155 2008-04-19 fw case 'i': /* Invite only */
393 55381155 2008-04-19 fw case 'm': /* Moderated */
394 55381155 2008-04-19 fw case 'n': /* Only members can write */
395 55381155 2008-04-19 fw case 's': /* Secret channel */
396 55381155 2008-04-19 fw case 't': /* Topic locked */
397 55381155 2008-04-19 fw if (modeok)
398 55381155 2008-04-19 fw x[0] = *mode_ptr;
399 55381155 2008-04-19 fw else
400 55381155 2008-04-19 fw ok = IRC_WriteStrClient(Origin, ERR_CHANOPRIVSNEEDED_MSG, Client_ID(Origin), Channel_Name(Channel));
401 55381155 2008-04-19 fw break;
402 55381155 2008-04-19 fw case 'k': /* Channel key */
403 55381155 2008-04-19 fw if (! set) {
404 55381155 2008-04-19 fw if (modeok)
405 55381155 2008-04-19 fw x[0] = *mode_ptr;
406 55381155 2008-04-19 fw else
407 55381155 2008-04-19 fw ok = IRC_WriteStrClient(Origin, ERR_CHANOPRIVSNEEDED_MSG, Client_ID(Origin), Channel_Name(Channel));
408 7f61f413 2002-12-16 alex break;
409 55381155 2008-04-19 fw }
410 55381155 2008-04-19 fw if (arg_arg > mode_arg) {
411 55381155 2008-04-19 fw if (modeok) {
412 55381155 2008-04-19 fw Channel_ModeDel(Channel, 'k');
413 55381155 2008-04-19 fw Channel_SetKey(Channel, Req->argv[arg_arg]);
414 55381155 2008-04-19 fw strlcpy(argadd, Channel_Key(Channel), sizeof(argadd));
415 55381155 2008-04-19 fw x[0] = *mode_ptr;
416 55381155 2008-04-19 fw } else {
417 55381155 2008-04-19 fw ok = IRC_WriteStrClient(Origin, ERR_CHANOPRIVSNEEDED_MSG, Client_ID(Origin), Channel_Name(Channel));
418 69ad0e38 2002-12-16 alex }
419 55381155 2008-04-19 fw Req->argv[arg_arg][0] = '\0';
420 55381155 2008-04-19 fw arg_arg++;
421 55381155 2008-04-19 fw } else {
422 55381155 2008-04-19 fw ok = IRC_WriteStrClient(Origin, ERR_NEEDMOREPARAMS_MSG, Client_ID(Origin), Req->command);
423 55381155 2008-04-19 fw }
424 55381155 2008-04-19 fw break;
425 55381155 2008-04-19 fw case 'l': /* Member limit */
426 55381155 2008-04-19 fw if (!set) {
427 55381155 2008-04-19 fw if (modeok)
428 55381155 2008-04-19 fw x[0] = *mode_ptr;
429 55381155 2008-04-19 fw else
430 55381155 2008-04-19 fw ok = IRC_WriteStrClient(Origin, ERR_CHANOPRIVSNEEDED_MSG, Client_ID(Origin), Channel_Name(Channel));
431 55381155 2008-04-19 fw break;
432 55381155 2008-04-19 fw }
433 55381155 2008-04-19 fw if (arg_arg > mode_arg) {
434 55381155 2008-04-19 fw if (modeok) {
435 55381155 2008-04-19 fw l = atol(Req->argv[arg_arg]);
436 55381155 2008-04-19 fw if (l > 0 && l < 0xFFFF) {
437 55381155 2008-04-19 fw Channel_ModeDel(Channel, 'l');
438 55381155 2008-04-19 fw Channel_SetMaxUsers(Channel, l);
439 55381155 2008-04-19 fw snprintf(argadd, sizeof(argadd), "%ld", l);
440 69ad0e38 2002-12-16 alex x[0] = *mode_ptr;
441 69ad0e38 2002-12-16 alex }
442 55381155 2008-04-19 fw } else {
443 55381155 2008-04-19 fw ok = IRC_WriteStrClient(Origin, ERR_CHANOPRIVSNEEDED_MSG, Client_ID(Origin), Channel_Name(Channel));
444 69ad0e38 2002-12-16 alex }
445 55381155 2008-04-19 fw Req->argv[arg_arg][0] = '\0';
446 55381155 2008-04-19 fw arg_arg++;
447 55381155 2008-04-19 fw } else {
448 55381155 2008-04-19 fw ok = IRC_WriteStrClient(Origin, ERR_NEEDMOREPARAMS_MSG, Client_ID(Origin), Req->command);
449 55381155 2008-04-19 fw }
450 55381155 2008-04-19 fw break;
451 55381155 2008-04-19 fw case 'P': /* Persistent channel */
452 55381155 2008-04-19 fw if (modeok) {
453 55381155 2008-04-19 fw /* Only IRC operators are allowed to
454 55381155 2008-04-19 fw * set the 'P' channel mode! */
455 55381155 2008-04-19 fw if (set && !(Client_OperByMe(Client) || Client_Type(Client) == CLIENT_SERVER))
456 55381155 2008-04-19 fw ok = IRC_WriteStrClient(Origin, ERR_NOPRIVILEGES_MSG, Client_ID(Origin));
457 55381155 2008-04-19 fw else
458 55381155 2008-04-19 fw x[0] = 'P';
459 55381155 2008-04-19 fw } else
460 55381155 2008-04-19 fw ok = IRC_WriteStrClient(Origin, ERR_CHANOPRIVSNEEDED_MSG, Client_ID(Origin), Channel_Name(Channel));
461 55381155 2008-04-19 fw break;
462 55381155 2008-04-19 fw /* --- Channel user modes --- */
463 55381155 2008-04-19 fw case 'o': /* Channel operator */
464 55381155 2008-04-19 fw case 'v': /* Voice */
465 55381155 2008-04-19 fw if (arg_arg > mode_arg) {
466 55381155 2008-04-19 fw if (modeok) {
467 55381155 2008-04-19 fw client = Client_Search(Req->argv[arg_arg]);
468 55381155 2008-04-19 fw if (client)
469 55381155 2008-04-19 fw x[0] = *mode_ptr;
470 55381155 2008-04-19 fw else
471 55381155 2008-04-19 fw ok = IRC_WriteStrClient(Client, ERR_NOSUCHNICK_MSG, Client_ID(Client), Req->argv[arg_arg]);
472 55381155 2008-04-19 fw } else {
473 55381155 2008-04-19 fw ok = IRC_WriteStrClient(Origin, ERR_CHANOPRIVSNEEDED_MSG, Client_ID(Origin), Channel_Name(Channel));
474 55381155 2008-04-19 fw }
475 55381155 2008-04-19 fw Req->argv[arg_arg][0] = '\0';
476 55381155 2008-04-19 fw arg_arg++;
477 55381155 2008-04-19 fw } else {
478 55381155 2008-04-19 fw ok = IRC_WriteStrClient(Origin, ERR_NEEDMOREPARAMS_MSG, Client_ID(Origin), Req->command);
479 55381155 2008-04-19 fw }
480 55381155 2008-04-19 fw break;
481 55381155 2008-04-19 fw /* --- Channel lists --- */
482 55381155 2008-04-19 fw case 'I': /* Invite lists */
483 55381155 2008-04-19 fw case 'b': /* Ban lists */
484 55381155 2008-04-19 fw if (arg_arg > mode_arg) {
485 55381155 2008-04-19 fw /* modify list */
486 55381155 2008-04-19 fw if (modeok) {
487 55381155 2008-04-19 fw ok = set ? Add_Ban_Invite(*mode_ptr, Origin, Client, Channel, Req->argv[arg_arg])
488 55381155 2008-04-19 fw : Del_Ban_Invite(*mode_ptr, Origin, Client, Channel, Req->argv[arg_arg]);
489 55381155 2008-04-19 fw } else {
490 55381155 2008-04-19 fw ok = IRC_WriteStrClient(Origin, ERR_CHANOPRIVSNEEDED_MSG,
491 55381155 2008-04-19 fw Client_ID(Origin), Channel_Name(Channel));
492 55381155 2008-04-19 fw }
493 55381155 2008-04-19 fw Req->argv[arg_arg][0] = '\0';
494 55381155 2008-04-19 fw arg_arg++;
495 55381155 2008-04-19 fw } else {
496 55381155 2008-04-19 fw if (*mode_ptr == 'I')
497 55381155 2008-04-19 fw Channel_ShowInvites(Origin, Channel);
498 55381155 2008-04-19 fw else
499 55381155 2008-04-19 fw Channel_ShowBans(Origin, Channel);
500 55381155 2008-04-19 fw }
501 55381155 2008-04-19 fw break;
502 55381155 2008-04-19 fw default:
503 55381155 2008-04-19 fw Log(LOG_DEBUG, "Unknown mode \"%c%c\" from \"%s\" on %s!?",
504 55381155 2008-04-19 fw set ? '+' : '-', *mode_ptr, Client_ID(Origin), Channel_Name(Channel));
505 55381155 2008-04-19 fw if (Client_Type(Client) != CLIENT_SERVER)
506 55381155 2008-04-19 fw ok = IRC_WriteStrClient(Origin, ERR_UMODEUNKNOWNFLAG2_MSG, Client_ID(Origin), set ? '+' : '-', *mode_ptr);
507 55381155 2008-04-19 fw x[0] = '\0';
508 55381155 2008-04-19 fw goto chan_exit;
509 55381155 2008-04-19 fw } /* switch() */
510 80c6dc86 2002-12-15 alex
511 55381155 2008-04-19 fw if (!ok)
512 55381155 2008-04-19 fw break;
513 55381155 2008-04-19 fw
514 80c6dc86 2002-12-15 alex /* Is there a valid mode change? */
515 55381155 2008-04-19 fw if (!x[0])
516 55381155 2008-04-19 fw continue;
517 c23199d9 2002-02-27 alex
518 fbec1f10 2003-01-21 alex /* Validate target client */
519 55381155 2008-04-19 fw if (client && (!Channel_IsMemberOf(Channel, client))) {
520 55381155 2008-04-19 fw if (!IRC_WriteStrClient(Origin, ERR_USERNOTINCHANNEL_MSG,
521 55381155 2008-04-19 fw Client_ID(Origin), Client_ID(client), Channel_Name(Channel)))
522 55381155 2008-04-19 fw break;
523 55381155 2008-04-19 fw
524 fbec1f10 2003-01-21 alex continue;
525 fbec1f10 2003-01-21 alex }
526 fbec1f10 2003-01-21 alex
527 11af3246 2008-04-19 fw if (client) {
528 11af3246 2008-04-19 fw /* Channel-User-Mode */
529 8df44531 2008-04-19 fw retval = set ? Channel_UserModeAdd(Channel, client, x[0]) : Channel_UserModeDel(Channel, client, x[0]);
530 8df44531 2008-04-19 fw if (retval) {
531 8df44531 2008-04-19 fw strlcat(the_args, " ", sizeof(the_args));
532 8df44531 2008-04-19 fw strlcat(the_args, Client_ID(client), sizeof(the_args));
533 8df44531 2008-04-19 fw strlcat(the_modes, x, sizeof(the_modes));
534 8df44531 2008-04-19 fw Log(LOG_DEBUG, "User \"%s\": Mode change on %s, now \"%s\"",
535 8df44531 2008-04-19 fw Client_Mask(client), Channel_Name(Channel), Channel_UserModes(Channel, client));
536 11af3246 2008-04-19 fw }
537 11af3246 2008-04-19 fw } else {
538 11af3246 2008-04-19 fw /* Channel-Mode */
539 8df44531 2008-04-19 fw retval = set ? Channel_ModeAdd(Channel, x[0]) : Channel_ModeDel(Channel, x[0]);
540 8df44531 2008-04-19 fw if (retval) {
541 8df44531 2008-04-19 fw strlcat(the_modes, x, sizeof(the_modes));
542 8df44531 2008-04-19 fw Log(LOG_DEBUG, "Channel %s: Mode change, now \"%s\".", Channel_Name(Channel), Channel_Modes(Channel));
543 c23199d9 2002-02-27 alex }
544 69ad0e38 2002-12-16 alex }
545 69ad0e38 2002-12-16 alex
546 69ad0e38 2002-12-16 alex /* Are there additional arguments to add? */
547 55381155 2008-04-19 fw if (argadd[0]) {
548 55381155 2008-04-19 fw strlcat(the_args, " ", sizeof(the_args));
549 55381155 2008-04-19 fw strlcat(the_args, argadd, sizeof(the_args));
550 69ad0e38 2002-12-16 alex }
551 c23199d9 2002-02-27 alex }
552 69ad0e38 2002-12-16 alex chan_exit:
553 80c6dc86 2002-12-15 alex /* Are there changed modes? */
554 e710e8ae 2008-02-26 fw if (the_modes[1]) {
555 c0d74a38 2002-12-15 alex /* Clean up mode string */
556 e710e8ae 2008-02-26 fw len = strlen(the_modes) - 1;
557 e710e8ae 2008-02-26 fw if ((the_modes[len] == '+') || (the_modes[len] == '-'))
558 e710e8ae 2008-02-26 fw the_modes[len] = '\0';
559 c0d74a38 2002-12-15 alex
560 e710e8ae 2008-02-26 fw if (Client_Type(Client) == CLIENT_SERVER) {
561 80c6dc86 2002-12-15 alex /* Forward mode changes to channel users and other servers */
562 e710e8ae 2008-02-26 fw IRC_WriteStrServersPrefix(Client, Origin, "MODE %s %s%s", Channel_Name( Channel ), the_modes, the_args);
563 55381155 2008-04-19 fw IRC_WriteStrChannelPrefix(Client, Channel, Origin, false, "MODE %s %s%s", Channel_Name(Channel), the_modes, the_args);
564 e710e8ae 2008-02-26 fw } else {
565 e710e8ae 2008-02-26 fw if (use_servermode)
566 e710e8ae 2008-02-26 fw Origin = Client_ThisServer();
567 80c6dc86 2002-12-15 alex /* Send reply to client and inform other servers and channel users */
568 55381155 2008-04-19 fw ok = IRC_WriteStrClientPrefix(Client, Origin, "MODE %s %s%s",
569 55381155 2008-04-19 fw Channel_Name(Channel), the_modes, the_args);
570 55381155 2008-04-19 fw IRC_WriteStrServersPrefix(Client, Origin, "MODE %s %s%s",
571 55381155 2008-04-19 fw Channel_Name(Channel), the_modes, the_args);
572 55381155 2008-04-19 fw IRC_WriteStrChannelPrefix(Client, Channel, Origin, false, "MODE %s %s%s",
573 55381155 2008-04-19 fw Channel_Name(Channel), the_modes, the_args);
574 c23199d9 2002-02-27 alex }
575 c23199d9 2002-02-27 alex }
576 c23199d9 2002-02-27 alex
577 55381155 2008-04-19 fw IRC_SetPenalty(Client, 1);
578 80c6dc86 2002-12-15 alex return CONNECTED;
579 80c6dc86 2002-12-15 alex } /* Channel_Mode */
580 c23199d9 2002-02-27 alex
581 c23199d9 2002-02-27 alex
582 8adff592 2005-03-19 fw GLOBAL bool
583 c2f60abe 2002-05-27 alex IRC_AWAY( CLIENT *Client, REQUEST *Req )
584 c23199d9 2002-02-27 alex {
585 c23199d9 2002-02-27 alex assert( Client != NULL );
586 c23199d9 2002-02-27 alex assert( Req != NULL );
587 c23199d9 2002-02-27 alex
588 c23199d9 2002-02-27 alex /* Falsche Anzahl Parameter? */
589 c23199d9 2002-02-27 alex if( Req->argc > 1 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
590 c23199d9 2002-02-27 alex
591 c23199d9 2002-02-27 alex if(( Req->argc == 1 ) && (Req->argv[0][0] ))
592 c23199d9 2002-02-27 alex {
593 c23199d9 2002-02-27 alex /* AWAY setzen */
594 c23199d9 2002-02-27 alex Client_SetAway( Client, Req->argv[0] );
595 8c1df9ef 2003-01-02 alex Client_ModeAdd( Client, 'a' );
596 c23199d9 2002-02-27 alex IRC_WriteStrServersPrefix( Client, Client, "MODE %s :+a", Client_ID( Client ));
597 c23199d9 2002-02-27 alex return IRC_WriteStrClient( Client, RPL_NOWAWAY_MSG, Client_ID( Client ));
598 c23199d9 2002-02-27 alex }
599 c23199d9 2002-02-27 alex else
600 c23199d9 2002-02-27 alex {
601 c23199d9 2002-02-27 alex /* AWAY loeschen */
602 8c1df9ef 2003-01-02 alex Client_ModeDel( Client, 'a' );
603 c23199d9 2002-02-27 alex IRC_WriteStrServersPrefix( Client, Client, "MODE %s :-a", Client_ID( Client ));
604 c23199d9 2002-02-27 alex return IRC_WriteStrClient( Client, RPL_UNAWAY_MSG, Client_ID( Client ));
605 c23199d9 2002-02-27 alex }
606 c23199d9 2002-02-27 alex } /* IRC_AWAY */
607 19ac723e 2002-09-08 alex
608 19ac723e 2002-09-08 alex
609 77f54693 2005-07-31 alex static bool
610 6b0c0948 2008-04-19 fw Add_Ban_Invite(int what, CLIENT *Prefix, CLIENT *Client, CHANNEL *Channel, const char *Pattern)
611 19ac723e 2002-09-08 alex {
612 2dd51a98 2008-04-19 fw const char *mask;
613 8adff592 2005-03-19 fw bool already;
614 2dd51a98 2008-04-19 fw bool ret;
615 19ac723e 2002-09-08 alex
616 19ac723e 2002-09-08 alex assert( Client != NULL );
617 19ac723e 2002-09-08 alex assert( Channel != NULL );
618 19ac723e 2002-09-08 alex assert( Pattern != NULL );
619 2dd51a98 2008-04-19 fw assert(what == 'I' || what == 'b');
620 c23199d9 2002-02-27 alex
621 2dd51a98 2008-04-19 fw mask = Lists_MakeMask(Pattern);
622 64d330b7 2004-04-09 alex
623 2dd51a98 2008-04-19 fw already = Lists_CheckDupeMask(Channel_GetListInvites(Channel), mask);
624 2dd51a98 2008-04-19 fw if (!already) {
625 2dd51a98 2008-04-19 fw if (what == 'I')
626 2dd51a98 2008-04-19 fw ret = Channel_AddInvite(Channel, mask, false);
627 2dd51a98 2008-04-19 fw else
628 2dd51a98 2008-04-19 fw ret = Channel_AddBan(Channel, mask);
629 2dd51a98 2008-04-19 fw if (!ret)
630 fa7bb279 2006-12-07 fw return CONNECTED;
631 fa7bb279 2006-12-07 fw }
632 2dd51a98 2008-04-19 fw if (already && (Client_Type(Prefix) == CLIENT_SERVER))
633 fa7bb279 2006-12-07 fw return CONNECTED;
634 96747679 2004-04-25 alex
635 2dd51a98 2008-04-19 fw if (what == 'I')
636 2dd51a98 2008-04-19 fw return Send_ListChange("+I", Prefix, Client, Channel, mask);
637 2dd51a98 2008-04-19 fw return Send_ListChange("+b", Prefix, Client, Channel, mask);
638 2dd51a98 2008-04-19 fw }
639 19ac723e 2002-09-08 alex
640 19ac723e 2002-09-08 alex
641 77f54693 2005-07-31 alex static bool
642 6b0c0948 2008-04-19 fw Del_Ban_Invite(int what, CLIENT *Prefix, CLIENT *Client, CHANNEL *Channel, const char *Pattern)
643 19ac723e 2002-09-08 alex {
644 6b0c0948 2008-04-19 fw const char *mask;
645 6b0c0948 2008-04-19 fw struct list_head *list;
646 19ac723e 2002-09-08 alex
647 19ac723e 2002-09-08 alex assert( Client != NULL );
648 19ac723e 2002-09-08 alex assert( Channel != NULL );
649 19ac723e 2002-09-08 alex assert( Pattern != NULL );
650 6b0c0948 2008-04-19 fw assert(what == 'I' || what == 'b');
651 19ac723e 2002-09-08 alex
652 19ac723e 2002-09-08 alex mask = Lists_MakeMask( Pattern );
653 19ac723e 2002-09-08 alex
654 6b0c0948 2008-04-19 fw if (what == 'I')
655 6b0c0948 2008-04-19 fw list = Channel_GetListInvites(Channel);
656 6b0c0948 2008-04-19 fw else
657 6b0c0948 2008-04-19 fw list = Channel_GetListBans(Channel);
658 19ac723e 2002-09-08 alex
659 6b0c0948 2008-04-19 fw Lists_Del(list, mask);
660 6b0c0948 2008-04-19 fw if (what == 'I')
661 6b0c0948 2008-04-19 fw return Send_ListChange( "-I", Prefix, Client, Channel, mask );
662 296ddebe 2002-09-08 alex return Send_ListChange( "-b", Prefix, Client, Channel, mask );
663 6b0c0948 2008-04-19 fw }
664 19ac723e 2002-09-08 alex
665 296ddebe 2002-09-08 alex
666 77f54693 2005-07-31 alex static bool
667 2dd51a98 2008-04-19 fw Send_ListChange( char *Mode, CLIENT *Prefix, CLIENT *Client, CHANNEL *Channel, const char *Mask )
668 296ddebe 2002-09-08 alex {
669 296ddebe 2002-09-08 alex /* Bestaetigung an Client schicken & andere Server sowie Channel-User informieren */
670 296ddebe 2002-09-08 alex
671 8adff592 2005-03-19 fw bool ok;
672 296ddebe 2002-09-08 alex
673 19ac723e 2002-09-08 alex if( Client_Type( Client ) == CLIENT_USER )
674 19ac723e 2002-09-08 alex {
675 296ddebe 2002-09-08 alex /* Bestaetigung an Client */
676 296ddebe 2002-09-08 alex ok = IRC_WriteStrClientPrefix( Client, Prefix, "MODE %s %s %s", Channel_Name( Channel ), Mode, Mask );
677 19ac723e 2002-09-08 alex }
678 8adff592 2005-03-19 fw else ok = true;
679 19ac723e 2002-09-08 alex
680 296ddebe 2002-09-08 alex /* an andere Server */
681 296ddebe 2002-09-08 alex IRC_WriteStrServersPrefix( Client, Prefix, "MODE %s %s %s", Channel_Name( Channel ), Mode, Mask );
682 19ac723e 2002-09-08 alex
683 296ddebe 2002-09-08 alex /* und lokale User im Channel */
684 8adff592 2005-03-19 fw IRC_WriteStrChannelPrefix( Client, Channel, Prefix, false, "MODE %s %s %s", Channel_Name( Channel ), Mode, Mask );
685 296ddebe 2002-09-08 alex
686 296ddebe 2002-09-08 alex return ok;
687 296ddebe 2002-09-08 alex } /* Send_ListChange */
688 296ddebe 2002-09-08 alex
689 296ddebe 2002-09-08 alex
690 c23199d9 2002-02-27 alex /* -eof- */