X-Git-Url: https://jfr.im/git/solanum.git/blobdiff_plain/a3143c9b6b884fe9c09475464151c7812485fcdf..a92275551218402bf4969a7fe613cab27416c4ef:/modules/m_set.c diff --git a/modules/m_set.c b/modules/m_set.c index 9a4bf642..95114fdd 100644 --- a/modules/m_set.c +++ b/modules/m_set.c @@ -20,8 +20,6 @@ * 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 */ @@ -33,7 +31,6 @@ #include "numeric.h" #include "s_serv.h" #include "send.h" -#include "common.h" #include "channel.h" #include "s_conf.h" #include "s_newconf.h" @@ -41,45 +38,48 @@ #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) (); - int wants_char; /* 1 if it expects (char *, [int]) */ - int wants_int; /* 1 if it expects ([char *], int) */ + void (*handler)(struct Client *source_p, const char *chararg, int intarg); + bool wants_char; /* true if it expects (char *, [int]) */ + bool wants_int; /* true if it expects ([char *], int) */ - /* eg: 0, 1 == only an int arg - * eg: 1, 1 == char and int args */ + /* eg: false, true == only an int arg + * eg: true, true == char and int args */ }; -static void quote_adminstring(struct Client *, const char *); +static void quote_adminstring(struct Client *, const char *, int); static void quote_autoconn(struct Client *, const 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 *, const char *); -static void quote_splitnum(struct Client *, int); -static void quote_splitusers(struct Client *, 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... @@ -88,23 +88,23 @@ static void list_quote_commands(struct Client *); */ static struct SetStruct set_cmd_table[] = { - /* name function string arg int arg */ + /* name function string arg bool arg */ /* -------------------------------------------------------- */ - {"ADMINSTRING", quote_adminstring, 1, 0 }, - {"AUTOCONN", quote_autoconn, 1, 1 }, - {"AUTOCONNALL", quote_autoconnall, 0, 1 }, - {"FLOODCOUNT", quote_floodcount, 0, 1 }, - {"IDENTTIMEOUT", quote_identtimeout, 0, 1 }, - {"MAX", quote_max, 0, 1 }, - {"MAXCLIENTS", quote_max, 0, 1 }, - {"OPERSTRING", quote_operstring, 1, 0 }, - {"SPAMNUM", quote_spamnum, 0, 1 }, - {"SPAMTIME", quote_spamtime, 0, 1 }, - {"SPLITMODE", quote_splitmode, 1, 0 }, - {"SPLITNUM", quote_splitnum, 0, 1 }, - {"SPLITUSERS", quote_splitusers, 0, 1 }, + {"ADMINSTRING", quote_adminstring, true, false }, + {"AUTOCONN", quote_autoconn, true, true }, + {"AUTOCONNALL", quote_autoconnall, false, true }, + {"FLOODCOUNT", quote_floodcount, false, true }, + {"IDENTTIMEOUT", quote_identtimeout, false, true }, + {"MAX", quote_max, false, true }, + {"MAXCLIENTS", quote_max, false, true }, + {"OPERSTRING", quote_operstring, true, false }, + {"SPAMNUM", quote_spamnum, false, true }, + {"SPAMTIME", quote_spamtime, false, true }, + {"SPLITMODE", quote_splitmode, true, false }, + {"SPLITNUM", quote_splitnum, false, true }, + {"SPLITUSERS", quote_splitusers, false, true }, /* -------------------------------------------------------- */ - {(char *) 0, (void (*)()) 0, 0, 0} + {NULL, NULL, false, false }, }; @@ -150,11 +150,11 @@ quote_autoconn(struct Client *source_p, const char *arg, int 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) { - sendto_realops_snomask(SNO_GENERAL, L_ALL, "%s has changed AUTOCONNALL to %i", + sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "%s has changed AUTOCONNALL to %i", source_p->name, newval); GlobalSetOptions.autoconn = newval; @@ -169,12 +169,12 @@ 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) { GlobalSetOptions.floodcount = newval; - sendto_realops_snomask(SNO_GENERAL, L_ALL, + sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "%s has changed FLOODCOUNT to %i", source_p->name, GlobalSetOptions.floodcount); } @@ -187,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)) { @@ -198,10 +198,11 @@ quote_identtimeout(struct Client *source_p, int newval) if(newval > 0) { - sendto_realops_snomask(SNO_GENERAL, L_ALL, + sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "%s has changed IDENTTIMEOUT to %d", get_oper_name(source_p), newval); GlobalSetOptions.ident_timeout = newval; + set_authd_timeout("ident_timeout", newval); } else sendto_one_notice(source_p, ":IDENTTIMEOUT is currently %d", @@ -210,7 +211,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) { @@ -231,10 +232,10 @@ quote_max(struct Client *source_p, int newval) GlobalSetOptions.maxclients = newval; - sendto_realops_snomask(SNO_GENERAL, L_ALL, + sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "%s!%s@%s set new MAXCLIENTS to %d (%lu current)", source_p->name, source_p->username, source_p->host, - GlobalSetOptions.maxclients, + GlobalSetOptions.maxclients, rb_dlink_list_length(&lclient_list)); return; @@ -248,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)) { @@ -258,8 +259,8 @@ quote_operstring(struct Client *source_p, const char *arg) { rb_strlcpy(GlobalSetOptions.operstring, arg, sizeof(GlobalSetOptions.operstring)); - - sendto_realops_snomask(SNO_GENERAL, L_ALL, + + sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "%s has changed OPERSTRING to '%s'", get_oper_name(source_p), arg); } @@ -267,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)) { @@ -277,8 +278,8 @@ quote_adminstring(struct Client *source_p, const char *arg) { rb_strlcpy(GlobalSetOptions.adminstring, arg, sizeof(GlobalSetOptions.adminstring)); - - sendto_realops_snomask(SNO_GENERAL, L_ALL, + + sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "%s has changed ADMINSTRING to '%s'", get_oper_name(source_p), arg); } @@ -286,13 +287,13 @@ 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) { if(newval == 0) { - sendto_realops_snomask(SNO_GENERAL, L_ALL, + sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "%s has disabled ANTI_SPAMBOT", source_p->name); GlobalSetOptions.spam_num = newval; return; @@ -305,7 +306,7 @@ quote_spamnum(struct Client *source_p, int newval) { GlobalSetOptions.spam_num = newval; } - sendto_realops_snomask(SNO_GENERAL, L_ALL, "%s has changed SPAMNUM to %i", + sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "%s has changed SPAMNUM to %i", source_p->name, GlobalSetOptions.spam_num); } else @@ -316,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) { @@ -328,7 +329,7 @@ quote_spamtime(struct Client *source_p, int newval) { GlobalSetOptions.spam_time = newval; } - sendto_realops_snomask(SNO_GENERAL, L_ALL, "%s has changed SPAMTIME to %i", + sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "%s has changed SPAMTIME to %i", source_p->name, GlobalSetOptions.spam_time); } else @@ -356,7 +357,7 @@ static const char *splitmode_status[] = { /* SET SPLITMODE */ static void -quote_splitmode(struct Client *source_p, const char *charval) +quote_splitmode(struct Client *source_p, const char *charval, int intval) { if(charval) { @@ -371,11 +372,11 @@ quote_splitmode(struct Client *source_p, const char *charval) /* OFF */ if(newval == 0) { - sendto_realops_snomask(SNO_GENERAL, L_ALL, + sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "%s is disabling splitmode", get_oper_name(source_p)); - splitmode = 0; - splitchecking = 0; + splitmode = false; + splitchecking = false; rb_event_delete(check_splitmode_ev); check_splitmode_ev = NULL; @@ -383,12 +384,12 @@ quote_splitmode(struct Client *source_p, const char *charval) /* ON */ else if(newval == 1) { - sendto_realops_snomask(SNO_GENERAL, L_ALL, + sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "%s is enabling and activating splitmode", get_oper_name(source_p)); - splitmode = 1; - splitchecking = 0; + splitmode = true; + splitchecking = false; /* we might be deactivating an automatic splitmode, so pull the event */ rb_event_delete(check_splitmode_ev); @@ -397,16 +398,16 @@ quote_splitmode(struct Client *source_p, const char *charval) /* AUTO */ else if(newval == 2) { - sendto_realops_snomask(SNO_GENERAL, L_ALL, + sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "%s is enabling automatic splitmode", get_oper_name(source_p)); - splitchecking = 1; + splitchecking = true; check_splitmode(NULL); } } 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_ */ @@ -416,11 +417,11 @@ quote_splitmode(struct Client *source_p, const 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) { - sendto_realops_snomask(SNO_GENERAL, L_ALL, + sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "%s has changed SPLITNUM to %i", source_p->name, newval); split_servers = newval; @@ -433,11 +434,11 @@ 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) { - sendto_realops_snomask(SNO_GENERAL, L_ALL, + sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "%s has changed SPLITUSERS to %i", source_p->name, newval); split_users = newval; @@ -452,8 +453,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; @@ -496,7 +497,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) @@ -528,30 +529,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; } } @@ -560,10 +545,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; }