]> jfr.im git - irc/rqf/shadowircd.git/blobdiff - modules/m_set.c
mkpasswd: Default to MD5-based crypt instead of SHA-based.
[irc/rqf/shadowircd.git] / modules / m_set.c
index 3d80d8400cd9884f3bb0b589ba16743ecc44816f..f803f727798e40d4d0396ce10e519a8f7e91bbf6 100644 (file)
  *  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 "irc_string.h"
-#include "sprintf_irc.h"
+#include "match.h"
 #include "ircd.h"
 #include "numeric.h"
 #include "s_serv.h"
@@ -37,6 +35,7 @@
 #include "common.h"
 #include "channel.h"
 #include "s_conf.h"
+#include "s_user.h"
 #include "s_newconf.h"
 #include "msg.h"
 #include "parse.h"
@@ -56,7 +55,7 @@ DECLARE_MODULE_AV1(set, NULL, NULL, set_clist, NULL, NULL, "$Revision: 3406 $");
 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) */
 
@@ -65,18 +64,20 @@ 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_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_operhost(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 *);
 
 
@@ -98,6 +99,7 @@ static struct SetStruct set_cmd_table[] = {
        {"IDENTTIMEOUT", quote_identtimeout,    0,      1       },
        {"MAX",         quote_max,              0,      1       },
        {"MAXCLIENTS",  quote_max,              0,      1       },
+       {"OPERHOST",    quote_operhost,         1,      0       },
        {"OPERSTRING",  quote_operstring,       1,      0       },
        {"SPAMNUM",     quote_spamnum,          0,      1       },
        {"SPAMTIME",    quote_spamtime,         0,      1       },
@@ -105,7 +107,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}
 };
 
 
@@ -144,14 +146,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)
        {
@@ -170,7 +172,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)
        {
@@ -188,7 +190,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))
        {
@@ -211,7 +213,7 @@ quote_identtimeout(struct Client *source_p, int newval)
 
 /* 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)
        {
@@ -247,9 +249,32 @@ quote_max(struct Client *source_p, int newval)
        }
 }
 
+/* SET OPERHOST */
+static void
+quote_operhost(struct Client *source_p, const char *arg, int newval)
+{
+       if(EmptyString(arg))
+       {
+               sendto_one_notice(source_p, ":OPERHOST is currently '%s'", GlobalSetOptions.operhost);
+       }
+       else if(!valid_hostname(arg))
+       {
+               sendto_one_notice(source_p, "Invalid hostmask.");
+       }
+       else
+       {
+               rb_strlcpy(GlobalSetOptions.operhost, arg,
+                       sizeof(GlobalSetOptions.operhost));
+               
+               sendto_realops_snomask(SNO_GENERAL, L_ALL,
+                                    "%s has changed OPERHOST to '%s'",
+                                    get_oper_name(source_p), arg);
+       }
+}
+
 /* 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))
        {
@@ -268,7 +293,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))
        {
@@ -287,7 +312,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)
        {
@@ -317,7 +342,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)
        {
@@ -357,7 +382,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)
        {
@@ -417,7 +442,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)
        {
@@ -434,7 +459,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)
        {
@@ -535,24 +560,8 @@ mo_set(struct Client *client_p, struct Client *source_p, int parc, const char *p
                                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 0;
                        }
                }