irced

ed, but like irc
git clone git://bvnf.space/irced.git
Log | Files | Refs | README

commit 1418b8d1d28214795b9876923bd564f81ee3d301
parent 17f308172c5e27f47200a9524f3a6209794aab92
Author: aabacchus <ben@bvnf.space>
Date:   Mon, 25 Jul 2022 20:42:29 +0100

announce arrival to others

Diffstat:
Mirced.c | 7++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/irced.c b/irced.c @@ -190,6 +190,7 @@ loop(int sfd) { /* shutdown */ close(fds[i].fd); fds[i].fd = -1; + /* TODO: actually handle this */ } else { fprintf(stderr, "got '"); write(2, buf, buf_used); @@ -205,12 +206,15 @@ loop(int sfd) { if ((p = memchr(unames[i-2], '\r', UNAME_LEN))) *p = '\0'; unames[i-2][UNAME_LEN] = '\0'; - continue; + /* announce arrival */ + buf_used = snprintf(buf, sizeof buf, "%s joined\n", unames[i-2]); + goto send_to_others; } /* send to ed */ if (i != 1 && write(to_ed, buf, buf_used) == -1) fail("couldn't write to ed: %s", strerror(errno)); +send_to_others: /* send to others */ for (int j = 2; j < n; j++) { if (i == j) /* don't send to self */ @@ -257,6 +261,7 @@ main(int argc, char **argv) { #ifdef __OpenBSD__ if (unveil("/bin/", "x") != 0) fail("unveil failed: %s", strerror(errno)); +#endif path = argv[optind]; drop_privileges(path); #ifdef __OpenBSD__