X-Git-Url: https://jfr.im/git/irc/rqf/shadowircd.git/blobdiff_plain/212380e3f42f585dc1ea927402252eb943f91f7b..8097430a810ac1535fe5304f74991b16ff58b064:/modules/m_set.c diff --git a/modules/m_set.c b/modules/m_set.c index d045b36..88e079a 100644 --- a/modules/m_set.c +++ b/modules/m_set.c @@ -21,19 +21,16 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * USA * - * $Id: m_set.c 494 2006-01-15 16:08:28Z jilles $ + * $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" @@ -52,13 +49,13 @@ struct Message set_msgtab = { }; mapi_clist_av1 set_clist[] = { &set_msgtab, NULL }; -DECLARE_MODULE_AV1(set, NULL, NULL, set_clist, NULL, NULL, "$Revision: 494 $"); +DECLARE_MODULE_AV1(set, NULL, NULL, set_clist, NULL, NULL, "$Revision: 3406 $"); /* 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,19 +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_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 *); @@ -99,7 +96,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 +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} }; @@ -124,8 +120,7 @@ list_quote_commands(struct Client *source_p) int j = 0; const char *names[4]; - sendto_one(source_p, ":%s NOTICE %s :Available QUOTE SET commands:", - me.name, source_p->name); + sendto_one_notice(source_p, ":Available QUOTE SET commands:"); names[0] = names[1] = names[2] = names[3] = ""; @@ -135,28 +130,28 @@ list_quote_commands(struct Client *source_p) if(j > 3) { - sendto_one(source_p, ":%s NOTICE %s :%s %s %s %s", - me.name, source_p->name, names[0], names[1], names[2], names[3]); + sendto_one_notice(source_p, ":%s %s %s %s", + names[0], names[1], names[2], names[3]); j = 0; names[0] = names[1] = names[2] = names[3] = ""; } } if(j) - sendto_one(source_p, ":%s NOTICE %s :%s %s %s %s", - me.name, source_p->name, names[0], names[1], names[2], names[3]); + sendto_one_notice(source_p, ":%s %s %s %s", + names[0], names[1], names[2], names[3]); } /* 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) { @@ -167,15 +162,15 @@ quote_autoconnall(struct Client *source_p, int newval) } else { - sendto_one(source_p, ":%s NOTICE %s :AUTOCONNALL is currently %i", - me.name, source_p->name, GlobalSetOptions.autoconn); + sendto_one_notice(source_p, ":AUTOCONNALL is currently %i", + GlobalSetOptions.autoconn); } } /* 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) { @@ -186,14 +181,14 @@ quote_floodcount(struct Client *source_p, int newval) } else { - sendto_one(source_p, ":%s NOTICE %s :FLOODCOUNT is currently %i", - me.name, source_p->name, GlobalSetOptions.floodcount); + sendto_one_notice(source_p, ":FLOODCOUNT is currently %i", + GlobalSetOptions.floodcount); } } /* 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)) { @@ -210,57 +205,28 @@ quote_identtimeout(struct Client *source_p, int newval) GlobalSetOptions.ident_timeout = newval; } else - sendto_one(source_p, ":%s NOTICE %s :IDENTTIMEOUT is currently %d", - me.name, source_p->name, 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(source_p, ":%s NOTICE %s :IDLETIME is currently %i", - me.name, source_p->name, GlobalSetOptions.idletime / 60); - } + sendto_one_notice(source_p, ":IDENTTIMEOUT is currently %d", + GlobalSetOptions.ident_timeout); } /* 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 > MASTER_MAX) + if(newval > maxconnections - MAX_BUFFER) { - sendto_one(source_p, - ":%s NOTICE %s :You cannot set MAXCLIENTS to > MASTER_MAX (%d)", - me.name, source_p->name, MASTER_MAX); + sendto_one_notice(source_p, + ":You cannot set MAXCLIENTS to > %d", + maxconnections - MAX_BUFFER); return; } if(newval < 32) { - sendto_one(source_p, - ":%s NOTICE %s :You cannot set MAXCLIENTS to < 32 (%d:%d)", - me.name, source_p->name, GlobalSetOptions.maxclients, - highest_fd); + sendto_one_notice(source_p, ":You cannot set MAXCLIENTS to < 32 (%d:%d)", + GlobalSetOptions.maxclients, rb_getmaxconnect()); return; } @@ -270,30 +236,28 @@ quote_max(struct Client *source_p, int newval) "%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)); + rb_dlink_list_length(&lclient_list)); return; } else { - sendto_one(source_p, ":%s NOTICE %s :Current Maxclients = %d (%lu)", - me.name, source_p->name, GlobalSetOptions.maxclients, - dlink_list_length(&lclient_list)); + sendto_one_notice(source_p, ":Current Maxclients = %d (%lu)", + 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)) { - sendto_one(source_p, ":%s NOTICE %s :OPERSTRING is currently '%s'", - me.name, source_p->name, GlobalSetOptions.operstring); + sendto_one_notice(source_p, ":OPERSTRING is currently '%s'", GlobalSetOptions.operstring); } else { - strlcpy(GlobalSetOptions.operstring, arg, + rb_strlcpy(GlobalSetOptions.operstring, arg, sizeof(GlobalSetOptions.operstring)); sendto_realops_snomask(SNO_GENERAL, L_ALL, @@ -304,16 +268,15 @@ 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)) { - sendto_one(source_p, ":%s NOTICE %s :ADMINSTRING is currently '%s'", - me.name, source_p->name, GlobalSetOptions.adminstring); + sendto_one_notice(source_p, ":ADMINSTRING is currently '%s'", GlobalSetOptions.adminstring); } else { - strlcpy(GlobalSetOptions.adminstring, arg, + rb_strlcpy(GlobalSetOptions.adminstring, arg, sizeof(GlobalSetOptions.adminstring)); sendto_realops_snomask(SNO_GENERAL, L_ALL, @@ -324,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) { @@ -348,14 +311,13 @@ quote_spamnum(struct Client *source_p, int newval) } else { - sendto_one(source_p, ":%s NOTICE %s :SPAMNUM is currently %i", - me.name, source_p->name, GlobalSetOptions.spam_num); + sendto_one_notice(source_p, ":SPAMNUM is currently %i", GlobalSetOptions.spam_num); } } /* 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) { @@ -372,8 +334,7 @@ quote_spamtime(struct Client *source_p, int newval) } else { - sendto_one(source_p, ":%s NOTICE %s :SPAMTIME is currently %i", - me.name, source_p->name, GlobalSetOptions.spam_time); + sendto_one_notice(source_p, ":SPAMTIME is currently %i", GlobalSetOptions.spam_time); } } @@ -396,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) { @@ -417,7 +378,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) @@ -430,7 +392,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) @@ -448,14 +411,13 @@ quote_splitmode(struct Client *source_p, char *charval) * 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_ */ - sendto_one(source_p, ":%s NOTICE %s :SPLITMODE is currently %s", - me.name, source_p->name, + sendto_one_notice(source_p, ":SPLITMODE is currently %s", splitmode_status[(splitchecking + (splitmode * 2))]); } /* 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) { @@ -467,13 +429,12 @@ quote_splitnum(struct Client *source_p, int newval) check_splitmode(NULL); } else - sendto_one(source_p, ":%s NOTICE %s :SPLITNUM is currently %i", - me.name, source_p->name, split_servers); + sendto_one_notice(source_p, ":SPLITNUM is currently %i", split_servers); } /* 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) { @@ -485,8 +446,7 @@ quote_splitusers(struct Client *source_p, int newval) check_splitmode(NULL); } else - sendto_one(source_p, ":%s NOTICE %s :SPLITUSERS is currently %i", - me.name, source_p->name, split_users); + sendto_one_notice(source_p, ":SPLITUSERS is currently %i", split_users); } /* @@ -530,9 +490,8 @@ mo_set(struct Client *client_p, struct Client *source_p, int parc, const char *p if((n - 1) > parc) { - sendto_one(source_p, - ":%s NOTICE %s :SET %s expects (\"%s%s\") args", - me.name, source_p->name, + sendto_one_notice(source_p, + ":SET %s expects (\"%s%s\") args", set_cmd_table[i].name, (set_cmd_table[i]. wants_char ? "string, " : ""), @@ -566,9 +525,8 @@ mo_set(struct Client *client_p, struct Client *source_p, int parc, const char *p if(newval < 0) { - sendto_one(source_p, - ":%s NOTICE %s :Value less than 0 illegal for %s", - me.name, source_p->name, + sendto_one_notice(source_p, + ":Value less than 0 illegal for %s", set_cmd_table[i].name); return 0; @@ -577,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; } } @@ -602,7 +544,7 @@ mo_set(struct Client *client_p, struct Client *source_p, int parc, const char *p * Code here will be executed when a /QUOTE SET command is not * found within set_cmd_table. */ - sendto_one(source_p, ":%s NOTICE %s :Variable not found.", me.name, parv[0]); + sendto_one_notice(source_p, ":Variable not found."); return 0; }