| 25 |
|
/* rewritten by jdc */ |
| 26 |
|
|
| 27 |
|
#include "stdinc.h" |
| 28 |
– |
#include "handlers.h" |
| 28 |
|
#include "client.h" |
| 29 |
|
#include "event.h" |
| 30 |
|
#include "irc_string.h" |
| 34 |
|
#include "s_bsd.h" |
| 35 |
|
#include "s_serv.h" |
| 36 |
|
#include "send.h" |
| 38 |
– |
#include "common.h" /* for NO */ |
| 37 |
|
#include "channel.h" |
| 38 |
< |
#include "s_log.h" |
| 41 |
< |
#include "s_conf.h" |
| 42 |
< |
#include "msg.h" |
| 38 |
> |
#include "conf.h" |
| 39 |
|
#include "parse.h" |
| 40 |
|
#include "modules.h" |
| 41 |
|
#include "s_user.h" |
| 42 |
+ |
#include "s_misc.h" |
| 43 |
|
|
| 44 |
|
|
| 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, m_error, m_ignore, mo_set, m_ignore} |
| 53 |
– |
}; |
| 54 |
– |
|
| 55 |
– |
#ifndef STATIC_MODULES |
| 56 |
– |
void |
| 57 |
– |
_modinit(void) |
| 58 |
– |
{ |
| 59 |
– |
mod_add_cmd(&set_msgtab); |
| 60 |
– |
} |
| 61 |
– |
|
| 62 |
– |
void |
| 63 |
– |
_moddeinit(void) |
| 64 |
– |
{ |
| 65 |
– |
mod_del_cmd(&set_msgtab); |
| 66 |
– |
} |
| 67 |
– |
|
| 68 |
– |
const char *_version = "$Revision$"; |
| 69 |
– |
#endif |
| 70 |
– |
|
| 45 |
|
/* Structure used for the SET table itself */ |
| 46 |
|
struct SetStruct |
| 47 |
|
{ |
| 48 |
|
const char *name; |
| 49 |
|
void (*handler)(); |
| 50 |
< |
int wants_char; /* 1 if it expects (char *, [int]) */ |
| 51 |
< |
int wants_int; /* 1 if it expects ([char *], int) */ |
| 50 |
> |
const int wants_char; /* 1 if it expects (char *, [int]) */ |
| 51 |
> |
const int wants_int; /* 1 if it expects ([char *], int) */ |
| 52 |
|
/* eg: 0, 1 == only an int arg |
| 53 |
|
* eg: 1, 1 == char and int args */ |
| 54 |
|
}; |
| 57 |
|
static void quote_autoconnall(struct Client *, int); |
| 58 |
|
static void quote_floodcount(struct Client *, int); |
| 59 |
|
static void quote_identtimeout(struct Client *, int); |
| 86 |
– |
static void quote_idletime(struct Client *, int); |
| 87 |
– |
static void quote_log(struct Client *, int); |
| 60 |
|
static void quote_max(struct Client *, int); |
| 61 |
|
static void quote_msglocale(struct Client *, char *); |
| 62 |
|
static void quote_spamnum(struct Client *, int); |
| 67 |
|
static void list_quote_commands(struct Client *); |
| 68 |
|
static void quote_jfloodtime(struct Client *, int); |
| 69 |
|
static void quote_jfloodcount(struct Client *, int); |
| 98 |
– |
static void quote_rejecttime(struct Client *, int); |
| 70 |
|
|
| 71 |
|
/* |
| 72 |
|
* If this ever needs to be expanded to more than one arg of each |
| 76 |
|
* -davidt |
| 77 |
|
*/ |
| 78 |
|
|
| 79 |
< |
static struct SetStruct set_cmd_table[] = |
| 79 |
> |
static const struct SetStruct set_cmd_table[] = |
| 80 |
|
{ |
| 81 |
|
/* name function string arg int arg */ |
| 82 |
|
/* -------------------------------------------------------- */ |
| 84 |
|
{ "AUTOCONNALL", quote_autoconnall, 0, 1 }, |
| 85 |
|
{ "FLOODCOUNT", quote_floodcount, 0, 1 }, |
| 86 |
|
{ "IDENTTIMEOUT", quote_identtimeout, 0, 1 }, |
| 116 |
– |
{ "IDLETIME", quote_idletime, 0, 1 }, |
| 117 |
– |
{ "LOG", quote_log, 0, 1 }, |
| 87 |
|
{ "MAX", quote_max, 0, 1 }, |
| 88 |
|
{ "MSGLOCALE", quote_msglocale, 1, 0 }, |
| 89 |
|
{ "SPAMNUM", quote_spamnum, 0, 1 }, |
| 93 |
|
{ "SPLITUSERS", quote_splitusers, 0, 1 }, |
| 94 |
|
{ "JFLOODTIME", quote_jfloodtime, 0, 1 }, |
| 95 |
|
{ "JFLOODCOUNT", quote_jfloodcount, 0, 1 }, |
| 127 |
– |
{ "REJECTTIME", quote_rejecttime, 0, 1 }, |
| 96 |
|
/* -------------------------------------------------------- */ |
| 97 |
< |
{ NULL, NULL, 0, 0 } |
| 97 |
> |
{ NULL, NULL, 0, 0 } |
| 98 |
|
}; |
| 99 |
|
|
| 100 |
|
/* |
| 104 |
|
static void |
| 105 |
|
list_quote_commands(struct Client *source_p) |
| 106 |
|
{ |
| 139 |
– |
int i; |
| 107 |
|
int j = 0; |
| 108 |
< |
const char *names[4]; |
| 108 |
> |
const struct SetStruct *tab = set_cmd_table; |
| 109 |
> |
const char *names[4] = { "", "", "", "" }; |
| 110 |
|
|
| 111 |
|
sendto_one(source_p, ":%s NOTICE %s :Available QUOTE SET commands:", |
| 112 |
|
me.name, source_p->name); |
| 113 |
|
|
| 114 |
< |
names[0] = names[1] = names[2] = names[3] = ""; |
| 147 |
< |
|
| 148 |
< |
for (i = 0; set_cmd_table[i].handler; i++) |
| 114 |
> |
for (; tab->handler; ++tab) |
| 115 |
|
{ |
| 116 |
< |
names[j++] = set_cmd_table[i].name; |
| 116 |
> |
names[j++] = tab->name; |
| 117 |
|
|
| 118 |
|
if (j > 3) |
| 119 |
|
{ |
| 126 |
|
} |
| 127 |
|
|
| 128 |
|
} |
| 129 |
+ |
|
| 130 |
|
if (j) |
| 131 |
|
sendto_one(source_p, ":%s NOTICE %s :%s %s %s %s", |
| 132 |
|
me.name, source_p->name, |
| 138 |
|
static void |
| 139 |
|
quote_autoconn(struct Client *source_p, const char *arg, int newval) |
| 140 |
|
{ |
| 141 |
< |
set_autoconn(source_p, arg, newval); |
| 141 |
> |
struct AccessItem *aconf; |
| 142 |
> |
|
| 143 |
> |
if (arg != NULL) |
| 144 |
> |
{ |
| 145 |
> |
struct ConfItem *conf = find_exact_name_conf(SERVER_TYPE, NULL, arg, NULL, NULL); |
| 146 |
> |
|
| 147 |
> |
if (conf != NULL) |
| 148 |
> |
{ |
| 149 |
> |
aconf = map_to_conf(conf); |
| 150 |
> |
if (newval) |
| 151 |
> |
SetConfAllowAutoConn(aconf); |
| 152 |
> |
else |
| 153 |
> |
ClearConfAllowAutoConn(aconf); |
| 154 |
> |
|
| 155 |
> |
sendto_realops_flags(UMODE_ALL, L_ALL, |
| 156 |
> |
"%s has changed AUTOCONN for %s to %i", |
| 157 |
> |
get_oper_name(source_p), arg, newval); |
| 158 |
> |
sendto_one(source_p, |
| 159 |
> |
":%s NOTICE %s :AUTOCONN for %s is now set to %i", |
| 160 |
> |
me.name, source_p->name, arg, newval); |
| 161 |
> |
} |
| 162 |
> |
else |
| 163 |
> |
{ |
| 164 |
> |
sendto_one(source_p, ":%s NOTICE %s :Can't find %s", |
| 165 |
> |
me.name, source_p->name, arg); |
| 166 |
> |
} |
| 167 |
> |
} |
| 168 |
> |
else |
| 169 |
> |
{ |
| 170 |
> |
sendto_one(source_p, ":%s NOTICE %s :Please specify a server name!", |
| 171 |
> |
me.name, source_p->name); |
| 172 |
> |
} |
| 173 |
|
} |
| 174 |
|
|
| 175 |
|
/* SET AUTOCONNALL */ |
| 179 |
|
if (newval >= 0) |
| 180 |
|
{ |
| 181 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, "%s has changed AUTOCONNALL to %i", |
| 182 |
< |
source_p->name, newval); |
| 182 |
> |
get_oper_name(source_p), newval); |
| 183 |
|
|
| 184 |
|
GlobalSetOptions.autoconn = newval; |
| 185 |
|
} |
| 196 |
|
{ |
| 197 |
|
GlobalSetOptions.floodcount = newval; |
| 198 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, |
| 199 |
< |
"%s has changed FLOODCOUNT to %i", source_p->name, |
| 200 |
< |
GlobalSetOptions.floodcount); |
| 199 |
> |
"%s has changed FLOODCOUNT to %i", |
| 200 |
> |
get_oper_name(source_p), GlobalSetOptions.floodcount); |
| 201 |
|
} |
| 202 |
|
else |
| 203 |
|
sendto_one(source_p, ":%s NOTICE %s :FLOODCOUNT is currently %i", |
| 208 |
|
static void |
| 209 |
|
quote_identtimeout(struct Client *source_p, int newval) |
| 210 |
|
{ |
| 211 |
< |
if (!IsAdmin(source_p)) |
| 211 |
> |
if (!HasUMode(source_p, UMODE_ADMIN)) |
| 212 |
|
{ |
| 213 |
|
sendto_one(source_p, form_str(ERR_NOPRIVS), |
| 214 |
|
me.name, source_p->name, "set"); |
| 218 |
|
if (newval > 0) |
| 219 |
|
{ |
| 220 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, |
| 221 |
< |
"%s has changed IDENTTIMEOUT to %d", |
| 222 |
< |
get_oper_name(source_p), newval); |
| 221 |
> |
"%s has changed IDENTTIMEOUT to %d", |
| 222 |
> |
get_oper_name(source_p), newval); |
| 223 |
|
GlobalSetOptions.ident_timeout = newval; |
| 224 |
|
} |
| 225 |
|
else |
| 226 |
|
sendto_one(source_p, ":%s NOTICE %s :IDENTTIMEOUT is currently %d", |
| 227 |
< |
me.name, source_p->name, GlobalSetOptions.ident_timeout); |
| 230 |
< |
} |
| 231 |
< |
|
| 232 |
< |
/* SET IDLETIME */ |
| 233 |
< |
static void |
| 234 |
< |
quote_idletime(struct Client *source_p, int newval) |
| 235 |
< |
{ |
| 236 |
< |
if (newval >= 0) |
| 237 |
< |
{ |
| 238 |
< |
if (newval == 0) |
| 239 |
< |
{ |
| 240 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, |
| 241 |
< |
"%s has disabled idletime checking", |
| 242 |
< |
source_p->name); |
| 243 |
< |
GlobalSetOptions.idletime = 0; |
| 244 |
< |
} |
| 245 |
< |
else |
| 246 |
< |
{ |
| 247 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, |
| 248 |
< |
"%s has changed IDLETIME to %i", |
| 249 |
< |
source_p->name, newval); |
| 250 |
< |
GlobalSetOptions.idletime = (newval*60); |
| 251 |
< |
} |
| 252 |
< |
} |
| 253 |
< |
else |
| 254 |
< |
{ |
| 255 |
< |
sendto_one(source_p, ":%s NOTICE %s :IDLETIME is currently %i", |
| 256 |
< |
me.name, source_p->name, GlobalSetOptions.idletime/60); |
| 257 |
< |
} |
| 258 |
< |
} |
| 259 |
< |
|
| 260 |
< |
/* SET LOG */ |
| 261 |
< |
static void |
| 262 |
< |
quote_log( struct Client *source_p, int newval ) |
| 263 |
< |
{ |
| 264 |
< |
const char *log_level_as_string; |
| 265 |
< |
|
| 266 |
< |
if (newval >= 0) |
| 267 |
< |
{ |
| 268 |
< |
if (newval < L_WARN) |
| 269 |
< |
{ |
| 270 |
< |
sendto_one(source_p, ":%s NOTICE %s :LOG must be > %d (L_WARN)", |
| 271 |
< |
me.name, source_p->name, L_WARN); |
| 272 |
< |
return; |
| 273 |
< |
} |
| 274 |
< |
|
| 275 |
< |
if (newval > L_DEBUG) |
| 276 |
< |
{ |
| 277 |
< |
newval = L_DEBUG; |
| 278 |
< |
} |
| 279 |
< |
|
| 280 |
< |
set_log_level(newval); |
| 281 |
< |
log_level_as_string = get_log_level_as_string(newval); |
| 282 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL,"%s has changed LOG level to %i (%s)", |
| 283 |
< |
source_p->name, newval, log_level_as_string); |
| 284 |
< |
} |
| 285 |
< |
else |
| 286 |
< |
{ |
| 287 |
< |
sendto_one(source_p, ":%s NOTICE %s :LOG level is currently %i (%s)", |
| 288 |
< |
me.name, source_p->name, get_log_level(), |
| 289 |
< |
get_log_level_as_string(get_log_level())); |
| 290 |
< |
} |
| 227 |
> |
me.name, source_p->name, GlobalSetOptions.ident_timeout); |
| 228 |
|
} |
| 229 |
|
|
| 230 |
|
/* SET MAX */ |
| 231 |
|
static void |
| 232 |
< |
quote_max (struct Client *source_p, int newval) |
| 232 |
> |
quote_max(struct Client *source_p, int newval) |
| 233 |
|
{ |
| 234 |
|
if (newval > 0) |
| 235 |
|
{ |
| 239 |
|
{ |
| 240 |
|
sendto_one(source_p, |
| 241 |
|
":%s NOTICE %s :You cannot set MAXCLIENTS to > %d, restoring to %d", |
| 242 |
< |
me.name, source_p->name, MAXCLIENTS_MAX); |
| 242 |
> |
me.name, source_p->name, MAXCLIENTS_MAX, ServerInfo.max_clients); |
| 243 |
|
return; |
| 244 |
|
} |
| 245 |
|
|
| 246 |
|
if (newval < MAXCLIENTS_MIN) |
| 247 |
|
{ |
| 248 |
|
sendto_one(source_p, |
| 249 |
< |
":%s NOTICE %s :You cannot set MAXCLIENTS to < %d, restoring to %d", |
| 250 |
< |
me.name, source_p->name, MAXCLIENTS_MIN, ServerInfo.max_clients); |
| 249 |
> |
":%s NOTICE %s :You cannot set MAXCLIENTS to < %d, restoring to %d", |
| 250 |
> |
me.name, source_p->name, MAXCLIENTS_MIN, ServerInfo.max_clients); |
| 251 |
|
return; |
| 252 |
|
} |
| 253 |
|
|
| 254 |
|
ServerInfo.max_clients = newval; |
| 255 |
|
|
| 256 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, |
| 257 |
< |
"%s!%s@%s set new MAXCLIENTS to %d (%d current)", |
| 258 |
< |
source_p->name, source_p->username, source_p->host, |
| 322 |
< |
ServerInfo.max_clients, Count.local); |
| 257 |
> |
"%s set new MAXCLIENTS to %d (%d current)", |
| 258 |
> |
get_oper_name(source_p), ServerInfo.max_clients, Count.local); |
| 259 |
|
} |
| 260 |
|
else |
| 261 |
|
sendto_one(source_p, ":%s NOTICE %s :Current MAXCLIENTS = %d (%d)", |
| 264 |
|
|
| 265 |
|
/* SET MSGLOCALE */ |
| 266 |
|
static void |
| 267 |
< |
quote_msglocale( struct Client *source_p, char *locale ) |
| 267 |
> |
quote_msglocale(struct Client *source_p, char *locale) |
| 268 |
|
{ |
| 269 |
|
if (locale != NULL) |
| 270 |
|
{ |
| 271 |
|
set_locale(locale); |
| 272 |
|
rebuild_isupport_message_line(); |
| 273 |
|
sendto_one(source_p, ":%s NOTICE %s :Set MSGLOCALE to '%s'", |
| 274 |
< |
me.name, source_p->name, get_locale()); |
| 274 |
> |
me.name, source_p->name, get_locale()); |
| 275 |
|
} |
| 276 |
|
else |
| 277 |
|
sendto_one(source_p, ":%s NOTICE %s :MSGLOCALE is currently '%s'", |
| 278 |
< |
me.name, source_p->name, get_locale()); |
| 278 |
> |
me.name, source_p->name, get_locale()); |
| 279 |
|
} |
| 280 |
|
|
| 281 |
|
/* SET SPAMNUM */ |
| 282 |
|
static void |
| 283 |
< |
quote_spamnum( struct Client *source_p, int newval ) |
| 283 |
> |
quote_spamnum(struct Client *source_p, int newval) |
| 284 |
|
{ |
| 285 |
< |
if (newval > 0) |
| 285 |
> |
if (newval >= 0) |
| 286 |
|
{ |
| 287 |
|
if (newval == 0) |
| 288 |
|
{ |
| 293 |
|
} |
| 294 |
|
|
| 295 |
|
GlobalSetOptions.spam_num = IRCD_MAX(newval, MIN_SPAM_NUM); |
| 296 |
< |
|
| 297 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL,"%s has changed SPAMNUM to %i", |
| 362 |
< |
source_p->name, GlobalSetOptions.spam_num); |
| 296 |
> |
sendto_realops_flags(UMODE_ALL, L_ALL, "%s has changed SPAMNUM to %i", |
| 297 |
> |
get_oper_name(source_p), GlobalSetOptions.spam_num); |
| 298 |
|
} |
| 299 |
|
else |
| 300 |
|
sendto_one(source_p, ":%s NOTICE %s :SPAMNUM is currently %i", |
| 301 |
< |
me.name, |
| 367 |
< |
source_p->name, GlobalSetOptions.spam_num); |
| 301 |
> |
me.name, source_p->name, GlobalSetOptions.spam_num); |
| 302 |
|
} |
| 303 |
|
|
| 304 |
|
/* SET SPAMTIME */ |
| 305 |
|
static void |
| 306 |
< |
quote_spamtime( struct Client *source_p, int newval ) |
| 306 |
> |
quote_spamtime(struct Client *source_p, int newval) |
| 307 |
|
{ |
| 308 |
|
if (newval > 0) |
| 309 |
|
{ |
| 310 |
|
GlobalSetOptions.spam_time = IRCD_MAX(newval, MIN_SPAM_TIME); |
| 311 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, "%s has changed SPAMTIME to %i", |
| 312 |
< |
source_p->name, GlobalSetOptions.spam_time); |
| 312 |
> |
get_oper_name(source_p), GlobalSetOptions.spam_time); |
| 313 |
|
} |
| 314 |
|
else |
| 315 |
|
sendto_one(source_p, ":%s NOTICE %s :SPAMTIME is currently %i", |
| 316 |
< |
me.name, |
| 383 |
< |
source_p->name, GlobalSetOptions.spam_time); |
| 316 |
> |
me.name, source_p->name, GlobalSetOptions.spam_time); |
| 317 |
|
} |
| 318 |
|
|
| 319 |
|
/* this table is what splitmode may be set to */ |
| 343 |
|
{ |
| 344 |
|
int newval; |
| 345 |
|
|
| 346 |
< |
for (newval = 0; splitmode_values[newval]; newval++) |
| 414 |
< |
{ |
| 346 |
> |
for (newval = 0; splitmode_values[newval]; ++newval) |
| 347 |
|
if (irccmp(splitmode_values[newval], charval) == 0) |
| 348 |
|
break; |
| 417 |
– |
} |
| 349 |
|
|
| 350 |
|
/* OFF */ |
| 351 |
|
if (newval == 0) |
| 364 |
|
{ |
| 365 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, |
| 366 |
|
"%s is enabling and activating splitmode", |
| 367 |
< |
get_oper_name(source_p)); |
| 368 |
< |
|
| 367 |
> |
get_oper_name(source_p)); |
| 368 |
> |
|
| 369 |
|
splitmode = 1; |
| 370 |
|
splitchecking = 0; |
| 371 |
|
|
| 377 |
|
{ |
| 378 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, |
| 379 |
|
"%s is enabling automatic splitmode", |
| 380 |
< |
get_oper_name(source_p)); |
| 380 |
> |
get_oper_name(source_p)); |
| 381 |
|
|
| 382 |
|
splitchecking = 1; |
| 383 |
|
check_splitmode(NULL); |
| 390 |
|
*/ |
| 391 |
|
sendto_one(source_p, ":%s NOTICE %s :SPLITMODE is currently %s", |
| 392 |
|
me.name, source_p->name, |
| 393 |
< |
splitmode_status[(splitchecking + (splitmode*2))]); |
| 393 |
> |
splitmode_status[(splitchecking + (splitmode * 2))]); |
| 394 |
|
} |
| 395 |
|
|
| 396 |
|
/* SET SPLITNUM */ |
| 401 |
|
{ |
| 402 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, |
| 403 |
|
"%s has changed SPLITNUM to %i", |
| 404 |
< |
source_p->name, newval); |
| 404 |
> |
get_oper_name(source_p), newval); |
| 405 |
|
split_servers = newval; |
| 406 |
|
|
| 407 |
|
if (splitchecking) |
| 420 |
|
{ |
| 421 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, |
| 422 |
|
"%s has changed SPLITUSERS to %i", |
| 423 |
< |
source_p->name, newval); |
| 423 |
> |
get_oper_name(source_p), newval); |
| 424 |
|
split_users = newval; |
| 425 |
|
|
| 426 |
|
if (splitchecking) |
| 439 |
|
{ |
| 440 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, |
| 441 |
|
"%s has changed JFLOODTIME to %i", |
| 442 |
< |
source_p->name, newval); |
| 442 |
> |
get_oper_name(source_p), newval); |
| 443 |
|
GlobalSetOptions.joinfloodtime = newval; |
| 444 |
|
} |
| 445 |
|
else |
| 455 |
|
{ |
| 456 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, |
| 457 |
|
"%s has changed JFLOODCOUNT to %i", |
| 458 |
< |
source_p->name, newval); |
| 458 |
> |
get_oper_name(source_p), newval); |
| 459 |
|
GlobalSetOptions.joinfloodcount = newval; |
| 460 |
|
} |
| 461 |
|
else |
| 463 |
|
me.name, source_p->name, GlobalSetOptions.joinfloodcount); |
| 464 |
|
} |
| 465 |
|
|
| 535 |
– |
/* SET REJECTTIME */ |
| 536 |
– |
static void |
| 537 |
– |
quote_rejecttime(struct Client *source_p, int newval) |
| 538 |
– |
{ |
| 539 |
– |
if (newval >= 0) |
| 540 |
– |
{ |
| 541 |
– |
sendto_realops_flags(UMODE_ALL, L_ALL, |
| 542 |
– |
"%s has changed REJECTTIME to %i seconds", |
| 543 |
– |
source_p->name, newval); |
| 544 |
– |
GlobalSetOptions.rejecttime = newval; |
| 545 |
– |
} |
| 546 |
– |
else |
| 547 |
– |
sendto_one(source_p, ":%s NOTICE %s :REJECTTIME is currently %i seconds", |
| 548 |
– |
me.name, source_p->name, GlobalSetOptions.rejecttime); |
| 549 |
– |
} |
| 550 |
– |
|
| 466 |
|
/* |
| 467 |
|
* mo_set - SET command handler |
| 468 |
|
* set options while running |
| 471 |
|
mo_set(struct Client *client_p, struct Client *source_p, |
| 472 |
|
int parc, char *parv[]) |
| 473 |
|
{ |
| 559 |
– |
int i; |
| 474 |
|
int n; |
| 475 |
|
int newval; |
| 476 |
|
const char *arg = NULL; |
| 477 |
|
const char *intarg = NULL; |
| 478 |
+ |
const struct SetStruct *tab = set_cmd_table; |
| 479 |
+ |
|
| 480 |
+ |
if (!HasOFlag(source_p, OPER_FLAG_SET)) |
| 481 |
+ |
{ |
| 482 |
+ |
sendto_one(source_p, form_str(ERR_NOPRIVS), |
| 483 |
+ |
me.name, source_p->name, "set"); |
| 484 |
+ |
return; |
| 485 |
+ |
} |
| 486 |
|
|
| 487 |
|
if (parc > 1) |
| 488 |
|
{ |
| 489 |
< |
/* Go through all the commands in set_cmd_table, until one is |
| 490 |
< |
* matched. I realize strcmp() is more intensive than a numeric |
| 491 |
< |
* lookup, but at least it's better than a big-ass switch/case |
| 570 |
< |
* statement. |
| 489 |
> |
/* |
| 490 |
> |
* Go through all the commands in set_cmd_table, until one is |
| 491 |
> |
* matched. |
| 492 |
|
*/ |
| 493 |
< |
for (i = 0; set_cmd_table[i].handler; i++) |
| 493 |
> |
for (; tab->handler; ++tab) |
| 494 |
|
{ |
| 495 |
< |
if (irccmp(set_cmd_table[i].name, parv[1]) == 0) |
| 495 |
> |
if (!irccmp(tab->name, parv[1])) |
| 496 |
|
{ |
| 497 |
|
/* |
| 498 |
|
* Command found; now execute the code |
| 499 |
|
*/ |
| 500 |
|
n = 2; |
| 501 |
|
|
| 502 |
< |
if (set_cmd_table[i].wants_char) |
| 582 |
< |
{ |
| 502 |
> |
if (tab->wants_char) |
| 503 |
|
arg = parv[n++]; |
| 584 |
– |
} |
| 504 |
|
|
| 505 |
< |
if (set_cmd_table[i].wants_int) |
| 587 |
< |
{ |
| 505 |
> |
if (tab->wants_int) |
| 506 |
|
intarg = parv[n++]; |
| 589 |
– |
} |
| 507 |
|
|
| 508 |
|
if ((n - 1) > parc) |
| 509 |
|
{ |
| 510 |
|
if (parc > 2) |
| 511 |
|
sendto_one(source_p, |
| 512 |
|
":%s NOTICE %s :SET %s expects (\"%s%s\") args", |
| 513 |
< |
me.name, source_p->name, set_cmd_table[i].name, |
| 514 |
< |
(set_cmd_table[i].wants_char ? "string, " : ""), |
| 515 |
< |
(set_cmd_table[i].wants_char ? "int" : "") |
| 599 |
< |
); |
| 513 |
> |
me.name, source_p->name, tab->name, |
| 514 |
> |
(tab->wants_char ? "string, " : ""), |
| 515 |
> |
(tab->wants_char ? "int" : "")); |
| 516 |
|
} |
| 517 |
|
|
| 518 |
|
if (parc <= 2) |
| 521 |
|
intarg = NULL; |
| 522 |
|
} |
| 523 |
|
|
| 524 |
< |
if (!strcmp(set_cmd_table[i].name, "AUTOCONN") && (parc < 4)) |
| 524 |
> |
if (!strcmp(tab->name, "AUTOCONN") && (parc < 4)) |
| 525 |
|
{ |
| 526 |
|
sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS), |
| 527 |
|
me.name, source_p->name, "SET"); |
| 528 |
|
return; |
| 529 |
|
} |
| 530 |
|
|
| 531 |
< |
if (set_cmd_table[i].wants_int && (parc > 2)) |
| 531 |
> |
if (tab->wants_int && (parc > 2)) |
| 532 |
|
{ |
| 533 |
|
if (intarg) |
| 534 |
|
{ |
| 540 |
|
newval = atoi(intarg); |
| 541 |
|
} |
| 542 |
|
else |
| 627 |
– |
{ |
| 543 |
|
newval = -1; |
| 629 |
– |
} |
| 544 |
|
|
| 545 |
|
if (newval < 0) |
| 546 |
|
{ |
| 547 |
|
sendto_one(source_p, |
| 548 |
|
":%s NOTICE %s :Value less than 0 illegal for %s", |
| 549 |
|
me.name, source_p->name, |
| 550 |
< |
set_cmd_table[i].name); |
| 550 |
> |
tab->name); |
| 551 |
|
|
| 552 |
|
return; |
| 553 |
|
} |
| 555 |
|
else |
| 556 |
|
newval = -1; |
| 557 |
|
|
| 558 |
< |
if (set_cmd_table[i].wants_char) |
| 558 |
> |
if (tab->wants_char) |
| 559 |
|
{ |
| 560 |
< |
if (set_cmd_table[i].wants_int) |
| 561 |
< |
set_cmd_table[i].handler(source_p, arg, newval); |
| 560 |
> |
if (tab->wants_int) |
| 561 |
> |
tab->handler(source_p, arg, newval); |
| 562 |
|
else |
| 563 |
< |
set_cmd_table[i].handler(source_p, arg); |
| 563 |
> |
tab->handler(source_p, arg); |
| 564 |
|
return; |
| 565 |
|
} |
| 566 |
|
else |
| 567 |
|
{ |
| 568 |
< |
if (set_cmd_table[i].wants_int) |
| 569 |
< |
set_cmd_table[i].handler(source_p, newval); |
| 568 |
> |
if (tab->wants_int) |
| 569 |
> |
tab->handler(source_p, newval); |
| 570 |
|
else |
| 571 |
|
/* Just in case someone actually wants a |
| 572 |
|
* set function that takes no args.. *shrug* */ |
| 573 |
< |
set_cmd_table[i].handler(source_p); |
| 573 |
> |
tab->handler(source_p); |
| 574 |
|
return; |
| 575 |
|
} |
| 576 |
|
} |
| 588 |
|
list_quote_commands(source_p); |
| 589 |
|
} |
| 590 |
|
|
| 591 |
+ |
static struct Message set_msgtab = { |
| 592 |
+ |
"SET", 0, 0, 0, MAXPARA, MFLG_SLOW, 0, |
| 593 |
+ |
{m_unregistered, m_not_oper, rfc1459_command_send_error, m_ignore, mo_set, m_ignore} |
| 594 |
+ |
}; |
| 595 |
+ |
|
| 596 |
+ |
static void |
| 597 |
+ |
module_init(void) |
| 598 |
+ |
{ |
| 599 |
+ |
mod_add_cmd(&set_msgtab); |
| 600 |
+ |
} |
| 601 |
+ |
|
| 602 |
+ |
static void |
| 603 |
+ |
module_exit(void) |
| 604 |
+ |
{ |
| 605 |
+ |
mod_del_cmd(&set_msgtab); |
| 606 |
+ |
} |
| 607 |
+ |
|
| 608 |
+ |
struct module module_entry = { |
| 609 |
+ |
.node = { NULL, NULL, NULL }, |
| 610 |
+ |
.name = NULL, |
| 611 |
+ |
.version = "$Revision$", |
| 612 |
+ |
.handle = NULL, |
| 613 |
+ |
.modinit = module_init, |
| 614 |
+ |
.modexit = module_exit, |
| 615 |
+ |
.flags = 0 |
| 616 |
+ |
}; |