src/nexus.c
changeset 17 5001564ac5fc
parent 16 20ce0029e4a0
child 18 dedf137b504f
--- a/src/nexus.c	Sat Feb 28 20:23:37 2009 +0200
+++ b/src/nexus.c	Sat Feb 28 21:39:15 2009 +0200
@@ -9,6 +9,7 @@
 
 #include "sock.h"
 #include "line_proto.h"
+#include "irc_line.h"
 
 #define CONNECT_HOST "irc.fixme.fi"
 #define CONNECT_SERV "6697"
@@ -32,9 +33,19 @@
     printf(" --ssl / -S             use SSL\n");
 }
 
-void on_line (const char *line, void *arg) 
+void on_line (char *line_buf, void *arg) 
 {
-    printf("<<< %s\n", line);
+    struct irc_line line;
+    int err;
+
+    // parse
+    if ((err = irc_line_parse(&line, line_buf)))
+        printf("!!! Invalid line: %s: %s\n", line_buf, error_name(err));
+
+    else
+        printf("<<< prefix=%s, command=%s, args={%s, %s, %s, ...}\n",
+                line.prefix, line.command, line.args[0], line.args[1], line.args[2]
+        );
 }
 
 int main (int argc, char **argv)