removed fullname, added support for tracking NICK changes

This commit is contained in:
Anselm R. Garbe 2007-02-09 16:16:06 +01:00
parent 75f0af7c42
commit 1160be7ffa
2 changed files with 8 additions and 15 deletions

4
sic.1
View File

@ -7,7 +7,6 @@ sic \- simple irc client
.RB [ \-p " <port>"] .RB [ \-p " <port>"]
.RB [ \-n " <nick>"] .RB [ \-n " <nick>"]
.RB [ \-k " <keyword>"] .RB [ \-k " <keyword>"]
.RB [ \-f " <fullname>"]
.RB [ \-v ] .RB [ \-v ]
.SH DESCRIPTION .SH DESCRIPTION
.B sic .B sic
@ -29,9 +28,6 @@ Override the default nick ($USER)
.B \-k <keyword> .B \-k <keyword>
Specifies the keyword to authenticate your nick on the server Specifies the keyword to authenticate your nick on the server
.TP .TP
.B \-f <fullname>
Specify the real name (default is $USER)
.TP
.BI \-v .BI \-v
Prints version information to standard output, then exits. Prints version information to standard output, then exits.
.SH COMMANDS .SH COMMANDS

19
sic.c
View File

@ -19,9 +19,8 @@
static char *host = "irc.oftc.net"; static char *host = "irc.oftc.net";
static unsigned short port = 6667; static unsigned short port = 6667;
static char *nick = NULL;
static char *fullname = NULL;
static char *password = NULL; static char *password = NULL;
static char nick[32];
static char bufin[MAXMSG], bufout[MAXMSG]; static char bufin[MAXMSG], bufout[MAXMSG];
static char channel[256]; static char channel[256];
@ -148,6 +147,8 @@ parsesrv(char *msg) {
else { else {
snprintf(bufout, sizeof bufout, ">< %s: %s", cmd, txt ? txt : ""); snprintf(bufout, sizeof bufout, ">< %s: %s", cmd, txt ? txt : "");
pout(usr, bufout); pout(usr, bufout);
if(!strncmp("NICK", cmd, 4) && !strncmp(usr, nick, sizeof nick) && txt)
strncpy(nick, txt, sizeof nick);
} }
} }
@ -160,7 +161,7 @@ main(int argc, char *argv[]) {
char ping[256]; char ping[256];
fd_set rd; fd_set rd;
nick = fullname = getenv("USER"); strncpy(nick, getenv("USER"), sizeof nick);
for(i = 1; i < argc; i++) for(i = 1; i < argc; i++)
if(!strncmp(argv[i], "-h", 3)) { if(!strncmp(argv[i], "-h", 3)) {
if(++i < argc) host = argv[i]; if(++i < argc) host = argv[i];
@ -169,19 +170,15 @@ main(int argc, char *argv[]) {
if(++i < argc) port = (unsigned short)atoi(argv[i]); if(++i < argc) port = (unsigned short)atoi(argv[i]);
} }
else if(!strncmp(argv[i], "-n", 3)) { else if(!strncmp(argv[i], "-n", 3)) {
if(++i < argc) nick = argv[i]; if(++i < argc) strncpy(nick, argv[i], sizeof nick);
} }
else if(!strncmp(argv[i], "-k", 3)) { else if(!strncmp(argv[i], "-k", 3)) {
if(++i < argc) password = argv[i]; if(++i < argc) password = argv[i];
} }
else if(!strncmp(argv[i], "-f", 3)) {
if(++i < argc) fullname = argv[i];
}
else if(!strncmp(argv[i], "-v", 3)) else if(!strncmp(argv[i], "-v", 3))
eprint("sic-"VERSION", (C)opyright MMVI Anselm R. Garbe\n"); eprint("sic-"VERSION", (C)opyright MMVI Anselm R. Garbe\n");
else else
eprint("usage: sic [-h host] [-p port] [-n nick]" eprint("usage: sic [-h host] [-p port] [-n nick] [-k keyword] [-v]\n");
" [-k keyword] [-f fullname] [-v]\n");
/* init */ /* init */
if((srv = socket(AF_INET, SOCK_STREAM, 0)) < 0) if((srv = socket(AF_INET, SOCK_STREAM, 0)) < 0)
@ -199,10 +196,10 @@ main(int argc, char *argv[]) {
if(password) if(password)
snprintf(bufout, sizeof bufout, snprintf(bufout, sizeof bufout,
"PASS %s\r\nNICK %s\r\nUSER %s localhost %s :%s\r\n", "PASS %s\r\nNICK %s\r\nUSER %s localhost %s :%s\r\n",
password, nick, nick, host, fullname); password, nick, nick, host, nick);
else else
snprintf(bufout, sizeof bufout, "NICK %s\r\nUSER %s localhost %s :%s\r\n", snprintf(bufout, sizeof bufout, "NICK %s\r\nUSER %s localhost %s :%s\r\n",
nick, nick, host, fullname); nick, nick, host, nick);
write(srv, bufout, strlen(bufout)); write(srv, bufout, strlen(bufout));
snprintf(ping, sizeof ping, "PING %s\r\n", host); snprintf(ping, sizeof ping, "PING %s\r\n", host);
channel[0] = 0; channel[0] = 0;