about summary refs log tree commit diff
path: root/writef.c
diff options
context:
space:
mode:
Diffstat (limited to 'writef.c')
-rw-r--r--writef.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/writef.c b/writef.c
index e010ca4..c5e6b95 100644
--- a/writef.c
+++ b/writef.c
@@ -65,3 +65,31 @@ writechanf(const struct Peer *except, const struct Channel *channel, const char
 
 	return count;
 }
+
+void
+announce(struct Peer *peer, const char *fmt, ...)
+{
+	va_list args;
+	size_t i, j;
+
+	va_start(args, fmt);
+	vstoref(fmt, args);
+	va_end(args);
+
+	if (!peer->channels_c)
+	{
+		write(peer->fd, buf, written);
+		return;
+	}
+
+	for (i = 0; i < peer->channels_c; ++i)
+		for (j = 0; j < peer->channels[i]->users_c; ++j)
+			peer->channels[i]->users[j]->flags |= ANNOUNCE;
+
+	for (i = 0; i < peers_c; ++i)
+		if (peers[i].flags & ANNOUNCE)
+		{
+			write(peers[i].fd, buf, written);
+			peers[i].flags &= ~ANNOUNCE;
+		}
+}