fixed compilation (added temporary ircd_config.h)
[NextIRCd.git] / src / main.c
index b2c8ca4b7782096504562f89158d0fedbe00166c..848023a0e5a62e9126d3701d862e03a4edbb9be9 100644 (file)
@@ -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
  * along with this program. If not, see <http://www.gnu.org/licenses/>. 
  */
 
-#include <stdio.h>
-#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 <stdlib.h>
+#include <stdio.h>
 
-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);
 }