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-7.2/modules/m_set.c (file contents), Revision 646 by michael, Wed Jun 7 12:42:00 2006 UTC vs.
ircd-hybrid-8/modules/m_set.c (file contents), Revision 1156 by michael, Tue Aug 9 20:29:20 2011 UTC

# Line 49 | Line 49 | static void mo_set(struct Client *, stru
49  
50   struct Message set_msgtab = {
51    "SET", 0, 0, 0, 0, MFLG_SLOW, 0,
52 <  {m_unregistered, m_not_oper, m_error, m_ignore, mo_set, m_ignore}
52 >  {m_unregistered, m_not_oper, rfc1459_command_send_error, m_ignore, mo_set, m_ignore}
53   };
54  
55 #ifndef STATIC_MODULES
55   void
56   _modinit(void)
57   {
# Line 66 | Line 65 | _moddeinit(void)
65   }
66  
67   const char *_version = "$Revision$";
69 #endif
68  
69   /* Structure used for the SET table itself */
70   struct SetStruct
71   {
72    const char *name;
73    void (*handler)();
74 <  int wants_char; /* 1 if it expects (char *, [int]) */
75 <  int wants_int;  /* 1 if it expects ([char *], int) */
74 >  const int wants_char; /* 1 if it expects (char *, [int]) */
75 >  const int wants_int;  /* 1 if it expects ([char *], int) */
76    /* eg:  0, 1 == only an int arg
77     * eg:  1, 1 == char and int args */
78   };
# Line 105 | Line 103 | static void quote_rejecttime(struct Clie
103   * -davidt
104   */
105  
106 < static struct SetStruct set_cmd_table[] =
106 > static const struct SetStruct set_cmd_table[] =
107   {
108    /* name               function        string arg  int arg */
109    /* -------------------------------------------------------- */
# Line 126 | Line 124 | static struct SetStruct set_cmd_table[]
124    { "JFLOODCOUNT",      quote_jfloodcount,      0,      1 },
125    { "REJECTTIME",       quote_rejecttime,       0,      1 },
126    /* -------------------------------------------------------- */
127 <  { NULL,               NULL,           0,      0 }
127 >  { NULL,               NULL,                   0,      0 }
128   };
129  
130   /*
# Line 136 | Line 134 | static struct SetStruct set_cmd_table[]
134   static void
135   list_quote_commands(struct Client *source_p)
136   {
139  int i;
137    int j = 0;
138 <  const char *names[4];
138 >  const struct SetStruct *tab = set_cmd_table;
139 >  const char *names[4] = { "", "", "", "" };
140  
141    sendto_one(source_p, ":%s NOTICE %s :Available QUOTE SET commands:",
142               me.name, source_p->name);
143  
144 <  names[0] = names[1] = names[2] = names[3] = "";
147 <
148 <  for (i = 0; set_cmd_table[i].handler; i++)
144 >  for (; tab->handler; ++tab)
145    {
146 <    names[j++] = set_cmd_table[i].name;
146 >    names[j++] = tab->name;
147  
148      if (j > 3)
149      {
# Line 160 | Line 156 | list_quote_commands(struct Client *sourc
156      }
157  
158    }
159 +
160    if (j)
161      sendto_one(source_p, ":%s NOTICE %s :%s %s %s %s",
162                 me.name, source_p->name,
# Line 171 | Line 168 | list_quote_commands(struct Client *sourc
168   static void
169   quote_autoconn(struct Client *source_p, const char *arg, int newval)
170   {
171 <  set_autoconn(source_p, arg, newval);
171 >  struct AccessItem *aconf;
172 >
173 >  if (arg != NULL)
174 >  {
175 >    struct ConfItem *conf = find_exact_name_conf(SERVER_TYPE, arg, NULL, NULL);
176 >
177 >    if (conf != NULL)
178 >    {
179 >      aconf = map_to_conf(conf);
180 >      if (newval)
181 >        SetConfAllowAutoConn(aconf);
182 >      else
183 >        ClearConfAllowAutoConn(aconf);
184 >
185 >      sendto_realops_flags(UMODE_ALL, L_ALL,
186 >                           "%s has changed AUTOCONN for %s to %i",
187 >                           get_oper_name(source_p), arg, newval);
188 >      sendto_one(source_p,
189 >                 ":%s NOTICE %s :AUTOCONN for %s is now set to %i",
190 >                 me.name, source_p->name, arg, newval);
191 >    }
192 >    else
193 >    {
194 >      sendto_one(source_p, ":%s NOTICE %s :Can't find %s",
195 >                 me.name, source_p->name, arg);
196 >    }
197 >  }
198 >  else
199 >  {
200 >    sendto_one(source_p, ":%s NOTICE %s :Please specify a server name!",
201 >               me.name, source_p->name);
202 >  }
203   }
204  
205   /* SET AUTOCONNALL */
# Line 181 | Line 209 | quote_autoconnall(struct Client *source_
209    if (newval >= 0)
210    {
211      sendto_realops_flags(UMODE_ALL, L_ALL, "%s has changed AUTOCONNALL to %i",
212 <                         source_p->name, newval);
212 >                         get_oper_name(source_p), newval);
213  
214      GlobalSetOptions.autoconn = newval;
215    }
# Line 198 | Line 226 | quote_floodcount(struct Client *source_p
226    {
227      GlobalSetOptions.floodcount = newval;
228      sendto_realops_flags(UMODE_ALL, L_ALL,
229 <                         "%s has changed FLOODCOUNT to %i", source_p->name,
230 <                         GlobalSetOptions.floodcount);
229 >                         "%s has changed FLOODCOUNT to %i",
230 >                         get_oper_name(source_p), GlobalSetOptions.floodcount);
231    }
232    else
233      sendto_one(source_p, ":%s NOTICE %s :FLOODCOUNT is currently %i",
# Line 239 | Line 267 | quote_idletime(struct Client *source_p,
267      {
268        sendto_realops_flags(UMODE_ALL, L_ALL,
269                             "%s has disabled idletime checking",
270 <                           source_p->name);
270 >                           get_oper_name(source_p));
271        GlobalSetOptions.idletime = 0;
272      }
273      else
274      {
275        sendto_realops_flags(UMODE_ALL, L_ALL,
276                             "%s has changed IDLETIME to %i",
277 <                           source_p->name, newval);
278 <      GlobalSetOptions.idletime = (newval*60);
277 >                           get_oper_name(source_p), newval);
278 >      GlobalSetOptions.idletime = (newval * 60);
279      }
280    }
281    else
# Line 259 | Line 287 | quote_idletime(struct Client *source_p,
287  
288   /* SET LOG */
289   static void
290 < quote_log( struct Client *source_p, int newval )
290 > quote_log(struct Client *source_p, int newval)
291   {
264  const char *log_level_as_string;
265
292    if (newval >= 0)
293    {
294      if (newval < L_WARN)
# Line 273 | Line 299 | quote_log( struct Client *source_p, int
299      }
300  
301      if (newval > L_DEBUG)
276    {
302        newval = L_DEBUG;
278    }
303  
304      set_log_level(newval);
305 <    log_level_as_string = get_log_level_as_string(newval);
306 <    sendto_realops_flags(UMODE_ALL, L_ALL,"%s has changed LOG level to %i (%s)",
307 <                         source_p->name, newval, log_level_as_string);
305 >    sendto_realops_flags(UMODE_ALL, L_ALL, "%s has changed LOG level to %i (%s)",
306 >                         get_oper_name(source_p), get_log_level(),
307 >                         get_log_level_as_string(get_log_level()));
308    }
309    else
286  {
310      sendto_one(source_p, ":%s NOTICE %s :LOG level is currently %i (%s)",
311                 me.name, source_p->name, get_log_level(),
312                 get_log_level_as_string(get_log_level()));
290  }
313   }
314  
315   /* SET MAX */
316   static void
317 < quote_max (struct Client *source_p, int newval)
317 > quote_max(struct Client *source_p, int newval)
318   {
319    if (newval > 0)
320    {
# Line 302 | Line 324 | quote_max (struct Client *source_p, int
324      {
325        sendto_one(source_p,
326          ":%s NOTICE %s :You cannot set MAXCLIENTS to > %d, restoring to %d",
327 <        me.name, source_p->name, MAXCLIENTS_MAX);
327 >        me.name, source_p->name, MAXCLIENTS_MAX, ServerInfo.max_clients);
328        return;
329      }
330  
# Line 317 | Line 339 | quote_max (struct Client *source_p, int
339      ServerInfo.max_clients = newval;
340  
341      sendto_realops_flags(UMODE_ALL, L_ALL,
342 <        "%s!%s@%s set new MAXCLIENTS to %d (%d current)",
343 <        source_p->name, source_p->username, source_p->host,
322 <        ServerInfo.max_clients, Count.local);
342 >        "%s set new MAXCLIENTS to %d (%d current)",
343 >        get_oper_name(source_p), ServerInfo.max_clients, Count.local);
344    }
345    else
346      sendto_one(source_p, ":%s NOTICE %s :Current MAXCLIENTS = %d (%d)",
# Line 328 | Line 349 | quote_max (struct Client *source_p, int
349  
350   /* SET MSGLOCALE */
351   static void
352 < quote_msglocale( struct Client *source_p, char *locale )
352 > quote_msglocale(struct Client *source_p, char *locale)
353   {
354    if (locale != NULL)
355    {
# Line 344 | Line 365 | quote_msglocale( struct Client *source_p
365  
366   /* SET SPAMNUM */
367   static void
368 < quote_spamnum( struct Client *source_p, int newval )
368 > quote_spamnum(struct Client *source_p, int newval)
369   {
370    if (newval >= 0)
371    {
# Line 357 | Line 378 | quote_spamnum( struct Client *source_p,
378      }
379  
380      GlobalSetOptions.spam_num = IRCD_MAX(newval, MIN_SPAM_NUM);
381 <
382 <    sendto_realops_flags(UMODE_ALL, L_ALL,"%s has changed SPAMNUM to %i",
362 <                source_p->name, GlobalSetOptions.spam_num);
381 >    sendto_realops_flags(UMODE_ALL, L_ALL, "%s has changed SPAMNUM to %i",
382 >                         get_oper_name(source_p), GlobalSetOptions.spam_num);
383    }
384    else
385      sendto_one(source_p, ":%s NOTICE %s :SPAMNUM is currently %i",
386 <                me.name,
367 <                source_p->name, GlobalSetOptions.spam_num);
386 >               me.name, source_p->name, GlobalSetOptions.spam_num);
387   }
388  
389   /* SET SPAMTIME */
390   static void
391 < quote_spamtime( struct Client *source_p, int newval )
391 > quote_spamtime(struct Client *source_p, int newval)
392   {
393    if (newval > 0)
394    {
395      GlobalSetOptions.spam_time = IRCD_MAX(newval, MIN_SPAM_TIME);
396      sendto_realops_flags(UMODE_ALL, L_ALL, "%s has changed SPAMTIME to %i",
397 <                source_p->name, GlobalSetOptions.spam_time);
397 >                         get_oper_name(source_p), GlobalSetOptions.spam_time);
398    }
399    else
400      sendto_one(source_p, ":%s NOTICE %s :SPAMTIME is currently %i",
401 <                me.name,
383 <                source_p->name, GlobalSetOptions.spam_time);
401 >               me.name, source_p->name, GlobalSetOptions.spam_time);
402   }
403  
404   /* this table is what splitmode may be set to */
# Line 410 | Line 428 | quote_splitmode(struct Client *source_p,
428    {
429      int newval;
430  
431 <    for (newval = 0; splitmode_values[newval]; newval++)
414 <    {
431 >    for (newval = 0; splitmode_values[newval]; ++newval)
432        if (irccmp(splitmode_values[newval], charval) == 0)
433          break;
417    }
434  
435      /* OFF */
436      if (newval == 0)
# Line 459 | Line 475 | quote_splitmode(struct Client *source_p,
475       */
476      sendto_one(source_p, ":%s NOTICE %s :SPLITMODE is currently %s",
477                 me.name, source_p->name,
478 <               splitmode_status[(splitchecking + (splitmode*2))]);
478 >               splitmode_status[(splitchecking + (splitmode * 2))]);
479   }
480  
481   /* SET SPLITNUM */
# Line 470 | Line 486 | quote_splitnum(struct Client *source_p,
486    {
487      sendto_realops_flags(UMODE_ALL, L_ALL,
488                           "%s has changed SPLITNUM to %i",
489 <                         source_p->name, newval);
489 >                         get_oper_name(source_p), newval);
490      split_servers = newval;
491  
492      if (splitchecking)
# Line 489 | Line 505 | quote_splitusers(struct Client *source_p
505    {
506      sendto_realops_flags(UMODE_ALL, L_ALL,
507                           "%s has changed SPLITUSERS to %i",
508 <                         source_p->name, newval);
508 >                         get_oper_name(source_p), newval);
509      split_users = newval;
510  
511      if (splitchecking)
# Line 508 | Line 524 | quote_jfloodtime(struct Client *source_p
524    {
525      sendto_realops_flags(UMODE_ALL, L_ALL,
526                           "%s has changed JFLOODTIME to %i",
527 <                         source_p->name, newval);
527 >                         get_oper_name(source_p), newval);
528      GlobalSetOptions.joinfloodtime = newval;
529    }
530    else
# Line 524 | Line 540 | quote_jfloodcount(struct Client *source_
540    {
541      sendto_realops_flags(UMODE_ALL, L_ALL,
542                           "%s has changed JFLOODCOUNT to %i",
543 <                         source_p->name, newval);
543 >                         get_oper_name(source_p), newval);
544      GlobalSetOptions.joinfloodcount = newval;
545    }
546    else
# Line 540 | Line 556 | quote_rejecttime(struct Client *source_p
556    {
557      sendto_realops_flags(UMODE_ALL, L_ALL,
558                           "%s has changed REJECTTIME to %i seconds",
559 <                         source_p->name, newval);
559 >                         get_oper_name(source_p), newval);
560      GlobalSetOptions.rejecttime = newval;
561    }
562    else
# Line 556 | Line 572 | static void
572   mo_set(struct Client *client_p, struct Client *source_p,
573         int parc, char *parv[])
574   {
559  int i;
575    int n;
576    int newval;
577    const char *arg    = NULL;
578    const char *intarg = NULL;
579 +  const struct SetStruct *tab = set_cmd_table;
580  
581    if (parc > 1)
582    {
583 <    /* Go through all the commands in set_cmd_table, until one is
584 <     * matched.  I realize strcmp() is more intensive than a numeric
585 <     * lookup, but at least it's better than a big-ass switch/case
570 <     * statement.
583 >    /*
584 >     * Go through all the commands in set_cmd_table, until one is
585 >     * matched.
586       */
587 <    for (i = 0; set_cmd_table[i].handler; i++)
587 >    for (; tab->handler; ++tab)
588      {
589 <      if (irccmp(set_cmd_table[i].name, parv[1]) == 0)
589 >      if (!irccmp(tab->name, parv[1]))
590        {
591          /*
592           * Command found; now execute the code
593           */
594          n = 2;
595  
596 <        if (set_cmd_table[i].wants_char)
582 <        {
596 >        if (tab->wants_char)
597            arg = parv[n++];
584        }
598  
599 <        if (set_cmd_table[i].wants_int)
587 <        {
599 >        if (tab->wants_int)
600            intarg = parv[n++];
589        }
601  
602          if ((n - 1) > parc)
603          {
604            if (parc > 2)
605              sendto_one(source_p,
606                         ":%s NOTICE %s :SET %s expects (\"%s%s\") args",
607 <                       me.name, source_p->name, set_cmd_table[i].name,
608 <                       (set_cmd_table[i].wants_char ? "string, " : ""),
609 <                       (set_cmd_table[i].wants_char ? "int" : "")
599 <                      );
607 >                       me.name, source_p->name, tab->name,
608 >                       (tab->wants_char ? "string, " : ""),
609 >                       (tab->wants_char ? "int" : ""));
610          }
611  
612          if (parc <= 2)
# Line 605 | Line 615 | mo_set(struct Client *client_p, struct C
615            intarg = NULL;
616          }
617  
618 <        if (!strcmp(set_cmd_table[i].name, "AUTOCONN") && (parc < 4))
618 >        if (!strcmp(tab->name, "AUTOCONN") && (parc < 4))
619          {
620            sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
621                       me.name, source_p->name, "SET");
622            return;
623          }
624  
625 <        if (set_cmd_table[i].wants_int && (parc > 2))
625 >        if (tab->wants_int && (parc > 2))
626          {
627            if (intarg)
628            {
# Line 633 | Line 643 | mo_set(struct Client *client_p, struct C
643              sendto_one(source_p,
644                         ":%s NOTICE %s :Value less than 0 illegal for %s",
645                         me.name, source_p->name,
646 <                       set_cmd_table[i].name);
646 >                       tab->name);
647  
648              return;
649            }
# Line 641 | Line 651 | mo_set(struct Client *client_p, struct C
651          else
652            newval = -1;
653  
654 <        if (set_cmd_table[i].wants_char)
654 >        if (tab->wants_char)
655          {
656 <          if (set_cmd_table[i].wants_int)
657 <            set_cmd_table[i].handler(source_p, arg, newval);
656 >          if (tab->wants_int)
657 >            tab->handler(source_p, arg, newval);
658            else
659 <            set_cmd_table[i].handler(source_p, arg);
659 >            tab->handler(source_p, arg);
660            return;
661          }
662          else
663          {
664 <          if (set_cmd_table[i].wants_int)
665 <            set_cmd_table[i].handler(source_p, newval);
664 >          if (tab->wants_int)
665 >            tab->handler(source_p, newval);
666            else
667              /* Just in case someone actually wants a
668               * set function that takes no args.. *shrug* */
669 <            set_cmd_table[i].handler(source_p);
669 >            tab->handler(source_p);
670            return;
671          }
672        }
# Line 673 | Line 683 | mo_set(struct Client *client_p, struct C
683  
684    list_quote_commands(source_p);
685   }
676

Diff Legend

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