10 Commits
0.2 ... 0.3

Author SHA1 Message Date
78e0c4f9ee new tag 2006-09-26 14:27:31 +02:00
b3412f0a14 new stuff 2006-09-26 14:24:26 +02:00
1230561e3d Added tag 0.3 for changeset dc05747ec127039afaa350094add73d151d17b72 2006-09-26 14:14:48 +02:00
b8950627a7 hotfix 2006-09-20 11:18:27 +02:00
5d19f0415e simplified sic 2006-09-19 16:54:52 +02:00
2c257c70bc fixed several annoyances 2006-09-05 09:47:15 +02:00
fb185a5e18 removed html crap 2006-09-05 07:32:24 +02:00
c9668b78f2 preparing new sic version 2006-09-05 07:31:46 +02:00
c2fcf48e6d applied Adriens patch 2006-09-04 08:54:14 +02:00
ee77b8efae Added tag 0.2 for changeset 56350a01f27753cfbdbb3dbc25f2a53dd4c2ac45 2006-07-21 21:12:33 +02:00
6 changed files with 84 additions and 131 deletions

View File

@ -1 +1,2 @@
de32c537aaf66554894712563ffba8d9bc4c2714 0.1 de32c537aaf66554894712563ffba8d9bc4c2714 0.1
56350a01f27753cfbdbb3dbc25f2a53dd4c2ac45 0.2

View File

@ -1,59 +1,57 @@
# ii - irc it - simple but flexible IRC client # sic - simple irc client
# (C)opyright MMV Anselm R. Garbe, Nico Golde # (C)opyright MMVI Anselm R. Garbe
include config.mk include config.mk
SRC = sic.c SRC = sic.c
OBJ = ${SRC:.c=.o} OBJ = ${SRC:.c=.o}
MAN1 = sic.1
BIN = sic
all: options sic all: options sic
@echo built sic
options: options:
@echo ii build options: @echo sic build options:
@echo "LIBS = ${LIBS}"
@echo "CFLAGS = ${CFLAGS}" @echo "CFLAGS = ${CFLAGS}"
@echo "LDFLAGS = ${LDFLAGS}" @echo "LDFLAGS = ${LDFLAGS}"
@echo "CC = ${CC}" @echo "CC = ${CC}"
@echo "LD = ${LD}"
.c.o: .c.o:
@echo CC $< @echo CC $<
@${CC} -c ${CFLAGS} $< @${CC} -c ${CFLAGS} $<
${OBJ}: config.mk
sic: ${OBJ}
@echo LD $@
@${LD} -o $@ ${OBJ} ${LDFLAGS}
@strip $@
clean: clean:
rm -f sic *.o core sic-${VERSION}.tar.gz @echo cleaning
@rm -f sic ${OBJ} sic-${VERSION}.tar.gz
dist: clean dist: clean
@echo creating dist tarball
@mkdir -p sic-${VERSION} @mkdir -p sic-${VERSION}
@cp -R Makefile README LICENSE config.mk sic.c sic.1 sic-${VERSION} @cp -R LICENSE Makefile README config.mk sic.1 ${SRC} sic-${VERSION}
@tar -cf sic-${VERSION}.tar sic-${VERSION} @tar -cf sic-${VERSION}.tar sic-${VERSION}
@gzip sic-${VERSION}.tar @gzip sic-${VERSION}.tar
@rm -rf sic-${VERSION} @rm -rf sic-${VERSION}
sic: ${OBJ}
@echo LD $@
@${CC} -o $@ ${OBJ} ${LDFLAGS}
install: all install: all
@echo installing executable file to ${DESTDIR}${PREFIX}/bin
@mkdir -p ${DESTDIR}${PREFIX}/bin @mkdir -p ${DESTDIR}${PREFIX}/bin
@cp -f ${BIN} ${DESTDIR}${PREFIX}/bin @cp -f sic ${DESTDIR}${PREFIX}/bin
@for i in ${BIN}; do \ @chmod 755 ${DESTDIR}${PREFIX}/bin/sic
chmod 755 ${DESTDIR}${PREFIX}/bin/`basename $$i`; \ @echo installing manual page to ${DESTDIR}${MANPREFIX}/man1
done
@echo installed executable files to ${DESTDIR}${PREFIX}/bin
@mkdir -p ${DESTDIR}${MANPREFIX}/man1 @mkdir -p ${DESTDIR}${MANPREFIX}/man1
@cp -f ${MAN1} ${DESTDIR}${MANPREFIX}/man1 @sed 's/VERSION/${VERSION}/g' < sic.1 > ${DESTDIR}${MANPREFIX}/man1/sic.1
@for i in ${MAN1}; do \ @chmod 644 ${DESTDIR}${MANPREFIX}/man1/sic.1
chmod 444 ${DESTDIR}${MANPREFIX}/man1/`basename $$i`; \
done
@echo installed manual pages to ${DESTDIR}${MANPREFIX}/man1
uninstall: uninstall:
for i in ${BIN}; do \ @echo removing executable file from ${DESTDIR}${PREFIX}/bin
rm -f ${DESTDIR}${PREFIX}/bin/`basename $$i`; \ @rm -f ${DESTDIR}${PREFIX}/bin/sic
done @echo removing manual page from ${DESTDIR}${MANPREFIX}/man1
for i in ${MAN1}; do \ @rm -f ${DESTDIR}${MANPREFIX}/man1/sic.1
rm -f ${DESTDIR}${MANPREFIX}/man1/`basename $$i`; \
done .PHONY: all options clean dist install uninstall

