]> jfr.im git - solanum.git/blobdiff - modules/m_monitor.c
msg: remove last vestiges of the fakelag system. charybdis has never supported fakelag.
[solanum.git] / modules / m_monitor.c
index ef0f6bac01b8115bba5a6450f80c95f2a431a0f9..ae26035be9ace6465baf2d11e92a45e6aa075a96 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
  *
@@ -31,7 +31,6 @@
  */
 
 #include "stdinc.h"
-#include "tools.h"
 #include "client.h"
 #include "msg.h"
 #include "parse.h"
 #include "monitor.h"
 #include "numeric.h"
 #include "s_conf.h"
+#include "send.h"
+#include "supported.h"
 
-static int m_monitor(struct Client *, struct Client *, int, const char **);
+static int monitor_init(void);
+static void monitor_deinit(void);
+static int 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_AV1(monitor, monitor_init, monitor_deinit, monitor_clist, NULL, NULL, "$Revision: 312 $");
+
+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)
@@ -74,13 +88,13 @@ add_monitor(struct Client *client_p, const char *nicks)
 
        tmp = LOCAL_COPY(nicks);
 
-       for(name = strtoken(&p, tmp, ","); name; name = strtoken(&p, NULL, ","))
+       for(name = rb_strtok_r(tmp, ",", &p); name; name = rb_strtok_r(NULL, ",", &p))
        {
                if(EmptyString(name) || strlen(name) > NICKLEN-1)
                        continue;
 
                if(rb_dlink_list_length(&client_p->localClient->monitor_list) >=
-                       ConfigFileEntry.max_monitor)
+                       (unsigned long)ConfigFileEntry.max_monitor)
                {
                        char buf[100];
 
@@ -100,18 +114,21 @@ 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 */
-               if(dlinkFind(client_p, &monptr->users))
+               if(rb_dlinkFind(client_p, &monptr->users))
                        continue;
 
-               dlinkAddAlloc(client_p, &monptr->users);
-               dlinkAddAlloc(monptr, &client_p->localClient->monitor_list);
+               rb_dlinkAddAlloc(client_p, &monptr->users);
+               rb_dlinkAddAlloc(monptr, &client_p->localClient->monitor_list);
 
                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);
@@ -171,7 +188,7 @@ del_monitor(struct Client *client_p, const char *nicks)
 
        tmp = LOCAL_COPY(nicks);
 
-       for(name = strtoken(&p, tmp, ","); name; name = strtoken(&p, NULL, ","))
+       for(name = rb_strtok_r(tmp, ",", &p); name; name = rb_strtok_r(NULL, ",", &p))
        {
                if(EmptyString(name))
                        continue;
@@ -182,6 +199,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 +247,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 +276,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);
@@ -305,7 +324,7 @@ show_monitor_status(struct Client *client_p)
 }
 
 static int
-m_monitor(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
+m_monitor(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
 {
        switch(parv[1][0])
        {
@@ -351,4 +370,3 @@ m_monitor(struct Client *client_p, struct Client *source_p, int parc, const char
 
        return 0;
 }
-