X-Git-Url: https://jfr.im/git/irc/rqf/shadowircd.git/blobdiff_plain/c240ecad4f96e6d74fc098d76301f92f8a4be8ac..b0e752b0f9572d4bdef62db949359a58a568d6f5:/modules/core/m_mode.c?ds=sidebyside diff --git a/modules/core/m_mode.c b/modules/core/m_mode.c index f59a950..fd1b183 100644 --- a/modules/core/m_mode.c +++ b/modules/core/m_mode.c @@ -21,33 +21,30 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * USA * - * $Id: m_mode.c 1006 2006-03-09 15:32:14Z nenolod $ */ #include "stdinc.h" -#include "tools.h" -#include "balloc.h" #include "channel.h" #include "client.h" #include "hash.h" -#include "irc_string.h" +#include "match.h" #include "ircd.h" #include "numeric.h" #include "s_user.h" #include "s_conf.h" #include "s_serv.h" -#include "s_log.h" +#include "logger.h" #include "send.h" #include "msg.h" #include "parse.h" #include "modules.h" #include "packet.h" -#include "sprintf_irc.h" #include "s_newconf.h" static int m_mode(struct Client *, struct Client *, int, const char **); static int ms_mode(struct Client *, struct Client *, int, const char **); static int ms_tmode(struct Client *, struct Client *, int, const char **); +static int ms_mlock(struct Client *, struct Client *, int, const char **); static int ms_bmask(struct Client *, struct Client *, int, const char **); struct Message mode_msgtab = { @@ -58,18 +55,21 @@ struct Message tmode_msgtab = { "TMODE", 0, 0, 0, MFLG_SLOW, {mg_ignore, mg_ignore, {ms_tmode, 4}, {ms_tmode, 4}, mg_ignore, mg_ignore} }; +struct Message mlock_msgtab = { + "MLOCK", 0, 0, 0, MFLG_SLOW, + {mg_ignore, mg_ignore, {ms_mlock, 3}, {ms_mlock, 3}, mg_ignore, mg_ignore} +}; struct Message bmask_msgtab = { "BMASK", 0, 0, 0, MFLG_SLOW, {mg_ignore, mg_ignore, mg_ignore, {ms_bmask, 5}, mg_ignore, mg_ignore} }; -mapi_clist_av1 mode_clist[] = { &mode_msgtab, &tmode_msgtab, &bmask_msgtab, NULL }; +mapi_clist_av1 mode_clist[] = { &mode_msgtab, &tmode_msgtab, &mlock_msgtab, &bmask_msgtab, NULL }; DECLARE_MODULE_AV1(mode, NULL, NULL, mode_clist, NULL, NULL, "$Revision: 1006 $"); /* * m_mode - MODE command handler - * parv[0] - sender * parv[1] - channel */ static int @@ -136,9 +136,6 @@ m_mode(struct Client *client_p, struct Client *source_p, int parc, const char *p { msptr = find_channel_membership(chptr, source_p); - if(is_deop(msptr)) - return 0; - /* Finish the flood grace period... */ if(MyClient(source_p) && !IsFloodDone(source_p)) { @@ -211,13 +208,44 @@ ms_tmode(struct Client *client_p, struct Client *source_p, int parc, const char return 0; } +static int +ms_mlock(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) +{ + struct Channel *chptr = NULL; + + /* Now, try to find the channel in question */ + if(!IsChanPrefix(parv[2][0]) || !check_channel_name(parv[2])) + { + sendto_one_numeric(source_p, ERR_BADCHANNAME, form_str(ERR_BADCHANNAME), parv[2]); + return 0; + } + + chptr = find_channel(parv[2]); + + if(chptr == NULL) + { + sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL, + form_str(ERR_NOSUCHCHANNEL), parv[2]); + return 0; + } + + /* TS is higher, drop it. */ + if(atol(parv[1]) > chptr->channelts) + return 0; + + if(IsServer(source_p)) + set_channel_mlock(client_p, source_p, chptr, parv[3], TRUE); + + return 0; +} + static int ms_bmask(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) { static char modebuf[BUFSIZE]; static char parabuf[BUFSIZE]; struct Channel *chptr; - dlink_list *banlist; + rb_dlink_list *banlist; const char *s; char *t; char *mbuf; @@ -283,7 +311,7 @@ ms_bmask(struct Client *client_p, struct Client *source_p, int parc, const char fakesource_p = &me; else fakesource_p = source_p; - mlen = ircsprintf(modebuf, ":%s MODE %s +", fakesource_p->name, chptr->chname); + mlen = rb_sprintf(modebuf, ":%s MODE %s +", fakesource_p->name, chptr->chname); mbuf = modebuf + mlen; pbuf = parabuf; @@ -331,7 +359,7 @@ ms_bmask(struct Client *client_p, struct Client *source_p, int parc, const char } *mbuf++ = parv[3][0]; - arglen = ircsprintf(pbuf, "%s ", s); + arglen = rb_sprintf(pbuf, "%s ", s); pbuf += arglen; plen += arglen; modecount++;