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 follow=1'>Use int when checking for EOFJune McEnroe 2021-01-28Move gpl.c and agpl.c templates out of etcJune McEnroe 2021-01-27Set para and sect for mdocJune McEnroe Copied from the OpenBSD defaults. 2021-01-26Use First state to match keyword at beginning of lineJune McEnroe Otherwise keywords at the beginnings of lines with preceeding whitespace are not matched. 2021-01-25Install vi on Linux and nvi on macOSJune McEnroe 2021-01-25Use vi and lessJune McEnroe I haven't used neovim in a couple weeks by now, so I may as well commit this. 2021-01-20Use mtags for sh in source-filterJune McEnroe 2021-01-20Generate tags for sh files in mtagsJune McEnroe Only matches functions declared at the beginnings of lines, but I'm fine with that. 2021-01-20Add messy sh lexerJune McEnroe Surprisingly seems to work for everything I looked at in my repos. 2021-01-20Add all target to git.causal.agency MakefileJune McEnroe 2021-01-20Remove Lua supportJune McEnroe Lua support is unused and the dlsym fwrite/write hacks horrify me. Clean it up. 2021-01-20Fix tests for diff spansJune McEnroe 2021-01-20Avoid matching ':' in make tagsJune McEnroe Otherwise a :: rule includes one of the ':'s in the tag name. 2021-01-19Prefer tag matches not preceded by [[:alnum:]]June McEnroe Otherwise the "id" in "void" matches for "void id". 2021-01-19Escape \ and / in mtags search patternsJune McEnroe 2021-01-20Use mtags in source-filterJune McEnroe 2021-01-19Add mtags to generate tags for make and mdocJune McEnroe 2021-01-19Map tags to IDs using only [[:alnum:]-._]June McEnroe 2021-01-19Don't use a pager if reading standard inputJune McEnroe 2021-01-19Support BSD make syntax and match *.amJune McEnroe These don't really go together, but... 2021-01-19Match tab following escaped newline in make assignmentsJune McEnroe Otherwise it ends up going into Shell state. 2021-01-18Allow matching lexers using first input lineJune McEnroe