10 #include <event2/event.h> |
10 #include <event2/event.h> |
11 |
11 |
12 #include "sock.h" |
12 #include "sock.h" |
13 #include "line_proto.h" |
13 #include "line_proto.h" |
14 |
14 |
15 #define CONNECT_HOST "localhost" |
15 #define CONNECT_HOST "irc.fixme.fi" |
16 #define CONNECT_SERV "5002" |
16 #define CONNECT_SERV "6697" |
17 #define LINE_LENGTH 512 |
17 #define LINE_LENGTH 512 |
18 |
18 |
19 void on_line (const char *line, void *arg) { |
19 void on_line (const char *line, void *arg) { |
20 printf("<<< %s\n", line); |
20 printf("<<< %s\n", line); |
21 } |
21 } |
33 // initialize sock module |
33 // initialize sock module |
34 if (sock_init(ev_base, &_err)) |
34 if (sock_init(ev_base, &_err)) |
35 errx(1, "sock_init: %s", error_msg(&_err)); |
35 errx(1, "sock_init: %s", error_msg(&_err)); |
36 |
36 |
37 // over-simplified connect |
37 // over-simplified connect |
38 if (sock_tcp_connect(&sock, CONNECT_HOST, CONNECT_SERV, &_err)) |
38 if (sock_ssl_connect(&sock, CONNECT_HOST, CONNECT_SERV, &_err)) |
39 errx(1, "sock_gnutls_connect: %s", error_msg(&_err)); |
39 errx(1, "sock_gnutls_connect: %s", error_msg(&_err)); |
40 |
40 |
41 // line protocol, with safety margin for buffer |
41 // line protocol, with safety margin for buffer |
42 if (line_proto_create(&lp, sock, LINE_LENGTH * 2, on_line, NULL, &_err)) |
42 if (line_proto_create(&lp, sock, LINE_LENGTH * 2, on_line, NULL, &_err)) |
43 errx(1, "line_proto_create: %s", error_msg(&_err)); |
43 errx(1, "line_proto_create: %s", error_msg(&_err)); |