diff options
| author | Nakidai Perumenei <nakidai@disroot.org> | 2026-12-02 20:52:27 +0300 |
|---|---|---|
| committer | Nakidai <nakidai@disroot.org> | 2026-01-30 15:32:45 +0300 |
| commit | 0e426a3395a95f08b47bdad512a0eaabbc5701d4 (patch) | |
| tree | e341bfe72b67d2f5bfccee9345b62e9740cea25a /writef.c | |
| parent | 559fac39d83083f1720b235e33a8219ed07de653 (diff) | |
| download | libreircd-0e426a3395a95f08b47bdad512a0eaabbc5701d4.tar.gz libreircd-0e426a3395a95f08b47bdad512a0eaabbc5701d4.zip | |
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
Diffstat (limited to 'writef.c')
| -rw-r--r-- | writef.c | 22 |
1 files changed, 22 insertions, 0 deletions
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; + } +} |