X-Git-Url: http://git.pk910.de/?a=blobdiff_plain;f=src%2Fmain.c;h=848023a0e5a62e9126d3701d862e03a4edbb9be9;hb=07cbc4d1b2b6e3a78376d7e42c7a7636a6cd33d7;hp=b2c8ca4b7782096504562f89158d0fedbe00166c;hpb=02cdeb3fbf84ac31949032ec23169d3cb048a16d;p=NextIRCd.git diff --git a/src/main.c b/src/main.c index b2c8ca4..848023a 100644 --- a/src/main.c +++ b/src/main.c @@ -1,5 +1,5 @@ -/* main.c - IOMultiplexer - * Copyright (C) 2012 Philipp Kreil (pk910) +/* main.c - NextIRCd + * Copyright (C) 2012-2013 Philipp Kreil (pk910) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -15,49 +15,28 @@ * along with this program. If not, see . */ -#include -#include "IOHandler.h" +#include "ircd_config.h" +#include "ircd_sock.h" +#include "IOHandler/IOHandler.h" +#include "IOHandler/IOLog.h" -static IOHANDLER_CALLBACK(io_callback); -static IOHANDLER_LOG_BACKEND(io_log); +#include +#include -static struct IODescriptor *irc_iofd = NULL; +static IOLOG_CALLBACK(io_log); int main(int argc, char *argv[]) { - iolog_backend = io_log; - - irc_iofd = iohandler_connect("pk910.de", 6667, 0, NULL, io_callback); + iohandler_init(); + iolog_register_callback(io_log); - struct IODescriptor *iofd; - iofd = iohandler_add(0, IOTYPE_STDIN, NULL, io_callback); - iofd->read_lines = 1; - while(1) { - iohandler_poll(); - } -} - -static IOHANDLER_CALLBACK(io_callback) { - switch(event->type) { - case IOEVENT_CONNECTED: - printf("[connect]\n"); - break; - case IOEVENT_CLOSED: - printf("[disconnect]\n"); - break; - case IOEVENT_RECV: - if(event->iofd->type == IOTYPE_STDIN) { - iohandler_printf(irc_iofd, "%s\n", event->data.recv_str); - printf("[out] %s\n", event->data.recv_str); - } else - printf("[in] %s\n", event->data.recv_str); - break; - - default: - break; - } + init_config(NULL); + init_sockets(); + + iohandler_run(); + return 0; } -static IOHANDLER_LOG_BACKEND(io_log) { - //printf("%s", line); +static IOLOG_CALLBACK(io_log) { + printf("%s", message); }