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 |
> |
if (arg != NULL) |
142 |
> |
{ |
143 |
> |
struct MaskItem *conf = find_exact_name_conf(CONF_SERVER, NULL, arg, NULL, NULL); |
144 |
> |
|
145 |
> |
if (conf != NULL) |
146 |
> |
{ |
147 |
> |
if (newval) |
148 |
> |
SetConfAllowAutoConn(conf); |
149 |
> |
else |
150 |
> |
ClearConfAllowAutoConn(conf); |
151 |
> |
|
152 |
> |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
153 |
> |
"%s has changed AUTOCONN for %s to %i", |
154 |
> |
get_oper_name(source_p), arg, newval); |
155 |
> |
sendto_one(source_p, |
156 |
> |
":%s NOTICE %s :AUTOCONN for %s is now set to %i", |
157 |
> |
me.name, source_p->name, arg, newval); |
158 |
> |
} |
159 |
> |
else |
160 |
> |
{ |
161 |
> |
sendto_one(source_p, ":%s NOTICE %s :Can't find %s", |
162 |
> |
me.name, source_p->name, arg); |
163 |
> |
} |
164 |
> |
} |
165 |
> |
else |
166 |
> |
{ |
167 |
> |
sendto_one(source_p, ":%s NOTICE %s :Please specify a server name!", |
168 |
> |
me.name, source_p->name); |
169 |
> |
} |
170 |
|
} |
171 |
|
|
172 |
|
/* SET AUTOCONNALL */ |
175 |
|
{ |
176 |
|
if (newval >= 0) |
177 |
|
{ |
178 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, "%s has changed AUTOCONNALL to %i", |
179 |
< |
source_p->name, newval); |
178 |
> |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
179 |
> |
"%s has changed AUTOCONNALL to %i", |
180 |
> |
get_oper_name(source_p), newval); |
181 |
|
|
182 |
|
GlobalSetOptions.autoconn = newval; |
183 |
|
} |
193 |
|
if (newval >= 0) |
194 |
|
{ |
195 |
|
GlobalSetOptions.floodcount = newval; |
196 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, |
197 |
< |
"%s has changed FLOODCOUNT to %i", source_p->name, |
198 |
< |
GlobalSetOptions.floodcount); |
196 |
> |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
197 |
> |
"%s has changed FLOODCOUNT to %i", |
198 |
> |
get_oper_name(source_p), GlobalSetOptions.floodcount); |
199 |
|
} |
200 |
|
else |
201 |
|
sendto_one(source_p, ":%s NOTICE %s :FLOODCOUNT is currently %i", |
206 |
|
static void |
207 |
|
quote_identtimeout(struct Client *source_p, int newval) |
208 |
|
{ |
209 |
< |
if (!IsAdmin(source_p)) |
209 |
> |
if (!HasUMode(source_p, UMODE_ADMIN)) |
210 |
|
{ |
211 |
|
sendto_one(source_p, form_str(ERR_NOPRIVS), |
212 |
|
me.name, source_p->name, "set"); |
215 |
|
|
216 |
|
if (newval > 0) |
217 |
|
{ |
218 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, |
219 |
< |
"%s has changed IDENTTIMEOUT to %d", |
220 |
< |
get_oper_name(source_p), newval); |
218 |
> |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
219 |
> |
"%s has changed IDENTTIMEOUT to %d", |
220 |
> |
get_oper_name(source_p), newval); |
221 |
|
GlobalSetOptions.ident_timeout = newval; |
222 |
|
} |
223 |
|
else |
224 |
|
sendto_one(source_p, ":%s NOTICE %s :IDENTTIMEOUT is currently %d", |
225 |
< |
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 |
< |
} |
225 |
> |
me.name, source_p->name, GlobalSetOptions.ident_timeout); |
226 |
|
} |
227 |
|
|
228 |
|
/* SET MAX */ |
229 |
|
static void |
230 |
< |
quote_max (struct Client *source_p, int newval) |
230 |
> |
quote_max(struct Client *source_p, int newval) |
231 |
|
{ |
232 |
|
if (newval > 0) |
233 |
|
{ |
237 |
|
{ |
238 |
|
sendto_one(source_p, |
239 |
|
":%s NOTICE %s :You cannot set MAXCLIENTS to > %d, restoring to %d", |
240 |
< |
me.name, source_p->name, MAXCLIENTS_MAX); |
240 |
> |
me.name, source_p->name, MAXCLIENTS_MAX, ServerInfo.max_clients); |
241 |
|
return; |
242 |
|
} |
243 |
|
|
244 |
|
if (newval < MAXCLIENTS_MIN) |
245 |
|
{ |
246 |
|
sendto_one(source_p, |
247 |
< |
":%s NOTICE %s :You cannot set MAXCLIENTS to < %d, restoring to %d", |
248 |
< |
me.name, source_p->name, MAXCLIENTS_MIN, ServerInfo.max_clients); |
247 |
> |
":%s NOTICE %s :You cannot set MAXCLIENTS to < %d, restoring to %d", |
248 |
> |
me.name, source_p->name, MAXCLIENTS_MIN, ServerInfo.max_clients); |
249 |
|
return; |
250 |
|
} |
251 |
|
|
252 |
|
ServerInfo.max_clients = newval; |
253 |
|
|
254 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, |
255 |
< |
"%s!%s@%s set new MAXCLIENTS to %d (%d current)", |
256 |
< |
source_p->name, source_p->username, source_p->host, |
322 |
< |
ServerInfo.max_clients, Count.local); |
254 |
> |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
255 |
> |
"%s set new MAXCLIENTS to %d (%d current)", |
256 |
> |
get_oper_name(source_p), ServerInfo.max_clients, Count.local); |
257 |
|
} |
258 |
|
else |
259 |
|
sendto_one(source_p, ":%s NOTICE %s :Current MAXCLIENTS = %d (%d)", |
262 |
|
|
263 |
|
/* SET MSGLOCALE */ |
264 |
|
static void |
265 |
< |
quote_msglocale( struct Client *source_p, char *locale ) |
265 |
> |
quote_msglocale(struct Client *source_p, char *locale) |
266 |
|
{ |
267 |
|
if (locale != NULL) |
268 |
|
{ |
269 |
|
set_locale(locale); |
270 |
|
rebuild_isupport_message_line(); |
271 |
|
sendto_one(source_p, ":%s NOTICE %s :Set MSGLOCALE to '%s'", |
272 |
< |
me.name, source_p->name, get_locale()); |
272 |
> |
me.name, source_p->name, get_locale()); |
273 |
|
} |
274 |
|
else |
275 |
|
sendto_one(source_p, ":%s NOTICE %s :MSGLOCALE is currently '%s'", |
276 |
< |
me.name, source_p->name, get_locale()); |
276 |
> |
me.name, source_p->name, get_locale()); |
277 |
|
} |
278 |
|
|
279 |
|
/* SET SPAMNUM */ |
280 |
|
static void |
281 |
< |
quote_spamnum( struct Client *source_p, int newval ) |
281 |
> |
quote_spamnum(struct Client *source_p, int newval) |
282 |
|
{ |
283 |
|
if (newval >= 0) |
284 |
|
{ |
285 |
|
if (newval == 0) |
286 |
|
{ |
287 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, |
287 |
> |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
288 |
|
"%s has disabled ANTI_SPAMBOT", source_p->name); |
289 |
|
GlobalSetOptions.spam_num = newval; |
290 |
|
return; |
291 |
|
} |
292 |
|
|
293 |
|
GlobalSetOptions.spam_num = IRCD_MAX(newval, MIN_SPAM_NUM); |
294 |
< |
|
295 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL,"%s has changed SPAMNUM to %i", |
296 |
< |
source_p->name, GlobalSetOptions.spam_num); |
294 |
> |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
295 |
> |
"%s has changed SPAMNUM to %i", |
296 |
> |
get_oper_name(source_p), GlobalSetOptions.spam_num); |
297 |
|
} |
298 |
|
else |
299 |
|
sendto_one(source_p, ":%s NOTICE %s :SPAMNUM is currently %i", |
300 |
< |
me.name, |
367 |
< |
source_p->name, GlobalSetOptions.spam_num); |
300 |
> |
me.name, source_p->name, GlobalSetOptions.spam_num); |
301 |
|
} |
302 |
|
|
303 |
|
/* SET SPAMTIME */ |
304 |
|
static void |
305 |
< |
quote_spamtime( struct Client *source_p, int newval ) |
305 |
> |
quote_spamtime(struct Client *source_p, int newval) |
306 |
|
{ |
307 |
|
if (newval > 0) |
308 |
|
{ |
309 |
|
GlobalSetOptions.spam_time = IRCD_MAX(newval, MIN_SPAM_TIME); |
310 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, "%s has changed SPAMTIME to %i", |
311 |
< |
source_p->name, GlobalSetOptions.spam_time); |
310 |
> |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
311 |
> |
"%s has changed SPAMTIME to %i", |
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) |
352 |
|
{ |
353 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, |
353 |
> |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
354 |
|
"%s is disabling splitmode", |
355 |
|
get_oper_name(source_p)); |
356 |
|
|
362 |
|
/* ON */ |
363 |
|
else if (newval == 1) |
364 |
|
{ |
365 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, |
365 |
> |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
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 |
|
|
375 |
|
/* AUTO */ |
376 |
|
else if (newval == 2) |
377 |
|
{ |
378 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, |
378 |
> |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
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 */ |
399 |
|
{ |
400 |
|
if (newval >= 0) |
401 |
|
{ |
402 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, |
402 |
> |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
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) |
418 |
|
{ |
419 |
|
if (newval >= 0) |
420 |
|
{ |
421 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, |
421 |
> |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
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) |
437 |
|
{ |
438 |
|
if (newval >= 0) |
439 |
|
{ |
440 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, |
440 |
> |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
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 |
453 |
|
{ |
454 |
|
if (newval >= 0) |
455 |
|
{ |
456 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, |
456 |
> |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
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 |
+ |
}; |