1 |
adx |
30 |
/* |
2 |
michael |
2820 |
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
3 |
adx |
30 |
* |
4 |
michael |
2820 |
* Copyright (c) 1997-2014 ircd-hybrid development team |
5 |
adx |
30 |
* |
6 |
|
|
* This program is free software; you can redistribute it and/or modify |
7 |
|
|
* it under the terms of the GNU General Public License as published by |
8 |
|
|
* the Free Software Foundation; either version 2 of the License, or |
9 |
|
|
* (at your option) any later version. |
10 |
|
|
* |
11 |
|
|
* This program is distributed in the hope that it will be useful, |
12 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
|
|
* GNU General Public License for more details. |
15 |
|
|
* |
16 |
|
|
* You should have received a copy of the GNU General Public License |
17 |
|
|
* along with this program; if not, write to the Free Software |
18 |
michael |
4564 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 |
19 |
adx |
30 |
* USA |
20 |
|
|
*/ |
21 |
|
|
|
22 |
michael |
2820 |
/*! \file m_set.c |
23 |
|
|
* \brief Includes required functions for processing the SET command. |
24 |
|
|
* \version $Id$ |
25 |
|
|
*/ |
26 |
adx |
30 |
|
27 |
|
|
#include "stdinc.h" |
28 |
|
|
#include "client.h" |
29 |
|
|
#include "event.h" |
30 |
|
|
#include "irc_string.h" |
31 |
|
|
#include "ircd.h" |
32 |
|
|
#include "numeric.h" |
33 |
|
|
#include "send.h" |
34 |
michael |
1309 |
#include "conf.h" |
35 |
adx |
30 |
#include "parse.h" |
36 |
|
|
#include "modules.h" |
37 |
michael |
3347 |
#include "misc.h" |
38 |
adx |
30 |
|
39 |
|
|
|
40 |
|
|
/* SET AUTOCONN */ |
41 |
|
|
static void |
42 |
|
|
quote_autoconn(struct Client *source_p, const char *arg, int newval) |
43 |
|
|
{ |
44 |
michael |
3383 |
if (!EmptyString(arg)) |
45 |
michael |
896 |
{ |
46 |
michael |
1632 |
struct MaskItem *conf = find_exact_name_conf(CONF_SERVER, NULL, arg, NULL, NULL); |
47 |
michael |
896 |
|
48 |
michael |
3372 |
if (conf) |
49 |
michael |
896 |
{ |
50 |
|
|
if (newval) |
51 |
michael |
1632 |
SetConfAllowAutoConn(conf); |
52 |
michael |
896 |
else |
53 |
michael |
1632 |
ClearConfAllowAutoConn(conf); |
54 |
michael |
896 |
|
55 |
michael |
1618 |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
56 |
michael |
896 |
"%s has changed AUTOCONN for %s to %i", |
57 |
michael |
1141 |
get_oper_name(source_p), arg, newval); |
58 |
michael |
3110 |
sendto_one_notice(source_p, &me, ":AUTOCONN for %s is now set to %i", |
59 |
|
|
arg, newval); |
60 |
michael |
896 |
} |
61 |
|
|
else |
62 |
michael |
3110 |
sendto_one_notice(source_p, &me, ":Cannot find %s", arg); |
63 |
michael |
896 |
} |
64 |
|
|
else |
65 |
michael |
3110 |
sendto_one_notice(source_p, &me, ":Please specify a server name!"); |
66 |
adx |
30 |
} |
67 |
|
|
|
68 |
|
|
/* SET AUTOCONNALL */ |
69 |
|
|
static void |
70 |
michael |
3372 |
quote_autoconnall(struct Client *source_p, const char *arg, int newval) |
71 |
adx |
30 |
{ |
72 |
|
|
if (newval >= 0) |
73 |
|
|
{ |
74 |
michael |
1618 |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
75 |
|
|
"%s has changed AUTOCONNALL to %i", |
76 |
michael |
1141 |
get_oper_name(source_p), newval); |
77 |
adx |
30 |
|
78 |
|
|
GlobalSetOptions.autoconn = newval; |
79 |
|
|
} |
80 |
|
|
else |
81 |
michael |
3110 |
sendto_one_notice(source_p, &me, ":AUTOCONNALL is currently %i", |
82 |
|
|
GlobalSetOptions.autoconn); |
83 |
adx |
30 |
} |
84 |
|
|
|
85 |
|
|
/* SET FLOODCOUNT */ |
86 |
|
|
static void |
87 |
michael |
3372 |
quote_floodcount(struct Client *source_p, const char *arg, int newval) |
88 |
adx |
30 |
{ |
89 |
|
|
if (newval >= 0) |
90 |
|
|
{ |
91 |
|
|
GlobalSetOptions.floodcount = newval; |
92 |
michael |
1618 |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
93 |
michael |
1141 |
"%s has changed FLOODCOUNT to %i", |
94 |
|
|
get_oper_name(source_p), GlobalSetOptions.floodcount); |
95 |
adx |
30 |
} |
96 |
|
|
else |
97 |
michael |
3110 |
sendto_one_notice(source_p, &me, ":FLOODCOUNT is currently %i", |
98 |
|
|
GlobalSetOptions.floodcount); |
99 |
adx |
30 |
} |
100 |
|
|
|
101 |
|
|
/* SET IDENTTIMEOUT */ |
102 |
|
|
static void |
103 |
michael |
3372 |
quote_identtimeout(struct Client *source_p, const char *arg, int newval) |
104 |
adx |
30 |
{ |
105 |
michael |
1219 |
if (!HasUMode(source_p, UMODE_ADMIN)) |
106 |
adx |
30 |
{ |
107 |
michael |
3109 |
sendto_one_numeric(source_p, &me, ERR_NOPRIVS, "set"); |
108 |
adx |
30 |
return; |
109 |
|
|
} |
110 |
|
|
|
111 |
|
|
if (newval > 0) |
112 |
|
|
{ |
113 |
michael |
1618 |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
114 |
michael |
1451 |
"%s has changed IDENTTIMEOUT to %d", |
115 |
|
|
get_oper_name(source_p), newval); |
116 |
adx |
30 |
GlobalSetOptions.ident_timeout = newval; |
117 |
|
|
} |
118 |
|
|
else |
119 |
michael |
3110 |
sendto_one_notice(source_p, &me, ":IDENTTIMEOUT is currently %d", |
120 |
|
|
GlobalSetOptions.ident_timeout); |
121 |
adx |
30 |
} |
122 |
|
|
|
123 |
|
|
/* SET MAX */ |
124 |
|
|
static void |
125 |
michael |
3372 |
quote_max(struct Client *source_p, const char *arg, int newval) |
126 |
adx |
30 |
{ |
127 |
|
|
if (newval > 0) |
128 |
|
|
{ |
129 |
|
|
if (newval > MAXCLIENTS_MAX) |
130 |
|
|
{ |
131 |
michael |
3110 |
sendto_one_notice(source_p, &me, ":You cannot set MAXCLIENTS to > %d, restoring to %d", |
132 |
michael |
4341 |
MAXCLIENTS_MAX, ConfigServerInfo.max_clients); |
133 |
adx |
30 |
return; |
134 |
|
|
} |
135 |
|
|
|
136 |
|
|
if (newval < MAXCLIENTS_MIN) |
137 |
|
|
{ |
138 |
michael |
3110 |
sendto_one_notice(source_p, &me, ":You cannot set MAXCLIENTS to < %d, restoring to %d", |
139 |
michael |
4341 |
MAXCLIENTS_MIN, ConfigServerInfo.max_clients); |
140 |
adx |
30 |
return; |
141 |
|
|
} |
142 |
|
|
|
143 |
michael |
4341 |
ConfigServerInfo.max_clients = newval; |
144 |
adx |
30 |
|
145 |
michael |
1618 |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
146 |
michael |
1451 |
"%s set new MAXCLIENTS to %d (%d current)", |
147 |
michael |
4341 |
get_oper_name(source_p), ConfigServerInfo.max_clients, Count.local); |
148 |
adx |
30 |
} |
149 |
|
|
else |
150 |
michael |
3110 |
sendto_one_notice(source_p, &me, ":Current MAXCLIENTS = %d (%d)", |
151 |
michael |
4341 |
ConfigServerInfo.max_clients, Count.local); |
152 |
adx |
30 |
} |
153 |
|
|
|
154 |
|
|
/* SET SPAMNUM */ |
155 |
|
|
static void |
156 |
michael |
3372 |
quote_spamnum(struct Client *source_p, const char *arg, int newval) |
157 |
adx |
30 |
{ |
158 |
michael |
646 |
if (newval >= 0) |
159 |
adx |
30 |
{ |
160 |
|
|
if (newval == 0) |
161 |
|
|
{ |
162 |
michael |
1618 |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
163 |
adx |
30 |
"%s has disabled ANTI_SPAMBOT", source_p->name); |
164 |
|
|
GlobalSetOptions.spam_num = newval; |
165 |
|
|
return; |
166 |
|
|
} |
167 |
|
|
|
168 |
|
|
GlobalSetOptions.spam_num = IRCD_MAX(newval, MIN_SPAM_NUM); |
169 |
michael |
1618 |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
170 |
|
|
"%s has changed SPAMNUM to %i", |
171 |
michael |
1141 |
get_oper_name(source_p), GlobalSetOptions.spam_num); |
172 |
adx |
30 |
} |
173 |
|
|
else |
174 |
michael |
3110 |
sendto_one_notice(source_p, &me, ":SPAMNUM is currently %i", |
175 |
|
|
GlobalSetOptions.spam_num); |
176 |
adx |
30 |
} |
177 |
|
|
|
178 |
|
|
/* SET SPAMTIME */ |
179 |
|
|
static void |
180 |
michael |
3372 |
quote_spamtime(struct Client *source_p, const char *arg, int newval) |
181 |
adx |
30 |
{ |
182 |
|
|
if (newval > 0) |
183 |
|
|
{ |
184 |
|
|
GlobalSetOptions.spam_time = IRCD_MAX(newval, MIN_SPAM_TIME); |
185 |
michael |
1618 |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
186 |
|
|
"%s has changed SPAMTIME to %i", |
187 |
michael |
1141 |
get_oper_name(source_p), GlobalSetOptions.spam_time); |
188 |
adx |
30 |
} |
189 |
|
|
else |
190 |
michael |
3110 |
sendto_one_notice(source_p, &me, ":SPAMTIME is currently %i", |
191 |
|
|
GlobalSetOptions.spam_time); |
192 |
adx |
30 |
} |
193 |
|
|
|
194 |
|
|
/* this table is what splitmode may be set to */ |
195 |
|
|
static const char *splitmode_values[] = |
196 |
|
|
{ |
197 |
|
|
"OFF", |
198 |
|
|
"ON", |
199 |
|
|
"AUTO", |
200 |
|
|
NULL |
201 |
|
|
}; |
202 |
|
|
|
203 |
|
|
/* this table is what splitmode may be */ |
204 |
|
|
static const char *splitmode_status[] = |
205 |
|
|
{ |
206 |
|
|
"OFF", |
207 |
|
|
"AUTO (OFF)", |
208 |
|
|
"ON", |
209 |
|
|
"AUTO (ON)", |
210 |
|
|
NULL |
211 |
|
|
}; |
212 |
|
|
|
213 |
|
|
/* SET SPLITMODE */ |
214 |
|
|
static void |
215 |
michael |
3372 |
quote_splitmode(struct Client *source_p, const char *charval, int val) |
216 |
adx |
30 |
{ |
217 |
|
|
if (charval) |
218 |
|
|
{ |
219 |
|
|
int newval; |
220 |
|
|
|
221 |
michael |
896 |
for (newval = 0; splitmode_values[newval]; ++newval) |
222 |
michael |
3372 |
if (!irccmp(splitmode_values[newval], charval)) |
223 |
adx |
30 |
break; |
224 |
|
|
|
225 |
|
|
/* OFF */ |
226 |
|
|
if (newval == 0) |
227 |
|
|
{ |
228 |
michael |
1618 |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
229 |
adx |
30 |
"%s is disabling splitmode", |
230 |
|
|
get_oper_name(source_p)); |
231 |
|
|
|
232 |
|
|
splitmode = 0; |
233 |
|
|
splitchecking = 0; |
234 |
|
|
|
235 |
michael |
4095 |
event_delete(&splitmode_event); |
236 |
adx |
30 |
} |
237 |
|
|
/* ON */ |
238 |
|
|
else if (newval == 1) |
239 |
|
|
{ |
240 |
michael |
1618 |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
241 |
adx |
30 |
"%s is enabling and activating splitmode", |
242 |
michael |
1451 |
get_oper_name(source_p)); |
243 |
|
|
|
244 |
adx |
30 |
splitmode = 1; |
245 |
|
|
splitchecking = 0; |
246 |
|
|
|
247 |
|
|
/* we might be deactivating an automatic splitmode, so pull the event */ |
248 |
michael |
4095 |
event_delete(&splitmode_event); |
249 |
adx |
30 |
} |
250 |
|
|
/* AUTO */ |
251 |
|
|
else if (newval == 2) |
252 |
|
|
{ |
253 |
michael |
1618 |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
254 |
adx |
30 |
"%s is enabling automatic splitmode", |
255 |
michael |
1451 |
get_oper_name(source_p)); |
256 |
adx |
30 |
|
257 |
|
|
splitchecking = 1; |
258 |
|
|
check_splitmode(NULL); |
259 |
|
|
} |
260 |
|
|
} |
261 |
|
|
else |
262 |
michael |
3790 |
/* if we add splitchecking to splitmode*2 we get a unique table to |
263 |
adx |
30 |
* pull values back out of, splitmode can be four states - but you can |
264 |
|
|
* only set to three, which means we cant use the same table --fl_ |
265 |
|
|
*/ |
266 |
michael |
3790 |
sendto_one_notice(source_p, &me, ":SPLITMODE is currently %s", |
267 |
michael |
3110 |
splitmode_status[(splitchecking + (splitmode * 2))]); |
268 |
adx |
30 |
} |
269 |
|
|
|
270 |
|
|
/* SET SPLITNUM */ |
271 |
|
|
static void |
272 |
michael |
3372 |
quote_splitnum(struct Client *source_p, const char *arg, int newval) |
273 |
adx |
30 |
{ |
274 |
|
|
if (newval >= 0) |
275 |
|
|
{ |
276 |
michael |
1618 |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
277 |
michael |
3790 |
"%s has changed SPLITNUM to %i", |
278 |
michael |
1451 |
get_oper_name(source_p), newval); |
279 |
adx |
30 |
split_servers = newval; |
280 |
|
|
|
281 |
|
|
if (splitchecking) |
282 |
|
|
check_splitmode(NULL); |
283 |
|
|
} |
284 |
|
|
else |
285 |
michael |
3790 |
sendto_one_notice(source_p, &me, ":SPLITNUM is currently %i", |
286 |
michael |
3110 |
split_servers); |
287 |
adx |
30 |
} |
288 |
|
|
|
289 |
|
|
/* SET SPLITUSERS */ |
290 |
|
|
static void |
291 |
michael |
3372 |
quote_splitusers(struct Client *source_p, const char *arg, int newval) |
292 |
adx |
30 |
{ |
293 |
|
|
if (newval >= 0) |
294 |
|
|
{ |
295 |
michael |
1618 |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
296 |
michael |
3790 |
"%s has changed SPLITUSERS to %i", |
297 |
michael |
1451 |
get_oper_name(source_p), newval); |
298 |
adx |
30 |
split_users = newval; |
299 |
|
|
|
300 |
|
|
if (splitchecking) |
301 |
|
|
check_splitmode(NULL); |
302 |
|
|
} |
303 |
|
|
else |
304 |
michael |
3790 |
sendto_one_notice(source_p, &me, ":SPLITUSERS is currently %i", |
305 |
michael |
3110 |
split_users); |
306 |
adx |
30 |
} |
307 |
|
|
|
308 |
|
|
/* SET JFLOODTIME */ |
309 |
|
|
static void |
310 |
michael |
3372 |
quote_jfloodtime(struct Client *source_p, const char *arg, int newval) |
311 |
adx |
30 |
{ |
312 |
|
|
if (newval >= 0) |
313 |
|
|
{ |
314 |
michael |
1618 |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
315 |
michael |
3790 |
"%s has changed JFLOODTIME to %i", |
316 |
michael |
1451 |
get_oper_name(source_p), newval); |
317 |
adx |
30 |
GlobalSetOptions.joinfloodtime = newval; |
318 |
|
|
} |
319 |
|
|
else |
320 |
michael |
3790 |
sendto_one_notice(source_p, &me, ":JFLOODTIME is currently %i", |
321 |
michael |
3110 |
GlobalSetOptions.joinfloodtime); |
322 |
adx |
30 |
} |
323 |
|
|
|
324 |
|
|
/* SET JFLOODCOUNT */ |
325 |
|
|
static void |
326 |
michael |
3372 |
quote_jfloodcount(struct Client *source_p, const char *arg, int newval) |
327 |
adx |
30 |
{ |
328 |
|
|
if (newval >= 0) |
329 |
|
|
{ |
330 |
michael |
1618 |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
331 |
michael |
3790 |
"%s has changed JFLOODCOUNT to %i", |
332 |
michael |
1451 |
get_oper_name(source_p), newval); |
333 |
adx |
30 |
GlobalSetOptions.joinfloodcount = newval; |
334 |
|
|
} |
335 |
|
|
else |
336 |
michael |
3790 |
sendto_one_notice(source_p, &me, ":JFLOODCOUNT is currently %i", |
337 |
michael |
3110 |
GlobalSetOptions.joinfloodcount); |
338 |
adx |
30 |
} |
339 |
|
|
|
340 |
michael |
1997 |
/* Structure used for the SET table itself */ |
341 |
|
|
struct SetStruct |
342 |
|
|
{ |
343 |
|
|
const char *name; |
344 |
michael |
3372 |
void (*handler)(struct Client *, const char *, int); |
345 |
michael |
3857 |
const unsigned int wants_char; /* 1 if it expects (char *, [int]) */ |
346 |
|
|
const unsigned int wants_int; /* 1 if it expects ([char *], int) */ |
347 |
michael |
1997 |
/* eg: 0, 1 == only an int arg |
348 |
|
|
* eg: 1, 1 == char and int args */ |
349 |
|
|
}; |
350 |
|
|
|
351 |
adx |
30 |
/* |
352 |
michael |
1997 |
* If this ever needs to be expanded to more than one arg of each |
353 |
|
|
* type, want_char/want_int could be the count of the arguments, |
354 |
|
|
* instead of just a boolean flag... |
355 |
|
|
* |
356 |
|
|
* -davidt |
357 |
|
|
*/ |
358 |
|
|
static const struct SetStruct set_cmd_table[] = |
359 |
|
|
{ |
360 |
|
|
/* name function string arg int arg */ |
361 |
|
|
/* -------------------------------------------------------- */ |
362 |
|
|
{ "AUTOCONN", quote_autoconn, 1, 1 }, |
363 |
|
|
{ "AUTOCONNALL", quote_autoconnall, 0, 1 }, |
364 |
|
|
{ "FLOODCOUNT", quote_floodcount, 0, 1 }, |
365 |
|
|
{ "IDENTTIMEOUT", quote_identtimeout, 0, 1 }, |
366 |
|
|
{ "MAX", quote_max, 0, 1 }, |
367 |
|
|
{ "SPAMNUM", quote_spamnum, 0, 1 }, |
368 |
|
|
{ "SPAMTIME", quote_spamtime, 0, 1 }, |
369 |
|
|
{ "SPLITMODE", quote_splitmode, 1, 0 }, |
370 |
|
|
{ "SPLITNUM", quote_splitnum, 0, 1 }, |
371 |
|
|
{ "SPLITUSERS", quote_splitusers, 0, 1 }, |
372 |
|
|
{ "JFLOODTIME", quote_jfloodtime, 0, 1 }, |
373 |
|
|
{ "JFLOODCOUNT", quote_jfloodcount, 0, 1 }, |
374 |
|
|
/* -------------------------------------------------------- */ |
375 |
|
|
{ NULL, NULL, 0, 0 } |
376 |
|
|
}; |
377 |
|
|
|
378 |
|
|
/* |
379 |
|
|
* list_quote_commands() sends the client all the available commands. |
380 |
|
|
* Four to a line for now. |
381 |
|
|
*/ |
382 |
|
|
static void |
383 |
|
|
list_quote_commands(struct Client *source_p) |
384 |
|
|
{ |
385 |
michael |
3283 |
unsigned int j = 0; |
386 |
michael |
1997 |
const char *names[4] = { "", "", "", "" }; |
387 |
|
|
|
388 |
michael |
3110 |
sendto_one_notice(source_p, &me, ":Available QUOTE SET commands:"); |
389 |
michael |
1997 |
|
390 |
michael |
3283 |
for (const struct SetStruct *tab = set_cmd_table; tab->handler; ++tab) |
391 |
michael |
1997 |
{ |
392 |
|
|
names[j++] = tab->name; |
393 |
|
|
|
394 |
|
|
if (j > 3) |
395 |
|
|
{ |
396 |
michael |
3110 |
sendto_one_notice(source_p, &me, ":%s %s %s %s", |
397 |
|
|
names[0], names[1], |
398 |
|
|
names[2], names[3]); |
399 |
michael |
1997 |
j = 0; |
400 |
|
|
names[0] = names[1] = names[2] = names[3] = ""; |
401 |
|
|
} |
402 |
|
|
} |
403 |
|
|
|
404 |
|
|
if (j) |
405 |
michael |
3110 |
sendto_one_notice(source_p, &me, ":%s %s %s %s", |
406 |
|
|
names[0], names[1], |
407 |
|
|
names[2], names[3]); |
408 |
michael |
1997 |
} |
409 |
|
|
|
410 |
|
|
/* |
411 |
adx |
30 |
* mo_set - SET command handler |
412 |
|
|
* set options while running |
413 |
|
|
*/ |
414 |
michael |
2820 |
static int |
415 |
michael |
3156 |
mo_set(struct Client *source_p, int parc, char *parv[]) |
416 |
adx |
30 |
{ |
417 |
|
|
int n; |
418 |
|
|
int newval; |
419 |
michael |
3372 |
const char *strarg = NULL; |
420 |
adx |
30 |
const char *intarg = NULL; |
421 |
|
|
|
422 |
michael |
1460 |
if (!HasOFlag(source_p, OPER_FLAG_SET)) |
423 |
|
|
{ |
424 |
michael |
3109 |
sendto_one_numeric(source_p, &me, ERR_NOPRIVS, "set"); |
425 |
michael |
2820 |
return 0; |
426 |
michael |
1460 |
} |
427 |
|
|
|
428 |
adx |
30 |
if (parc > 1) |
429 |
|
|
{ |
430 |
michael |
1013 |
/* |
431 |
|
|
* Go through all the commands in set_cmd_table, until one is |
432 |
|
|
* matched. |
433 |
adx |
30 |
*/ |
434 |
michael |
3283 |
for (const struct SetStruct *tab = set_cmd_table; tab->handler; ++tab) |
435 |
adx |
30 |
{ |
436 |
michael |
3373 |
if (irccmp(tab->name, parv[1])) |
437 |
michael |
3372 |
continue; |
438 |
adx |
30 |
|
439 |
michael |
3372 |
/* |
440 |
|
|
* Command found; now execute the code |
441 |
|
|
*/ |
442 |
|
|
n = 2; |
443 |
adx |
30 |
|
444 |
michael |
3372 |
if (tab->wants_char) |
445 |
|
|
strarg = parv[n++]; |
446 |
adx |
30 |
|
447 |
michael |
3372 |
if (tab->wants_int) |
448 |
|
|
intarg = parv[n++]; |
449 |
adx |
30 |
|
450 |
michael |
3372 |
if ((n - 1) > parc) |
451 |
michael |
3373 |
sendto_one_notice(source_p, &me, ":SET %s expects (\"%s%s\") args", tab->name, |
452 |
|
|
(tab->wants_char ? "string, " : ""), |
453 |
|
|
(tab->wants_int ? "int" : "")); |
454 |
adx |
30 |
|
455 |
michael |
3372 |
if (parc <= 2) |
456 |
|
|
{ |
457 |
|
|
strarg = NULL; |
458 |
|
|
intarg = NULL; |
459 |
|
|
} |
460 |
adx |
30 |
|
461 |
michael |
3372 |
if (tab->wants_int && parc > 2) |
462 |
|
|
{ |
463 |
|
|
if (intarg) |
464 |
adx |
30 |
{ |
465 |
michael |
3372 |
if (!irccmp(intarg, "yes") || !irccmp(intarg, "on")) |
466 |
|
|
newval = 1; |
467 |
michael |
3854 |
else if (!irccmp(intarg, "no") || !irccmp(intarg, "off")) |
468 |
michael |
3372 |
newval = 0; |
469 |
adx |
30 |
else |
470 |
michael |
3372 |
newval = atoi(intarg); |
471 |
adx |
30 |
} |
472 |
|
|
else |
473 |
|
|
newval = -1; |
474 |
|
|
|
475 |
michael |
3372 |
if (newval < 0) |
476 |
adx |
30 |
{ |
477 |
michael |
3372 |
sendto_one_notice(source_p, &me, ":Value less than 0 illegal for %s", |
478 |
|
|
tab->name); |
479 |
michael |
2820 |
return 0; |
480 |
adx |
30 |
} |
481 |
|
|
} |
482 |
michael |
3372 |
else |
483 |
|
|
newval = -1; |
484 |
|
|
|
485 |
|
|
tab->handler(source_p, strarg, newval); |
486 |
|
|
return 0; |
487 |
adx |
30 |
} |
488 |
|
|
|
489 |
|
|
/* |
490 |
|
|
* Code here will be executed when a /QUOTE SET command is not |
491 |
|
|
* found within set_cmd_table. |
492 |
|
|
*/ |
493 |
michael |
3110 |
sendto_one_notice(source_p, &me, ":Variable not found."); |
494 |
michael |
2820 |
return 0; |
495 |
adx |
30 |
} |
496 |
|
|
|
497 |
|
|
list_quote_commands(source_p); |
498 |
michael |
2820 |
return 0; |
499 |
adx |
30 |
} |
500 |
michael |
1230 |
|
501 |
michael |
2820 |
static struct Message set_msgtab = |
502 |
|
|
{ |
503 |
michael |
4546 |
"SET", NULL, 0, 0, 0, MAXPARA, MFLG_SLOW, 0, |
504 |
michael |
2820 |
{ m_unregistered, m_not_oper, m_ignore, m_ignore, mo_set, m_ignore } |
505 |
michael |
1230 |
}; |
506 |
|
|
|
507 |
|
|
static void |
508 |
|
|
module_init(void) |
509 |
|
|
{ |
510 |
|
|
mod_add_cmd(&set_msgtab); |
511 |
|
|
} |
512 |
|
|
|
513 |
|
|
static void |
514 |
|
|
module_exit(void) |
515 |
|
|
{ |
516 |
|
|
mod_del_cmd(&set_msgtab); |
517 |
|
|
} |
518 |
|
|
|
519 |
michael |
2820 |
struct module module_entry = |
520 |
|
|
{ |
521 |
michael |
1230 |
.node = { NULL, NULL, NULL }, |
522 |
|
|
.name = NULL, |
523 |
|
|
.version = "$Revision$", |
524 |
|
|
.handle = NULL, |
525 |
|
|
.modinit = module_init, |
526 |
|
|
.modexit = module_exit, |
527 |
|
|
.flags = 0 |
528 |
|
|
}; |