added basic ssl support to ircu
[ircu2.10.12-pk.git] / ircd / m_clearmode.c
index cbd961f88ce6629e0b81b649d0e71776c12e6055..81392da469942342c67b2c07f85302629874fd7f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * IRC - Internet Relay Chat, ircd/m_tmpl.c
+ * IRC - Internet Relay Chat, ircd/m_clearmode.c
  * Copyright (C) 1990 Jarkko Oikarinen and
  *                    University of Oulu, Computing Center
  * Copyright (C) 2000 Kevin L. Mitchell <klmitch@mit.edu>
 #include "msg.h"
 #include "numeric.h"
 #include "numnicks.h"
+#include "s_conf.h"
 #include "send.h"
-#include "support.h"
 
-#include <assert.h>
+/* #include <assert.h> -- Now using assert in ircd_log.h */
 
 /*
  * do_clearmode(struct Client *cptr, struct Client *sptr,
@@ -122,6 +122,8 @@ do_clearmode(struct Client *cptr, struct Client *sptr, struct Channel *chptr,
     MODE_KEY,          'k',
     MODE_BAN,          'b',
     MODE_LIMIT,                'l',
+    MODE_REGONLY,      'r',
+    MODE_DELJOINS,      'D',
     0x0, 0x0
   };
   int *flag_p;
@@ -129,13 +131,9 @@ do_clearmode(struct Client *cptr, struct Client *sptr, struct Channel *chptr,
   char control_buf[20];
   int control_buf_i = 0;
   struct ModeBuf mbuf;
-  struct SLink *link, *next;
+  struct Ban *link, *next;
   struct Membership *member;
 
-  /* Um...yeah, like it's supposed to have any modes at all. */
-  if (IsModelessChannel(chptr->chname))
-    return 0;
-
   /* Ok, so what are we supposed to get rid of? */
   for (; *control; control++) {
     for (flag_p = flags; flag_p[0]; flag_p += 2)
@@ -179,13 +177,13 @@ do_clearmode(struct Client *cptr, struct Client *sptr, struct Channel *chptr,
    */
   if (del_mode & MODE_BAN) {
     for (link = chptr->banlist; link; link = next) {
+      char *bandup;
       next = link->next;
 
+      DupString(bandup, link->banstr);
       modebuf_mode_string(&mbuf, MODE_DEL | MODE_BAN, /* delete ban */
-                         link->value.ban.banstr, 1);
-
-      MyFree(link->value.ban.who); /* free up who string */
-      free_link(link); /* and of course the link itself */
+                         bandup, 1);
+      free_ban(link);
     }
 
     chptr->banlist = 0;
@@ -202,13 +200,13 @@ do_clearmode(struct Client *cptr, struct Client *sptr, struct Channel *chptr,
 
       /* Drop channel operator status */
       if (IsChanOp(member) && del_mode & MODE_CHANOP) {
-       modebuf_mode_client(&mbuf, MODE_DEL | MODE_CHANOP, member->user);
+       modebuf_mode_client(&mbuf, MODE_DEL | MODE_CHANOP, member->user, MAXOPLEVEL + 1);
        member->status &= ~CHFL_CHANOP;
       }
 
       /* Drop voice */
       if (HasVoice(member) && del_mode & MODE_VOICE) {
-       modebuf_mode_client(&mbuf, MODE_DEL | MODE_VOICE, member->user);
+       modebuf_mode_client(&mbuf, MODE_DEL | MODE_VOICE, member->user, MAXOPLEVEL + 1);
        member->status &= ~CHFL_VOICE;
       }
     }
@@ -255,7 +253,7 @@ ms_clearmode(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
     return need_more_params(sptr, "CLEARMODE");
 
   if (!IsPrivileged(sptr)) {
-    protocol_violation(sptr,"No priviledges on source for CLEARMODE, desync?");
+    protocol_violation(sptr,"No privileges on source for CLEARMODE, desync?");
     return send_reply(sptr, ERR_NOPRIVILEGES);
   }
 
@@ -278,6 +276,8 @@ mo_clearmode(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
 {
   struct Channel *chptr;
   char *control = "ovpsmikbl"; /* default control string */
+  const char *chname, *qreason;
+  int force = 0;
 
   if (!feature_bool(FEAT_CONFIG_OPERCMDS))
     return send_reply(sptr, ERR_DISABLED, "CLEARMODE");
@@ -288,14 +288,26 @@ mo_clearmode(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
   if (parc > 2)
     control = parv[2];
 
-  clean_channelname(parv[1]);
+  chname = parv[1];
+  if (*chname == '!')
+  {
+    chname++;
+    if (!HasPriv(sptr, IsLocalChannel(chname) ?
+                         PRIV_FORCE_LOCAL_OPMODE :
+                         PRIV_FORCE_OPMODE))
+      return send_reply(sptr, ERR_NOPRIVILEGES);
+    force = 1;
+  }
 
   if (!HasPriv(sptr,
-              IsLocalChannel(parv[1]) ? PRIV_LOCAL_OPMODE : PRIV_OPMODE))
+              IsLocalChannel(chname) ? PRIV_LOCAL_OPMODE : PRIV_OPMODE))
     return send_reply(sptr, ERR_NOPRIVILEGES);
 
-  if (('#' != *parv[1] && '&' != *parv[1]) || !(chptr = FindChannel(parv[1])))
-    return send_reply(sptr, ERR_NOSUCHCHANNEL, parv[1]);
+  if (('#' != *chname && '&' != *chname) || !(chptr = FindChannel(chname)))
+    return send_reply(sptr, ERR_NOSUCHCHANNEL, chname);
+
+  if (!force && (qreason = find_quarantine(chptr->chname)))
+    return send_reply(sptr, ERR_QUARANTINED, chptr->chname, qreason);
 
   return do_clearmode(cptr, sptr, chptr, control);
 }