* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
- * $Id: send.c 1379 2006-05-20 14:11:07Z jilles $
+ * $Id: send.c 3520 2007-06-30 22:15:35Z jilles $
*/
#include "stdinc.h"
#include "s_log.h"
#include "memory.h"
#include "hook.h"
+#include "monitor.h"
#define LOG_BUFSIZE 2048
#ifdef USE_IODEBUG_HOOKS
hook_data_int hd;
#endif
+ fde_t *F = comm_locate_fd(to->localClient->fd);
+ if (!F)
+ return;
+
/* cant write anything to a dead socket. */
if(IsIOError(to))
return;
if(linebuf_len(&to->localClient->buf_sendq))
{
while ((retlen =
- linebuf_flush(to->localClient->fd, &to->localClient->buf_sendq)) > 0)
+ linebuf_flush(F, &to->localClient->buf_sendq)) > 0)
{
/* We have some data written .. update counters */
#ifdef USE_IODEBUG_HOOKS
struct Client *dest_p;
va_list args;
buf_head_t linebuf;
+ char *to;
/* send remote if to->from non NULL */
if(target_p->from != NULL)
va_start(args, pattern);
linebuf_putmsg(&linebuf, pattern, &args,
":%s NOTICE %s ",
- get_id(&me, target_p), get_id(target_p, target_p));
+ get_id(&me, target_p), *(to = get_id(target_p, target_p)) != '\0' ? to : "*");
va_end(args);
_send_linebuf(dest_p, &linebuf);
struct Client *dest_p;
va_list args;
buf_head_t linebuf;
+ char *to;
/* send remote if to->from non NULL */
if(target_p->from != NULL)
linebuf_putmsg(&linebuf, pattern, &args,
":%s %03d %s ",
get_id(&me, target_p),
- numeric, get_id(target_p, target_p));
+ numeric, *(to = get_id(target_p, target_p)) != '\0' ? to : "*");
va_end(args);
_send_linebuf(dest_p, &linebuf);
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