1 |
/* |
2 |
* ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). |
3 |
* m_set.c: Sets a server parameter. |
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 |
/* rewritten by jdc */ |
26 |
|
27 |
#include "stdinc.h" |
28 |
#include "handlers.h" |
29 |
#include "client.h" |
30 |
#include "event.h" |
31 |
#include "irc_string.h" |
32 |
#include "ircd.h" |
33 |
#include "numeric.h" |
34 |
#include "fdlist.h" |
35 |
#include "s_bsd.h" |
36 |
#include "s_serv.h" |
37 |
#include "send.h" |
38 |
#include "common.h" /* for NO */ |
39 |
#include "channel.h" |
40 |
#include "s_log.h" |
41 |
#include "s_conf.h" |
42 |
#include "msg.h" |
43 |
#include "parse.h" |
44 |
#include "modules.h" |
45 |
#include "s_user.h" |
46 |
|
47 |
|
48 |
static void mo_set(struct Client *, struct Client *, int, char *[]); |
49 |
|
50 |
struct Message set_msgtab = { |
51 |
"SET", 0, 0, 0, 0, MFLG_SLOW, 0, |
52 |
{m_unregistered, m_not_oper, rfc1459_command_send_error, m_ignore, mo_set, m_ignore} |
53 |
}; |
54 |
|
55 |
void |
56 |
_modinit(void) |
57 |
{ |
58 |
mod_add_cmd(&set_msgtab); |
59 |
} |
60 |
|
61 |
void |
62 |
_moddeinit(void) |
63 |
{ |
64 |
mod_del_cmd(&set_msgtab); |
65 |
} |
66 |
|
67 |
const char *_version = "$Revision$"; |
68 |
|
69 |
/* Structure used for the SET table itself */ |
70 |
struct SetStruct |
71 |
{ |
72 |
const char *name; |
73 |
void (*handler)(); |
74 |
const int wants_char; /* 1 if it expects (char *, [int]) */ |
75 |
const int wants_int; /* 1 if it expects ([char *], int) */ |
76 |
/* eg: 0, 1 == only an int arg |
77 |
* eg: 1, 1 == char and int args */ |
78 |
}; |
79 |
|
80 |
static void quote_autoconn(struct Client *, const char *, int); |
81 |
static void quote_autoconnall(struct Client *, int); |
82 |
static void quote_floodcount(struct Client *, int); |
83 |
static void quote_identtimeout(struct Client *, int); |
84 |
static void quote_idletime(struct Client *, int); |
85 |
static void quote_log(struct Client *, int); |
86 |
static void quote_max(struct Client *, int); |
87 |
static void quote_msglocale(struct Client *, char *); |
88 |
static void quote_spamnum(struct Client *, int); |
89 |
static void quote_spamtime(struct Client *, int); |
90 |
static void quote_splitmode(struct Client *, char *); |
91 |
static void quote_splitnum(struct Client *, int); |
92 |
static void quote_splitusers(struct Client *, int); |
93 |
static void list_quote_commands(struct Client *); |
94 |
static void quote_jfloodtime(struct Client *, int); |
95 |
static void quote_jfloodcount(struct Client *, int); |
96 |
static void quote_rejecttime(struct Client *, int); |
97 |
|
98 |
/* |
99 |
* If this ever needs to be expanded to more than one arg of each |
100 |
* type, want_char/want_int could be the count of the arguments, |
101 |
* instead of just a boolean flag... |
102 |
* |
103 |
* -davidt |
104 |
*/ |
105 |
|
106 |
static const struct SetStruct set_cmd_table[] = |
107 |
{ |
108 |
/* name function string arg int arg */ |
109 |
/* -------------------------------------------------------- */ |
110 |
{ "AUTOCONN", quote_autoconn, 1, 1 }, |
111 |
{ "AUTOCONNALL", quote_autoconnall, 0, 1 }, |
112 |
{ "FLOODCOUNT", quote_floodcount, 0, 1 }, |
113 |
{ "IDENTTIMEOUT", quote_identtimeout, 0, 1 }, |
114 |
{ "IDLETIME", quote_idletime, 0, 1 }, |
115 |
{ "LOG", quote_log, 0, 1 }, |
116 |
{ "MAX", quote_max, 0, 1 }, |
117 |
{ "MSGLOCALE", quote_msglocale, 1, 0 }, |
118 |
{ "SPAMNUM", quote_spamnum, 0, 1 }, |
119 |
{ "SPAMTIME", quote_spamtime, 0, 1 }, |
120 |
{ "SPLITMODE", quote_splitmode, 1, 0 }, |
121 |
{ "SPLITNUM", quote_splitnum, 0, 1 }, |
122 |
{ "SPLITUSERS", quote_splitusers, 0, 1 }, |
123 |
{ "JFLOODTIME", quote_jfloodtime, 0, 1 }, |
124 |
{ "JFLOODCOUNT", quote_jfloodcount, 0, 1 }, |
125 |
{ "REJECTTIME", quote_rejecttime, 0, 1 }, |
126 |
/* -------------------------------------------------------- */ |
127 |
{ NULL, NULL, 0, 0 } |
128 |
}; |
129 |
|
130 |
/* |
131 |
* list_quote_commands() sends the client all the available commands. |
132 |
* Four to a line for now. |
133 |
*/ |
134 |
static void |
135 |
list_quote_commands(struct Client *source_p) |
136 |
{ |
137 |
int j = 0; |
138 |
const struct SetStruct *tab = set_cmd_table; |
139 |
const char *names[4] = { "", "", "", "" }; |
140 |
|
141 |
sendto_one(source_p, ":%s NOTICE %s :Available QUOTE SET commands:", |
142 |
me.name, source_p->name); |
143 |
|
144 |
for (; tab->handler; ++tab) |
145 |
{ |
146 |
names[j++] = tab->name; |
147 |
|
148 |
if (j > 3) |
149 |
{ |
150 |
sendto_one(source_p, ":%s NOTICE %s :%s %s %s %s", |
151 |
me.name, source_p->name, |
152 |
names[0], names[1], |
153 |
names[2], names[3]); |
154 |
j = 0; |
155 |
names[0] = names[1] = names[2] = names[3] = ""; |
156 |
} |
157 |
|
158 |
} |
159 |
|
160 |
if (j) |
161 |
sendto_one(source_p, ":%s NOTICE %s :%s %s %s %s", |
162 |
me.name, source_p->name, |
163 |
names[0], names[1], |
164 |
names[2], names[3]); |
165 |
} |
166 |
|
167 |
/* SET AUTOCONN */ |
168 |
static void |
169 |
quote_autoconn(struct Client *source_p, const char *arg, int newval) |
170 |
{ |
171 |
struct AccessItem *aconf; |
172 |
|
173 |
if (arg != NULL) |
174 |
{ |
175 |
struct ConfItem *conf = find_exact_name_conf(SERVER_TYPE, arg, NULL, NULL); |
176 |
|
177 |
if (conf != NULL) |
178 |
{ |
179 |
aconf = map_to_conf(conf); |
180 |
if (newval) |
181 |
SetConfAllowAutoConn(aconf); |
182 |
else |
183 |
ClearConfAllowAutoConn(aconf); |
184 |
|
185 |
sendto_realops_flags(UMODE_ALL, L_ALL, |
186 |
"%s has changed AUTOCONN for %s to %i", |
187 |
get_oper_name(source_p), arg, newval); |
188 |
sendto_one(source_p, |
189 |
":%s NOTICE %s :AUTOCONN for %s is now set to %i", |
190 |
me.name, source_p->name, arg, newval); |
191 |
} |
192 |
else |
193 |
{ |
194 |
sendto_one(source_p, ":%s NOTICE %s :Can't find %s", |
195 |
me.name, source_p->name, arg); |
196 |
} |
197 |
} |
198 |
else |
199 |
{ |
200 |
sendto_one(source_p, ":%s NOTICE %s :Please specify a server name!", |
201 |
me.name, source_p->name); |
202 |
} |
203 |
} |
204 |
|
205 |
/* SET AUTOCONNALL */ |
206 |
static void |
207 |
quote_autoconnall(struct Client *source_p, int newval) |
208 |
{ |
209 |
if (newval >= 0) |
210 |
{ |
211 |
sendto_realops_flags(UMODE_ALL, L_ALL, "%s has changed AUTOCONNALL to %i", |
212 |
get_oper_name(source_p), newval); |
213 |
|
214 |
GlobalSetOptions.autoconn = newval; |
215 |
} |
216 |
else |
217 |
sendto_one(source_p, ":%s NOTICE %s :AUTOCONNALL is currently %i", |
218 |
me.name, source_p->name, GlobalSetOptions.autoconn); |
219 |
} |
220 |
|
221 |
/* SET FLOODCOUNT */ |
222 |
static void |
223 |
quote_floodcount(struct Client *source_p, int newval) |
224 |
{ |
225 |
if (newval >= 0) |
226 |
{ |
227 |
GlobalSetOptions.floodcount = newval; |
228 |
sendto_realops_flags(UMODE_ALL, L_ALL, |
229 |
"%s has changed FLOODCOUNT to %i", |
230 |
get_oper_name(source_p), GlobalSetOptions.floodcount); |
231 |
} |
232 |
else |
233 |
sendto_one(source_p, ":%s NOTICE %s :FLOODCOUNT is currently %i", |
234 |
me.name, source_p->name, GlobalSetOptions.floodcount); |
235 |
} |
236 |
|
237 |
/* SET IDENTTIMEOUT */ |
238 |
static void |
239 |
quote_identtimeout(struct Client *source_p, int newval) |
240 |
{ |
241 |
if (!IsAdmin(source_p)) |
242 |
{ |
243 |
sendto_one(source_p, form_str(ERR_NOPRIVS), |
244 |
me.name, source_p->name, "set"); |
245 |
return; |
246 |
} |
247 |
|
248 |
if (newval > 0) |
249 |
{ |
250 |
sendto_realops_flags(UMODE_ALL, L_ALL, |
251 |
"%s has changed IDENTTIMEOUT to %d", |
252 |
get_oper_name(source_p), newval); |
253 |
GlobalSetOptions.ident_timeout = newval; |
254 |
} |
255 |
else |
256 |
sendto_one(source_p, ":%s NOTICE %s :IDENTTIMEOUT is currently %d", |
257 |
me.name, source_p->name, GlobalSetOptions.ident_timeout); |
258 |
} |
259 |
|
260 |
/* SET IDLETIME */ |
261 |
static void |
262 |
quote_idletime(struct Client *source_p, int newval) |
263 |
{ |
264 |
if (newval >= 0) |
265 |
{ |
266 |
if (newval == 0) |
267 |
{ |
268 |
sendto_realops_flags(UMODE_ALL, L_ALL, |
269 |
"%s has disabled idletime checking", |
270 |
get_oper_name(source_p)); |
271 |
GlobalSetOptions.idletime = 0; |
272 |
} |
273 |
else |
274 |
{ |
275 |
sendto_realops_flags(UMODE_ALL, L_ALL, |
276 |
"%s has changed IDLETIME to %i", |
277 |
get_oper_name(source_p), newval); |
278 |
GlobalSetOptions.idletime = (newval * 60); |
279 |
} |
280 |
} |
281 |
else |
282 |
{ |
283 |
sendto_one(source_p, ":%s NOTICE %s :IDLETIME is currently %i", |
284 |
me.name, source_p->name, GlobalSetOptions.idletime/60); |
285 |
} |
286 |
} |
287 |
|
288 |
/* SET LOG */ |
289 |
static void |
290 |
quote_log(struct Client *source_p, int newval) |
291 |
{ |
292 |
if (newval >= 0) |
293 |
{ |
294 |
if (newval < L_WARN) |
295 |
{ |
296 |
sendto_one(source_p, ":%s NOTICE %s :LOG must be > %d (L_WARN)", |
297 |
me.name, source_p->name, L_WARN); |
298 |
return; |
299 |
} |
300 |
|
301 |
if (newval > L_DEBUG) |
302 |
newval = L_DEBUG; |
303 |
|
304 |
set_log_level(newval); |
305 |
sendto_realops_flags(UMODE_ALL, L_ALL, "%s has changed LOG level to %i (%s)", |
306 |
get_oper_name(source_p), get_log_level(), |
307 |
get_log_level_as_string(get_log_level())); |
308 |
} |
309 |
else |
310 |
sendto_one(source_p, ":%s NOTICE %s :LOG level is currently %i (%s)", |
311 |
me.name, source_p->name, get_log_level(), |
312 |
get_log_level_as_string(get_log_level())); |
313 |
} |
314 |
|
315 |
/* SET MAX */ |
316 |
static void |
317 |
quote_max(struct Client *source_p, int newval) |
318 |
{ |
319 |
if (newval > 0) |
320 |
{ |
321 |
recalc_fdlimit(NULL); |
322 |
|
323 |
if (newval > MAXCLIENTS_MAX) |
324 |
{ |
325 |
sendto_one(source_p, |
326 |
":%s NOTICE %s :You cannot set MAXCLIENTS to > %d, restoring to %d", |
327 |
me.name, source_p->name, MAXCLIENTS_MAX, ServerInfo.max_clients); |
328 |
return; |
329 |
} |
330 |
|
331 |
if (newval < MAXCLIENTS_MIN) |
332 |
{ |
333 |
sendto_one(source_p, |
334 |
":%s NOTICE %s :You cannot set MAXCLIENTS to < %d, restoring to %d", |
335 |
me.name, source_p->name, MAXCLIENTS_MIN, ServerInfo.max_clients); |
336 |
return; |
337 |
} |
338 |
|
339 |
ServerInfo.max_clients = newval; |
340 |
|
341 |
sendto_realops_flags(UMODE_ALL, L_ALL, |
342 |
"%s set new MAXCLIENTS to %d (%d current)", |
343 |
get_oper_name(source_p), source_p->username, source_p->host, |
344 |
ServerInfo.max_clients, Count.local); |
345 |
} |
346 |
else |
347 |
sendto_one(source_p, ":%s NOTICE %s :Current MAXCLIENTS = %d (%d)", |
348 |
me.name, source_p->name, ServerInfo.max_clients, Count.local); |
349 |
} |
350 |
|
351 |
/* SET MSGLOCALE */ |
352 |
static void |
353 |
quote_msglocale(struct Client *source_p, char *locale) |
354 |
{ |
355 |
if (locale != NULL) |
356 |
{ |
357 |
set_locale(locale); |
358 |
rebuild_isupport_message_line(); |
359 |
sendto_one(source_p, ":%s NOTICE %s :Set MSGLOCALE to '%s'", |
360 |
me.name, source_p->name, get_locale()); |
361 |
} |
362 |
else |
363 |
sendto_one(source_p, ":%s NOTICE %s :MSGLOCALE is currently '%s'", |
364 |
me.name, source_p->name, get_locale()); |
365 |
} |
366 |
|
367 |
/* SET SPAMNUM */ |
368 |
static void |
369 |
quote_spamnum(struct Client *source_p, int newval) |
370 |
{ |
371 |
if (newval >= 0) |
372 |
{ |
373 |
if (newval == 0) |
374 |
{ |
375 |
sendto_realops_flags(UMODE_ALL, L_ALL, |
376 |
"%s has disabled ANTI_SPAMBOT", source_p->name); |
377 |
GlobalSetOptions.spam_num = newval; |
378 |
return; |
379 |
} |
380 |
|
381 |
GlobalSetOptions.spam_num = IRCD_MAX(newval, MIN_SPAM_NUM); |
382 |
sendto_realops_flags(UMODE_ALL, L_ALL, "%s has changed SPAMNUM to %i", |
383 |
get_oper_name(source_p), GlobalSetOptions.spam_num); |
384 |
} |
385 |
else |
386 |
sendto_one(source_p, ":%s NOTICE %s :SPAMNUM is currently %i", |
387 |
me.name, source_p->name, GlobalSetOptions.spam_num); |
388 |
} |
389 |
|
390 |
/* SET SPAMTIME */ |
391 |
static void |
392 |
quote_spamtime(struct Client *source_p, int newval) |
393 |
{ |
394 |
if (newval > 0) |
395 |
{ |
396 |
GlobalSetOptions.spam_time = IRCD_MAX(newval, MIN_SPAM_TIME); |
397 |
sendto_realops_flags(UMODE_ALL, L_ALL, "%s has changed SPAMTIME to %i", |
398 |
get_oper_name(source_p), GlobalSetOptions.spam_time); |
399 |
} |
400 |
else |
401 |
sendto_one(source_p, ":%s NOTICE %s :SPAMTIME is currently %i", |
402 |
me.name, source_p->name, GlobalSetOptions.spam_time); |
403 |
} |
404 |
|
405 |
/* this table is what splitmode may be set to */ |
406 |
static const char *splitmode_values[] = |
407 |
{ |
408 |
"OFF", |
409 |
"ON", |
410 |
"AUTO", |
411 |
NULL |
412 |
}; |
413 |
|
414 |
/* this table is what splitmode may be */ |
415 |
static const char *splitmode_status[] = |
416 |
{ |
417 |
"OFF", |
418 |
"AUTO (OFF)", |
419 |
"ON", |
420 |
"AUTO (ON)", |
421 |
NULL |
422 |
}; |
423 |
|
424 |
/* SET SPLITMODE */ |
425 |
static void |
426 |
quote_splitmode(struct Client *source_p, char *charval) |
427 |
{ |
428 |
if (charval) |
429 |
{ |
430 |
int newval; |
431 |
|
432 |
for (newval = 0; splitmode_values[newval]; ++newval) |
433 |
if (irccmp(splitmode_values[newval], charval) == 0) |
434 |
break; |
435 |
|
436 |
/* OFF */ |
437 |
if (newval == 0) |
438 |
{ |
439 |
sendto_realops_flags(UMODE_ALL, L_ALL, |
440 |
"%s is disabling splitmode", |
441 |
get_oper_name(source_p)); |
442 |
|
443 |
splitmode = 0; |
444 |
splitchecking = 0; |
445 |
|
446 |
eventDelete(check_splitmode, NULL); |
447 |
} |
448 |
/* ON */ |
449 |
else if (newval == 1) |
450 |
{ |
451 |
sendto_realops_flags(UMODE_ALL, L_ALL, |
452 |
"%s is enabling and activating splitmode", |
453 |
get_oper_name(source_p)); |
454 |
|
455 |
splitmode = 1; |
456 |
splitchecking = 0; |
457 |
|
458 |
/* we might be deactivating an automatic splitmode, so pull the event */ |
459 |
eventDelete(check_splitmode, NULL); |
460 |
} |
461 |
/* AUTO */ |
462 |
else if (newval == 2) |
463 |
{ |
464 |
sendto_realops_flags(UMODE_ALL, L_ALL, |
465 |
"%s is enabling automatic splitmode", |
466 |
get_oper_name(source_p)); |
467 |
|
468 |
splitchecking = 1; |
469 |
check_splitmode(NULL); |
470 |
} |
471 |
} |
472 |
else |
473 |
/* if we add splitchecking to splitmode*2 we get a unique table to |
474 |
* pull values back out of, splitmode can be four states - but you can |
475 |
* only set to three, which means we cant use the same table --fl_ |
476 |
*/ |
477 |
sendto_one(source_p, ":%s NOTICE %s :SPLITMODE is currently %s", |
478 |
me.name, source_p->name, |
479 |
splitmode_status[(splitchecking + (splitmode * 2))]); |
480 |
} |
481 |
|
482 |
/* SET SPLITNUM */ |
483 |
static void |
484 |
quote_splitnum(struct Client *source_p, int newval) |
485 |
{ |
486 |
if (newval >= 0) |
487 |
{ |
488 |
sendto_realops_flags(UMODE_ALL, L_ALL, |
489 |
"%s has changed SPLITNUM to %i", |
490 |
get_oper_name(source_p), newval); |
491 |
split_servers = newval; |
492 |
|
493 |
if (splitchecking) |
494 |
check_splitmode(NULL); |
495 |
} |
496 |
else |
497 |
sendto_one(source_p, ":%s NOTICE %s :SPLITNUM is currently %i", |
498 |
me.name, source_p->name, split_servers); |
499 |
} |
500 |
|
501 |
/* SET SPLITUSERS */ |
502 |
static void |
503 |
quote_splitusers(struct Client *source_p, int newval) |
504 |
{ |
505 |
if (newval >= 0) |
506 |
{ |
507 |
sendto_realops_flags(UMODE_ALL, L_ALL, |
508 |
"%s has changed SPLITUSERS to %i", |
509 |
get_oper_name(source_p), newval); |
510 |
split_users = newval; |
511 |
|
512 |
if (splitchecking) |
513 |
check_splitmode(NULL); |
514 |
} |
515 |
else |
516 |
sendto_one(source_p, ":%s NOTICE %s :SPLITUSERS is currently %i", |
517 |
me.name, source_p->name, split_users); |
518 |
} |
519 |
|
520 |
/* SET JFLOODTIME */ |
521 |
static void |
522 |
quote_jfloodtime(struct Client *source_p, int newval) |
523 |
{ |
524 |
if (newval >= 0) |
525 |
{ |
526 |
sendto_realops_flags(UMODE_ALL, L_ALL, |
527 |
"%s has changed JFLOODTIME to %i", |
528 |
get_oper_name(source_p), newval); |
529 |
GlobalSetOptions.joinfloodtime = newval; |
530 |
} |
531 |
else |
532 |
sendto_one(source_p, ":%s NOTICE %s :JFLOODTIME is currently %i", |
533 |
me.name, source_p->name, GlobalSetOptions.joinfloodtime); |
534 |
} |
535 |
|
536 |
/* SET JFLOODCOUNT */ |
537 |
static void |
538 |
quote_jfloodcount(struct Client *source_p, int newval) |
539 |
{ |
540 |
if (newval >= 0) |
541 |
{ |
542 |
sendto_realops_flags(UMODE_ALL, L_ALL, |
543 |
"%s has changed JFLOODCOUNT to %i", |
544 |
get_oper_name(source_p), newval); |
545 |
GlobalSetOptions.joinfloodcount = newval; |
546 |
} |
547 |
else |
548 |
sendto_one(source_p, ":%s NOTICE %s :JFLOODCOUNT is currently %i", |
549 |
me.name, source_p->name, GlobalSetOptions.joinfloodcount); |
550 |
} |
551 |
|
552 |
/* SET REJECTTIME */ |
553 |
static void |
554 |
quote_rejecttime(struct Client *source_p, int newval) |
555 |
{ |
556 |
if (newval >= 0) |
557 |
{ |
558 |
sendto_realops_flags(UMODE_ALL, L_ALL, |
559 |
"%s has changed REJECTTIME to %i seconds", |
560 |
get_oper_name(source_p), newval); |
561 |
GlobalSetOptions.rejecttime = newval; |
562 |
} |
563 |
else |
564 |
sendto_one(source_p, ":%s NOTICE %s :REJECTTIME is currently %i seconds", |
565 |
me.name, source_p->name, GlobalSetOptions.rejecttime); |
566 |
} |
567 |
|
568 |
/* |
569 |
* mo_set - SET command handler |
570 |
* set options while running |
571 |
*/ |
572 |
static void |
573 |
mo_set(struct Client *client_p, struct Client *source_p, |
574 |
int parc, char *parv[]) |
575 |
{ |
576 |
int n; |
577 |
int newval; |
578 |
const char *arg = NULL; |
579 |
const char *intarg = NULL; |
580 |
const struct SetStruct *tab = set_cmd_table; |
581 |
|
582 |
if (parc > 1) |
583 |
{ |
584 |
/* |
585 |
* Go through all the commands in set_cmd_table, until one is |
586 |
* matched. |
587 |
*/ |
588 |
for (; tab->handler; ++tab) |
589 |
{ |
590 |
if (!irccmp(tab->name, parv[1])) |
591 |
{ |
592 |
/* |
593 |
* Command found; now execute the code |
594 |
*/ |
595 |
n = 2; |
596 |
|
597 |
if (tab->wants_char) |
598 |
arg = parv[n++]; |
599 |
|
600 |
if (tab->wants_int) |
601 |
intarg = parv[n++]; |
602 |
|
603 |
if ((n - 1) > parc) |
604 |
{ |
605 |
if (parc > 2) |
606 |
sendto_one(source_p, |
607 |
":%s NOTICE %s :SET %s expects (\"%s%s\") args", |
608 |
me.name, source_p->name, tab->name, |
609 |
(tab->wants_char ? "string, " : ""), |
610 |
(tab->wants_char ? "int" : "")); |
611 |
} |
612 |
|
613 |
if (parc <= 2) |
614 |
{ |
615 |
arg = NULL; |
616 |
intarg = NULL; |
617 |
} |
618 |
|
619 |
if (!strcmp(tab->name, "AUTOCONN") && (parc < 4)) |
620 |
{ |
621 |
sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS), |
622 |
me.name, source_p->name, "SET"); |
623 |
return; |
624 |
} |
625 |
|
626 |
if (tab->wants_int && (parc > 2)) |
627 |
{ |
628 |
if (intarg) |
629 |
{ |
630 |
if (irccmp(intarg, "yes") == 0 || irccmp(intarg, "on") == 0) |
631 |
newval = 1; |
632 |
else if (irccmp(intarg, "no") == 0|| irccmp(intarg, "off") == 0) |
633 |
newval = 0; |
634 |
else |
635 |
newval = atoi(intarg); |
636 |
} |
637 |
else |
638 |
{ |
639 |
newval = -1; |
640 |
} |
641 |
|
642 |
if (newval < 0) |
643 |
{ |
644 |
sendto_one(source_p, |
645 |
":%s NOTICE %s :Value less than 0 illegal for %s", |
646 |
me.name, source_p->name, |
647 |
tab->name); |
648 |
|
649 |
return; |
650 |
} |
651 |
} |
652 |
else |
653 |
newval = -1; |
654 |
|
655 |
if (tab->wants_char) |
656 |
{ |
657 |
if (tab->wants_int) |
658 |
tab->handler(source_p, arg, newval); |
659 |
else |
660 |
tab->handler(source_p, arg); |
661 |
return; |
662 |
} |
663 |
else |
664 |
{ |
665 |
if (tab->wants_int) |
666 |
tab->handler(source_p, newval); |
667 |
else |
668 |
/* Just in case someone actually wants a |
669 |
* set function that takes no args.. *shrug* */ |
670 |
tab->handler(source_p); |
671 |
return; |
672 |
} |
673 |
} |
674 |
} |
675 |
|
676 |
/* |
677 |
* Code here will be executed when a /QUOTE SET command is not |
678 |
* found within set_cmd_table. |
679 |
*/ |
680 |
sendto_one(source_p, ":%s NOTICE %s :Variable not found.", |
681 |
me.name, source_p->name); |
682 |
return; |
683 |
} |
684 |
|
685 |
list_quote_commands(source_p); |
686 |
} |