]> jfr.im git - solanum.git/blobdiff - modules/m_set.c
authd/provider: add blacklist provider.
[solanum.git] / modules / m_set.c
index 342e1de0572131fb800d5bf4ed08a7f441765d92..e28b7002ef1ac0ab22ba0de1278374a9a2c2ca90 100644 (file)
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
  *  USA
- *
- *  $Id: m_set.c 3406 2007-04-13 19:06:53Z jilles $
  */
 
 /* rewritten by jdc */
 
 #include "stdinc.h"
 #include "client.h"
-#include "event.h"
-#include "irc_string.h"
-#include "sprintf_irc.h"
+#include "match.h"
 #include "ircd.h"
 #include "numeric.h"
-#include "commio.h"
 #include "s_serv.h"
 #include "send.h"
-#include "common.h"
 #include "channel.h"
 #include "s_conf.h"
 #include "s_newconf.h"
 #include "parse.h"
 #include "modules.h"
 
-static int mo_set(struct Client *, struct Client *, int, const char **);
+static const char set_desc[] = "Provides the SET command to change server parameters";
+
+static void mo_set(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
 
 struct Message set_msgtab = {
-       "SET", 0, 0, 0, MFLG_SLOW,
+       "SET", 0, 0, 0, 0,
        {mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_set, 0}}
 };
 
 mapi_clist_av1 set_clist[] = { &set_msgtab, NULL };
-DECLARE_MODULE_AV1(set, NULL, NULL, set_clist, NULL, NULL, "$Revision: 3406 $");
+DECLARE_MODULE_AV2(set, NULL, NULL, set_clist, NULL, NULL, NULL, NULL, set_desc);
 
 /* Structure used for the SET table itself */
 struct SetStruct
 {
        const char *name;
-       void (*handler) ();
+       void (*handler)(struct Client *source_p, const char *chararg, int intarg);
        int wants_char;         /* 1 if it expects (char *, [int]) */
        int wants_int;          /* 1 if it expects ([char *], int) */
 
@@ -67,23 +63,23 @@ struct SetStruct
 };
 
 
-static void quote_adminstring(struct Client *, const char *);
-static void quote_autoconn(struct Client *, char *, int);
-static void quote_autoconnall(struct Client *, int);
-static void quote_floodcount(struct Client *, int);
-static void quote_identtimeout(struct Client *, int);
-static void quote_idletime(struct Client *, int);
-static void quote_max(struct Client *, int);
-static void quote_operstring(struct Client *, const char *);
-static void quote_spamnum(struct Client *, int);
-static void quote_spamtime(struct Client *, int);
-static void quote_splitmode(struct Client *, char *);
-static void quote_splitnum(struct Client *, int);
-static void quote_splitusers(struct Client *, int);
+static void quote_adminstring(struct Client *, const char *, int);
+static void quote_autoconn(struct Client *, const char *, int);
+static void quote_autoconnall(struct Client *, const char *, int);
+static void quote_floodcount(struct Client *, const char *, int);
+static void quote_identtimeout(struct Client *, const char *, int);
+static void quote_max(struct Client *, const char *, int);
+static void quote_operstring(struct Client *, const char *, int);
+static void quote_spamnum(struct Client *, const char *, int);
+static void quote_spamtime(struct Client *, const char *, int);
+static void quote_splitmode(struct Client *, const char *, int);
+static void quote_splitnum(struct Client *, const char *, int);
+static void quote_splitusers(struct Client *, const char *, int);
+
 static void list_quote_commands(struct Client *);
 
 
-/* 
+/*
  * If this ever needs to be expanded to more than one arg of each
  * type, want_char/want_int could be the count of the arguments,
  * instead of just a boolean flag...
@@ -99,7 +95,6 @@ static struct SetStruct set_cmd_table[] = {
        {"AUTOCONNALL", quote_autoconnall,      0,      1       },
        {"FLOODCOUNT",  quote_floodcount,       0,      1       },
        {"IDENTTIMEOUT", quote_identtimeout,    0,      1       },
-       {"IDLETIME",    quote_idletime,         0,      1       },
        {"MAX",         quote_max,              0,      1       },
        {"MAXCLIENTS",  quote_max,              0,      1       },
        {"OPERSTRING",  quote_operstring,       1,      0       },
@@ -109,7 +104,7 @@ static struct SetStruct set_cmd_table[] = {
        {"SPLITNUM",    quote_splitnum,         0,      1       },
        {"SPLITUSERS",  quote_splitusers,       0,      1       },
        /* -------------------------------------------------------- */
-       {(char *) 0, (void (*)()) 0, 0, 0}
+       {(char *) 0, (void (*)(struct Client *, const char *, int)) 0, 0, 0}
 };
 
 
@@ -148,14 +143,14 @@ list_quote_commands(struct Client *source_p)
 
 /* SET AUTOCONN */
 static void
-quote_autoconn(struct Client *source_p, char *arg, int newval)
+quote_autoconn(struct Client *source_p, const char *arg, int newval)
 {
        set_server_conf_autoconn(source_p, arg, newval);
 }
 
 /* SET AUTOCONNALL */
 static void
