diff options
author | June McEnroe <june@causal.agency> | 2020-02-04 03:58:56 -0500 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2020-02-04 03:58:56 -0500 |
commit | 43845c61156bf27955891d68c2e1a2504786b587 (patch) | |
tree | e8cb5c9c104c23f5d60b920d24c21b1677bda5cc /chat.c | |
parent | Use time_t rather than struct tm (diff) | |
download | catgirl-43845c61156bf27955891d68c2e1a2504786b587.tar.gz catgirl-43845c61156bf27955891d68c2e1a2504786b587.zip |
Add beginnings of input handling
Diffstat (limited to '')
-rw-r--r-- | chat.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/chat.c b/chat.c index 162f68f..3402621 100644 --- a/chat.c +++ b/chat.c @@ -15,7 +15,9 @@ */ #include <err.h> +#include <errno.h> #include <locale.h> +#include <poll.h> #include <stdbool.h> #include <stdio.h> #include <stdlib.h> @@ -98,8 +100,16 @@ int main(int argc, char *argv[]) { ircFormat("NICK :%s\r\n", nick); ircFormat("USER %s 0 * :%s\r\n", user, real); + struct pollfd fds[2] = { + { .events = POLLIN, .fd = STDIN_FILENO }, + { .events = POLLIN, .fd = irc }, + }; for (;;) { + int nfds = poll(fds, 2, -1); + if (nfds < 0 && errno != EINTR) err(EX_IOERR, "poll"); + + if (fds[0].revents) uiRead(); + if (fds[1].revents) ircRecv(); uiDraw(); - ircRecv(); } } |