]> jfr.im git - solanum.git/blobdiff - modules/m_monitor.c
Add oper:testline
[solanum.git] / modules / m_monitor.c
index f230fa92b87190de89dedc837838c02581cbdc35..4269ad5678227c86360880a3d6d4c392be0c8f81 100644 (file)
@@ -1,5 +1,5 @@
 /* modules/m_monitor.c
- * 
+ *
  *  Copyright (C) 2005 Lee Hardy <lee@leeh.co.uk>
  *  Copyright (C) 2005 ircd-ratbox development team
  *
@@ -26,8 +26,6 @@
  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
- *
- * $Id: m_monitor.c 312 2005-11-07 10:47:33Z jilles $
  */
 
 #include "stdinc.h"
 #include "numeric.h"
 #include "s_conf.h"
 #include "send.h"
+#include "supported.h"
+
+static const char monitor_desc[] = "Provides the MONITOR facility for tracking user signon and signoff";
 
-static int m_monitor(struct Client *, struct Client *, int, const char **);
+static int monitor_init(void);
+static void monitor_deinit(void);
+static void m_monitor(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
 
 struct Message monitor_msgtab = {
-       "MONITOR", 0, 0, 0, MFLG_SLOW,
+       "MONITOR", 0, 0, 0, 0,
        {mg_unreg, {m_monitor, 2}, mg_ignore, mg_ignore, mg_ignore, {m_monitor, 2}}
 };
 
 mapi_clist_av1 monitor_clist[] = { &monitor_msgtab, NULL };
-DECLARE_MODULE_AV1(monitor, NULL, NULL, monitor_clist, NULL, NULL, "$Revision: 312 $");
+
+DECLARE_MODULE_AV2(monitor, monitor_init, monitor_deinit, monitor_clist, NULL, NULL, NULL, NULL, monitor_desc);
+
+static int monitor_init(void)
+{
+       add_isupport("MONITOR", isupport_intptr, &ConfigFileEntry.max_monitor);
+       return 0;
+}
+
+static void monitor_deinit(void)
+{
+       delete_isupport("MONITOR");
+}
 
 static void
 add_monitor(struct Client *client_p, const char *nicks)
@@ -80,7 +95,7 @@ add_monitor(struct Client *client_p, const char *nicks)
                        continue;
 
                if(rb_dlink_list_length(&client_p->localClient->monitor_list) >=
-                       ConfigFileEntry.max_monitor)
+                       (unsigned long)ConfigFileEntry.max_monitor)
                {
                        char buf[100];
 
@@ -90,9 +105,9 @@ add_monitor(struct Client *client_p, const char *nicks)
                                sendto_one(client_p, "%s", offbuf);
 
                        if(p)
-                               rb_snprintf(buf, sizeof(buf), "%s,%s", name, p);
+                               snprintf(buf, sizeof(buf), "%s,%s", name, p);
                        else
-                               rb_snprintf(buf, sizeof(buf), "%s", name);
+                               snprintf(buf, sizeof(buf), "%s", name);
 
                        sendto_one(client_p, form_str(ERR_MONLISTFULL),
                                        me.name, client_p->name,
@@ -100,6 +115,9 @@ add_monitor(struct Client *client_p, const char *nicks)
                        return;
                }
 
+               if (!clean_nick(name, 0))
+                       continue;
+
                monptr = find_monitor(name, 1);
 
                /* already monitoring this nick */
@@ -111,7 +129,7 @@ add_monitor(struct Client *client_p, const char *nicks)
 
                if((target_p = find_named_person(name)) != NULL)
                {
-                       if(cur_onlen + strlen(target_p->name) + 
+                       if(cur_onlen + strlen(target_p->name) +
                           strlen(target_p->username) + strlen(target_p->host) + 3 >= BUFSIZE-3)
                        {
                                sendto_one(client_p, "%s", onbuf);
@@ -182,6 +200,8 @@ del_monitor(struct Client *client_p, const char *nicks)
 
                rb_dlinkFindDestroy(client_p, &monptr->users);
                rb_dlinkFindDestroy(monptr, &client_p->localClient->monitor_list);
+
+               free_monitor(monptr);
        }
 }
 
@@ -228,7 +248,7 @@ list_monitor(struct Client *client_p)
        }
 
        sendto_one(client_p, "%s", buf);
-       sendto_one(client_p, form_str(RPL_ENDOFMONLIST), 
+       sendto_one(client_p, form_str(RPL_ENDOFMONLIST),
                        me.name, client_p->name);
 }
 
@@ -257,7 +277,7 @@ show_monitor_status(struct Client *client_p)
 
                if((target_p = find_named_person(monptr->name)) != NULL)
                {
-                       if(cur_onlen + strlen(target_p->name) + 
+                       if(cur_onlen + strlen(target_p->name) +
                           strlen(target_p->username) + strlen(target_p->host) + 3 >= BUFSIZE-3)
                        {
                                sendto_one(client_p, "%s", onbuf);
@@ -304,8 +324,8 @@ show_monitor_status(struct Client *client_p)
                sendto_one(client_p, "%s", offbuf);
 }
 
-static int
-m_monitor(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
+static void
+m_monitor(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
 {
        switch(parv[1][0])
        {
@@ -314,7 +334,7 @@ m_monitor(struct Client *client_p, struct Client *source_p, int parc, const char
                        {
                                sendto_one(client_p, form_str(ERR_NEEDMOREPARAMS),
                                                me.name, source_p->name, "MONITOR");
-                               return 0;
+                               return;
                        }
 
                        add_monitor(source_p, parv[2]);
@@ -324,7 +344,7 @@ m_monitor(struct Client *client_p, struct Client *source_p, int parc, const char
                        {
                                sendto_one(client_p, form_str(ERR_NEEDMOREPARAMS),
                                                me.name, source_p->name, "MONITOR");
-                               return 0;
+                               return;
                        }
 
                        del_monitor(source_p, parv[2]);
@@ -348,7 +368,4 @@ m_monitor(struct Client *client_p, struct Client *source_p, int parc, const char
                default:
                        break;
        }
-
-       return 0;
 }
-