From 0e426a3395a95f08b47bdad512a0eaabbc5701d4 Mon Sep 17 00:00:00 2001 From: Nakidai Perumenei Date: Wed, 2 Dec 2026 20:52:27 +0300 Subject: Move announcing code to writef.c Well, I guess that code is needed more then once, so it'll be good to move it to some function --- writef.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'writef.c') diff --git a/writef.c b/writef.c index e010ca4..c7baa0a 100644 --- a/writef.c +++ b/writef.c @@ -65,3 +65,25 @@ 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); + + 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; + } +} -- cgit 1.4.1