diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/irc.c | 47 | ||||
| -rw-r--r-- | src/main.c | 14 |
2 files changed, 44 insertions, 17 deletions
@@ -1,8 +1,10 @@ #include <stdio.h> +#include <stdlib.h> #include <string.h> #include <ctype.h> #include "irc.h" +#include "numerics.h" #ifdef __ATARI__ #include <atari.h> @@ -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 @@ -72,13 +72,13 @@ void get_config(void) { if(tx_buf[0] != CH_EOL) strcpy_to_eol(channel, tx_buf); /* - print("\n\nURL: "); - print(url); - print("\nNick: "); - print(usernick); - print("\nChannel: "); - print(channel); - */ + print("\n\nURL: "); + print(url); + print("\nNick: "); + print(usernick); + print("\nChannel: "); + print(channel); + */ print("\n\nAre these settings OK [Y/n]? "); if(tolower(cgetc()) != 'n') break; |
