ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_set.c
(Generate patch)

Comparing:
ircd-hybrid/modules/m_set.c (file contents), Revision 31 by knight, Sun Oct 2 20:34:05 2005 UTC vs.
ircd-hybrid/trunk/modules/m_set.c (file contents), Revision 1997 by michael, Sat May 11 17:35:07 2013 UTC

# Line 25 | Line 25
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"
# Line 35 | Line 34
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  
45 < 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 <
71 < /* Structure used for the SET table itself */
72 < struct SetStruct
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) */
78 <  /* eg:  0, 1 == only an int arg
79 <   * eg:  1, 1 == char and int args */
80 < };
81 <
82 < static void quote_autoconn(struct Client *, const char *, int);
83 < static void quote_autoconnall(struct Client *, int);
84 < static void quote_floodcount(struct Client *, int);
85 < static void quote_identtimeout(struct Client *, int);
86 < static void quote_idletime(struct Client *, int);
87 < static void quote_log(struct Client *, int);
88 < static void quote_max(struct Client *, int);
89 < static void quote_msglocale(struct Client *, char *);
90 < static void quote_spamnum(struct Client *, int);
91 < static void quote_spamtime(struct Client *, int);
92 < static void quote_splitmode(struct Client *, char *);
93 < static void quote_splitnum(struct Client *, int);
94 < static void quote_splitusers(struct Client *, int);
95 < static void list_quote_commands(struct Client *);
96 < static void quote_jfloodtime(struct Client *, int);
97 < static void quote_jfloodcount(struct Client *, int);
98 < static void quote_rejecttime(struct Client *, int);
99 <
100 < /*
101 < * If this ever needs to be expanded to more than one arg of each
102 < * type, want_char/want_int could be the count of the arguments,
103 < * instead of just a boolean flag...
104 < *
105 < * -davidt
106 < */
107 <
108 < static struct SetStruct set_cmd_table[] =
109 < {
110 <  /* name               function        string arg  int arg */
111 <  /* -------------------------------------------------------- */
112 <  { "AUTOCONN",         quote_autoconn,         1,      1 },
113 <  { "AUTOCONNALL",      quote_autoconnall,      0,      1 },
114 <  { "FLOODCOUNT",       quote_floodcount,       0,      1 },
115 <  { "IDENTTIMEOUT",     quote_identtimeout,     0,      1 },
116 <  { "IDLETIME",         quote_idletime,         0,      1 },
117 <  { "LOG",              quote_log,              0,      1 },
118 <  { "MAX",              quote_max,              0,      1 },
119 <  { "MSGLOCALE",        quote_msglocale,        1,      0 },
120 <  { "SPAMNUM",          quote_spamnum,          0,      1 },
121 <  { "SPAMTIME",         quote_spamtime,         0,      1 },
122 <  { "SPLITMODE",        quote_splitmode,        1,      0 },
123 <  { "SPLITNUM",         quote_splitnum,         0,      1 },
124 <  { "SPLITUSERS",       quote_splitusers,       0,      1 },
125 <  { "JFLOODTIME",       quote_jfloodtime,       0,      1 },
126 <  { "JFLOODCOUNT",      quote_jfloodcount,      0,      1 },
127 <  { "REJECTTIME",       quote_rejecttime,       0,      1 },
128 <  /* -------------------------------------------------------- */
129 <  { NULL,               NULL,           0,      0 }
130 < };
131 <
132 < /*
133 < * list_quote_commands() sends the client all the available commands.
134 < * Four to a line for now.
135 < */
45 > /* SET AUTOCONN */
46   static void
47 < list_quote_commands(struct Client *source_p)
47 > quote_autoconn(struct Client *source_p, const char *arg, int newval)
48   {
49 <  int i;
140 <  int j = 0;
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++)
49 >  if (arg != NULL)
50    {
51 <    names[j++] = set_cmd_table[i].name;
51 >    struct MaskItem *conf = find_exact_name_conf(CONF_SERVER, NULL, arg, NULL, NULL);
52  
53 <    if (j > 3)
53 >    if (conf != NULL)
54      {
55 <      sendto_one(source_p, ":%s NOTICE %s :%s %s %s %s",
56 <                 me.name, source_p->name,
57 <                 names[0], names[1],
58 <                 names[2], names[3]);
158 <      j = 0;
159 <      names[0] = names[1] = names[2] = names[3] = "";
160 <    }
55 >      if (newval)
56 >        SetConfAllowAutoConn(conf);
57 >      else
58 >        ClearConfAllowAutoConn(conf);
59  
60 +      sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
61 +                           "%s has changed AUTOCONN for %s to %i",
62 +                           get_oper_name(source_p), arg, newval);
63 +      sendto_one(source_p,
64 +                 ":%s NOTICE %s :AUTOCONN for %s is now set to %i",
65 +                 me.name, source_p->name, arg, newval);
66 +    }
67 +    else
68 +    {
69 +      sendto_one(source_p, ":%s NOTICE %s :Can't find %s",
70 +                 me.name, source_p->name, arg);
71 +    }
72 +  }
73 +  else
74 +  {
75 +    sendto_one(source_p, ":%s NOTICE %s :Please specify a server name!",
76 +               me.name, source_p->name);
77    }
163 –  if (j)
164 –    sendto_one(source_p, ":%s NOTICE %s :%s %s %s %s",
165 –               me.name, source_p->name,
166 –               names[0], names[1],
167 –               names[2], names[3]);
168 – }
169 –
170 – /* SET AUTOCONN */
171 – static void
172 – quote_autoconn(struct Client *source_p, const char *arg, int newval)
173 – {
174 –  set_autoconn(source_p, arg, newval);
78   }
79  
80   /* SET AUTOCONNALL */
# Line 180 | Line 83 | quote_autoconnall(struct Client *source_
83   {
84    if (newval >= 0)
85    {
86 <    sendto_realops_flags(UMODE_ALL, L_ALL, "%s has changed AUTOCONNALL to %i",
87 <                         source_p->name, newval);
86 >    sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
87 >                         "%s has changed AUTOCONNALL to %i",
88 >                         get_oper_name(source_p), newval);
89  
90      GlobalSetOptions.autoconn = newval;
91    }
# Line 197 | Line 101 | quote_floodcount(struct Client *source_p
101    if (newval >= 0)
102    {
103      GlobalSetOptions.floodcount = newval;
104 <    sendto_realops_flags(UMODE_ALL, L_ALL,
105 <                         "%s has changed FLOODCOUNT to %i", source_p->name,
106 <                         GlobalSetOptions.floodcount);
104 >    sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
105 >                         "%s has changed FLOODCOUNT to %i",
106 >                         get_oper_name(source_p), GlobalSetOptions.floodcount);
107    }
108    else
109      sendto_one(source_p, ":%s NOTICE %s :FLOODCOUNT is currently %i",
# Line 210 | Line 114 | quote_floodcount(struct Client *source_p
114   static void
115   quote_identtimeout(struct Client *source_p, int newval)
116   {
117 <  if (!IsAdmin(source_p))
117 >  if (!HasUMode(source_p, UMODE_ADMIN))
118    {
119      sendto_one(source_p, form_str(ERR_NOPRIVS),
120                 me.name, source_p->name, "set");
# Line 219 | Line 123 | quote_identtimeout(struct Client *source
123  
124    if (newval > 0)
125    {
126 <    sendto_realops_flags(UMODE_ALL, L_ALL,
127 <                         "%s has changed IDENTTIMEOUT to %d",
128 <                         get_oper_name(source_p), newval);
126 >    sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
127 >                         "%s has changed IDENTTIMEOUT to %d",
128 >                         get_oper_name(source_p), newval);
129      GlobalSetOptions.ident_timeout = newval;
130    }
131    else
132      sendto_one(source_p, ":%s NOTICE %s :IDENTTIMEOUT is currently %d",
133 <               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 <  }
133 >               me.name, source_p->name, GlobalSetOptions.ident_timeout);
134   }
135  
136   /* SET MAX */
137   static void
138 < quote_max (struct Client *source_p, int newval)
138 > quote_max(struct Client *source_p, int newval)
139   {
140    if (newval > 0)
141    {
299 –    recalc_fdlimit(NULL);
300 –
142      if (newval > MAXCLIENTS_MAX)
143      {
144        sendto_one(source_p,
145          ":%s NOTICE %s :You cannot set MAXCLIENTS to > %d, restoring to %d",
146 <        me.name, source_p->name, MAXCLIENTS_MAX);
146 >        me.name, source_p->name, MAXCLIENTS_MAX, ServerInfo.max_clients);
147        return;
148      }
149  
150      if (newval < MAXCLIENTS_MIN)
151      {
152        sendto_one(source_p,
153 <        ":%s NOTICE %s :You cannot set MAXCLIENTS to < %d, restoring to %d",
154 <        me.name, source_p->name, MAXCLIENTS_MIN, ServerInfo.max_clients);
153 >        ":%s NOTICE %s :You cannot set MAXCLIENTS to < %d, restoring to %d",
154 >        me.name, source_p->name, MAXCLIENTS_MIN, ServerInfo.max_clients);
155        return;
156      }
157  
158      ServerInfo.max_clients = newval;
159  
160 <    sendto_realops_flags(UMODE_ALL, L_ALL,
161 <        "%s!%s@%s set new MAXCLIENTS to %d (%d current)",
162 <        source_p->name, source_p->username, source_p->host,
322 <        ServerInfo.max_clients, Count.local);
160 >    sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
161 >        "%s set new MAXCLIENTS to %d (%d current)",
162 >        get_oper_name(source_p), ServerInfo.max_clients, Count.local);
163    }
164    else
165      sendto_one(source_p, ":%s NOTICE %s :Current MAXCLIENTS = %d (%d)",
166                 me.name, source_p->name, ServerInfo.max_clients, Count.local);
167   }
168  
329 – /* SET MSGLOCALE */
330 – static void
331 – quote_msglocale( struct Client *source_p, char *locale )
332 – {
333 –  if (locale != NULL)
334 –  {
335 –    set_locale(locale);
336 –    rebuild_isupport_message_line();
337 –    sendto_one(source_p, ":%s NOTICE %s :Set MSGLOCALE to '%s'",
338 –               me.name, source_p->name, get_locale());
339 –  }
340 –  else
341 –    sendto_one(source_p, ":%s NOTICE %s :MSGLOCALE is currently '%s'",
342 –               me.name, source_p->name, get_locale());
343 – }
344 –
169   /* SET SPAMNUM */
170   static void
171 < quote_spamnum( struct Client *source_p, int newval )
171 > quote_spamnum(struct Client *source_p, int newval)
172   {
173 <  if (newval > 0)
173 >  if (newval >= 0)
174    {
175      if (newval == 0)
176      {
177 <      sendto_realops_flags(UMODE_ALL, L_ALL,
177 >      sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
178                             "%s has disabled ANTI_SPAMBOT", source_p->name);
179        GlobalSetOptions.spam_num = newval;
180        return;
181      }
182  
183      GlobalSetOptions.spam_num = IRCD_MAX(newval, MIN_SPAM_NUM);
184 <
185 <    sendto_realops_flags(UMODE_ALL, L_ALL,"%s has changed SPAMNUM to %i",
186 <                source_p->name, GlobalSetOptions.spam_num);
184 >    sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
185 >                         "%s has changed SPAMNUM to %i",
186 >                         get_oper_name(source_p), GlobalSetOptions.spam_num);
187    }
188    else
189      sendto_one(source_p, ":%s NOTICE %s :SPAMNUM is currently %i",
190 <                me.name,
367 <                source_p->name, GlobalSetOptions.spam_num);
190 >               me.name, source_p->name, GlobalSetOptions.spam_num);
191   }
192  
193   /* SET SPAMTIME */
194   static void
195 < quote_spamtime( struct Client *source_p, int newval )
195 > quote_spamtime(struct Client *source_p, int newval)
196   {
197    if (newval > 0)
198    {
199      GlobalSetOptions.spam_time = IRCD_MAX(newval, MIN_SPAM_TIME);
200 <    sendto_realops_flags(UMODE_ALL, L_ALL, "%s has changed SPAMTIME to %i",
201 <                source_p->name, GlobalSetOptions.spam_time);
200 >    sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
201 >                         "%s has changed SPAMTIME to %i",
202 >                         get_oper_name(source_p), GlobalSetOptions.spam_time);
203    }
204    else
205      sendto_one(source_p, ":%s NOTICE %s :SPAMTIME is currently %i",
206 <                me.name,
383 <                source_p->name, GlobalSetOptions.spam_time);
206 >               me.name, source_p->name, GlobalSetOptions.spam_time);
207   }
208  
209   /* this table is what splitmode may be set to */
# Line 410 | Line 233 | quote_splitmode(struct Client *source_p,
233    {
234      int newval;
235  
236 <    for (newval = 0; splitmode_values[newval]; newval++)
414 <    {
236 >    for (newval = 0; splitmode_values[newval]; ++newval)
237        if (irccmp(splitmode_values[newval], charval) == 0)
238          break;
417 –    }
239  
240      /* OFF */
241      if (newval == 0)
242      {
243 <      sendto_realops_flags(UMODE_ALL, L_ALL,
243 >      sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
244                             "%s is disabling splitmode",
245                             get_oper_name(source_p));
246  
# Line 431 | Line 252 | quote_splitmode(struct Client *source_p,
252      /* ON */
253      else if (newval == 1)
254      {
255 <      sendto_realops_flags(UMODE_ALL, L_ALL,
255 >      sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
256                             "%s is enabling and activating splitmode",
257 <                           get_oper_name(source_p));
258 <                
257 >                           get_oper_name(source_p));
258 >
259        splitmode = 1;
260        splitchecking = 0;
261  
# Line 444 | Line 265 | quote_splitmode(struct Client *source_p,
265      /* AUTO */
266      else if (newval == 2)
267      {
268 <      sendto_realops_flags(UMODE_ALL, L_ALL,
268 >      sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
269                             "%s is enabling automatic splitmode",
270 <                           get_oper_name(source_p));
270 >                           get_oper_name(source_p));
271  
272        splitchecking = 1;
273        check_splitmode(NULL);
# Line 459 | Line 280 | quote_splitmode(struct Client *source_p,
280       */
281      sendto_one(source_p, ":%s NOTICE %s :SPLITMODE is currently %s",
282                 me.name, source_p->name,
283 <               splitmode_status[(splitchecking + (splitmode*2))]);
283 >               splitmode_status[(splitchecking + (splitmode * 2))]);
284   }
285  
286   /* SET SPLITNUM */
# Line 468 | Line 289 | quote_splitnum(struct Client *source_p,
289   {
290    if (newval >= 0)
291    {
292 <    sendto_realops_flags(UMODE_ALL, L_ALL,
292 >    sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
293                           "%s has changed SPLITNUM to %i",
294 <                         source_p->name, newval);
294 >                         get_oper_name(source_p), newval);
295      split_servers = newval;
296  
297      if (splitchecking)
# Line 487 | Line 308 | quote_splitusers(struct Client *source_p
308   {
309    if (newval >= 0)
310    {
311 <    sendto_realops_flags(UMODE_ALL, L_ALL,
311 >    sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
312                           "%s has changed SPLITUSERS to %i",
313 <                         source_p->name, newval);
313 >                         get_oper_name(source_p), newval);
314      split_users = newval;
315  
316      if (splitchecking)
# Line 506 | Line 327 | quote_jfloodtime(struct Client *source_p
327   {
328    if (newval >= 0)
329    {
330 <    sendto_realops_flags(UMODE_ALL, L_ALL,
330 >    sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
331                           "%s has changed JFLOODTIME to %i",
332 <                         source_p->name, newval);
332 >                         get_oper_name(source_p), newval);
333      GlobalSetOptions.joinfloodtime = newval;
334    }
335    else
# Line 522 | Line 343 | quote_jfloodcount(struct Client *source_
343   {
344    if (newval >= 0)
345    {
346 <    sendto_realops_flags(UMODE_ALL, L_ALL,
346 >    sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
347                           "%s has changed JFLOODCOUNT to %i",
348 <                         source_p->name, newval);
348 >                         get_oper_name(source_p), newval);
349      GlobalSetOptions.joinfloodcount = newval;
350    }
351    else
# Line 532 | Line 353 | quote_jfloodcount(struct Client *source_
353                 me.name, source_p->name, GlobalSetOptions.joinfloodcount);
354   }
355  
356 < /* SET REJECTTIME */
356 > /* Structure used for the SET table itself */
357 > struct SetStruct
358 > {
359 >  const char *name;
360 >  void (*handler)();
361 >  const int wants_char; /* 1 if it expects (char *, [int]) */
362 >  const int wants_int;  /* 1 if it expects ([char *], int) */
363 >  /* eg:  0, 1 == only an int arg
364 >   * eg:  1, 1 == char and int args */
365 > };
366 >
367 > /*
368 > * If this ever needs to be expanded to more than one arg of each
369 > * type, want_char/want_int could be the count of the arguments,
370 > * instead of just a boolean flag...
371 > *
372 > * -davidt
373 > */
374 > static const struct SetStruct set_cmd_table[] =
375 > {
376 >  /* name               function        string arg  int arg */
377 >  /* -------------------------------------------------------- */
378 >  { "AUTOCONN",         quote_autoconn,         1,      1 },
379 >  { "AUTOCONNALL",      quote_autoconnall,      0,      1 },
380 >  { "FLOODCOUNT",       quote_floodcount,       0,      1 },
381 >  { "IDENTTIMEOUT",     quote_identtimeout,     0,      1 },
382 >  { "MAX",              quote_max,              0,      1 },
383 >  { "SPAMNUM",          quote_spamnum,          0,      1 },
384 >  { "SPAMTIME",         quote_spamtime,         0,      1 },
385 >  { "SPLITMODE",        quote_splitmode,        1,      0 },
386 >  { "SPLITNUM",         quote_splitnum,         0,      1 },
387 >  { "SPLITUSERS",       quote_splitusers,       0,      1 },
388 >  { "JFLOODTIME",       quote_jfloodtime,       0,      1 },
389 >  { "JFLOODCOUNT",      quote_jfloodcount,      0,      1 },
390 >  /* -------------------------------------------------------- */
391 >  { NULL,               NULL,                   0,      0 }
392 > };
393 >
394 > /*
395 > * list_quote_commands() sends the client all the available commands.
396 > * Four to a line for now.
397 > */
398   static void
399 < quote_rejecttime(struct Client *source_p, int newval)
399 > list_quote_commands(struct Client *source_p)
400   {
401 <  if (newval >= 0)
401 >  int j = 0;
402 >  const struct SetStruct *tab = set_cmd_table;
403 >  const char *names[4] = { "", "", "", "" };
404 >
405 >  sendto_one(source_p, ":%s NOTICE %s :Available QUOTE SET commands:",
406 >             me.name, source_p->name);
407 >
408 >  for (; tab->handler; ++tab)
409    {
410 <    sendto_realops_flags(UMODE_ALL, L_ALL,
411 <                         "%s has changed REJECTTIME to %i seconds",
412 <                         source_p->name, newval);
413 <    GlobalSetOptions.rejecttime = newval;
410 >    names[j++] = tab->name;
411 >
412 >    if (j > 3)
413 >    {
414 >      sendto_one(source_p, ":%s NOTICE %s :%s %s %s %s",
415 >                 me.name, source_p->name,
416 >                 names[0], names[1],
417 >                 names[2], names[3]);
418 >      j = 0;
419 >      names[0] = names[1] = names[2] = names[3] = "";
420 >    }
421 >
422    }
423 <  else
424 <    sendto_one(source_p, ":%s NOTICE %s :REJECTTIME is currently %i seconds",
425 <               me.name, source_p->name, GlobalSetOptions.rejecttime);
423 >
424 >  if (j)
425 >    sendto_one(source_p, ":%s NOTICE %s :%s %s %s %s",
426 >               me.name, source_p->name,
427 >               names[0], names[1],
428 >               names[2], names[3]);
429   }
430  
431   /*
# Line 556 | Line 436 | static void
436   mo_set(struct Client *client_p, struct Client *source_p,
437         int parc, char *parv[])
438   {
559 –  int i;
439    int n;
440    int newval;
441    const char *arg    = NULL;
442    const char *intarg = NULL;
443 +  const struct SetStruct *tab = set_cmd_table;
444 +
445 +  if (!HasOFlag(source_p, OPER_FLAG_SET))
446 +  {
447 +    sendto_one(source_p, form_str(ERR_NOPRIVS),
448 +               me.name, source_p->name, "set");
449 +    return;
450 +  }
451  
452    if (parc > 1)
453    {
454 <    /* Go through all the commands in set_cmd_table, until one is
455 <     * matched.  I realize strcmp() is more intensive than a numeric
456 <     * lookup, but at least it's better than a big-ass switch/case
570 <     * statement.
454 >    /*
455 >     * Go through all the commands in set_cmd_table, until one is
456 >     * matched.
457       */
458 <    for (i = 0; set_cmd_table[i].handler; i++)
458 >    for (; tab->handler; ++tab)
459      {
460 <      if (irccmp(set_cmd_table[i].name, parv[1]) == 0)
460 >      if (!irccmp(tab->name, parv[1]))
461        {
462          /*
463           * Command found; now execute the code
464           */
465          n = 2;
466  
467 <        if (set_cmd_table[i].wants_char)
582 <        {
467 >        if (tab->wants_char)
468            arg = parv[n++];
584 –        }
469  
470 <        if (set_cmd_table[i].wants_int)
587 <        {
470 >        if (tab->wants_int)
471            intarg = parv[n++];
589 –        }
472  
473          if ((n - 1) > parc)
474          {
475            if (parc > 2)
476              sendto_one(source_p,
477                         ":%s NOTICE %s :SET %s expects (\"%s%s\") args",
478 <                       me.name, source_p->name, set_cmd_table[i].name,
479 <                       (set_cmd_table[i].wants_char ? "string, " : ""),
480 <                       (set_cmd_table[i].wants_char ? "int" : "")
599 <                      );
478 >                       me.name, source_p->name, tab->name,
479 >                       (tab->wants_char ? "string, " : ""),
480 >                       (tab->wants_char ? "int" : ""));
481          }
482  
483          if (parc <= 2)
# Line 605 | Line 486 | mo_set(struct Client *client_p, struct C
486            intarg = NULL;
487          }
488  
489 <        if (!strcmp(set_cmd_table[i].name, "AUTOCONN") && (parc < 4))
489 >        if (!strcmp(tab->name, "AUTOCONN") && (parc < 4))
490          {
491            sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
492                       me.name, source_p->name, "SET");
493            return;
494          }
495  
496 <        if (set_cmd_table[i].wants_int && (parc > 2))
496 >        if (tab->wants_int && (parc > 2))
497          {
498            if (intarg)
499            {
# Line 624 | Line 505 | mo_set(struct Client *client_p, struct C
505                newval = atoi(intarg);
506            }
507            else
627 –          {
508              newval = -1;
629 –          }
509  
510            if (newval < 0)
511            {
512              sendto_one(source_p,
513                         ":%s NOTICE %s :Value less than 0 illegal for %s",
514                         me.name, source_p->name,
515 <                       set_cmd_table[i].name);
515 >                       tab->name);
516  
517              return;
518            }
# Line 641 | Line 520 | mo_set(struct Client *client_p, struct C
520          else
521            newval = -1;
522  
523 <        if (set_cmd_table[i].wants_char)
523 >        if (tab->wants_char)
524          {
525 <          if (set_cmd_table[i].wants_int)
526 <            set_cmd_table[i].handler(source_p, arg, newval);
525 >          if (tab->wants_int)
526 >            tab->handler(source_p, arg, newval);
527            else
528 <            set_cmd_table[i].handler(source_p, arg);
528 >            tab->handler(source_p, arg);
529            return;
530          }
531          else
532          {
533 <          if (set_cmd_table[i].wants_int)
534 <            set_cmd_table[i].handler(source_p, newval);
533 >          if (tab->wants_int)
534 >            tab->handler(source_p, newval);
535            else
536              /* Just in case someone actually wants a
537               * set function that takes no args.. *shrug* */
538 <            set_cmd_table[i].handler(source_p);
538 >            tab->handler(source_p);
539            return;
540          }
541        }
# Line 674 | Line 553 | mo_set(struct Client *client_p, struct C
553    list_quote_commands(source_p);
554   }
555  
556 + static struct Message set_msgtab = {
557 +  "SET", 0, 0, 0, MAXPARA, MFLG_SLOW, 0,
558 +  {m_unregistered, m_not_oper, rfc1459_command_send_error, m_ignore, mo_set, m_ignore}
559 + };
560 +
561 + static void
562 + module_init(void)
563 + {
564 +  mod_add_cmd(&set_msgtab);
565 + }
566 +
567 + static void
568 + module_exit(void)
569 + {
570 +  mod_del_cmd(&set_msgtab);
571 + }
572 +
573 + struct module module_entry = {
574 +  .node    = { NULL, NULL, NULL },
575 +  .name    = NULL,
576 +  .version = "$Revision$",
577 +  .handle  = NULL,
578 +  .modinit = module_init,
579 +  .modexit = module_exit,
580 +  .flags   = 0
581 + };

Comparing:
ircd-hybrid/modules/m_set.c (property svn:keywords), Revision 31 by knight, Sun Oct 2 20:34:05 2005 UTC vs.
ircd-hybrid/trunk/modules/m_set.c (property svn:keywords), Revision 1997 by michael, Sat May 11 17:35:07 2013 UTC

# Line 1 | Line 1
1 < "Id Revision"
1 > Id Revision

Diff Legend

– Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)