src/nexus.c
changeset 21 0911d0b828d4
parent 18 dedf137b504f
child 22 c339c020fd33
--- a/src/nexus.c	Sun Mar 01 00:34:33 2009 +0200
+++ b/src/nexus.c	Sun Mar 01 01:48:14 2009 +0200
@@ -1,14 +1,15 @@
+
+#include "log.h"
+#include "sock.h"
+#include "irc_conn.h"
 
 #include <stdlib.h>
 #include <stdbool.h>
-#include <err.h>
 #include <stdio.h>
 #include <getopt.h>
 
 #include <event2/event.h>
 
-#include "sock.h"
-#include "irc_conn.h"
 
 #define DEFAULT_HOST "irc.fixme.fi"
 #define DEFAULT_PORT "6667"
@@ -38,7 +39,7 @@
     struct event_base *ev_base;
     struct sock_stream *sock;
     struct irc_conn *conn;
-    struct error_info _err;
+    struct error_info err;
 
     const char *hostname = DEFAULT_HOST, *portname = DEFAULT_PORT;
     bool ssl = 0;
@@ -82,30 +83,30 @@
 
     // initialize libevent
     if ((ev_base = event_base_new()) == NULL)
-        err(1, "event_base_new");
+        FATAL("event_base_new");
 
     // initialize sock module
-    if (sock_init(ev_base, &_err))
-        errx(1, "sock_init: %s", error_msg(&_err));
+    if (sock_init(ev_base, &err))
+        FATAL_ERROR(&err, "sock_init");
 
     // over-simplified connect
     if (ssl) {
-        if (sock_ssl_connect(&sock, hostname, portname, &_err))
-            errx(1, "sock_ssl_connect: %s", error_msg(&_err));
+        if (sock_ssl_connect(&sock, hostname, portname, &err))
+            FATAL_ERROR(&err, "sock_ssl_connect(%s, %s)", hostname, portname);
 
     } else {
-        if (sock_tcp_connect(&sock, hostname, portname, &_err))
-            errx(1, "sock_tcp_connect: %s", error_msg(&_err));
+        if (sock_tcp_connect(&sock, hostname, portname, &err))
+            FATAL_ERROR(&err, "sock_tcp_connect(%s, %s)", hostname, portname);
 
     }
 
     // create the irc connection state
-    if (irc_conn_create(&conn, sock, &conn_config, &_err))
-        errx(1, "irc_conn_create: %s", error_msg(&_err));
+    if (irc_conn_create(&conn, sock, &conn_config, &err))
+        FATAL_ERROR(&err, "irc_conn_create");
 
     // run event loop
     if (event_base_dispatch(ev_base))
-        errx(1, "event_base_dispatch");
+        FATAL("event_base_dispatch");
     
     // ok, no cleanup
     return 0;