aboutsummaryrefslogtreecommitdiff
path: root/sys/cmd/ic/ic.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/cmd/ic/ic.c')
-rw-r--r--sys/cmd/ic/ic.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/sys/cmd/ic/ic.c b/sys/cmd/ic/ic.c
index 19b868d..7fc37d8 100644
--- a/sys/cmd/ic/ic.c
+++ b/sys/cmd/ic/ic.c
@@ -1,6 +1,6 @@
/* See LICENSE file for license details. */
#include <u.h>
-#include <libn.h>
+#include <base.h>
#include <sys/select.h>
#include <sys/socket.h>
@@ -308,7 +308,7 @@ channel_rm(Channel *c)
free(c);
}
-static
+static
void
channel_leave(Channel *c)
{
@@ -321,7 +321,7 @@ channel_leave(Channel *c)
channel_rm(c);
}
-static
+static
void
loginkey(int ircfd, const char *key)
{
@@ -347,13 +347,13 @@ udsopen(const char *uds)
size_t len;
int fd;
- if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) {
+ if((fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) {
fprintf(stderr, "%s: socket: %s\n", argv0, strerror(errno));
exit(1);
}
sun.sun_family = AF_UNIX;
- if (strlcpy(sun.sun_path, uds, sizeof(sun.sun_path)) >= sizeof(sun.sun_path)) {
+ if(strlcpy(sun.sun_path, uds, sizeof(sun.sun_path)) >= sizeof(sun.sun_path)) {
fprintf(stderr, "%s: UNIX domain socket path truncation\n", argv0);
exit(1);
}
@@ -403,7 +403,7 @@ tcpopen(const char *host, const char *service)
return fd;
}
-static
+static
int
isnumeric(const char *s)
{
@@ -464,7 +464,7 @@ proc_channels_privmsg(int ircfd, Channel *c, char *buf)
ewritestr(ircfd, msg);
}
-static
+static
void
proc_channels_input(int ircfd, Channel *c, char *buf)
{
@@ -700,8 +700,8 @@ handle_channels_input(int ircfd, Channel *c)
{
char buf[IRC_MSG_MAX];
- if (read_line(c->fdin, buf, sizeof(buf)) == -1) {
- if (channel_reopen(c) == -1)
+ if(read_line(c->fdin, buf, sizeof(buf)) == -1) {
+ if(channel_reopen(c) == -1)
channel_rm(c);
return;
}
@@ -755,7 +755,7 @@ run(int ircfd, const char *host)
int r, maxfd;
snprintf(ping_msg, sizeof(ping_msg), "PING %s\r\n", host);
- while (isrunning) {
+ while(isrunning) {
maxfd = ircfd;
FD_ZERO(&rdset);
FD_SET(ircfd, &rdset);
@@ -767,12 +767,12 @@ run(int ircfd, const char *host)
memset(&tv, 0, sizeof(tv));
tv.tv_sec = 120;
r = select(maxfd + 1, &rdset, 0, 0, &tv);
- if (r < 0) {
+ if(r < 0){
if (errno == EINTR)
continue;
fprintf(stderr, "%s: select: %s\n", argv0, strerror(errno));
exit(1);
- } else if (r == 0) {
+ }else if(r == 0){
if (time(nil) - last_response >= PING_TIMEOUT) {
channel_print(channelmaster, "-!- ii shutting down: ping timeout");
exit(2); /* status code 2 for timeout */
@@ -780,11 +780,11 @@ run(int ircfd, const char *host)
ewritestr(ircfd, ping_msg);
continue;
}
- if (FD_ISSET(ircfd, &rdset)) {
+ if(FD_ISSET(ircfd, &rdset)) {
handle_server_output(ircfd);
last_response = time(nil);
}
- for (c = channels; c; c = tmp) {
+ for(c = channels; c; c = tmp) {
tmp = c->next;
if (FD_ISSET(c->fdin, &rdset))
handle_channels_input(ircfd, c);
@@ -803,7 +803,7 @@ main(int argc, char *argv[])
int ircfd, r;
/* use nickname and home dir of user by default */
- if (!(spw = getpwuid(getuid()))) {
+ if(!(spw = getpwuid(getuid()))) {
fprintf(stderr, "%s: getpwuid: %s\n", argv0, strerror(errno));
exit(1);
}
@@ -837,10 +837,10 @@ main(int argc, char *argv[])
break;
} ARGEND
- if (!*host)
+ if(!*host)
usage();
- if (uds)
+ if(uds)
ircfd = udsopen(uds);
else
ircfd = tcpopen(host, service);
@@ -861,15 +861,15 @@ main(int argc, char *argv[])
create_dirtree(ircpath);
channelmaster = channel_add(""); /* master channel */
- if (key)
+ if(key)
loginkey(ircfd, key);
loginuser(ircfd, host, fullname && *fullname ? fullname : nick);
setup();
run(ircfd, host);
- if (channelmaster)
+ if(channelmaster)
channel_leave(channelmaster);
- for (c = channels; c; c = tmp) {
+ for(c = channels; c; c = tmp) {
tmp = c->next;
channel_leave(c);
}