src/nexus.c
changeset 17 5001564ac5fc
parent 16 20ce0029e4a0
child 18 dedf137b504f
equal deleted inserted replaced
16:20ce0029e4a0 17:5001564ac5fc
     7 
     7 
     8 #include <event2/event.h>
     8 #include <event2/event.h>
     9 
     9 
    10 #include "sock.h"
    10 #include "sock.h"
    11 #include "line_proto.h"
    11 #include "line_proto.h"
       
    12 #include "irc_line.h"
    12 
    13 
    13 #define CONNECT_HOST "irc.fixme.fi"
    14 #define CONNECT_HOST "irc.fixme.fi"
    14 #define CONNECT_SERV "6697"
    15 #define CONNECT_SERV "6697"
    15 #define LINE_LENGTH 512
    16 #define LINE_LENGTH 512
    16 
    17 
    30     printf(" --hostname / -H HOST   set hostname to connect to\n");
    31     printf(" --hostname / -H HOST   set hostname to connect to\n");
    31     printf(" --port / -P PORT       set service port to connect to\n");
    32     printf(" --port / -P PORT       set service port to connect to\n");
    32     printf(" --ssl / -S             use SSL\n");
    33     printf(" --ssl / -S             use SSL\n");
    33 }
    34 }
    34 
    35 
    35 void on_line (const char *line, void *arg) 
    36 void on_line (char *line_buf, void *arg) 
    36 {
    37 {
    37     printf("<<< %s\n", line);
    38     struct irc_line line;
       
    39     int err;
       
    40 
       
    41     // parse
       
    42     if ((err = irc_line_parse(&line, line_buf)))
       
    43         printf("!!! Invalid line: %s: %s\n", line_buf, error_name(err));
       
    44 
       
    45     else
       
    46         printf("<<< prefix=%s, command=%s, args={%s, %s, %s, ...}\n",
       
    47                 line.prefix, line.command, line.args[0], line.args[1], line.args[2]
       
    48         );
    38 }
    49 }
    39 
    50 
    40 int main (int argc, char **argv) 
    51 int main (int argc, char **argv) 
    41 {
    52 {
    42     int opt, option_index;
    53     int opt, option_index;