From 8aba962d4307746f8eca05d56c9ea34c370332b9 Mon Sep 17 00:00:00 2001 From: jilles Date: Sat, 30 Jun 2007 15:15:35 -0700 Subject: [PATCH] [svn] monitor: send the same message buffer to all users monitoring a certain nick; the target field of the numeric becomes *, much like server notices --- ChangeLog | 9 +++++++++ doc/monitor.txt | 8 +++++++- include/send.h | 5 ++++- include/serno.h | 2 +- src/monitor.c | 20 ++++---------------- src/send.c | 37 ++++++++++++++++++++++++++++++++++++- 6 files changed, 61 insertions(+), 20 deletions(-) diff --git a/ChangeLog b/ChangeLog index 06a80a3..86887d0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +jilles 2007/06/22 21:59:09 UTC (20070622-3518) + Log: + Call add_to_hostname_hash() with correct (orig) hostname. + + + Changes: Modified: + +1 -1 trunk/modules/core/m_nick.c (File Modified) + + jilles 2007/06/10 16:14:03 UTC (20070610-3516) Log: Version bump on trunk to 2.3. diff --git a/doc/monitor.txt b/doc/monitor.txt index d99889f..4b10e92 100644 --- a/doc/monitor.txt +++ b/doc/monitor.txt @@ -1,6 +1,6 @@ MONITOR - Protocol for notification of when clients become online/offline Lee Hardy -$Id: monitor.txt 6 2005-09-10 01:02:21Z nenolod $ +$Id: monitor.txt 3520 2007-06-30 22:15:35Z jilles $ ------------------------------------------------------------------------- Currently, ISON requests by clients use a large amount of bandwidth. It is @@ -76,6 +76,10 @@ This numeric is used to indicate to a client that either a nickname has just become online, or that a nickname they have added to their monitor list is online. +The server may send "*" instead of the target nick (). (This makes it +possible to send the exact same message to all clients monitoring a certain +nick.) + 731 - RPL_MONOFFLINE -------------------- : 731 :nick[,nick1]* @@ -86,6 +90,8 @@ list is offline. The argument is a chained list of nicknames that are offline. +As with 730 the server may send "*" instead of the target nick. + 732 - RPL_MONLIST ----------------- : 732 :nick[,nick1]* diff --git a/include/send.h b/include/send.h index f1f5349..924c670 100644 --- a/include/send.h +++ b/include/send.h @@ -21,7 +21,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * USA * - * $Id: send.h 661 2006-02-03 04:20:31Z gxti $ + * $Id: send.h 3520 2007-06-30 22:15:35Z jilles $ */ #ifndef INCLUDED_send_h @@ -33,6 +33,7 @@ struct Client; struct Channel; struct dlink_list; +struct monitor; /* The nasty global also used in s_serv.c for server bursts */ extern unsigned long current_serial; @@ -65,6 +66,8 @@ extern void sendto_match_butone(struct Client *, struct Client *, extern void sendto_match_servs(struct Client *source_p, const char *mask, int capab, int, const char *, ...) AFP(5, 6); +extern void sendto_monitor(struct monitor *monptr, const char *, ...) AFP(2, 3); + extern void sendto_anywhere(struct Client *, struct Client *, const char *, const char *, ...) AFP(4, 5); diff --git a/include/serno.h b/include/serno.h index af9ef24..8112dea 100644 --- a/include/serno.h +++ b/include/serno.h @@ -1 +1 @@ -#define SERNO "20070610-3516" +#define SERNO "20070622-3518" diff --git a/src/monitor.c b/src/monitor.c index c0a6694..8456d6f 100644 --- a/src/monitor.c +++ b/src/monitor.c @@ -29,7 +29,7 @@ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * $Id: monitor.c 312 2005-11-07 10:47:33Z jilles $ + * $Id: monitor.c 3520 2007-06-30 22:15:35Z jilles $ */ #include "stdinc.h" #include "tools.h" @@ -98,8 +98,6 @@ monitor_signon(struct Client *client_p) { char buf[USERHOST_REPLYLEN]; struct monitor *monptr = find_monitor(client_p->name, 0); - struct Client *target_p; - dlink_node *ptr; /* noones watching this nick */ if(monptr == NULL) @@ -108,13 +106,7 @@ monitor_signon(struct Client *client_p) ircsnprintf(buf, sizeof(buf), "%s!%s@%s", client_p->name, client_p->username, client_p->host); - DLINK_FOREACH(ptr, monptr->users.head) - { - target_p = ptr->data; - - sendto_one(target_p, form_str(RPL_MONONLINE), - me.name, target_p->name, buf); - } + sendto_monitor(monptr, form_str(RPL_MONONLINE), me.name, "*", buf); } /* monitor_signoff() @@ -128,17 +120,13 @@ void monitor_signoff(struct Client *client_p) { struct monitor *monptr = find_monitor(client_p->name, 0); - dlink_node *ptr; /* noones watching this nick */ if(monptr == NULL) return; - DLINK_FOREACH(ptr, monptr->users.head) - { - sendto_one(ptr->data, form_str(RPL_MONOFFLINE), - me.name, ((struct Client *) ptr->data)->name, client_p->name); - } + sendto_monitor(monptr, form_str(RPL_MONOFFLINE), me.name, "*", + client_p->name); } void diff --git a/src/send.c b/src/send.c index e32e7fb..bd4adea 100644 --- a/src/send.c +++ b/src/send.c @@ -21,7 +21,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * USA * - * $Id: send.c 3161 2007-01-25 07:23:01Z nenolod $ + * $Id: send.c 3520 2007-06-30 22:15:35Z jilles $ */ #include "stdinc.h" @@ -43,6 +43,7 @@ #include "s_log.h" #include "memory.h" #include "hook.h" +#include "monitor.h" #define LOG_BUFSIZE 2048 @@ -928,6 +929,40 @@ sendto_match_servs(struct Client *source_p, const char *mask, int cap, linebuf_donebuf(&linebuf_name); } +/* sendto_monitor() + * + * inputs - monitor nick to send to, format, va_args + * outputs - message to local users monitoring the given nick + * side effects - + */ +void +sendto_monitor(struct monitor *monptr, const char *pattern, ...) +{ + va_list args; + buf_head_t linebuf; + struct Client *target_p; + dlink_node *ptr; + dlink_node *next_ptr; + + linebuf_newbuf(&linebuf); + + va_start(args, pattern); + linebuf_putmsg(&linebuf, pattern, &args, NULL); + va_end(args); + + DLINK_FOREACH_SAFE(ptr, next_ptr, monptr->users.head) + { + target_p = ptr->data; + + if(IsIOError(target_p)) + continue; + + _send_linebuf(target_p, &linebuf); + } + + linebuf_donebuf(&linebuf); +} + /* sendto_anywhere() * * inputs - target, source, va_args