fixed server out issue

This commit is contained in:
Anselm R. Garbe 2006-01-23 14:11:36 +02:00
parent ebd28d7733
commit f7348448b4

25
ii.c
View File

@ -44,7 +44,7 @@ static void usage()
{ {
fprintf(stderr, "%s", fprintf(stderr, "%s",
"ii - irc it - " VERSION "\n" "ii - irc it - " VERSION "\n"
" (C)opyright MMV Anselm R. Garbe, Nico Golde\n" " (C)opyright MMVI Anselm R. Garbe, Nico Golde\n"
"usage: ii [-i <irc dir>] [-s <host>] [-p <port>]\n" "usage: ii [-i <irc dir>] [-s <host>] [-p <port>]\n"
" [-n <nick>] [-k <password>] [-f <fullname>]\n"); " [-n <nick>] [-k <password>] [-f <fullname>]\n");
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
@ -108,10 +108,15 @@ static int open_channel(char *name)
static void add_channel(char *name) static void add_channel(char *name)
{ {
Channel *c; Channel *c;
int fd = open_channel(name); int fd;
for(c = channels; c; c = c->next)
if(!strcmp(name, c->name))
return; /* already handled */
fd = open_channel(name);
if(fd == -1) { if(fd == -1) {
perror("ii: cannot create in channels"); perror("ii: cannot create in channel");
return; return;
} }
if(!channels) if(!channels)
@ -420,7 +425,6 @@ static void run()
fd_set rd; fd_set rd;
for(;;) { for(;;) {
/* prepare */
FD_ZERO(&rd); FD_ZERO(&rd);
maxfd = irc; maxfd = irc;
FD_SET(irc, &rd); FD_SET(irc, &rd);
@ -438,14 +442,11 @@ static void run()
perror("ii: error on select()"); perror("ii: error on select()");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} else if(r > 0) { } else if(r > 0) {
for(c = channels; c; c = c->next) { if(FD_ISSET(irc, &rd))
if(FD_ISSET(c->fd, &rd)) { handle_server_output();
if(c->fd == irc) for(c = channels; c; c = c->next)
handle_server_output(); if(FD_ISSET(c->fd, &rd))
else handle_channels_input(c);
handle_channels_input(c);
}
}
} }
} }
} }