projects
/
IOMultiplexer.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
8ba4de3
)
[IOMultiplexer] changed example main.c to be a very very basic irc client
author
pk910
<philipp@zoelle1.de>
Sun, 12 Aug 2012 01:20:28 +0000
(
03:20
+0200)
committer
pk910
<philipp@zoelle1.de>
Mon, 13 Aug 2012 00:03:49 +0000
(
02:03
+0200)
src/main.c
patch
|
blob
|
history
diff --git
a/src/main.c
b/src/main.c
index b8e0d6cccb6a5fdcaca926e200fb52c97aea921a..b2c8ca4b7782096504562f89158d0fedbe00166c 100644
(file)
--- a/
src/main.c
+++ b/
src/main.c
@@
-21,10
+21,12
@@
static IOHANDLER_CALLBACK(io_callback);
static IOHANDLER_LOG_BACKEND(io_log);
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;
int main(int argc, char *argv[]) {
iolog_backend = io_log;
- iohandler_connect("pk910.de", 6667, 0, NULL, io_callback);
+ i
rc_iofd = i
ohandler_connect("pk910.de", 6667, 0, NULL, io_callback);
struct IODescriptor *iofd;
iofd = iohandler_add(0, IOTYPE_STDIN, NULL, io_callback);
struct IODescriptor *iofd;
iofd = iohandler_add(0, IOTYPE_STDIN, NULL, io_callback);
@@
-40,14
+42,22
@@
static IOHANDLER_CALLBACK(io_callback) {
case IOEVENT_CONNECTED:
printf("[connect]\n");
break;
case IOEVENT_CONNECTED:
printf("[connect]\n");
break;
+ case IOEVENT_CLOSED:
+ printf("[disconnect]\n");
+ break;
case IOEVENT_RECV:
case IOEVENT_RECV:
- printf("[in] %s\n", event->data.recv_str);
+ 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;
break;
+
default:
break;
}
}
static IOHANDLER_LOG_BACKEND(io_log) {
default:
break;
}
}
static IOHANDLER_LOG_BACKEND(io_log) {
-
printf("%s\n
", line);
+
//printf("%s
", line);
}
}