From 7425076e521f23564249263984cd680c54cbc885 Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Wed, 24 Jun 2020 17:08:51 -0400 Subject: Bump ParamCap to 254 Apparently IRCds have decided that the 15-parameter limit doesn't matter anymore. 254 is the maximum number of single-byte parameters (following a single-byte command) which fit in a 512-byte CR-LF-terminated line. When everyone decides that the 512-byte line length limit doesn't matter either, I will delete my software and people can use some JavaScript garbage instead. This makes struct Message 2080 bytes, but there's only ever one of it around at once. Avoid passing it by value to handle. --- litterbox.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/litterbox.c b/litterbox.c index 0fe8797..a291ad0 100644 --- a/litterbox.c +++ b/litterbox.c @@ -69,7 +69,7 @@ static void format(const char *format, ...) { clientWrite(buf, len); } -enum { ParamCap = 15 }; +enum { ParamCap = 254 }; struct Message { size_t pos; char *time; @@ -691,19 +691,19 @@ static int compar(const void *cmd, const void *_handler) { return strcmp(cmd, handler->cmd); } -static void handle(struct Message msg) { - if (!msg.cmd) return; +static void handle(struct Message *msg) { + if (!msg->cmd) return; const struct Handler *handler = bsearch( - msg.cmd, Handlers, ARRAY_LEN(Handlers), sizeof(*handler), compar + msg->cmd, Handlers, ARRAY_LEN(Handlers), sizeof(*handler), compar ); if (!handler) return; if (handler->transaction) { dbExec(SQL(BEGIN TRANSACTION;)); - handler->fn(&msg); - if (msg.pos) updateConsumer(msg.pos); + handler->fn(msg); + if (msg->pos) updateConsumer(msg->pos); dbExec(SQL(COMMIT TRANSACTION;)); } else { - handler->fn(&msg); + handler->fn(msg); } } @@ -885,7 +885,8 @@ int main(int argc, char *argv[]) { char *crlf = memmem(line, &buf[len] - line, "\r\n", 2); if (!crlf) break; crlf[0] = '\0'; - handle(parse(line)); + struct Message msg = parse(line); + handle(&msg); line = crlf + 2; } len -= line - buf; -- cgit 1.4.1