View File

@ -1,18 +1,22 @@
# Customize to fit your system # sic version
VERSION = 0.3
# Customize below to fit your system
# paths # paths
PREFIX = /usr/local PREFIX = /usr/local
MANPREFIX = ${PREFIX}/share/man MANPREFIX = ${PREFIX}/share/man
VERSION = 0.2
# includes and libs # includes and libs
LIBS = -L${PREFIX}/lib -L/usr/lib -lc INCS = -I. -I/usr/include
LIBS = -L/usr/lib -lc
# compiler # flags
CFLAGS = -O3 -I${PREFIX}/include -I/usr/include \ CFLAGS = -Os ${INCS} -DVERSION=\"${VERSION}\"
-DVERSION=\"${VERSION}\" LDFLAGS = ${LIBS}
LDFLAGS = ${LIBS} #CFLAGS = -g -Wall -O2 ${INCS} -DVERSION=\"${VERSION}\"
#CFLAGS = -g -Wall -O2 -I${PREFIX}/include -I/usr/include \ #LDFLAGS = -g ${LIBS}
# -DVERSION=\"${VERSION}\"
#LDFLAGS = -g ${LIBS} # compiler and linker
CC = cc
LD = ${CC}

38
sic.1
View File

@ -1,19 +1,13 @@
.TH SIC 1 sic-0.2 .TH SIC 1 sic-VERSION
.SH NAME .SH NAME
sic \- simple irc client sic \- simple irc client
.SH SYNOPSIS .SH SYNOPSIS
.B sic .B sic
.RB [ \-s .RB [ \-s <server> ]
.IR server ] .RB [ \-p <port> ]
.RB [ \-p .RB [ \-n <nick> ]
.IR port ] .RB [ \-k <keyword> ]
.RB [ \-n .RB [ \-f <fullname> ]
.IR nick ]
.RB [ \-k
.IR keyword ]
.RB [ \-f
.IR fullname ]
.RB \-v
.RB [ \-v ] .RB [ \-v ]
.SH DESCRIPTION .SH DESCRIPTION
.B sic .B sic
@ -23,38 +17,38 @@ also all channel traffic into one output, that you don't have to switch
different channel buffers, that's actually a feature. different channel buffers, that's actually a feature.
.SH OPTIONS .SH OPTIONS
.TP .TP
.BI \-s " server" .B \-s <server>
Overrides the default server (irc.oftc.net) Overrides the default server (irc.oftc.net)
.TP .TP
.BI \-p " port" .B \-p <port>
Overrides the default port (6667) Overrides the default port (6667)
.TP .TP
.BI \-n " nickname" .B \-n <nickname>
Override the default nick ($USER) Override the default nick ($USER)
.TP .TP
.BI \-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
.BI \-f " fullname" .B \-f <fullname>
Specify the real name (default is $USER) Specify the real name (default is $USER)
.TP .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
.TP .TP
.BI /j " #channel " .B /j #channel
Join a channel Join a channel
.TP .TP
.BI /l " #channel " .B /l #channel
Leave a channel Leave a channel
.TP .TP
.BI /m " #channel/user msg " .B /m #channel/user msg
Write a message to #channel/user Write a message to #channel/user
.TP .TP
.BI /s " #channel/user " .B /s #channel/user
Set default channel/user Set default channel/user
.TP .TP
.BI /t " topic" .B /t topic
Set the channel topic Set the channel topic
.TP .TP
Everything which is not a command will simply be posted into the channel or to Everything which is not a command will simply be posted into the channel or to

55
sic.c
View File

