]> jfr.im git - irc/rqf/shadowircd.git/blobdiff - modules/m_set.c
Allow /ojoin !#channel/%#channel, if admin/halfop are enabled.
[irc/rqf/shadowircd.git] / modules / m_set.c
index d79b2bbe1e0a28d6ca6769348a77c8aa8ac332cc..88e079a18a3b5ee0105c8b0d1ccd320ee403420c 100644 (file)
 
 #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"
@@ -58,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) */
 
@@ -67,18 +64,19 @@ 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_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 *);
 
 
@@ -107,7 +105,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}
 };
 
 
@@ -146,14 +144,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)
        {
@@ -172,7 +170,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)
        {
@@ -190,7 +188,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,22 +211,22 @@ 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)
        {
-               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)",
-                                  GlobalSetOptions.maxclients);
+                       sendto_one_notice(source_p, ":You cannot set MAXCLIENTS to < 32 (%d:%d)",
+                                  GlobalSetOptions.maxclients, rb_getmaxconnect());
                        return;
                }
 
@@ -251,7 +249,7 @@ quote_max(struct Client *source_p, int newval)
 
 /* 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))
        {
@@ -259,7 +257,7 @@ 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,
@@ -270,7 +268,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))
        {
@@ -278,7 +276,7 @@ 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,
@@ -289,7 +287,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)
        {
@@ -319,7 +317,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)
        {
@@ -359,7 +357,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)
        {
@@ -380,7 +378,8 @@ quote_splitmode(struct Client *source_p, char *charval)
                        splitmode = 0;
                        splitchecking = 0;
 
-                       rb_event_delete(check_splitmode, NULL);
+                       rb_event_delete(check_splitmode_ev);
+                       check_splitmode_ev = NULL;
                }
                /* ON */
                else if(newval == 1)
@@ -393,7 +392,8 @@ quote_splitmode(struct Client *source_p, char *charval)
                        splitchecking = 0;
 
                        /* we might be deactivating an automatic splitmode, so pull the event */
-                       rb_event_delete(check_splitmode, NULL);
+                       rb_event_delete(check_splitmode_ev);
+                       check_splitmode_ev = NULL;
                }
                /* AUTO */
                else if(newval == 2)
@@ -417,7 +417,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 +434,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 +535,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;
                        }
                }