From 126c147638538ce54fc21a3803955b3693a99add Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Wed, 11 Feb 2026 16:00:24 -0500 Subject: irc.c: handle a few numerics. --- src/irc.c | 47 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 37 insertions(+), 10 deletions(-) (limited to 'src/irc.c') diff --git a/src/irc.c b/src/irc.c index 94450d9..28ce527 100644 --- a/src/irc.c +++ b/src/irc.c @@ -1,8 +1,10 @@ #include +#include #include #include #include "irc.h" +#include "numerics.h" #ifdef __ATARI__ #include @@ -68,17 +70,22 @@ static void do_privmsg(void) { ui_print(msg_text); } -static void do_catchall(void) { - int i; +/* numerics call this with arg==1, since arg 0 is always our nick. + other commands call with arg==0 to print everything. + */ +static void do_catchall(int arg) { if(msg_src) { ui_print(msg_src); ui_putchar(' '); } + ui_print(msg_cmd); - for(i = 0; i < msg_argcount; i++) { + + for(; arg < msg_argcount; arg++) { ui_putchar(' '); - ui_print(msg_args[i]); + ui_print(msg_args[arg]); } + if(msg_text) { ui_putchar(' '); ui_print(msg_text); @@ -86,11 +93,31 @@ static void do_catchall(void) { } static void do_numeric(void) { - do_catchall(); - - /* RPL_ENDOFMOTD or RPL_NOMOTD */ - if(!joined && (streq(msg_cmd, "372") || streq(msg_cmd, "422"))) { - join_channel(); + unsigned int num = atoi(msg_cmd); + + switch(num) { + /* don't print these, but they do trigger an action */ + case RPL_MOTDSTART: + case RPL_ENDOFMOTD: + if(!joined) join_channel(); + break; + + case RPL_TOPIC: + ui_print("Topic for "); + ui_print(msg_args[1]); + ui_print(": "); + ui_print(msg_text); + break; + + case RPL_TOPICWHOTIME: + ui_print("Topic set by: "); + ui_print(msg_args[1]); + ui_putchar('\n'); + break; + + default: + do_catchall(1); + break; } } @@ -189,7 +216,7 @@ static void parse_msg(void) { } else if(isdigit(msg_cmd[0])) { do_numeric(); } else { - do_catchall(); + do_catchall(0); } ui_end_msg(); #else -- cgit v1.2.3