@ -11,6 +11,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <time.h> #include <time.h>
#include <unistd.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/time.h> #include <sys/time.h>
@ -20,7 +21,7 @@
enum { Tnick, Tuser, Tcmd, Tchan, Targ, Ttext, Tlast }; enum { Tnick, Tuser, Tcmd, Tchan, Targ, Ttext, Tlast };
static char *server = "irc.oftc.net"; static char *server = "irc.oftc.net";
static int port = 6667; static unsigned short port = 6667;
static char *nick = NULL; static char *nick = NULL;
static char *fullname = NULL; static char *fullname = NULL;
static char *password = NULL; static char *password = NULL;
@ -75,36 +76,27 @@ parsein(char *msg)
privmsg(channel, msg); privmsg(channel, msg);
return; return;
} }
if((p = strchr(&msg[3], ' '))) if(!strncmp(msg + 1, "j ", 2) && (msg[3] == '#'))
*(p++) = 0; snprintf(bufout, sizeof(bufout), "JOIN %s\r\n", &msg[3]);
switch (msg[1]) { else if(!strncmp(msg + 1, "l ", 2))
default: snprintf(bufout, sizeof(bufout), "PART %s :sic\r\n", &msg[3]);
snprintf(bufout, sizeof(bufout), "%s\r\n", &msg[1]); else if(!strncmp(msg + 1, "m ", 2)) {
break; if(p = strchr(&msg[3], ' '))
case 'j': *(p++) = 0;
if(msg[3] == '#')
snprintf(bufout, sizeof(bufout), "JOIN %s\r\n", &msg[3]);
else if(p) {
privmsg(&msg[3], p + 1);
return;
}
break;
case 'l':
if(p)
snprintf(bufout, sizeof(bufout), "PART %s :%s\r\n", &msg[3], p);
else
snprintf(bufout, sizeof(bufout), "PART %s :sic\r\n", &msg[3]);
break;
case 'm':
privmsg(&msg[3], p); privmsg(&msg[3], p);
return; return;
case 's': }
else if(!strncmp(msg + 1, "s ", 2)) {
strncpy(channel, &msg[3], sizeof(channel)); strncpy(channel, &msg[3], sizeof(channel));
return; return;
case 't':
snprintf(bufout, sizeof(bufout), "TOPIC %s :%s\r\n", &msg[3], p);
break;
} }
else if(!strncmp(msg + 1, "t ", 2)) {
if(p = strchr(&msg[3], ' '))
*(p++) = 0;
snprintf(bufout, sizeof(bufout), "TOPIC %s :%s\r\n", &msg[3], p);
}
else
snprintf(bufout, sizeof(bufout), "%s\r\n", &msg[1]);
write(srv, bufout, strlen(bufout)); write(srv, bufout, strlen(bufout));
} }
@ -241,7 +233,7 @@ main(int argc, char *argv[])
int i; int i;
struct timeval tv; struct timeval tv;
struct hostent *hp; struct hostent *hp;
struct sockaddr_in addr = { 0 }; static struct sockaddr_in addr; /* initially filled with 0's */
char ping[256]; char ping[256];
fd_set rd; fd_set rd;
@ -257,7 +249,7 @@ main(int argc, char *argv[])
server = argv[++i]; server = argv[++i];
break; break;
case 'p': case 'p':
port = atoi(argv[++i]); port = (unsigned short)atoi(argv[++i]);
break; break;
case 'n': case 'n':
nick = argv[++i]; nick = argv[++i];
@ -280,10 +272,13 @@ main(int argc, char *argv[])
fprintf(stderr, "sic: cannot connect server '%s'\n", server); fprintf(stderr, "sic: cannot connect server '%s'\n", server);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
hp = gethostbyname(server); if (NULL == (hp = gethostbyname(server))) {
fprintf(stderr, "sic: cannot resolve hostname '%s'\n", server);
exit(EXIT_FAILURE);
}
addr.sin_family = AF_INET; addr.sin_family = AF_INET;
addr.sin_port = htons(port); addr.sin_port = htons(port);
bcopy(hp->h_addr, &addr.sin_addr, hp->h_length); memcpy(&addr.sin_addr, hp->h_addr, hp->h_length);
if(connect(srv, (struct sockaddr *) &addr, sizeof(struct sockaddr_in))) { if(connect(srv, (struct sockaddr *) &addr, sizeof(struct sockaddr_in))) {
close(srv); close(srv);
fprintf(stderr, "sic: cannot connect server '%s'\n", server); fprintf(stderr, "sic: cannot connect server '%s'\n", server);

View File

@ -1,39 +0,0 @@
<html>
<head>
<title>sic - simple irc client</title>
<meta name="author" content="Anselm R. Garbe">
<meta name="generator" content="ed">
<meta name="copyright" content="(C)opyright 2006 by Anselm R. Garbe">
<style type="text/css">
body {
color: #000000;
font-family: sans-serif;
margin: 20px 20px 20px 20px;
}
</style>
</head>
<body>
<center>
<h3>simple irc client</h3>
</center>
<h3>Description</h3>
<p>
sic is an extremly simple IRC client. It consists of lesser than 400 lines of code.
</p>
<ul>
<li><a href="http://10kloc.org/cgi-bin/man/man2html?query=sic">Man page</a></li>
</ul>
<h3>Download</h3>
<ul>
<li><a href="http://10kloc.org/download/sic-0.2.tar.gz">sic 0.2</a> (5kb) (20060721)</li>
</ul>
<h3>Development</h3>
<p>
You can <a href="http://10kloc.org/cgi-bin/hgwebdir.cgi/sic">browse</a> its source code repository or get a copy using <a href="http://www.selenic.com/mercurial/">Mercurial</a> with following command:
</p>
<p>
<code>hg clone http://10kloc.org/cgi-bin/hgwebdir.cgi/sic</code>
</p>
<p><small>--Anselm (20060719)</small></p>
</body>
</html>