-quote_autoconnall(struct Client *source_p, int newval)
+quote_autoconnall(struct Client *source_p, const char *arg, int newval)
 {
        if(newval >= 0)
        {
@@ -174,7 +169,7 @@ quote_autoconnall(struct Client *source_p, int newval)
 
 /* SET FLOODCOUNT */
 static void
-quote_floodcount(struct Client *source_p, int newval)
+quote_floodcount(struct Client *source_p, const char *arg, int newval)
 {
        if(newval >= 0)
        {
@@ -192,7 +187,7 @@ quote_floodcount(struct Client *source_p, int newval)
 
 /* SET IDENTTIMEOUT */
 static void
-quote_identtimeout(struct Client *source_p, int newval)
+quote_identtimeout(struct Client *source_p, const char *arg, int newval)
 {
        if(!IsOperAdmin(source_p))
        {
@@ -213,51 +208,24 @@ quote_identtimeout(struct Client *source_p, int newval)
                           GlobalSetOptions.ident_timeout);
 }
 
-/* SET IDLETIME */
-static void
-quote_idletime(struct Client *source_p, int newval)
-{
-       if(newval >= 0)
-       {
-               if(newval == 0)
-               {
-                       sendto_realops_snomask(SNO_GENERAL, L_ALL,
-                                            "%s has disabled idletime checking", source_p->name);
-                       GlobalSetOptions.idletime = 0;
-               }
-               else
-               {
-                       sendto_realops_snomask(SNO_GENERAL, L_ALL,
-                                            "%s has changed IDLETIME to %i",
-                                            source_p->name, newval);
-                       GlobalSetOptions.idletime = (newval * 60);
-               }
-       }
-       else
-       {
-               sendto_one_notice(source_p, ":IDLETIME is currently %i",
-                       GlobalSetOptions.idletime / 60);
-       }
-}
-
 /* SET MAX */
 static void
-quote_max(struct Client *source_p, int newval)
+quote_max(struct Client *source_p, const char *arg, int newval)
 {
        if(newval > 0)
        {
-               if(newval > ServerInfo.max_clients)
+               if(newval > maxconnections - MAX_BUFFER)
                {
                        sendto_one_notice(source_p,
-                                  ":You cannot set MAXCLIENTS to > max_clients (%d)",
-                                  ServerInfo.max_clients);
+                                         ":You cannot set MAXCLIENTS to > %d",
+                                         maxconnections - MAX_BUFFER);
                        return;
                }
 
                if(newval < 32)
                {
                        sendto_one_notice(source_p, ":You cannot set MAXCLIENTS to < 32 (%d:%d)",
-                                  GlobalSetOptions.maxclients, highest_fd);
+                                  GlobalSetOptions.maxclients, rb_getmaxconnect());
                        return;
                }
 
@@ -266,21 +234,21 @@ quote_max(struct Client *source_p, int newval)
                sendto_realops_snomask(SNO_GENERAL, L_ALL,
                                     "%s!%s@%s set new MAXCLIENTS to %d (%lu current)",
                                     source_p->name, source_p->username, source_p->host,
-                                    GlobalSetOptions.maxclients, 
-                                    dlink_list_length(&lclient_list));
+                                    GlobalSetOptions.maxclients,
+                                    rb_dlink_list_length(&lclient_list));
 
                return;
        }
        else
        {
                sendto_one_notice(source_p, ":Current Maxclients = %d (%lu)",
-                          GlobalSetOptions.maxclients, dlink_list_length(&lclient_list));
+                          GlobalSetOptions.maxclients, rb_dlink_list_length(&lclient_list));
        }
 }
 
 /* SET OPERSTRING */
 static void
