1 |
adx |
30 |
/* |
2 |
michael |
2820 |
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
3 |
adx |
30 |
* |
4 |
michael |
2820 |
* Copyright (c) 1997-2014 ircd-hybrid development team |
5 |
adx |
30 |
* |
6 |
|
|
* This program is free software; you can redistribute it and/or modify |
7 |
|
|
* it under the terms of the GNU General Public License as published by |
8 |
|
|
* the Free Software Foundation; either version 2 of the License, or |
9 |
|
|
* (at your option) any later version. |
10 |
|
|
* |
11 |
|
|
* This program is distributed in the hope that it will be useful, |
12 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
|
|
* GNU General Public License for more details. |
15 |
|
|
* |
16 |
|
|
* You should have received a copy of the GNU General Public License |
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 |
|
|
|
22 |
michael |
2820 |
/*! \file m_set.c |
23 |
|
|
* \brief Includes required functions for processing the SET command. |
24 |
|
|
* \version $Id$ |
25 |
|
|
*/ |
26 |
adx |
30 |
|
27 |
|
|
#include "stdinc.h" |
28 |
|
|
#include "client.h" |
29 |
|
|
#include "event.h" |
30 |
|
|
#include "irc_string.h" |
31 |
|
|
#include "ircd.h" |
32 |
|
|
#include "numeric.h" |
33 |
|
|
#include "fdlist.h" |
34 |
|
|
#include "s_bsd.h" |
35 |
|
|
#include "s_serv.h" |
36 |
|
|
#include "send.h" |
37 |
|
|
#include "channel.h" |
38 |
michael |
1309 |
#include "conf.h" |
39 |
adx |
30 |
#include "parse.h" |
40 |
|
|
#include "modules.h" |
41 |
|
|
#include "s_user.h" |
42 |
michael |
1243 |
#include "s_misc.h" |
43 |
adx |
30 |
|
44 |
|
|
|
45 |
|
|
/* SET AUTOCONN */ |
46 |
|
|
static void |
47 |
|
|
quote_autoconn(struct Client *source_p, const char *arg, int newval) |
48 |
|
|
{ |
49 |
michael |
896 |
if (arg != NULL) |
50 |
|
|
{ |
51 |
michael |
1632 |
struct MaskItem *conf = find_exact_name_conf(CONF_SERVER, NULL, arg, NULL, NULL); |
52 |
michael |
896 |
|
53 |
|
|
if (conf != NULL) |
54 |
|
|
{ |
55 |
|
|
if (newval) |
56 |
michael |
1632 |
SetConfAllowAutoConn(conf); |
57 |
michael |
896 |
else |
58 |
michael |
1632 |
ClearConfAllowAutoConn(conf); |
59 |
michael |
896 |
|
60 |
michael |
1618 |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
61 |
michael |
896 |
"%s has changed AUTOCONN for %s to %i", |
62 |
michael |
1141 |
get_oper_name(source_p), arg, newval); |
63 |
michael |
3110 |
sendto_one_notice(source_p, &me, ":AUTOCONN for %s is now set to %i", |
64 |
|
|
arg, newval); |
65 |
michael |
896 |
} |
66 |
|
|
else |
67 |
|
|
{ |
68 |
michael |
3110 |
sendto_one_notice(source_p, &me, ":Cannot find %s", arg); |
69 |
michael |
896 |
} |
70 |
|
|
} |
71 |
|
|
else |
72 |
|
|
{ |
73 |
michael |
3110 |
sendto_one_notice(source_p, &me, ":Please specify a server name!"); |
74 |
michael |
896 |
} |
75 |
adx |
30 |
} |
76 |
|
|
|
77 |
|
|
/* SET AUTOCONNALL */ |
78 |
|
|
static void |
79 |
|
|
quote_autoconnall(struct Client *source_p, int newval) |
80 |
|
|
{ |
81 |
|
|
if (newval >= 0) |
82 |
|
|
{ |
83 |
michael |
1618 |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
84 |
|
|
"%s has changed AUTOCONNALL to %i", |
85 |
michael |
1141 |
get_oper_name(source_p), newval); |
86 |
adx |
30 |
|
87 |
|
|
GlobalSetOptions.autoconn = newval; |
88 |
|
|
} |
89 |
|
|
else |
90 |
michael |
3110 |
sendto_one_notice(source_p, &me, ":AUTOCONNALL is currently %i", |
91 |
|
|
GlobalSetOptions.autoconn); |
92 |
adx |
30 |
} |
93 |
|
|
|
94 |
|
|
/* SET FLOODCOUNT */ |
95 |
|
|
static void |
96 |
|
|
quote_floodcount(struct Client *source_p, int newval) |
97 |
|
|
{ |
98 |
|
|
if (newval >= 0) |
99 |
|
|
{ |
100 |
|
|
GlobalSetOptions.floodcount = newval; |
101 |
michael |
1618 |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
102 |
michael |
1141 |
"%s has changed FLOODCOUNT to %i", |
103 |
|
|
get_oper_name(source_p), GlobalSetOptions.floodcount); |
104 |
adx |
30 |
} |
105 |
|
|
else |
106 |
michael |
3110 |
sendto_one_notice(source_p, &me, ":FLOODCOUNT is currently %i", |
107 |
|
|
GlobalSetOptions.floodcount); |
108 |
adx |
30 |
} |
109 |
|
|
|
110 |
|
|
/* SET IDENTTIMEOUT */ |
111 |
|
|
static void |
112 |
|
|
quote_identtimeout(struct Client *source_p, int newval) |
113 |
|
|
{ |
114 |
michael |
1219 |
if (!HasUMode(source_p, UMODE_ADMIN)) |
115 |
adx |
30 |
{ |
116 |
michael |
3109 |
sendto_one_numeric(source_p, &me, ERR_NOPRIVS, "set"); |
117 |
adx |
30 |
return; |
118 |
|
|
} |
119 |
|
|
|
120 |
|
|
if (newval > 0) |
121 |
|
|
{ |
122 |
michael |
1618 |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
123 |
michael |
1451 |
"%s has changed IDENTTIMEOUT to %d", |
124 |
|
|
get_oper_name(source_p), newval); |
125 |
adx |
30 |
GlobalSetOptions.ident_timeout = newval; |
126 |
|
|
} |
127 |
|
|
else |
128 |
michael |
3110 |
sendto_one_notice(source_p, &me, ":IDENTTIMEOUT is currently %d", |
129 |
|
|
GlobalSetOptions.ident_timeout); |
130 |
adx |
30 |
} |
131 |
|
|
|
132 |
|
|
/* SET MAX */ |
133 |
|
|
static void |
134 |
michael |
896 |
quote_max(struct Client *source_p, int newval) |
135 |
adx |
30 |
{ |
136 |
|
|
if (newval > 0) |
137 |
|
|
{ |
138 |
|
|
if (newval > MAXCLIENTS_MAX) |
139 |
|
|
{ |
140 |
michael |
3110 |
sendto_one_notice(source_p, &me, ":You cannot set MAXCLIENTS to > %d, restoring to %d", |
141 |
|
|
MAXCLIENTS_MAX, ServerInfo.max_clients); |
142 |
adx |
30 |
return; |
143 |
|
|
} |
144 |
|
|
|
145 |
|
|
if (newval < MAXCLIENTS_MIN) |
146 |
|
|
{ |
147 |
michael |
3110 |
sendto_one_notice(source_p, &me, ":You cannot set MAXCLIENTS to < %d, restoring to %d", |
148 |
|
|
MAXCLIENTS_MIN, ServerInfo.max_clients); |
149 |
adx |
30 |
return; |
150 |
|
|
} |
151 |
|
|
|
152 |
|
|
ServerInfo.max_clients = newval; |
153 |
|
|
|
154 |
michael |
1618 |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
155 |
michael |
1451 |
"%s set new MAXCLIENTS to %d (%d current)", |
156 |
|
|
get_oper_name(source_p), ServerInfo.max_clients, Count.local); |
157 |
adx |
30 |
} |
158 |
|
|
else |
159 |
michael |
3110 |
sendto_one_notice(source_p, &me, ":Current MAXCLIENTS = %d (%d)", |
160 |
|
|
ServerInfo.max_clients, Count.local); |
161 |
adx |
30 |
} |
162 |
|
|
|
163 |
|
|
/* SET SPAMNUM */ |
164 |
|
|
static void |
165 |
michael |
896 |
quote_spamnum(struct Client *source_p, int newval) |
166 |
adx |
30 |
{ |
167 |
michael |
646 |
if (newval >= 0) |
168 |
adx |
30 |
{ |
169 |
|
|
if (newval == 0) |
170 |
|
|
{ |
171 |
michael |
1618 |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
172 |
adx |
30 |
"%s has disabled ANTI_SPAMBOT", source_p->name); |
173 |
|
|
GlobalSetOptions.spam_num = newval; |
174 |
|
|
return; |
175 |
|
|
} |
176 |
|
|
|
177 |
|
|
GlobalSetOptions.spam_num = IRCD_MAX(newval, MIN_SPAM_NUM); |
178 |
michael |
1618 |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
179 |
|
|
"%s has changed SPAMNUM to %i", |
180 |
michael |
1141 |
get_oper_name(source_p), GlobalSetOptions.spam_num); |
181 |
adx |
30 |
} |
182 |
|
|
else |
183 |
michael |
3110 |
sendto_one_notice(source_p, &me, ":SPAMNUM is currently %i", |
184 |
|
|
GlobalSetOptions.spam_num); |
185 |
adx |
30 |
} |
186 |
|
|
|
187 |
|
|
/* SET SPAMTIME */ |
188 |
|
|
static void |
189 |
michael |
896 |
quote_spamtime(struct Client *source_p, int newval) |
190 |
adx |
30 |
{ |
191 |
|
|
if (newval > 0) |
192 |
|
|
{ |
193 |
|
|
GlobalSetOptions.spam_time = IRCD_MAX(newval, MIN_SPAM_TIME); |
194 |
michael |
1618 |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
195 |
|
|
"%s has changed SPAMTIME to %i", |
196 |
michael |
1141 |
get_oper_name(source_p), GlobalSetOptions.spam_time); |
197 |
adx |
30 |
} |
198 |
|
|
else |
199 |
michael |
3110 |
sendto_one_notice(source_p, &me, ":SPAMTIME is currently %i", |
200 |
|
|
GlobalSetOptions.spam_time); |
201 |
adx |
30 |
} |
202 |
|
|
|
203 |
|
|
/* this table is what splitmode may be set to */ |
204 |
|
|
static const char *splitmode_values[] = |
205 |
|
|
{ |
206 |
|
|
"OFF", |
207 |
|
|
"ON", |
208 |
|
|
"AUTO", |
209 |
|
|
NULL |
210 |
|
|
}; |
211 |
|
|
|
212 |
|
|
/* this table is what splitmode may be */ |
213 |
|
|
static const char *splitmode_status[] = |
214 |
|
|
{ |
215 |
|
|
"OFF", |
216 |
|
|
"AUTO (OFF)", |
217 |
|
|
"ON", |
218 |
|
|
"AUTO (ON)", |
219 |
|
|
NULL |
220 |
|
|
}; |
221 |
|
|
|
222 |
|
|
/* SET SPLITMODE */ |
223 |
|
|
static void |
224 |
|
|
quote_splitmode(struct Client *source_p, char *charval) |
225 |
|
|
{ |
226 |
|
|
if (charval) |
227 |
|
|
{ |
228 |
|
|
int newval; |
229 |
|
|
|
230 |
michael |
896 |
for (newval = 0; splitmode_values[newval]; ++newval) |
231 |
adx |
30 |
if (irccmp(splitmode_values[newval], charval) == 0) |
232 |
|
|
break; |
233 |
|
|
|
234 |
|
|
/* OFF */ |
235 |
|
|
if (newval == 0) |
236 |
|
|
{ |
237 |
michael |
1618 |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
238 |
adx |
30 |
"%s is disabling splitmode", |
239 |
|
|
get_oper_name(source_p)); |
240 |
|
|
|
241 |
|
|
splitmode = 0; |
242 |
|
|
splitchecking = 0; |
243 |
|
|
|
244 |
|
|
eventDelete(check_splitmode, NULL); |
245 |
|
|
} |
246 |
|
|
/* ON */ |
247 |
|
|
else if (newval == 1) |
248 |
|
|
{ |
249 |
michael |
1618 |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
250 |
adx |
30 |
"%s is enabling and activating splitmode", |
251 |
michael |
1451 |
get_oper_name(source_p)); |
252 |
|
|
|
253 |
adx |
30 |
splitmode = 1; |
254 |
|
|
splitchecking = 0; |
255 |
|
|
|
256 |
|
|
/* we might be deactivating an automatic splitmode, so pull the event */ |
257 |
|
|
eventDelete(check_splitmode, NULL); |
258 |
|
|
} |
259 |
|
|
/* AUTO */ |
260 |
|
|
else if (newval == 2) |
261 |
|
|
{ |
262 |
michael |
1618 |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
263 |
adx |
30 |
"%s is enabling automatic splitmode", |
264 |
michael |
1451 |
get_oper_name(source_p)); |
265 |
adx |
30 |
|
266 |
|
|
splitchecking = 1; |
267 |
|
|
check_splitmode(NULL); |
268 |
|
|
} |
269 |
|
|
} |
270 |
|
|
else |
271 |
|
|
/* if we add splitchecking to splitmode*2 we get a unique table to |
272 |
|
|
* pull values back out of, splitmode can be four states - but you can |
273 |
|
|
* only set to three, which means we cant use the same table --fl_ |
274 |
|
|
*/ |
275 |
michael |
3110 |
sendto_one_notice(source_p, &me, ":SPLITMODE is currently %s", |
276 |
|
|
splitmode_status[(splitchecking + (splitmode * 2))]); |
277 |
adx |
30 |
} |
278 |
|
|
|
279 |
|
|
/* SET SPLITNUM */ |
280 |
|
|
static void |
281 |
|
|
quote_splitnum(struct Client *source_p, int newval) |
282 |
|
|
{ |
283 |
|
|
if (newval >= 0) |
284 |
|
|
{ |
285 |
michael |
1618 |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
286 |
adx |
30 |
"%s has changed SPLITNUM to %i", |
287 |
michael |
1451 |
get_oper_name(source_p), newval); |
288 |
adx |
30 |
split_servers = newval; |
289 |
|
|
|
290 |
|
|
if (splitchecking) |
291 |
|
|
check_splitmode(NULL); |
292 |
|
|
} |
293 |
|
|
else |
294 |
michael |
3110 |
sendto_one_notice(source_p, &me, ":SPLITNUM is currently %i", |
295 |
|
|
split_servers); |
296 |
adx |
30 |
} |
297 |
|
|
|
298 |
|
|
/* SET SPLITUSERS */ |
299 |
|
|
static void |
300 |
|
|
quote_splitusers(struct Client *source_p, int newval) |
301 |
|
|
{ |
302 |
|
|
if (newval >= 0) |
303 |
|
|
{ |
304 |
michael |
1618 |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
305 |
adx |
30 |
"%s has changed SPLITUSERS to %i", |
306 |
michael |
1451 |
get_oper_name(source_p), newval); |
307 |
adx |
30 |
split_users = newval; |
308 |
|
|
|
309 |
|
|
if (splitchecking) |
310 |
|
|
check_splitmode(NULL); |
311 |
|
|
} |
312 |
|
|
else |
313 |
michael |
3110 |
sendto_one_notice(source_p, &me, ":SPLITUSERS is currently %i", |
314 |
|
|
split_users); |
315 |
adx |
30 |
} |
316 |
|
|
|
317 |
|
|
/* SET JFLOODTIME */ |
318 |
|
|
static void |
319 |
|
|
quote_jfloodtime(struct Client *source_p, int newval) |
320 |
|
|
{ |
321 |
|
|
if (newval >= 0) |
322 |
|
|
{ |
323 |
michael |
1618 |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
324 |
adx |
30 |
"%s has changed JFLOODTIME to %i", |
325 |
michael |
1451 |
get_oper_name(source_p), newval); |
326 |
adx |
30 |
GlobalSetOptions.joinfloodtime = newval; |
327 |
|
|
} |
328 |
|
|
else |
329 |
michael |
3110 |
sendto_one_notice(source_p, &me, ":JFLOODTIME is currently %i", |
330 |
|
|
GlobalSetOptions.joinfloodtime); |
331 |
adx |
30 |
} |
332 |
|
|
|
333 |
|
|
/* SET JFLOODCOUNT */ |
334 |
|
|
static void |
335 |
|
|
quote_jfloodcount(struct Client *source_p, int newval) |
336 |
|
|
{ |
337 |
|
|
if (newval >= 0) |
338 |
|
|
{ |
339 |
michael |
1618 |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
340 |
adx |
30 |
"%s has changed JFLOODCOUNT to %i", |
341 |
michael |
1451 |
get_oper_name(source_p), newval); |
342 |
adx |
30 |
GlobalSetOptions.joinfloodcount = newval; |
343 |
|
|
} |
344 |
|
|
else |
345 |
michael |
3110 |
sendto_one_notice(source_p, &me, ":JFLOODCOUNT is currently %i", |
346 |
|
|
GlobalSetOptions.joinfloodcount); |
347 |
adx |
30 |
} |
348 |
|
|
|
349 |
michael |
1997 |
/* Structure used for the SET table itself */ |
350 |
|
|
struct SetStruct |
351 |
|
|
{ |
352 |
|
|
const char *name; |
353 |
|
|
void (*handler)(); |
354 |
|
|
const int wants_char; /* 1 if it expects (char *, [int]) */ |
355 |
|
|
const int wants_int; /* 1 if it expects ([char *], int) */ |
356 |
|
|
/* eg: 0, 1 == only an int arg |
357 |
|
|
* eg: 1, 1 == char and int args */ |
358 |
|
|
}; |
359 |
|
|
|
360 |
adx |
30 |
/* |
361 |
michael |
1997 |
* If this ever needs to be expanded to more than one arg of each |
362 |
|
|
* type, want_char/want_int could be the count of the arguments, |
363 |
|
|
* instead of just a boolean flag... |
364 |
|
|
* |
365 |
|
|
* -davidt |
366 |
|
|
*/ |
367 |
|
|
static const struct SetStruct set_cmd_table[] = |
368 |
|
|
{ |
369 |
|
|
/* name function string arg int arg */ |
370 |
|
|
/* -------------------------------------------------------- */ |
371 |
|
|
{ "AUTOCONN", quote_autoconn, 1, 1 }, |
372 |
|
|
{ "AUTOCONNALL", quote_autoconnall, 0, 1 }, |
373 |
|
|
{ "FLOODCOUNT", quote_floodcount, 0, 1 }, |
374 |
|
|
{ "IDENTTIMEOUT", quote_identtimeout, 0, 1 }, |
375 |
|
|
{ "MAX", quote_max, 0, 1 }, |
376 |
|
|
{ "SPAMNUM", quote_spamnum, 0, 1 }, |
377 |
|
|
{ "SPAMTIME", quote_spamtime, 0, 1 }, |
378 |
|
|
{ "SPLITMODE", quote_splitmode, 1, 0 }, |
379 |
|
|
{ "SPLITNUM", quote_splitnum, 0, 1 }, |
380 |
|
|
{ "SPLITUSERS", quote_splitusers, 0, 1 }, |
381 |
|
|
{ "JFLOODTIME", quote_jfloodtime, 0, 1 }, |
382 |
|
|
{ "JFLOODCOUNT", quote_jfloodcount, 0, 1 }, |
383 |
|
|
/* -------------------------------------------------------- */ |
384 |
|
|
{ NULL, NULL, 0, 0 } |
385 |
|
|
}; |
386 |
|
|
|
387 |
|
|
/* |
388 |
|
|
* list_quote_commands() sends the client all the available commands. |
389 |
|
|
* Four to a line for now. |
390 |
|
|
*/ |
391 |
|
|
static void |
392 |
|
|
list_quote_commands(struct Client *source_p) |
393 |
|
|
{ |
394 |
|
|
int j = 0; |
395 |
|
|
const struct SetStruct *tab = set_cmd_table; |
396 |
|
|
const char *names[4] = { "", "", "", "" }; |
397 |
|
|
|
398 |
michael |
3110 |
sendto_one_notice(source_p, &me, ":Available QUOTE SET commands:"); |
399 |
michael |
1997 |
|
400 |
|
|
for (; tab->handler; ++tab) |
401 |
|
|
{ |
402 |
|
|
names[j++] = tab->name; |
403 |
|
|
|
404 |
|
|
if (j > 3) |
405 |
|
|
{ |
406 |
michael |
3110 |
sendto_one_notice(source_p, &me, ":%s %s %s %s", |
407 |
|
|
names[0], names[1], |
408 |
|
|
names[2], names[3]); |
409 |
michael |
1997 |
j = 0; |
410 |
|
|
names[0] = names[1] = names[2] = names[3] = ""; |
411 |
|
|
} |
412 |
|
|
|
413 |
|
|
} |
414 |
|
|
|
415 |
|
|
if (j) |
416 |
michael |
3110 |
sendto_one_notice(source_p, &me, ":%s %s %s %s", |
417 |
|
|
names[0], names[1], |
418 |
|
|
names[2], names[3]); |
419 |
michael |
1997 |
} |
420 |
|
|
|
421 |
|
|
/* |
422 |
adx |
30 |
* mo_set - SET command handler |
423 |
|
|
* set options while running |
424 |
|
|
*/ |
425 |
michael |
2820 |
static int |
426 |
adx |
30 |
mo_set(struct Client *client_p, struct Client *source_p, |
427 |
|
|
int parc, char *parv[]) |
428 |
|
|
{ |
429 |
|
|
int n; |
430 |
|
|
int newval; |
431 |
|
|
const char *arg = NULL; |
432 |
|
|
const char *intarg = NULL; |
433 |
michael |
1013 |
const struct SetStruct *tab = set_cmd_table; |
434 |
adx |
30 |
|
435 |
michael |
1460 |
if (!HasOFlag(source_p, OPER_FLAG_SET)) |
436 |
|
|
{ |
437 |
michael |
3109 |
sendto_one_numeric(source_p, &me, ERR_NOPRIVS, "set"); |
438 |
michael |
2820 |
return 0; |
439 |
michael |
1460 |
} |
440 |
|
|
|
441 |
adx |
30 |
if (parc > 1) |
442 |
|
|
{ |
443 |
michael |
1013 |
/* |
444 |
|
|
* Go through all the commands in set_cmd_table, until one is |
445 |
|
|
* matched. |
446 |
adx |
30 |
*/ |
447 |
michael |
1013 |
for (; tab->handler; ++tab) |
448 |
adx |
30 |
{ |
449 |
michael |
1013 |
if (!irccmp(tab->name, parv[1])) |
450 |
adx |
30 |
{ |
451 |
|
|
/* |
452 |
|
|
* Command found; now execute the code |
453 |
|
|
*/ |
454 |
|
|
n = 2; |
455 |
|
|
|
456 |
michael |
1013 |
if (tab->wants_char) |
457 |
adx |
30 |
arg = parv[n++]; |
458 |
|
|
|
459 |
michael |
1013 |
if (tab->wants_int) |
460 |
adx |
30 |
intarg = parv[n++]; |
461 |
|
|
|
462 |
|
|
if ((n - 1) > parc) |
463 |
|
|
{ |
464 |
|
|
if (parc > 2) |
465 |
michael |
3110 |
sendto_one_notice(source_p, &me, ":SET %s expects (\"%s%s\") args", |
466 |
|
|
(tab->wants_char ? "string, " : ""), |
467 |
|
|
(tab->wants_char ? "int" : "")); |
468 |
adx |
30 |
} |
469 |
|
|
|
470 |
|
|
if (parc <= 2) |
471 |
|
|
{ |
472 |
|
|
arg = NULL; |
473 |
|
|
intarg = NULL; |
474 |
|
|
} |
475 |
|
|
|
476 |
michael |
1013 |
if (!strcmp(tab->name, "AUTOCONN") && (parc < 4)) |
477 |
adx |
30 |
{ |
478 |
michael |
3109 |
sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, "SET"); |
479 |
michael |
2820 |
return 0; |
480 |
adx |
30 |
} |
481 |
|
|
|
482 |
michael |
1013 |
if (tab->wants_int && (parc > 2)) |
483 |
adx |
30 |
{ |
484 |
|
|
if (intarg) |
485 |
|
|
{ |
486 |
|
|
if (irccmp(intarg, "yes") == 0 || irccmp(intarg, "on") == 0) |
487 |
|
|
newval = 1; |
488 |
|
|
else if (irccmp(intarg, "no") == 0|| irccmp(intarg, "off") == 0) |
489 |
|
|
newval = 0; |
490 |
|
|
else |
491 |
|
|
newval = atoi(intarg); |
492 |
|
|
} |
493 |
|
|
else |
494 |
|
|
newval = -1; |
495 |
|
|
|
496 |
|
|
if (newval < 0) |
497 |
|
|
{ |
498 |
michael |
3110 |
sendto_one_notice(source_p, &me, ":Value less than 0 illegal for %s", |
499 |
|
|
tab->name); |
500 |
adx |
30 |
|
501 |
michael |
2820 |
return 0; |
502 |
adx |
30 |
} |
503 |
|
|
} |
504 |
|
|
else |
505 |
|
|
newval = -1; |
506 |
|
|
|
507 |
michael |
1013 |
if (tab->wants_char) |
508 |
adx |
30 |
{ |
509 |
michael |
1013 |
if (tab->wants_int) |
510 |
|
|
tab->handler(source_p, arg, newval); |
511 |
adx |
30 |
else |
512 |
michael |
1013 |
tab->handler(source_p, arg); |
513 |
michael |
2820 |
return 0; |
514 |
adx |
30 |
} |
515 |
|
|
else |
516 |
|
|
{ |
517 |
michael |
1013 |
if (tab->wants_int) |
518 |
|
|
tab->handler(source_p, newval); |
519 |
adx |
30 |
else |
520 |
|
|
/* Just in case someone actually wants a |
521 |
|
|
* set function that takes no args.. *shrug* */ |
522 |
michael |
1013 |
tab->handler(source_p); |
523 |
michael |
2820 |
return 0; |
524 |
adx |
30 |
} |
525 |
|
|
} |
526 |
|
|
} |
527 |
|
|
|
528 |
|
|
/* |
529 |
|
|
* Code here will be executed when a /QUOTE SET command is not |
530 |
|
|
* found within set_cmd_table. |
531 |
|
|
*/ |
532 |
michael |
3110 |
sendto_one_notice(source_p, &me, ":Variable not found."); |
533 |
michael |
2820 |
return 0; |
534 |
adx |
30 |
} |
535 |
|
|
|
536 |
|
|
list_quote_commands(source_p); |
537 |
michael |
2820 |
return 0; |
538 |
adx |
30 |
} |
539 |
michael |
1230 |
|
540 |
michael |
2820 |
static struct Message set_msgtab = |
541 |
|
|
{ |
542 |
michael |
1230 |
"SET", 0, 0, 0, MAXPARA, MFLG_SLOW, 0, |
543 |
michael |
2820 |
{ m_unregistered, m_not_oper, m_ignore, m_ignore, mo_set, m_ignore } |
544 |
michael |
1230 |
}; |
545 |
|
|
|
546 |
|
|
static void |
547 |
|
|
module_init(void) |
548 |
|
|
{ |
549 |
|
|
mod_add_cmd(&set_msgtab); |
550 |
|
|
} |
551 |
|
|
|
552 |
|
|
static void |
553 |
|
|
module_exit(void) |
554 |
|
|
{ |
555 |
|
|
mod_del_cmd(&set_msgtab); |
556 |
|
|
} |
557 |
|
|
|
558 |
michael |
2820 |
struct module module_entry = |
559 |
|
|
{ |
560 |
michael |
1230 |
.node = { NULL, NULL, NULL }, |
561 |
|
|
.name = NULL, |
562 |
|
|
.version = "$Revision$", |
563 |
|
|
.handle = NULL, |
564 |
|
|
.modinit = module_init, |
565 |
|
|
.modexit = module_exit, |
566 |
|
|
.flags = 0 |
567 |
|
|
}; |