diff --git a/bin/sic-1.1/Makefile.mk b/bin/sic-1.1/Makefile.mk new file mode 100644 index 0000000..7fae9a6 --- /dev/null +++ b/bin/sic-1.1/Makefile.mk @@ -0,0 +1,12 @@ +DEFINES += -DVERSION=1.1 #-D__STACK_CHECK__=1 +CFLAGS += $(DEFINES) -v -w +LDFLAGS += -l/usr/lib/libnetdb + +OBJS = sic.o + + +sic: $(OBJS) + $(CC) $(LDFLAGS) $(OBJS) $(LDLIBS) -o $@ + + +sic.o: sic.c util.c diff --git a/bin/sic-1.1/sic.1 b/bin/sic-1.1/sic.1 index cfc8dc2..d0dd3bb 100644 --- a/bin/sic-1.1/sic.1 +++ b/bin/sic-1.1/sic.1 @@ -1,4 +1,4 @@ -.TH SIC 1 sic-VERSION +.TH SIC 1 sic-1.1 .SH NAME sic \- simple irc client .SH SYNOPSIS diff --git a/bin/sic-1.1/sic.c b/bin/sic-1.1/sic.c index 9b0b36a..1e2e5cd 100644 --- a/bin/sic-1.1/sic.c +++ b/bin/sic-1.1/sic.c @@ -6,8 +6,18 @@ #include #include #include +#include #include +#ifdef __GNO__ +#include +#endif + +#ifdef __ORCAC__ +#pragma optimize 79 +#pragma stacksize 2048 // 1063 bytes ... better safe than sorry. +#endif + static char *host = "irc.oftc.net"; static char *port = "ircd"; static char *password; @@ -30,8 +40,13 @@ pout(char *channel, char *fmt, ...) { vsnprintf(bufout, sizeof bufout, fmt, ap); va_end(ap); t = time(NULL); + +#ifdef __GNO__ + fprintf(stdout, "%-12s: %s\n", channel, bufout); +#else strftime(timestr, sizeof timestr, "%D %R", localtime(&t)); fprintf(stdout, "%-12s: %s %s\n", channel, timestr, bufout); +#endif } static void @@ -138,6 +153,10 @@ main(int argc, char *argv[]) { const char *user = getenv("USER"); fd_set rd; +#ifdef __GNO__ + __REPORT_STACK(); +#endif + strlcpy(nick, user ? user : "unknown", sizeof nick); for(i = 1; i < argc; i++) { c = argv[i][1]; @@ -157,14 +176,18 @@ main(int argc, char *argv[]) { if(++i < argc) password = argv[i]; break; case 'v': - eprint("sic-"VERSION", © 2005-2009 Kris Maglione, Anselm R. Garbe, Nico Golde\n"); + eprint("sic-1.1, (c) 2005-2009 Kris Maglione, Anselm R. Garbe, Nico Golde\n"); default: eprint("usage: sic [-h host] [-p port] [-n nick] [-k keyword] [-v]\n"); } } /* init */ i = dial(host, port); +#ifdef __GNO__ + srv = fdopen(i, "rb+"); +#else srv = fdopen(i, "r+"); +#endif /* login */ if(password) sout("PASS %s", password); @@ -175,7 +198,7 @@ main(int argc, char *argv[]) { setbuf(srv, NULL); for(;;) { /* main loop */ FD_ZERO(&rd); - FD_SET(0, &rd); + FD_SET(STDIN_FILENO, &rd); FD_SET(fileno(srv), &rd); tv.tv_sec = 120; tv.tv_usec = 0; @@ -183,6 +206,7 @@ main(int argc, char *argv[]) { if(i < 0) { if(errno == EINTR) continue; + perror(NULL); eprint("sic: error on select():"); } else if(i == 0) { @@ -197,11 +221,12 @@ main(int argc, char *argv[]) { parsesrv(bufin); trespond = time(NULL); } - if(FD_ISSET(0, &rd)) { + if(FD_ISSET(STDIN_FILENO, &rd)) { if(fgets(bufin, sizeof bufin, stdin) == NULL) eprint("sic: broken pipe\n"); parsein(bufin); } } + return 0; } diff --git a/bin/sic-1.1/util.c b/bin/sic-1.1/util.c index 26953d0..497e417 100644 --- a/bin/sic-1.1/util.c +++ b/bin/sic-1.1/util.c @@ -2,6 +2,26 @@ #include #include #include +#ifndef __GNO__ +#include +#endif +// from freebsd 9.0.0 + +void * +memccpy(void *t, const void *f, int c, size_t n) +{ + + if (n) { + unsigned char *tp = t; + const unsigned char *fp = f; + unsigned char uc = c; + do { + if ((*tp++ = *fp++) == uc) + return (tp); + } while (--n != 0); + } + return (0); +} static void eprint(const char *fmt, ...) { @@ -18,6 +38,31 @@ eprint(const char *fmt, ...) { static int dial(char *host, char *port) { +#ifdef __GNO__ + int srv; + struct hostent *hp; + struct sockaddr_in sin; + + hp = gethostbyname(host); + if (hp == NULL) + eprint("error: cannot resolve hostname '%s':", host); + + + srv = socket(hp->h_addrtype, SOCK_STREAM, 0); + if (srv < 0) + eprint("error: socket"); + + bzero((caddr_t)&sin, sizeof (sin)); + bcopy(hp->h_addr, (char *)&sin.sin_addr, hp->h_length); + + sin.sin_port = htons(atoi(port)); + + if (connect(srv, (struct __SOCKADDR *)&sin, sizeof(sin)) < 0) + eprint("error: cannot connect to host '%s'\n", host); + + return srv; + +#else static struct addrinfo hints; int srv; struct addrinfo *res, *r; @@ -38,6 +83,7 @@ dial(char *host, char *port) { if(!r) eprint("error: cannot connect to host '%s'\n", host); return srv; +#endif } #define strlcpy _strlcpy