aboutsummaryrefslogtreecommitdiff
path: root/src/irc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/irc.c')
-rw-r--r--src/irc.c47
1 files changed, 37 insertions, 10 deletions
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 <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