applied Jeroen Schot's patch
This commit is contained in:
parent
f3827eec2a
commit
ca6ba9a64a
4
LICENSE
4
LICENSE
@ -1,6 +1,8 @@
|
|||||||
MIT/X Consortium License
|
MIT/X Consortium License
|
||||||
|
|
||||||
© 2005-2008 Anselm R Garbe <garbeam at gmail dot com>
|
|
||||||
|
© 2005-2009 Anselm R Garbe <garbeam at gmail dot com>
|
||||||
|
© 2008-2009 Jeroen Schot <schot at a-eskwadraat dot nl>
|
||||||
© 2005 Nico Golde <nico at ngolde dot de>
|
© 2005 Nico Golde <nico at ngolde dot de>
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a
|
Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
2
sic.1
2
sic.1
@ -17,7 +17,7 @@ different channel buffers, that's actually a feature.
|
|||||||
.SH OPTIONS
|
.SH OPTIONS
|
||||||
.TP
|
.TP
|
||||||
.B \-h <host>
|
.B \-h <host>
|
||||||
Overrides the default host (irc.oftc.net)
|
Overrides the default host (irc6.oftc.net)
|
||||||
.TP
|
.TP
|
||||||
.B \-p <port>
|
.B \-p <port>
|
||||||
Overrides the default port (6667)
|
Overrides the default port (6667)
|
||||||
|
36
sic.c
36
sic.c
@ -1,6 +1,4 @@
|
|||||||
/* © 2005-2008 Anselm R Garbe <garbeam at gmail dot com>
|
/* See LICENSE file for license details. */
|
||||||
* © 2005 Nico Golde <nico at ngolde dot de>
|
|
||||||
* See LICENSE file for license details. */
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
@ -23,8 +21,8 @@ static void parsein(char *msg);
|
|||||||
static void parsesrv(char *msg);
|
static void parsesrv(char *msg);
|
||||||
static int readl(int fd, unsigned int len, char *buf);
|
static int readl(int fd, unsigned int len, char *buf);
|
||||||
|
|
||||||
static char *host = "irc.oftc.net";
|
static char *host = "irc6.oftc.net";
|
||||||
static unsigned short port = 6667;
|
static char *port = "6667";
|
||||||
static char *password = NULL;
|
static char *password = NULL;
|
||||||
static char nick[32];
|
static char nick[32];
|
||||||
|
|
||||||
@ -161,8 +159,7 @@ int
|
|||||||
main(int argc, char *argv[]) {
|
main(int argc, char *argv[]) {
|
||||||
int i;
|
int i;
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
struct hostent *hp;
|
static struct addrinfo hints, *res, *r;
|
||||||
static struct sockaddr_in addr; /* initially filled with 0's */
|
|
||||||
char ping[256];
|
char ping[256];
|
||||||
fd_set rd;
|
fd_set rd;
|
||||||
|
|
||||||
@ -172,7 +169,7 @@ main(int argc, char *argv[]) {
|
|||||||
if(++i < argc) host = argv[i];
|
if(++i < argc) host = argv[i];
|
||||||
}
|
}
|
||||||
else if(!strncmp(argv[i], "-p", 3)) {
|
else if(!strncmp(argv[i], "-p", 3)) {
|
||||||
if(++i < argc) port = (unsigned short)atoi(argv[i]);
|
if(++i < argc) port = argv[i];
|
||||||
}
|
}
|
||||||
else if(!strncmp(argv[i], "-n", 3)) {
|
else if(!strncmp(argv[i], "-n", 3)) {
|
||||||
if(++i < argc) strncpy(nick, argv[i], sizeof nick);
|
if(++i < argc) strncpy(nick, argv[i], sizeof nick);
|
||||||
@ -181,22 +178,27 @@ main(int argc, char *argv[]) {
|
|||||||
if(++i < argc) password = argv[i];
|
if(++i < argc) password = argv[i];
|
||||||
}
|
}
|
||||||
else if(!strncmp(argv[i], "-v", 3))
|
else if(!strncmp(argv[i], "-v", 3))
|
||||||
die("sic-"VERSION", © 2005-2008 Anselm R Garbe, Nico Golde\n");
|
die("sic-"VERSION", © 2005-2009 sic engineers\n");
|
||||||
else
|
else
|
||||||
die("usage: sic [-h host] [-p port] [-n nick] [-k keyword] [-v]\n");
|
die("usage: sic [-h host] [-p port] [-n nick] [-k keyword] [-v]\n");
|
||||||
|
|
||||||
/* init */
|
/* init */
|
||||||
if((srv = socket(AF_INET, SOCK_STREAM, 0)) < 0)
|
memset(&hints, 0, sizeof hints);
|
||||||
die("error: cannot connect host '%s'\n", host);
|
hints.ai_family = AF_UNSPEC;
|
||||||
if(NULL == (hp = gethostbyname(host)))
|
hints.ai_socktype = SOCK_STREAM;
|
||||||
|
if(getaddrinfo(host, port, &hints, &res) != 0)
|
||||||
die("error: cannot resolve hostname '%s'\n", host);
|
die("error: cannot resolve hostname '%s'\n", host);
|
||||||
addr.sin_family = AF_INET;
|
for(ri = res; r; r = r->ai_next) {
|
||||||
addr.sin_port = htons(port);
|
if((srv = socket(r->ai_family, r->ai_socktype, r->ai_protocol)) == -1)
|
||||||
memcpy(&addr.sin_addr, hp->h_addr, hp->h_length);
|
continue;
|
||||||
if(connect(srv, (struct sockaddr *) &addr, sizeof(struct sockaddr_in))) {
|
if(connect(srv, r->ai_addr, r->ai_addrlen) == 0)
|
||||||
|
break;
|
||||||
close(srv);
|
close(srv);
|
||||||
die("error: cannot connect host '%s'\n", host);
|
|
||||||
}
|
}
|
||||||
|
freeaddrinfo(res);
|
||||||
|
if(!r)
|
||||||
|
die("error: cannot connect to host '%s'\n", host);
|
||||||
|
|
||||||
/* login */
|
/* login */
|
||||||
if(password)
|
if(password)
|
||||||
snprintf(bufout, sizeof bufout,
|
snprintf(bufout, sizeof bufout,
|
||||||
|
Loading…
Reference in New Issue
Block a user