1 /* main.c - IOMultiplexer
2 * Copyright (C) 2012 Philipp Kreil (pk910)
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #include "../IOHandler.h"
21 static IOHANDLER_CALLBACK(io_callback);
22 static IOHANDLER_LOG_BACKEND(io_log);
24 static struct IODescriptor *irc_iofd = NULL;
26 int main(int argc, char *argv[]) {
27 iolog_backend = io_log;
29 irc_iofd = iohandler_connect("pk910.de", 6667, 0, NULL, io_callback);
31 struct IODescriptor *iofd;
32 iofd = iohandler_add(0, IOTYPE_STDIN, NULL, io_callback);
40 static IOHANDLER_CALLBACK(io_callback) {
42 case IOEVENT_CONNECTED:
43 printf("[connect]\n");
46 printf("[disconnect]\n");
49 if(event->iofd->type == IOTYPE_STDIN) {
50 iohandler_printf(irc_iofd, "%s\n", event->data.recv_str);
51 printf("[out] %s\n", event->data.recv_str);
53 printf("[in] %s\n", event->data.recv_str);
61 static IOHANDLER_LOG_BACKEND(io_log) {