| 49 |
|
|
| 50 |
|
struct Message set_msgtab = { |
| 51 |
|
"SET", 0, 0, 0, 0, MFLG_SLOW, 0, |
| 52 |
< |
{m_unregistered, m_not_oper, m_error, m_ignore, mo_set, m_ignore} |
| 52 |
> |
{m_unregistered, m_not_oper, rfc1459_command_send_error, m_ignore, mo_set, m_ignore} |
| 53 |
|
}; |
| 54 |
|
|
| 55 |
|
#ifndef STATIC_MODULES |
| 73 |
|
{ |
| 74 |
|
const char *name; |
| 75 |
|
void (*handler)(); |
| 76 |
< |
int wants_char; /* 1 if it expects (char *, [int]) */ |
| 77 |
< |
int wants_int; /* 1 if it expects ([char *], int) */ |
| 76 |
> |
const int wants_char; /* 1 if it expects (char *, [int]) */ |
| 77 |
> |
const int wants_int; /* 1 if it expects ([char *], int) */ |
| 78 |
|
/* eg: 0, 1 == only an int arg |
| 79 |
|
* eg: 1, 1 == char and int args */ |
| 80 |
|
}; |
| 105 |
|
* -davidt |
| 106 |
|
*/ |
| 107 |
|
|
| 108 |
< |
static struct SetStruct set_cmd_table[] = |
| 108 |
> |
static const struct SetStruct set_cmd_table[] = |
| 109 |
|
{ |
| 110 |
|
/* name function string arg int arg */ |
| 111 |
|
/* -------------------------------------------------------- */ |
| 126 |
|
{ "JFLOODCOUNT", quote_jfloodcount, 0, 1 }, |
| 127 |
|
{ "REJECTTIME", quote_rejecttime, 0, 1 }, |
| 128 |
|
/* -------------------------------------------------------- */ |
| 129 |
< |
{ NULL, NULL, 0, 0 } |
| 129 |
> |
{ NULL, NULL, 0, 0 } |
| 130 |
|
}; |
| 131 |
|
|
| 132 |
|
/* |
| 136 |
|
static void |
| 137 |
|
list_quote_commands(struct Client *source_p) |
| 138 |
|
{ |
| 139 |
– |
int i; |
| 139 |
|
int j = 0; |
| 140 |
< |
const char *names[4]; |
| 140 |
> |
const struct SetStruct *tab = set_cmd_table; |
| 141 |
> |
const char *names[4] = { "", "", "", "" }; |
| 142 |
|
|
| 143 |
|
sendto_one(source_p, ":%s NOTICE %s :Available QUOTE SET commands:", |
| 144 |
|
me.name, source_p->name); |
| 145 |
|
|
| 146 |
< |
names[0] = names[1] = names[2] = names[3] = ""; |
| 147 |
< |
|
| 148 |
< |
for (i = 0; set_cmd_table[i].handler; i++) |
| 146 |
> |
for (; tab->handler; ++tab) |
| 147 |
|
{ |
| 148 |
< |
names[j++] = set_cmd_table[i].name; |
| 148 |
> |
names[j++] = tab->name; |
| 149 |
|
|
| 150 |
|
if (j > 3) |
| 151 |
|
{ |
| 158 |
|
} |
| 159 |
|
|
| 160 |
|
} |
| 161 |
+ |
|
| 162 |
|
if (j) |
| 163 |
|
sendto_one(source_p, ":%s NOTICE %s :%s %s %s %s", |
| 164 |
|
me.name, source_p->name, |
| 170 |
|
static void |
| 171 |
|
quote_autoconn(struct Client *source_p, const char *arg, int newval) |
| 172 |
|
{ |
| 173 |
< |
set_autoconn(source_p, arg, newval); |
| 173 |
> |
struct AccessItem *aconf; |
| 174 |
> |
|
| 175 |
> |
if (arg != NULL) |
| 176 |
> |
{ |
| 177 |
> |
struct ConfItem *conf = find_exact_name_conf(SERVER_TYPE, arg, NULL, NULL); |
| 178 |
> |
|
| 179 |
> |
if (conf != NULL) |
| 180 |
> |
{ |
| 181 |
> |
aconf = map_to_conf(conf); |
| 182 |
> |
if (newval) |
| 183 |
> |
SetConfAllowAutoConn(aconf); |
| 184 |
> |
else |
| 185 |
> |
ClearConfAllowAutoConn(aconf); |
| 186 |
> |
|
| 187 |
> |
sendto_realops_flags(UMODE_ALL, L_ALL, |
| 188 |
> |
"%s has changed AUTOCONN for %s to %i", |
| 189 |
> |
source_p->name, arg, newval); |
| 190 |
> |
sendto_one(source_p, |
| 191 |
> |
":%s NOTICE %s :AUTOCONN for %s is now set to %i", |
| 192 |
> |
me.name, source_p->name, arg, newval); |
| 193 |
> |
} |
| 194 |
> |
else |
| 195 |
> |
{ |
| 196 |
> |
sendto_one(source_p, ":%s NOTICE %s :Can't find %s", |
| 197 |
> |
me.name, source_p->name, arg); |
| 198 |
> |
} |
| 199 |
> |
} |
| 200 |
> |
else |
| 201 |
> |
{ |
| 202 |
> |
sendto_one(source_p, ":%s NOTICE %s :Please specify a server name!", |
| 203 |
> |
me.name, source_p->name); |
| 204 |
> |
} |
| 205 |
|
} |
| 206 |
|
|
| 207 |
|
/* SET AUTOCONNALL */ |
| 289 |
|
|
| 290 |
|
/* SET LOG */ |
| 291 |
|
static void |
| 292 |
< |
quote_log( struct Client *source_p, int newval ) |
| 292 |
> |
quote_log(struct Client *source_p, int newval) |
| 293 |
|
{ |
| 264 |
– |
const char *log_level_as_string; |
| 265 |
– |
|
| 294 |
|
if (newval >= 0) |
| 295 |
|
{ |
| 296 |
|
if (newval < L_WARN) |
| 301 |
|
} |
| 302 |
|
|
| 303 |
|
if (newval > L_DEBUG) |
| 276 |
– |
{ |
| 304 |
|
newval = L_DEBUG; |
| 278 |
– |
} |
| 305 |
|
|
| 306 |
|
set_log_level(newval); |
| 281 |
– |
log_level_as_string = get_log_level_as_string(newval); |
| 307 |
|
sendto_realops_flags(UMODE_ALL, L_ALL,"%s has changed LOG level to %i (%s)", |
| 308 |
< |
source_p->name, newval, log_level_as_string); |
| 308 |
> |
source_p->name, get_log_level(), |
| 309 |
> |
get_log_level_as_string(get_log_level())); |
| 310 |
|
} |
| 311 |
|
else |
| 286 |
– |
{ |
| 312 |
|
sendto_one(source_p, ":%s NOTICE %s :LOG level is currently %i (%s)", |
| 313 |
|
me.name, source_p->name, get_log_level(), |
| 314 |
|
get_log_level_as_string(get_log_level())); |
| 290 |
– |
} |
| 315 |
|
} |
| 316 |
|
|
| 317 |
|
/* SET MAX */ |
| 318 |
|
static void |
| 319 |
< |
quote_max (struct Client *source_p, int newval) |
| 319 |
> |
quote_max(struct Client *source_p, int newval) |
| 320 |
|
{ |
| 321 |
|
if (newval > 0) |
| 322 |
|
{ |
| 352 |
|
|
| 353 |
|
/* SET MSGLOCALE */ |
| 354 |
|
static void |
| 355 |
< |
quote_msglocale( struct Client *source_p, char *locale ) |
| 355 |
> |
quote_msglocale(struct Client *source_p, char *locale) |
| 356 |
|
{ |
| 357 |
|
if (locale != NULL) |
| 358 |
|
{ |
| 368 |
|
|
| 369 |
|
/* SET SPAMNUM */ |
| 370 |
|
static void |
| 371 |
< |
quote_spamnum( struct Client *source_p, int newval ) |
| 371 |
> |
quote_spamnum(struct Client *source_p, int newval) |
| 372 |
|
{ |
| 373 |
< |
if (newval > 0) |
| 373 |
> |
if (newval >= 0) |
| 374 |
|
{ |
| 375 |
|
if (newval == 0) |
| 376 |
|
{ |
| 381 |
|
} |
| 382 |
|
|
| 383 |
|
GlobalSetOptions.spam_num = IRCD_MAX(newval, MIN_SPAM_NUM); |
| 360 |
– |
|
| 384 |
|
sendto_realops_flags(UMODE_ALL, L_ALL,"%s has changed SPAMNUM to %i", |
| 385 |
< |
source_p->name, GlobalSetOptions.spam_num); |
| 385 |
> |
source_p->name, GlobalSetOptions.spam_num); |
| 386 |
|
} |
| 387 |
|
else |
| 388 |
|
sendto_one(source_p, ":%s NOTICE %s :SPAMNUM is currently %i", |
| 389 |
< |
me.name, |
| 367 |
< |
source_p->name, GlobalSetOptions.spam_num); |
| 389 |
> |
me.name, source_p->name, GlobalSetOptions.spam_num); |
| 390 |
|
} |
| 391 |
|
|
| 392 |
|
/* SET SPAMTIME */ |
| 393 |
|
static void |
| 394 |
< |
quote_spamtime( struct Client *source_p, int newval ) |
| 394 |
> |
quote_spamtime(struct Client *source_p, int newval) |
| 395 |
|
{ |
| 396 |
|
if (newval > 0) |
| 397 |
|
{ |
| 398 |
|
GlobalSetOptions.spam_time = IRCD_MAX(newval, MIN_SPAM_TIME); |
| 399 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, "%s has changed SPAMTIME to %i", |
| 400 |
< |
source_p->name, GlobalSetOptions.spam_time); |
| 400 |
> |
source_p->name, GlobalSetOptions.spam_time); |
| 401 |
|
} |
| 402 |
|
else |
| 403 |
|
sendto_one(source_p, ":%s NOTICE %s :SPAMTIME is currently %i", |
| 404 |
< |
me.name, |
| 383 |
< |
source_p->name, GlobalSetOptions.spam_time); |
| 404 |
> |
me.name, source_p->name, GlobalSetOptions.spam_time); |
| 405 |
|
} |
| 406 |
|
|
| 407 |
|
/* this table is what splitmode may be set to */ |
| 431 |
|
{ |
| 432 |
|
int newval; |
| 433 |
|
|
| 434 |
< |
for (newval = 0; splitmode_values[newval]; newval++) |
| 414 |
< |
{ |
| 434 |
> |
for (newval = 0; splitmode_values[newval]; ++newval) |
| 435 |
|
if (irccmp(splitmode_values[newval], charval) == 0) |
| 436 |
|
break; |
| 417 |
– |
} |
| 437 |
|
|
| 438 |
|
/* OFF */ |
| 439 |
|
if (newval == 0) |
| 575 |
|
mo_set(struct Client *client_p, struct Client *source_p, |
| 576 |
|
int parc, char *parv[]) |
| 577 |
|
{ |
| 559 |
– |
int i; |
| 578 |
|
int n; |
| 579 |
|
int newval; |
| 580 |
|
const char *arg = NULL; |
| 581 |
|
const char *intarg = NULL; |
| 582 |
+ |
const struct SetStruct *tab = set_cmd_table; |
| 583 |
|
|
| 584 |
|
if (parc > 1) |
| 585 |
|
{ |
| 586 |
< |
/* Go through all the commands in set_cmd_table, until one is |
| 587 |
< |
* matched. I realize strcmp() is more intensive than a numeric |
| 588 |
< |
* lookup, but at least it's better than a big-ass switch/case |
| 570 |
< |
* statement. |
| 586 |
> |
/* |
| 587 |
> |
* Go through all the commands in set_cmd_table, until one is |
| 588 |
> |
* matched. |
| 589 |
|
*/ |
| 590 |
< |
for (i = 0; set_cmd_table[i].handler; i++) |
| 590 |
> |
for (; tab->handler; ++tab) |
| 591 |
|
{ |
| 592 |
< |
if (irccmp(set_cmd_table[i].name, parv[1]) == 0) |
| 592 |
> |
if (!irccmp(tab->name, parv[1])) |
| 593 |
|
{ |
| 594 |
|
/* |
| 595 |
|
* Command found; now execute the code |
| 596 |
|
*/ |
| 597 |
|
n = 2; |
| 598 |
|
|
| 599 |
< |
if (set_cmd_table[i].wants_char) |
| 582 |
< |
{ |
| 599 |
> |
if (tab->wants_char) |
| 600 |
|
arg = parv[n++]; |
| 584 |
– |
} |
| 601 |
|
|
| 602 |
< |
if (set_cmd_table[i].wants_int) |
| 587 |
< |
{ |
| 602 |
> |
if (tab->wants_int) |
| 603 |
|
intarg = parv[n++]; |
| 589 |
– |
} |
| 604 |
|
|
| 605 |
|
if ((n - 1) > parc) |
| 606 |
|
{ |
| 607 |
|
if (parc > 2) |
| 608 |
|
sendto_one(source_p, |
| 609 |
|
":%s NOTICE %s :SET %s expects (\"%s%s\") args", |
| 610 |
< |
me.name, source_p->name, set_cmd_table[i].name, |
| 611 |
< |
(set_cmd_table[i].wants_char ? "string, " : ""), |
| 612 |
< |
(set_cmd_table[i].wants_char ? "int" : "") |
| 599 |
< |
); |
| 610 |
> |
me.name, source_p->name, tab->name, |
| 611 |
> |
(tab->wants_char ? "string, " : ""), |
| 612 |
> |
(tab->wants_char ? "int" : "")); |
| 613 |
|
} |
| 614 |
|
|
| 615 |
|
if (parc <= 2) |
| 618 |
|
intarg = NULL; |
| 619 |
|
} |
| 620 |
|
|
| 621 |
< |
if (!strcmp(set_cmd_table[i].name, "AUTOCONN") && (parc < 4)) |
| 621 |
> |
if (!strcmp(tab->name, "AUTOCONN") && (parc < 4)) |
| 622 |
|
{ |
| 623 |
|
sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS), |
| 624 |
|
me.name, source_p->name, "SET"); |
| 625 |
|
return; |
| 626 |
|
} |
| 627 |
|
|
| 628 |
< |
if (set_cmd_table[i].wants_int && (parc > 2)) |
| 628 |
> |
if (tab->wants_int && (parc > 2)) |
| 629 |
|
{ |
| 630 |
|
if (intarg) |
| 631 |
|
{ |
| 646 |
|
sendto_one(source_p, |
| 647 |
|
":%s NOTICE %s :Value less than 0 illegal for %s", |
| 648 |
|
me.name, source_p->name, |
| 649 |
< |
set_cmd_table[i].name); |
| 649 |
> |
tab->name); |
| 650 |
|
|
| 651 |
|
return; |
| 652 |
|
} |
| 654 |
|
else |
| 655 |
|
newval = -1; |
| 656 |
|
|
| 657 |
< |
if (set_cmd_table[i].wants_char) |
| 657 |
> |
if (tab->wants_char) |
| 658 |
|
{ |
| 659 |
< |
if (set_cmd_table[i].wants_int) |
| 660 |
< |
set_cmd_table[i].handler(source_p, arg, newval); |
| 659 |
> |
if (tab->wants_int) |
| 660 |
> |
tab->handler(source_p, arg, newval); |
| 661 |
|
else |
| 662 |
< |
set_cmd_table[i].handler(source_p, arg); |
| 662 |
> |
tab->handler(source_p, arg); |
| 663 |
|
return; |
| 664 |
|
} |
| 665 |
|
else |
| 666 |
|
{ |
| 667 |
< |
if (set_cmd_table[i].wants_int) |
| 668 |
< |
set_cmd_table[i].handler(source_p, newval); |
| 667 |
> |
if (tab->wants_int) |
| 668 |
> |
tab->handler(source_p, newval); |
| 669 |
|
else |
| 670 |
|
/* Just in case someone actually wants a |
| 671 |
|
* set function that takes no args.. *shrug* */ |
| 672 |
< |
set_cmd_table[i].handler(source_p); |
| 672 |
> |
tab->handler(source_p); |
| 673 |
|
return; |
| 674 |
|
} |
| 675 |
|
} |
| 686 |
|
|
| 687 |
|
list_quote_commands(source_p); |
| 688 |
|
} |
| 676 |
– |
|