X-Git-Url: https://jfr.im/git/solanum.git/blobdiff_plain/81af5bcb394280ff1af82486961d852b102b923b..59cfd72e68e7b41c134eb066f1537abf7f57e024:/modules/m_monitor.c diff --git a/modules/m_monitor.c b/modules/m_monitor.c index e64b9479..4269ad56 100644 --- a/modules/m_monitor.c +++ b/modules/m_monitor.c @@ -1,5 +1,5 @@ /* modules/m_monitor.c - * + * * Copyright (C) 2005 Lee Hardy * 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" @@ -38,16 +36,34 @@ #include "monitor.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) @@ -73,13 +89,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]; @@ -99,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 */ @@ -110,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); @@ -170,7 +189,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; @@ -181,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); } } @@ -227,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); } @@ -256,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); @@ -303,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]) { @@ -313,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]); @@ -323,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]); @@ -347,7 +368,4 @@ m_monitor(struct Client *client_p, struct Client *source_p, int parc, const char default: break; } - - return 0; } -