From b20be7cbad775ec2119e022ed8e4d225a488c90c Mon Sep 17 00:00:00 2001 From: C. McEnroe Date: Sun, 16 Feb 2020 23:05:43 -0500 Subject: Various small cleanups Haven't really gone through ui.c yet. --- chat.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'chat.c') diff --git a/chat.c b/chat.c index 16ecb8a..fa1240a 100644 --- a/chat.c +++ b/chat.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -39,7 +40,7 @@ static void genCert(const char *path) { const char *name = strrchr(path, '/'); name = (name ? &name[1] : path); - char subj[256]; + char subj[4 + NAME_MAX]; snprintf(subj, sizeof(subj), "/CN=%.*s", (int)strcspn(name, "."), name); umask(0066); execlp( @@ -56,13 +57,11 @@ char *idNames[IDCap] = { [Debug] = "", [Network] = "", }; - enum Color idColors[IDCap] = { [None] = Black, [Debug] = Green, [Network] = Gray, }; - uint idNext = Network + 1; struct Network network; @@ -79,32 +78,33 @@ static void exitSave(void) { uint32_t hashInit; -int utilPipe[2] = { -1, -1 }; +uint execID; int execPipe[2] = { -1, -1 }; +int utilPipe[2] = { -1, -1 }; -static void utilRead(void) { +static void execRead(void) { char buf[1024]; - ssize_t len = read(utilPipe[0], buf, sizeof(buf) - 1); + ssize_t len = read(execPipe[0], buf, sizeof(buf) - 1); if (len < 0) err(EX_IOERR, "read"); if (!len) return; buf[len] = '\0'; char *ptr = buf; while (ptr) { char *line = strsep(&ptr, "\n"); - if (line[0]) uiFormat(Network, Warm, NULL, "%s", line); + if (line[0]) command(execID, line); } } -static void execRead(void) { +static void utilRead(void) { char buf[1024]; - ssize_t len = read(execPipe[0], buf, sizeof(buf) - 1); + ssize_t len = read(utilPipe[0], buf, sizeof(buf) - 1); if (len < 0) err(EX_IOERR, "read"); if (!len) return; buf[len] = '\0'; char *ptr = buf; while (ptr) { char *line = strsep(&ptr, "\n"); - if (line[0]) command(execID, line); + if (line[0]) uiFormat(Network, Warm, NULL, "%s", line); } } @@ -188,7 +188,7 @@ int main(int argc, char *argv[]) { if (!user) user = nick; if (!real) real = nick; - set(&network.name, host); + // Modes defined in RFC 1459: set(&network.chanTypes, "#&"); set(&network.prefixes, "@+"); set(&network.prefixModes, "ov"); @@ -196,6 +196,8 @@ int main(int argc, char *argv[]) { set(&network.paramModes, "k"); set(&network.setParamModes, "l"); set(&network.channelModes, "imnpst"); + + set(&network.name, host); set(&self.nick, "*"); commandComplete(); -- cgit 1.4.1-2-gfad0