From: pk910 Date: Sun, 12 Aug 2012 23:50:47 +0000 (+0200) Subject: [IOMultiplexer] moved test program into own sub-directory X-Git-Tag: v5.5~9^2~3^2~4 X-Git-Url: http://git.pk910.de/?p=NeonServV5.git;a=commitdiff_plain;h=95e17dcb3ada7fc8ea8a63bb922819b10e2de2e1 [IOMultiplexer] moved test program into own sub-directory --- diff --git a/src/Makefile b/src/Makefile deleted file mode 100644 index 434a929..0000000 --- a/src/Makefile +++ /dev/null @@ -1,12 +0,0 @@ - -CC = gcc -CFLAGS = -g -O0 -Wall -Wshadow -Werror -LDFLAGS = -lws2_32 - -OBJ = IOEngine_epoll.o IOEngine_kevent.o IOEngine_select.o IOEngine_win32.o IOHandler.o IOHandler_SSL.o main.o - -all: $(OBJ) - $(CC) $(CFLAGS) -oiotest $(OBJ) $(LDFLAGS) - -%.o: %.c - $(CC) $(CFLAGS) -c $< diff --git a/src/main.c b/src/main.c deleted file mode 100644 index b2c8ca4..0000000 --- a/src/main.c +++ /dev/null @@ -1,63 +0,0 @@ -/* main.c - IOMultiplexer - * Copyright (C) 2012 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 - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include -#include "IOHandler.h" - -static IOHANDLER_CALLBACK(io_callback); -static IOHANDLER_LOG_BACKEND(io_log); - -static struct IODescriptor *irc_iofd = NULL; - -int main(int argc, char *argv[]) { - iolog_backend = io_log; - - irc_iofd = iohandler_connect("pk910.de", 6667, 0, NULL, io_callback); - - 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; - } -} - -static IOHANDLER_LOG_BACKEND(io_log) { - //printf("%s", line); -} diff --git a/src/test/Makefile b/src/test/Makefile new file mode 100644 index 0000000..df861f0 --- /dev/null +++ b/src/test/Makefile @@ -0,0 +1,12 @@ + +CC = gcc +CFLAGS = -g -O0 -Wall -Wshadow -Werror +LDFLAGS = -lws2_32 + +OBJ = ../IOEngine_epoll.o ../IOEngine_kevent.o ../IOEngine_select.o ../IOEngine_win32.o ../IOHandler.o ../IOHandler_SSL.o iotest.o + +all: $(OBJ) + $(CC) $(CFLAGS) -oiotest $(OBJ) $(LDFLAGS) + +%.o: %.c + $(CC) $(CFLAGS) -o$@ -c $< diff --git a/src/test/iotest.c b/src/test/iotest.c new file mode 100644 index 0000000..15f32f4 --- /dev/null +++ b/src/test/iotest.c @@ -0,0 +1,63 @@ +/* main.c - IOMultiplexer + * Copyright (C) 2012 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 + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include "../IOHandler.h" + +static IOHANDLER_CALLBACK(io_callback); +static IOHANDLER_LOG_BACKEND(io_log); + +static struct IODescriptor *irc_iofd = NULL; + +int main(int argc, char *argv[]) { + iolog_backend = io_log; + + irc_iofd = iohandler_connect("pk910.de", 6667, 0, NULL, io_callback); + + 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; + } +} + +static IOHANDLER_LOG_BACKEND(io_log) { + //printf("%s", line); +}