41 |
|
static void |
42 |
|
quote_autoconn(struct Client *source_p, const char *arg, int newval) |
43 |
|
{ |
44 |
< |
if (arg != NULL) |
44 |
> |
if (arg) |
45 |
|
{ |
46 |
|
struct MaskItem *conf = find_exact_name_conf(CONF_SERVER, NULL, arg, NULL, NULL); |
47 |
|
|
48 |
< |
if (conf != NULL) |
48 |
> |
if (conf) |
49 |
|
{ |
50 |
|
if (newval) |
51 |
|
SetConfAllowAutoConn(conf); |
59 |
|
arg, newval); |
60 |
|
} |
61 |
|
else |
62 |
– |
{ |
62 |
|
sendto_one_notice(source_p, &me, ":Cannot find %s", arg); |
64 |
– |
} |
63 |
|
} |
64 |
|
else |
67 |
– |
{ |
65 |
|
sendto_one_notice(source_p, &me, ":Please specify a server name!"); |
69 |
– |
} |
66 |
|
} |
67 |
|
|
68 |
|
/* SET AUTOCONNALL */ |
69 |
|
static void |
70 |
< |
quote_autoconnall(struct Client *source_p, int newval) |
70 |
> |
quote_autoconnall(struct Client *source_p, const char *arg, int newval) |
71 |
|
{ |
72 |
|
if (newval >= 0) |
73 |
|
{ |
84 |
|
|
85 |
|
/* SET FLOODCOUNT */ |
86 |
|
static void |
87 |
< |
quote_floodcount(struct Client *source_p, int newval) |
87 |
> |
quote_floodcount(struct Client *source_p, const char *arg, int newval) |
88 |
|
{ |
89 |
|
if (newval >= 0) |
90 |
|
{ |
100 |
|
|
101 |
|
/* SET IDENTTIMEOUT */ |
102 |
|
static void |
103 |
< |
quote_identtimeout(struct Client *source_p, int newval) |
103 |
> |
quote_identtimeout(struct Client *source_p, const char *arg, int newval) |
104 |
|
{ |
105 |
|
if (!HasUMode(source_p, UMODE_ADMIN)) |
106 |
|
{ |
122 |
|
|
123 |
|
/* SET MAX */ |
124 |
|
static void |
125 |
< |
quote_max(struct Client *source_p, int newval) |
125 |
> |
quote_max(struct Client *source_p, const char *arg, int newval) |
126 |
|
{ |
127 |
|
if (newval > 0) |
128 |
|
{ |
153 |
|
|
154 |
|
/* SET SPAMNUM */ |
155 |
|
static void |
156 |
< |
quote_spamnum(struct Client *source_p, int newval) |
156 |
> |
quote_spamnum(struct Client *source_p, const char *arg, int newval) |
157 |
|
{ |
158 |
|
if (newval >= 0) |
159 |
|
{ |
177 |
|
|
178 |
|
/* SET SPAMTIME */ |
179 |
|
static void |
180 |
< |
quote_spamtime(struct Client *source_p, int newval) |
180 |
> |
quote_spamtime(struct Client *source_p, const char *arg, int newval) |
181 |
|
{ |
182 |
|
if (newval > 0) |
183 |
|
{ |
212 |
|
|
213 |
|
/* SET SPLITMODE */ |
214 |
|
static void |
215 |
< |
quote_splitmode(struct Client *source_p, char *charval) |
215 |
> |
quote_splitmode(struct Client *source_p, const char *charval, int val) |
216 |
|
{ |
217 |
|
if (charval) |
218 |
|
{ |
219 |
|
int newval; |
220 |
|
|
221 |
|
for (newval = 0; splitmode_values[newval]; ++newval) |
222 |
< |
if (irccmp(splitmode_values[newval], charval) == 0) |
222 |
> |
if (!irccmp(splitmode_values[newval], charval)) |
223 |
|
break; |
224 |
|
|
225 |
|
/* OFF */ |
269 |
|
|
270 |
|
/* SET SPLITNUM */ |
271 |
|
static void |
272 |
< |
quote_splitnum(struct Client *source_p, int newval) |
272 |
> |
quote_splitnum(struct Client *source_p, const char *arg, int newval) |
273 |
|
{ |
274 |
|
if (newval >= 0) |
275 |
|
{ |
288 |
|
|
289 |
|
/* SET SPLITUSERS */ |
290 |
|
static void |
291 |
< |
quote_splitusers(struct Client *source_p, int newval) |
291 |
> |
quote_splitusers(struct Client *source_p, const char *arg, int newval) |
292 |
|
{ |
293 |
|
if (newval >= 0) |
294 |
|
{ |
307 |
|
|
308 |
|
/* SET JFLOODTIME */ |
309 |
|
static void |
310 |
< |
quote_jfloodtime(struct Client *source_p, int newval) |
310 |
> |
quote_jfloodtime(struct Client *source_p, const char *arg, int newval) |
311 |
|
{ |
312 |
|
if (newval >= 0) |
313 |
|
{ |
323 |
|
|
324 |
|
/* SET JFLOODCOUNT */ |
325 |
|
static void |
326 |
< |
quote_jfloodcount(struct Client *source_p, int newval) |
326 |
> |
quote_jfloodcount(struct Client *source_p, const char *arg, int newval) |
327 |
|
{ |
328 |
|
if (newval >= 0) |
329 |
|
{ |
341 |
|
struct SetStruct |
342 |
|
{ |
343 |
|
const char *name; |
344 |
< |
void (*handler)(); |
344 |
> |
void (*handler)(struct Client *, const char *, int); |
345 |
|
const int wants_char; /* 1 if it expects (char *, [int]) */ |
346 |
|
const int wants_int; /* 1 if it expects ([char *], int) */ |
347 |
|
/* eg: 0, 1 == only an int arg |
417 |
|
{ |
418 |
|
int n; |
419 |
|
int newval; |
420 |
< |
const char *arg = NULL; |
420 |
> |
const char *strarg = NULL; |
421 |
|
const char *intarg = NULL; |
422 |
|
|
423 |
|
if (!HasOFlag(source_p, OPER_FLAG_SET)) |
435 |
|
for (const struct SetStruct *tab = set_cmd_table; tab->handler; ++tab) |
436 |
|
{ |
437 |
|
if (!irccmp(tab->name, parv[1])) |
438 |
< |
{ |
443 |
< |
/* |
444 |
< |
* Command found; now execute the code |
445 |
< |
*/ |
446 |
< |
n = 2; |
438 |
> |
continue; |
439 |
|
|
440 |
< |
if (tab->wants_char) |
441 |
< |
arg = parv[n++]; |
440 |
> |
/* |
441 |
> |
* Command found; now execute the code |
442 |
> |
*/ |
443 |
> |
n = 2; |
444 |
|
|
445 |
< |
if (tab->wants_int) |
446 |
< |
intarg = parv[n++]; |
445 |
> |
if (tab->wants_char) |
446 |
> |
strarg = parv[n++]; |
447 |
|
|
448 |
< |
if ((n - 1) > parc) |
449 |
< |
{ |
456 |
< |
if (parc > 2) |
457 |
< |
sendto_one_notice(source_p, &me, ":SET %s expects (\"%s%s\") args", tab->name, |
458 |
< |
(tab->wants_char ? "string, " : ""), |
459 |
< |
(tab->wants_char ? "int" : "")); |
460 |
< |
} |
448 |
> |
if (tab->wants_int) |
449 |
> |
intarg = parv[n++]; |
450 |
|
|
451 |
< |
if (parc <= 2) |
452 |
< |
{ |
453 |
< |
arg = NULL; |
454 |
< |
intarg = NULL; |
466 |
< |
} |
451 |
> |
if ((n - 1) > parc) |
452 |
> |
sendto_one_notice(source_p, &me, ":SET %s expects (\"%s%s\") args", tab->name, |
453 |
> |
(tab->wants_char ? "string, " : ""), |
454 |
> |
(tab->wants_int ? "int" : "")); |
455 |
|
|
456 |
< |
if (!strcmp(tab->name, "AUTOCONN") && (parc < 4)) |
457 |
< |
{ |
458 |
< |
sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, "SET"); |
459 |
< |
return 0; |
460 |
< |
} |
456 |
> |
if (parc <= 2) |
457 |
> |
{ |
458 |
> |
strarg = NULL; |
459 |
> |
intarg = NULL; |
460 |
> |
} |
461 |
> |
/* XXX */ |
462 |
> |
if (!strcmp(tab->name, "AUTOCONN") && parc < 4) |
463 |
> |
{ |
464 |
> |
sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, "SET"); |
465 |
> |
return 0; |
466 |
> |
} |
467 |
|
|
468 |
< |
if (tab->wants_int && (parc > 2)) |
468 |
> |
if (tab->wants_int && parc > 2) |
469 |
> |
{ |
470 |
> |
if (intarg) |
471 |
|
{ |
472 |
< |
if (intarg) |
473 |
< |
{ |
474 |
< |
if (irccmp(intarg, "yes") == 0 || irccmp(intarg, "on") == 0) |
475 |
< |
newval = 1; |
480 |
< |
else if (irccmp(intarg, "no") == 0|| irccmp(intarg, "off") == 0) |
481 |
< |
newval = 0; |
482 |
< |
else |
483 |
< |
newval = atoi(intarg); |
484 |
< |
} |
472 |
> |
if (!irccmp(intarg, "yes") || !irccmp(intarg, "on")) |
473 |
> |
newval = 1; |
474 |
> |
else if (!irccmp(intarg, "no")|| !irccmp(intarg, "off")) |
475 |
> |
newval = 0; |
476 |
|
else |
477 |
< |
newval = -1; |
487 |
< |
|
488 |
< |
if (newval < 0) |
489 |
< |
{ |
490 |
< |
sendto_one_notice(source_p, &me, ":Value less than 0 illegal for %s", |
491 |
< |
tab->name); |
492 |
< |
|
493 |
< |
return 0; |
494 |
< |
} |
477 |
> |
newval = atoi(intarg); |
478 |
|
} |
479 |
|
else |
480 |
|
newval = -1; |
481 |
|
|
482 |
< |
if (tab->wants_char) |
482 |
> |
if (newval < 0) |
483 |
|
{ |
484 |
< |
if (tab->wants_int) |
485 |
< |
tab->handler(source_p, arg, newval); |
503 |
< |
else |
504 |
< |
tab->handler(source_p, arg); |
505 |
< |
return 0; |
506 |
< |
} |
507 |
< |
else |
508 |
< |
{ |
509 |
< |
if (tab->wants_int) |
510 |
< |
tab->handler(source_p, newval); |
511 |
< |
else |
512 |
< |
/* Just in case someone actually wants a |
513 |
< |
* set function that takes no args.. *shrug* */ |
514 |
< |
tab->handler(source_p); |
484 |
> |
sendto_one_notice(source_p, &me, ":Value less than 0 illegal for %s", |
485 |
> |
tab->name); |
486 |
|
return 0; |
487 |
|
} |
488 |
|
} |
489 |
+ |
else |
490 |
+ |
newval = -1; |
491 |
+ |
|
492 |
+ |
tab->handler(source_p, strarg, newval); |
493 |
+ |
return 0; |
494 |
|
} |
495 |
|
|
496 |
|
/* |