-quote_operstring(struct Client *source_p, const char *arg)
+quote_operstring(struct Client *source_p, const char *arg, int newval)
 {
        if(EmptyString(arg))
        {
@@ -288,9 +256,9 @@ quote_operstring(struct Client *source_p, const char *arg)
        }
        else
        {
-               strlcpy(GlobalSetOptions.operstring, arg,
+               rb_strlcpy(GlobalSetOptions.operstring, arg,
                        sizeof(GlobalSetOptions.operstring));
-               
+
                sendto_realops_snomask(SNO_GENERAL, L_ALL,
                                     "%s has changed OPERSTRING to '%s'",
                                     get_oper_name(source_p), arg);
@@ -299,7 +267,7 @@ quote_operstring(struct Client *source_p, const char *arg)
 
 /* SET ADMINSTRING */
 static void
-quote_adminstring(struct Client *source_p, const char *arg)
+quote_adminstring(struct Client *source_p, const char *arg, int newval)
 {
        if(EmptyString(arg))
        {
@@ -307,9 +275,9 @@ quote_adminstring(struct Client *source_p, const char *arg)
        }
        else
        {
-               strlcpy(GlobalSetOptions.adminstring, arg,
+               rb_strlcpy(GlobalSetOptions.adminstring, arg,
                        sizeof(GlobalSetOptions.adminstring));
-               
+
                sendto_realops_snomask(SNO_GENERAL, L_ALL,
                                     "%s has changed ADMINSTRING to '%s'",
                                     get_oper_name(source_p), arg);
@@ -318,7 +286,7 @@ quote_adminstring(struct Client *source_p, const char *arg)
 
 /* SET SPAMNUM */
 static void
-quote_spamnum(struct Client *source_p, int newval)
+quote_spamnum(struct Client *source_p, const char *arg, int newval)
 {
        if(newval > 0)
        {
@@ -348,7 +316,7 @@ quote_spamnum(struct Client *source_p, int newval)
 
 /* SET SPAMTIME */
 static void
-quote_spamtime(struct Client *source_p, int newval)
+quote_spamtime(struct Client *source_p, const char *arg, int newval)
 {
        if(newval > 0)
        {
@@ -388,7 +356,7 @@ static const char *splitmode_status[] = {
 
 /* SET SPLITMODE */
 static void
-quote_splitmode(struct Client *source_p, char *charval)
+quote_splitmode(struct Client *source_p, const char *charval, int intval)
 {
        if(charval)
        {
@@ -409,7 +377,8 @@ quote_splitmode(struct Client *source_p, char *charval)
                        splitmode = 0;
                        splitchecking = 0;
 
-                       eventDelete(check_splitmode, NULL);
+                       rb_event_delete(check_splitmode_ev);
+                       check_splitmode_ev = NULL;
                }
                /* ON */
                else if(newval == 1)
@@ -422,7 +391,8 @@ quote_splitmode(struct Client *source_p, char *charval)
                        splitchecking = 0;
 
                        /* we might be deactivating an automatic splitmode, so pull the event */
-                       eventDelete(check_splitmode, NULL);
+                       rb_event_delete(check_splitmode_ev);
+                       check_splitmode_ev = NULL;
                }
                /* AUTO */
                else if(newval == 2)
@@ -436,7 +406,7 @@ quote_splitmode(struct Client *source_p, char *charval)
                }
        }
        else
-               /* if we add splitchecking to splitmode*2 we get a unique table to 
+               /* if we add splitchecking to splitmode*2 we get a unique table to
                 * pull values back out of, splitmode can be four states - but you can
                 * only set to three, which means we cant use the same table --fl_
                 */
@@ -446,7 +416,7 @@ quote_splitmode(struct Client *source_p, char *charval)
 
 /* SET SPLITNUM */
 static void
-quote_splitnum(struct Client *source_p, int newval)
+quote_splitnum(struct Client *source_p, const char *arg, int newval)
 {
        if(newval >= 0)
        {
@@ -463,7 +433,7 @@ quote_splitnum(struct Client *source_p, int newval)
 
 /* SET SPLITUSERS */
 static void
-quote_splitusers(struct Client *source_p, int newval)
+quote_splitusers(struct Client *source_p, const char *arg, int newval)
 {
        if(newval >= 0)
        {
@@ -482,8 +452,8 @@ quote_splitusers(struct Client *source_p, int newval)
  * mo_set - SET command handler
  * set options while running
  */
-static int
-mo_set(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
+static void
+mo_set(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
 {
        int newval;
        int i, n;
@@ -526,7 +496,7 @@ mo_set(struct Client *client_p, struct Client *source_p, int parc, const char *p
                                                    wants_char ? "string, " : ""),
                                                   (set_cmd_table[i].
                                                    wants_char ? "int" : ""));
-                                       return 0;
+                                       return;
                                }
 
                                if(parc <= 2)
@@ -558,30 +528,14 @@ mo_set(struct Client *client_p, struct Client *source_p, int parc, const char *p
                                                           ":Value less than 0 illegal for %s",
                                                           set_cmd_table[i].name);
 
-                                               return 0;
+                                               return;
                                        }
                                }
                                else
                                        newval = -1;
 
-                               if(set_cmd_table[i].wants_char)
-                               {
-                                       if(set_cmd_table[i].wants_int)
-                                               set_cmd_table[i].handler(source_p, arg, newval);
-                                       else
-                                               set_cmd_table[i].handler(source_p, arg);
-                                       return 0;
-                               }
-                               else
-                               {
-                                       if(set_cmd_table[i].wants_int)
-                                               set_cmd_table[i].handler(source_p, newval);
-                                       else
-                                               /* Just in case someone actually wants a
-                                                * set function that takes no args.. *shrug* */
-                                               set_cmd_table[i].handler(source_p);
-                                       return 0;
-                               }
+                               set_cmd_table[i].handler(source_p, arg, newval);
+                               return;
                        }
                }
 
@@ -590,10 +544,8 @@ mo_set(struct Client *client_p, struct Client *source_p, int parc, const char *p
                 * found within set_cmd_table.
                 */
                sendto_one_notice(source_p, ":Variable not found.");
-               return 0;
+               return;
        }
 
        list_quote_commands(source_p);
-
-       return 0;
 }