--- a/src/nexus.c Sun Feb 22 10:16:28 2009 +0200
+++ b/src/nexus.c Sat Feb 28 17:39:37 2009 +0200
@@ -13,14 +13,17 @@
#include "line_proto.h"
#define CONNECT_HOST "irc.fixme.fi"
-#define CONNECT_SERV "6697"
+#define CONNECT_SERV "6667"
#define LINE_LENGTH 512
+void on_line (const char *line, void *arg) {
+ printf("<<< %s\n", line);
+}
+
int main (int argc, char **argv) {
struct event_base *ev_base;
struct sock_stream *sock;
struct line_proto *lp;
- char *line;
struct error_info _err;
// initialize libevent
@@ -32,25 +35,18 @@
errx(1, "sock_init: %s", error_msg(&_err));
// over-simplified connect
- if (sock_gnutls_connect(&sock, CONNECT_HOST, CONNECT_SERV, &_err))
+ if (sock_tcp_connect(&sock, CONNECT_HOST, CONNECT_SERV, &_err))
errx(1, "sock_gnutls_connect: %s", error_msg(&_err));
// line protocol
- if (line_proto_create(&lp, sock, LINE_LENGTH, NULL, NULL, &_err))
+ if (line_proto_create(&lp, sock, LINE_LENGTH, on_line, NULL, &_err))
errx(1, "line_proto_create: %s", error_msg(&_err));
- // read lines and dump them out
- do {
- // recv
- if (line_proto_read(lp, &line))
- errx(1, "line_proto_read: %s", error_msg(line_proto_error(lp)));
-
- // printf
- printf("<<< %s\n", line);
-
- } while (1);
+ // run event loop
+ if (event_base_dispatch(ev_base))
+ errx(1, "event_base_dispatch");
- // ok
+ // ok, no cleanup
return 0;
}