--- Heyho, this was done to most other suckless projects as well and I just noticed it when reading the EXIT_TIMEOUT patch, so here you go. --Markus ii.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/ii.c b/ii.c index 5d57458..857388e 100644 --- a/ii.c +++ b/ii.c _AT_@ -19,8 +19,6 @@ #include <time.h> #include <unistd.h> -#define EXIT_TIMEOUT 2 - #ifndef PIPE_BUF /* For OS that doesn't includes PIPE_BUF in limits.h, FreeBSD? */ #define PIPE_BUF _POSIX_PIPE_BUF #endif _AT_@ -50,7 +48,7 @@ static void usage() { "(C)opyright MMV-MMXI Nico Golde\n" "usage: ii [-i <irc dir>] [-s <host>] [-p <port>]\n" " [-n <nick>] [-k <password>] [-f <fullname>]\n", stderr); - exit(EXIT_FAILURE); + exit(1); } static char *striplower(char *s) { _AT_@ -93,7 +91,7 @@ static int get_filepath(char *filepath, size_t len, char *channel, char *file) { static void create_filepath(char *filepath, size_t len, char *channel, char *suffix) { if(!get_filepath(filepath, len, striplower(channel), suffix)) { fputs("ii: path to irc directory too long\n", stderr); - exit(EXIT_FAILURE); + exit(1); } } _AT_@ -117,12 +115,12 @@ static void add_channel(char *cname) { fd = open_channel(name); if(fd == -1) { printf("ii: exiting, cannot create in channel: %s\n", name); - exit(EXIT_FAILURE); + exit(1); } c = calloc(1, sizeof(Channel)); if(!c) { perror("ii: cannot allocate memory"); - exit(EXIT_FAILURE); + exit(1); } if(!channels) channels = c; else { _AT_@ -162,18 +160,18 @@ static int tcpopen(unsigned short port) { memset(&sin, 0, sizeof(struct sockaddr_in)); if(!hp) { perror("ii: cannot retrieve host information"); - exit(EXIT_FAILURE); + exit(1); } sin.sin_family = AF_INET; memcpy(&sin.sin_addr, hp->h_addr, hp->h_length); sin.sin_port = htons(port); if((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { perror("ii: cannot create socket"); - exit(EXIT_FAILURE); + exit(1); } if(connect(fd, (const struct sockaddr *) &sin, sizeof(sin)) < 0) { perror("ii: cannot connect to host"); - exit(EXIT_FAILURE); + exit(1); } return fd; } _AT_@ -414,7 +412,7 @@ static void handle_server_output() { static char buf[PIPE_BUF]; if(read_line(irc, PIPE_BUF, buf) == -1) { perror("ii: remote host closed connection"); - exit(EXIT_FAILURE); + exit(1); } proc_server_cmd(buf); } _AT_@ -444,11 +442,11 @@ static void run() { if(errno == EINTR) continue; perror("ii: error on select()"); - exit(EXIT_FAILURE); + exit(1); } else if(r == 0) { if(time(NULL) - last_response >= PING_TIMEOUT) { print_out(NULL, "-!- ii shutting down: ping timeout"); - exit(EXIT_TIMEOUT); + exit(2); } write(irc, ping_msg, strlen(ping_msg)); continue; _AT_@ -474,7 +472,7 @@ int main(int argc, char *argv[]) { if(!spw) { fputs("ii: getpwuid() failed\n", stderr); - exit(EXIT_FAILURE); + exit(1); } snprintf(nick, sizeof(nick), "%s", spw->pw_name); snprintf(prefix, sizeof(prefix),"%s/irc", spw->pw_dir); _AT_@ -496,13 +494,13 @@ int main(int argc, char *argv[]) { #ifdef __OpenBSD__ /* OpenBSD pledge(2) support */ if (pledge("stdio rpath wpath cpath dpath", NULL) == -1) { fprintf(stderr, "ii pledge: %s\n", strerror(errno)); - exit(EXIT_FAILURE); + exit(1); } #endif if(!snprintf(path, sizeof(path), "%s/%s", prefix, host)) { fputs("ii: path to irc directory too long\n", stderr); - exit(EXIT_FAILURE); + exit(1); } create_dirtree(path); _AT_@ -510,5 +508,5 @@ int main(int argc, char *argv[]) { login(key, fullname); run(); - return EXIT_SUCCESS; + return 0; } -- 2.7.3Received on Fri Oct 14 2016 - 01:42:16 CEST
This archive was generated by hypermail 2.3.0 : Fri Oct 14 2016 - 01:48:14 CEST