diff -r 97604efda1ce -r 12d806823775 src/nexus.c --- a/src/nexus.c Fri Mar 13 15:22:46 2009 +0200 +++ b/src/nexus.c Fri Mar 13 16:10:48 2009 +0200 @@ -1,5 +1,4 @@ - -#include "irc_net.h" +#include "nexus.h" #include "irc_log.h" #include "signals.h" #include "log.h" @@ -10,9 +9,6 @@ #include #include -#include - - #define DEFAULT_HOST "irc.fixme.fi" #define DEFAULT_PORT "6667" #define DEFAULT_PORT_SSL "6697" @@ -46,17 +42,6 @@ printf(" --log-channel channel to log\n"); } -/** - * Context for async nexus operation - */ -struct nexus_ctx { - /** The libevent base */ - struct event_base *ev_base; - - /** The one IRC network */ - struct irc_net *net; -}; - void on_sigint (evutil_socket_t sig, short what, void *arg) { struct nexus_ctx *ctx = arg; @@ -64,19 +49,19 @@ (void) sig; (void) what; - if (ctx->net && ctx->net->conn && !ctx->net->conn->quitting) { + if (ctx->client && !ctx->client->quitting) { log_info("Quitting..."); // quit it - irc_net_quit(ctx->net, "Goodbye, cruel world ;("); + irc_client_quit(ctx->client, "Goodbye, cruel world ;("); } else { log_error("Aborting"); // die - if (ctx->net) { - irc_net_destroy(ctx->net); - ctx->net = NULL; + if (ctx->client) { + irc_client_destroy(ctx->client); + ctx->client = NULL; } // exit @@ -87,8 +72,9 @@ int main (int argc, char **argv) { int opt, option_index; + struct signals *signals; struct nexus_ctx ctx; - struct signals *signals; + struct irc_net *net; struct error_info err; struct irc_net_info net_info = { @@ -164,9 +150,13 @@ if (sock_init(ctx.ev_base, &err)) FATAL_ERROR(&err, "sock_init"); + // the IRC client + if (irc_client_create(&ctx.client, &err)) + FATAL_ERROR(&err, "irc_client_create"); + // the IRC network - if (irc_net_create(&ctx.net, &net_info, &err)) - FATAL_ERROR(&err, "irc_net_create"); + if (irc_client_add_net(ctx.client, &net, &net_info)) + FATAL_ERR(ERROR_CODE(&err), "irc_client_add_net"); // add our signal handlers if ( @@ -178,7 +168,7 @@ // logging? if (log_info.db_info || log_chan_info.channel) { // get the channel - if (log_chan_info.channel && (log_info.channel = irc_net_add_chan(ctx.net, &log_chan_info)) == NULL) + if (log_chan_info.channel && (log_info.channel = irc_net_add_chan(net, &log_chan_info)) == NULL) FATAL("irc_net_add_chan"); // init the irc_log module