tinyirc-1.1.dfsg.1/0000750000175000001440000000000010275167226013450 5ustar decklinuserstinyirc-1.1.dfsg.1/Makefile0000640000175000001440000000262406421501506015104 0ustar decklinusers# tinyirc makefile # by Nathan Laredo # # I don't wish to assert any rights (copyright) over this makefile # but please give me credit if you use my code. # SERVER = irc.linpeople.org PORT = 7000 # all: ## Please use "make target" ## where target is one of the following ## ## aix hpux gnu posix generic debug ## ## If you have trouble with the input line, try a different target debug: $(MAKE) tinyirc CFLAGS=-g LDFLAGS=-g CC=gcc LIBS=-ltermcap generic: $(MAKE) tinyirc CFLAGS=-O LDFLAGS=-s LIBS=-ltermcap aix: $(MAKE) tinyirccv CFLAGS="-O -D_AIX_" \ LDFLAGS=-s LIBS=-lcurses CC=bsdcc posix: $(MAKE) tinyirc CFLAGS="-O2 -m486 -DPOSIX" LDFLAGS="-s" LIBS=-ltermcap gnu: $(MAKE) tinyirc CFLAGS="-O2 -pipe -DPOSIX -Wall -Wunused -Wformat" \ LDFLAGS=-s LIBS=-ltermcap CC=gcc hpux: $(MAKE) tinyirccv LDFLAGS=-s LIBS=-lcurses ntest: $(MAKE) tinyirccv CFLAGS="-O -I/usr/include/ncurses -DPOSIX" \ LDFLAGS="-L/usr/local/lib" LIBS=-lncurses CC=gcc ctest: $(MAKE) tinyirccv CFLAGS=-O LDFLAGS=-s LIBS=-lcurses DEFINES = -DDEFAULTSERVER=\"$(SERVER)\" -DDEFAULTPORT=$(PORT) tinyirc: tinyirc.o $(CC) $(LDFLAGS) -o tinyirc tinyirc.o $(LIBS) tinyirccv: tinyirccv.o $(CC) $(LDFLAGS) -o tinyirc tinyirccv.o $(LIBS) tinyirc.o: tinyirc.c Makefile $(CC) $(CFLAGS) $(DEFINES) -c tinyirc.c -o tinyirc.o tinyirccv.o: tinyirccv.c Makefile $(CC) $(CFLAGS) $(DEFINES) -c tinyirccv.c -o tinyirccv.o #EOF tinyirc-1.1.dfsg.1/ctcp.doc0000640000175000001440000004737506421501506015100 0ustar decklinusers From frechett@ucsu.Colorado.EDU Fri Jul 17 15:56:07 1992 To: hrose@eff.org Subject: CTCP stuff.. Date: Mon, 13 Jul 92 09:48:54 -0600 From: frechett@ucsu.Colorado.EDU X-Mts: smtp ------- Forwarded Message From owner-irc-dev@coke.CS.Berkeley.EDU Tue May 19 20:50:56 1992 Received: from coke.CS.Berkeley.EDU by ucsu.Colorado.EDU with SMTP id AA10565 (5.65c+/IDA-1.4.4/CNS-2.1 for ); Tue, 19 May 1992 11:05:19 -0600 Received: by coke.CS.Berkeley.EDU (5.65/1.43) id AA04019; Tue, 19 May 92 09:52:06 -0700 Received: from sunic.sunet.se by coke.CS.Berkeley.EDU (5.65/1.43) id AA04014; Tue, 19 May 92 09:51:38 -0700 Received: from Minsk.DoCS.UU.SE by sunic.sunet.se (5.65c8/1.25) id AA26625; Tue, 19 May 1992 18:50:59 +0200 Received: by Minsk.DoCS.UU.SE (Sun-4/630, SunOS 4.1.2) with sendmail 5.61-bind 1.5+ida/ICU/DoCS id AA14442; Tue, 19 May 92 18:50:56 +0200 Date: Tue, 19 May 92 18:50:56 +0200 From: Klaus Zeuge Message-Id: <9205191650.AA14442@Minsk.DoCS.UU.SE> X-Zippy-Proclaims: I hope I bought the right relish... zzzzzzzzz... X-Dogma: 36 >> 32 X-Last-Band-Seen: Beagle at Barowiak in Uppsala, Sweden, 920409. X-Mini-Review: Pretty nice, FUNNY. To: irc-dev@coke.CS.Berkeley.EDU Subject: CTCP -- please comment Sometime in the fall last year I started writing on a paper to summerize the usage of CTCP (client to client protocoll), quoting etc. This is it. It needs proofreading, and suggestions about what's good and bad. It's not complete either. Maybe it's a start. - ----------------------------------------------------------------------------- sojge@docs.uu.se Sun Oct 27 17:27:59 1991 -*-Text-*- The client-to-client protocol (CTCP) *13* This client-to-client protocol is meant to be used as a way to 1/ in general send structered data (such as graphics, voice and different font information) between users clients, and in a more specific case 2/ place a query to a users client and getting an answer. As of now, only a simple text encryption scheme is implemented in category 1, and a few query/reply pairs in category 2. This paper will concentrate on the latter category. ***************************************** BASIC PROTOCOL BETWEEN CLIENTS AND SERVER ***************************************** Characters between client and server are 8 bit bytes (also known as octets) and can have nummeric values from octal 0 up to 0377 inclusive (0 up to 255 decimal). Some characters are special. CHARS ::= '\000' .. '\377' NUL ::= '\000' NL ::= '\n' CR ::= '\r' A line sent to a server, or received from a server (here called "low level messages") consist or zero or more octets (expcept NUL, NL or CR) with either a NL or CR appended. L-CHARS ::= '\001' .. '\011' | '\013' | '\014' | '\016' .. '\377' L-LINE ::= L-CHARS* CR LF A NUL is never sent over to the server. ***************** LOW LEVEL QUOTING ***************** As messages to and from servers can't contain NUL, NL and CR, but it still might be desirable to send ANY character (in so called "middle level messages") between clients, those three characters have to be quoted. Therefor a quote character is needed. Of course, the quote character itself has to be quoted too. M-QUOTE ::= '\020' (Ie a CNTRL/P). When sending a middle level message, if finding a character being one of NUL, NL, CR or M-QUOTE, that character is replaced by a two character sequence according to the following table. NUL --> M-QUOTE '0' NL --> M-QUOTE 'n' CR --> M-QUOTE 'r' M-QUOTE --> M-QUOTE M-QUOTE When receiving a low level message, and seeing a M-QUOTE, look at the next character, and replace those two according to the following table to get the corresponding middle level message. M-QUOTE '0' --> NUL M-QUOTE 'n' --> NL M-QUOTE 'r' --> CR M-QUOTE M-QUOTE --> M-QUOTE If the character following M-QUOTE isn't any of the listed characters, that is an error, so drop the M-QUOTE character from the message, optionally warning the user about it. Ie, a string 'x' M-QUOTE 'y' 'z' >from a server dequotes into 'x 'y' 'z'. Before low level quoting, a message to the server (and in the opposite direction: after low level dequoting, a message from the server) looks like M-LINE ::= CHARS* *********** TAGGED DATA *********** To send both extended data and query/reply pairs between clients, an extended data format is needed. The extended data are sent in the text part of a middle level message (and efter low level quoting of course also in the text part of the low level message). To send extended data inside the text, we need some way to delimit it. This is done by starting and ending extended data with a delimiter character. X-DELIM ::= '\001' As both the starting and ending delimiter looks the same, every second X-DELIM is called the odd, and every second the even delimiter. The first one in a message is odd. When having being quoted (and conversly, before having been dequoted) any number of characters of any kind except X-DELIM can be used in the extended data, ie inside the X-DELIM pair. X-CHR ::= '\000' | '\002' .. '\377' An extended message is either empty (ie nothing between the odd and even delimiter), has one or more non-space characters (ie any character but '\040') or has one or more non-space characters followed by a space followed by zero or more characters. X-N-AS ::= '\000' | '\002' .. '\037' | '\041' .. '\377' SPC ::= '\040' X-MSG ::= | X-N-AS+ | X-N-AS+ SPC X-CHR* The first characters up until the first SPC (or if no SPC, all of the X-MSG) is called the tag of the extended message. The tag is used to know what kind of extended data is used. The tag can be *any* strings of characters and if the happen to be letters, they are case sensitive, so upper and lower case matters. Extended data is only valid in PRIVMSG and NOTICE commands. If the extended data is a reply to a query, it is sent in a NOTICE, else it is sent in a PRIVMSG. Both PRIVMSG and NOTICE to a user and to a channel may contain extended data. The text part of a PRIVMSG or NOTICE might contain zero or more extended messages, intermixed with zero or more chunks of non-extended data. ****************** CTCP LEVEL QUOTING ****************** In order to be able to send the delimiter X-DELIM inside an extended data message, it has to be quoted. This introduces another quote character (which should differ from the low level quote character so it won't have to be quoted yet again). X-QUOTE ::= '\134' (Ie a back slash). When quoting on the CTCP level, only actual CTCP message (ie extended data, queries, replies) are quoted. This enables users to actually send X-QUOTE characters at will. The following translations should be used X-DELIM --> X-QUOTE 'a' X-QUOTE --> X-QUOTE X-QUOTE and when dequoting on the CTCP level, only CTCP messages are dequoted whereby the following table is used. X-QUOTE 'a' --> X-DELIM X-QUOTE X-QUOTE --> X-QUOTE If a X-QUOTE is seen with another the character following it than the ones above, that's an error and the X-QUOTE character should be dropped. Ie the CTCP-quoted string 'x' X-QUOTE 'y' 'z' becomes after dequoting the three character string 'x' 'y' 'z'. If a X-DELIM is found outside a CTCP message, the message will contain the X-DELIM. (This should only happen with the last X-DELIM when there are an odd number of X-DELIM's in a middle level message. *************** QUTING EXAMPLES *************** There are basically three levels of messages. The highest level (H) is the text on the user-to-client level. The middle layer (M) is on the level where CTCP quoting has been applied to the H-level message. The lowest level (L) is on the client-to-server level, where low level quoting has been applied to the M-level message. The following relations are true, with lowQuote(message) being a function doing the low level quoting, lowDequote(message) the low level dequoting, ctcpQuote(message) the CTCP level quoting, ctcpDequote(message) the CTCP level dequoting, and ctcpExtract(message) the removing of all CTCP messages from a message. The operator || denotes string concatenation. L = lowQuote(M) M = ctcpDequote(L) M = ctcpQuote(H) H = ctcpDequote(ctcpExtract(M)) When sending CTCP message imbedded in normal text M = ctcpQuote(H1) || '\001' || ctcpQuote(X) || '\001' || ctcpQuote(H2) Of course, there might be zero or more normal text messages and zero or more CTCP messages mixed. - --- Example 1 ----------------------------------------------------------------- A user (called actor) wanting to send the string Hi there!\nHow are you? to user victim, ie a message where the user has entered an inline newline (how this is done, if at all, differs from client to client), will result internaly in the client in the command PRIVMSG victim :Hi there!\nHow are you? \K? which will be CTCP quoted into PRIVMSG victim :Hi there!\nHow are you? \\K? which in turn will be low level quoted into PRIVMSG victim :Hi there!\020nHow are you? \\K? and sent to the server after appending a newline at the end. This will arrive on victim's side as :actor PRIVMSG victim :Hi there!\020nHow are you? \\K? (where the \\K would look similar to OK in SIS D47 et al) which after low level dequoting becomes :actor PRIVMSG victim :Hi there!\nHow are you? \\K? and after CTCP dequoting :actom PRIVMSG victim :Hi there!\nHow are you? \K? How this is displayed differs from client to client, but it suggested that a line break should occour between the words "there" and "How". - --- Example 2 ----------------------------------------------------------------- If actor's client wants to send the string "Emacs wins" this might become the string "\n\t\big\020\001\000\\:" when being SED-encrypted using some key, so the client starts by CTCP-quoting this string into the string "\n\t\big\020\\a\000\\\\:" and builds the M-level command PRIVMSG victim :\001SED \n\t\big\020\\a\000\\\\:\001 which after low level quoting becomes PRIVMSG victim :\001SED \020n\t\big\020\020\\a\0200\\\\:\001 which will be sent to the server, with a newline tacked on. On victim's side, the string :actor PRIVMSG victim :\001SED \020n\t\big\020\020\\a\0200\\\\:\001 will be received from the server and low level dequoted into :actor PRIVMSG victim :\001SED \n\t\big\020\\a\000\\\\:\001 whereafter the string "\n\t\big\020\\a\000\\\\:" will be extracted and first CTCP dequoted into "\n\t\big\020\001\000\\:" and then SED decoded getting back "Emacs wins" when using the same key. - --- Example 3 ----------------------------------------------------------------- If the user actor want's to query the USERINFO of user victim, and is in the middle of a conversation, the client may decide to tack on USERINFO request on a normal text message. Then the client wants to send the textmessage "Say hi to Ron\n\t/actor" and the CTCP request "USERINFO" to victim. PRIVMSG victim :Say hi to Ron\n\t/actor plus USERINFO which after CTCP quoting become PRIVMSG victim :Say hi to Ron\n\t/actor plus USERINFO which gets merged into PRIVMSG victim :Say hi to Ron\n\t/actor\001USERINFO\001 and after low level quoting PRIVMSG victim :Say hi to Ron\020n\t/actor\001USERINFO\001 and sent off to the server. On victim's side, the message :actor PRIVMSG victim :Say hi to Ron\020n\t/actor\001USERINFO\001 arrives. This gets low level dequoted into :actor PRIVMSG victim :Say hi to Ron\n\t/actor\001USERINFO\001 and thereafter split up into :actor PRIVMSG victim :Say hi to Ron\n\t/actor plus USERINFO After CTCP dequoting both, the message :actor PRiVMSG victim :Say hi to Ron\n\t/actor gets displayed, while the CTCP command USERINFO gets replied to. The reply might be USERINFO :CS student\n\001test\001 which gets CTCP quoted into USERINFO :CS student\n\\atest\\a and sent in a NOTICE as it is a reply: NOTICE actor :\001USERINFO :CS student\n\\atest\\a\001 and low level quoted into NOTICE actor :\001USERINFO :CS student\020n\\atest\\a\001 after which is it sent to victim's server. When arriving on actor's side, the message :victim NOTICE actor :\001USERINFO :CS student\020n\\atest\\a\001 gets low level dequoted into :victim NOTICE actor :\001USERINFO :CS student\n\\atest\\a\001 At this point, all CTCP replies get extracted, giving 1 CTCP reply and no normal NOTICE USERINFO :CS student\n\\atest\\a The remaining reply gets CTCP dequoted into USERINFO :CS student\n\001test\001 and presumly displayed to user actor. ******************* KNOWN EXTENDED DATA ******************* ************************* KNOWN REQUEST/REPLY PAIRS ************************* A request/reply pair is sent between the two clients in two phases. The first phase is to send the request. This is done with a "privmsg" command (either to a nick or to a channel -- it doesn't matter). The second phase is to send a reply. This is done with a "notice" command. The known request/reply pairs are for the following commands. CLIENTINFO - Dynamic master index of what a client knows ERRMSG - Used when an error needs to be replied with FINGER - Mainly used to get a users idle time USERINFO - A string set by the user (never client coder) VERSION - The version and type of the client FINGER This is used to get some data stored locally at a users system about the user and also the idle time of the user. The request is in a "privmsg" and looks like \001FINGER\001 while the reply is in a "notice" and looks like \001FINGER :#\001 where the # denotes contains information about the users real name, login name at clientmachine and idle time and is of type X-N-AS. VERSION This is used to get information about the name of the other client and the version of it. The request in a "privmsg" is simply \001VERSION\001 and the reply \001VERSION #:#:#\001 where the first # denotes the name of the client, the second # denotes the version of the client, the third # the enviroment the client is running in. Using X-N-CLN ::= '\000' .. '\071' | '\073' .. '\377' the client name is a string of type X-N-CLN saying things like "Kiwi" or "ircII", the version saying things like "5.2" or "2.1.5c", the enviroment saying things like "GNU Emacs 18.57.19 under SunOS 4.1.1 on Sun SLC" or "Compiled with gcc -ansi under Ultrix 4.0 on VAX-11/730". SOURCE This is used to get information about where to get a copy of the client. The request in a "privmsg" is simply \001SOURCE\001 and the reply is zero or more CTCP replies of the form \001SOURCE #:#:#\001 followed by an end marker \001SOURCE\001 where the first # is the name of an Internet host where the client can be gotten from with anonymous FTP the second # a directory names, and the third # a space separated list of files to be gotten from that directory. Using X-N-SPC ::= '\000' .. '\037' | '\041' .. '\377' the name of the FTP site is to be given by name like "cs.bu.edu" or "funic.funet.fi". The file name field is a directory specification optionally followed by one or more file names, delimited by spaces. If only a directory name is given, all files in that directory should be copied when retrieving the clients source. If some files are given, only those files in that directpry should be copied. Note that the spcification allows for all characters but space in the names, this includes allowing :. Examples are "pub/emacs/irc/" to get all files in directory pub/emacs/irc/, the client should be able to first login as user "ftp" and the give the command "CD pub/emacs/irc/", followed by the command "mget *". (It of course has to take care of binary and prompt mode too). Another example is "/pub/irc Kiwi.5.2.el.Z" in which case a "CD /pub/irc" and "get Kiwi.5.2.el.Z" is what should be done. USERINFO This is used to transmit a string which is settable by the user (and never should be set by the client). The query is simply \001USERINFO\001 with the reply \001USERINFO :#\001 where the # is the value of the string the client's user has set. CLIENTINFO This is for client developers use to make it easier to show other client hackers what a certain client knows when it comes to CTCP. The replies should be fairly verbose explaining what CTCP commands are understood, what arguments are expected of what type, and what replies might be expected from the client. The query is the word CLIENTINFO in a "privmsg" optionally followed by a colon and one or more specifying words delimited by spaces, where the word CLIENTINFO by itself, \001CLIENTINFO\001 should be replied to by giving a list of known tags (see above in section TAGGED DATA). This is only intended to be read by humans. With one argument, the reply should be a description of how to use that tag. With two arguments, a description of how to use that tag's subcommand. And so on. ERRMSG This is used as a reply whenever an unknown query is seen. Also, when used as a query, the reply should echo back the text in the query, together with an indication that no error has happened. Should the query form be used, it is \001ERRMSG #\001 where # is a string containing any character, with the reply \001ERRMSG # :#\001 where the first # is the same string as in the query and the second # a short text notifying the user that no error has occurred. A normal ERRMSG reply which is sent when a corrupted query or some corrupted extended data is received, looks like \001ERRMSG # :#\001 where the first # is the the failed query or corrupted extended data and the second # a text explaining what the problem is, like "unknown query" or "failed decrypting text". ******** EXAMPLES ******** Sending PRIVMSG victim :\001FINGER\001 might return :victim NOTICE actor :\001FINGER :Please check my USERINFO instead :Klaus Zeuge (sojge@mizar) 1 second has passed since victim gave a command last.\001 (this is only one line) or why not :victim NOTICE actor :\001FINGER :Please check my USERINFO instead :Klaus Zeuge (sojge@mizar) 427 seconds (7 minutes and 7 seconds) have passed since victim gave a command last.\001 if Klaus Zeuge happens to be lazy? :-) Sending PRIVMSG victim :CLIENTINFO might return :victim NOTICE actor :CLIENTINFO :You can request help of the commands CLIENTINFO ERRMSG FINGER USERINFO VERSION by giving an argument to CLIENTINFO. Sending PRIVMSG victim :CLIENTINFO CLIENTINFO might return :victim NOTICE actor :CLIENTINFO :CLIENTINFO with 0 arguments gives a list of known client query keywords. With 1 argument, a description of the client query keyword is returned. while sending PRIVMSG victim :clientinfo clientinfo probaly will return something like :victim NOTICE actor :ERRMSG clientinfo clientinfo :Query is unknown as tag "clientinfo" isn't known. Sending PRIVMSG victim :CLIENTINFO ERRMSG might return :victim NOTICE actor :CLIENTINFO :ERRMSG is the given answer on seeing an unknown keyword. When seeing the keyword ERRMSG, it works like an echo. Sending PRIVMSG victim :\001USERINFO\001 might return the somewhat pathetically long :victim NOTICE actor :USERINFO :I'm studying computer science in Uppsala, I'm male (somehow, that seems to be an important matter on IRC:-) and I speak fluent swedish, decent german, and some english. Sending PRIVMSG victim :\001VERSION\001 might return :victim NOTICE actor :\001VERSION Kiwi:5.2:GNU Emacs 18.57.19 under SunOS 4.1.1 on Sun SLC:FTP.Lysator.LiU.SE:/pub/emacs Kiwi-5.2.el.Z Kiwi.README\001 if the client is named Kiwi of version 5.2 and is used under GNU Emacs 18.57.19 running on a Sun SLCwith SunOS 4.1.1. The client claims a copy of it can be found with anonymous FTP on FTP.Lysator.LiU.SE after giving the FTP command "cd /pub/emacs/". There, one should get files Kiwi-5.2.el.Z and Kiwi.README; presumly one of the files tells how to proceed with building the client after having gotten the files. - ----------------------------------------------------------------------------- End of file. ------- End of Forwarded Message tinyirc-1.1.dfsg.1/tinyircd.c0000640000175000001440000001524006421501506015433 0ustar decklinusers#define RELEASE "tinyircd 0.1" /* tinyircd 0.1 Copyright (C) 1996 Nathan I. Laredo This program is modifiable/redistributable under the terms of the GNU General Public Licence. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Send your comments and all your spare pocket change to laredo@gnu.ai.mit.edu (Nathan Laredo) or to PSC1, BOX 709, Lackland AFB, TX, 78236-5128 */ #include #ifndef POSIX #include #define USE_OLD_TTY #include #if !defined(sun) && !defined(sequent) && !defined(__hpux) && \ !defined(_AIX_) #include #define strchr index #else #include #endif #else #include #include #endif #include #include #include #include #include #include #include #include #include #include #include #define ischan(x) (*x == '#' || *x == '&' || *x == '+') /* global structures */ struct channel_list { char *name; char *users; char *modes; char *banlist; char *moderators; time_t creation; struct channel_list *next; }; struct user_list { char *nick; char *logname; char *loghost; char *realname; char *mode; time_t creation; int hopcount; }; /*************************************************************/ int my_stricmp(str1, str2) char *str1, *str2; { int cmp; while (*str1 != 0 && str2 != 0) { if (isalpha(*str1) && isalpha(*str2)) { cmp = *str1 ^ *str2; if ((cmp != 32) && (cmp != 0)) return (*str1 - *str2); } else { if (*str1 != *str2) return (*str1 - *str2); } str1++; str2++; } return (*str1 - *str2); } int makeconnect(hostname) char *hostname; { struct sockaddr_in sa; struct hostent *hp; int s, t; if ((hp = gethostbyname(hostname)) == NULL) return -1; for (t = 0, s = -1; s < 0 && hp->h_addr_list[t] != NULL; t++) { bzero(&sa, sizeof(sa)); bcopy(hp->h_addr_list[t], (char *) &sa.sin_addr, hp->h_length); sa.sin_family = hp->h_addrtype; sa.sin_port = htons((unsigned short) IRCPORT); s = socket(hp->h_addrtype, SOCK_STREAM, 0); if (s > 0) if (connect(s, (struct sockaddr *) &sa, sizeof(sa)) < 0) { close(s); s = -1; } else { fcntl(s, F_SETFL, O_NDELAY); my_tcp = s; sprintf(lineout, "NICK :%s\n", IRCNAME); sendline(); sprintf(lineout, "USER %s * * :%s\n", IRCLOGIN, IRCGECOS); sendline(); } } return s; } main(argc, argv) int argc; char **argv; { int i = 0; printf("%s Copyright (C) 1991-1996 Nathan Laredo\n\ This is free software with ABSOLUTELY NO WARRANTY.\n\ For details please see the file COPYING.\n", RELEASE); if (!(tmp = (char *) getenv("IRCSERVER"))) strcpy(hostname, DEFAULTSERVER); else { while (*tmp && *tmp != ':') hostname[i++] = *(tmp++); hostname[i] = '\0'; if (*tmp == ':') IRCPORT = (unsigned short) atoi(++tmp); } if (argc > 1) { for (i = 1; i < argc; i++) if (argv[i][0] == '-') { if (argv[i][1] == 'd') dumb = 1; else { fprintf(stderr, "usage: %s %s\n", argv[0], "[nick] [server] [port] [-dumb]"); exit(1); } } else if (strchr(argv[i], '.')) strcpy(hostname, argv[i]); else if (atoi(argv[i]) > 255) IRCPORT = atoi(argv[i]); else strncpy(IRCNAME, argv[i], sizeof(IRCNAME)); } if ((my_tty = open("/dev/tty", O_RDWR, 0)) == -1) my_tty = fileno(stdin); IRCGECOS[i = 63] = 0; if (!getpeername(my_tty, IRCGECOS, &i)) { /* inetd */ strcpy(IRCNAME, IRCGECOS); strcpy(IRCLOGIN, "fromident"); setenv("TERM", "vt102", 1); } else { userinfo = getpwuid(getuid()); tmp = (char *) getenv("IRCNICK"); if (tmp == NULL) strncpy(IRCNAME, userinfo->pw_name, sizeof(IRCNAME)); else strncpy(IRCNAME, tmp, sizeof(IRCNAME)); strcpy(IRCLOGIN, userinfo->pw_name); setutent(); strcpy(ut.ut_line, strrchr(ttyname(0), '/') + 1); if ((utmp = getutline(&ut)) == NULL || !(utmp->ut_addr) || *((char *) utmp->ut_host) == ':' /* X connection */ ) tmp = userinfo->pw_gecos; else { struct hostent *h; struct in_addr a; a.s_addr = utmp->ut_addr; if (!(h = gethostbyaddr((char *) &a.s_addr, sizeof(a.s_addr), AF_INET))) tmp = (char *) inet_ntoa(a); else tmp = (char *) h->h_name; } strcpy(IRCGECOS, tmp); endutent(); } fprintf(stderr, "*** User is %s\n", IRCGECOS); printf("*** trying port %d of %s\n\n", IRCPORT, hostname); if (makeconnect(hostname) < 0) { fprintf(stderr, "*** %s refused connection, aborting\n", hostname); exit(0); } idletimer = time(NULL); ptr = termcap; if ((term = (char *) getenv("TERM")) == NULL) { fprintf(stderr, "tinyirc: TERM not set\n"); exit(1); } if (tgetent(bp, term) < 1) { fprintf(stderr, "tinyirc: no termcap entry for %s\n", term); exit(1); } if ((CO = tgetnum("co") - 2) < 20) CO = 78; if ((LI = tgetnum("li")) == -1) LI = 24; if (!dumb) { #define tgs(x) ((char *) tgetstr(x, &ptr)) if ((CM = tgs("cm")) == NULL) CM = tgs("CM"); if ((SO = tgs("so")) == NULL) SO = ""; if ((SE = tgs("se")) == NULL) SE = ""; if (!CM || !(CS = tgs("cs")) || !(CE = tgs("ce"))) { printf("tinyirc: sorry, no termcap cm,cs,ce: dumb mode set\n"); dumb = 1; } if (!dumb) { DC = tgs("dc"); savetty(); raw(); #ifdef CURSES nonl(); noecho(); #endif } } redraw(); signal(SIGINT, cleanup); signal(SIGHUP, cleanup); signal(SIGTERM, cleanup); signal(SIGSEGV, cleanup); signal(SIGTTIN, stopin); for (i = 0; i < HISTLEN; i++) hist[i] = (char *) calloc(512, sizeof(char)); linein = hist[hline = 0]; while (sok) { FD_ZERO(&readfs); FD_SET(my_tcp, &readfs); if (!noinput) FD_SET(my_tty, &readfs); if (!dumb) { timeout.tv_sec = 61; timeout.tv_usec = 0; } if (select(FD_SETSIZE, &readfs, NULL, NULL, (dumb ? NULL : &timeout))) { if (FD_ISSET(my_tty, &readfs)) userinput(); if (FD_ISSET(my_tcp, &readfs)) sok = serverinput(); if (!wasdate) updatestatus(); } else updatestatus(); if (!sok && reconnect) { close(my_tcp); /* dead socket */ printf("*** trying port %d of %s\n\n", IRCPORT, hostname); if (makeconnect(hostname) < 0) { fprintf(stderr, "*** %s refused connection\n", hostname); exit(0); } sok++; } if (!dumb) tputs_x(tgoto(CM, curx % CO, LI - 1)); fflush(stdout); } if (!dumb) { tputs_x(tgoto(CS, -1, -1)); tputs_x(tgoto(CM, 0, LI - 1)); #ifdef CURSES echo(); nl(); #endif resetty(); } exit(0); } /* EOF */ tinyirc-1.1.dfsg.1/magic0000640000175000001440000000001206421501506014434 0ustar decklinusers103276200 tinyirc-1.1.dfsg.1/announce0000640000175000001440000000551306421501506015175 0ustar decklinusersFOR RELEASE NOVEMBER 11, 1994 -- TINYIRC VERSION 1.0 IS NOW AVAILABLE! Tinyirc was developed on SunOS 4.1.3, and has been verified compatable with hpux, linux 1.3.51, AIX, DYNIX, and will probably run on many other platforms using one of the make options. it is available via anonymous ftp to ftp.netcom.com in /pub/Linux/tinyirc-1.0.tar.gz this tar file is 13k because it includes the GNU public licence. PLEASE NOTE- The termcap-based version of tinyirc has fewer features than the curses-based version, and development will continue in this direction. If you want to use the curses version of tinyirc, I highly recommend installing ncurses on your system and linking with it. ncurses is available on ftp.netcom.com /pub/zmbenhal/ncurses ncurses routines may be integrated into tinyirc sometime in the future and the termcap version dropped (next version?) Here's what's been added since tinyirc-pre1.0 ----------------------------------------------------------------- Configuration options moved into Makefile Curses is used on systems where termcap is not available Large speed improvements on hpux and aix (with curses) Output of "/MSG" resembles IrcII instead of raw data Tokinization of server input no longer trashes spaces Word wrap algorithm fixes (for long lines without spaces) Environment variable IRCSERVER compatable with IrcII defs Cosmetic changes to status line, channel mode added "/MODE" now allows unlimited parameters instead of only 1 "/JOIN user" makes default object a user "/PART user" removes user from object list Suspending, Backgrounding and Foregrounding is supported Curses version able to restore screen completely Scrollback in curses version (PageUp/PageDown, C-u/C-v) Arrow keys supported by curses version (when available) More bug fixes. Here's what's been added since version 0.4 of tinyirc.c ----------------------------------------------------------------- Support for 2.8.x servers SUPPORT FOR OLDER SERVERS REMOVED! Configurable command line history Emacs-style command line editing ^W channel switching "/JOIN" can be used to set the default channel "/MSG" is supported "/NOTICE" is fixed command completion ("/QU" = "/QUIT", etc) full screen mode optimized to use entire display highly-optimized input line. Only updates what is needed cursor properly tracks input position in full screen mode And hundreds of other enhancements and bug fixes too numerous to mention! ----------------------------------------------------------------- Grab your copy today and test it out! Send me a little note letting me know how much you like tinyirc so that I'll be motivated to keep enhancing it. If you have trouble getting it to work, please send me email. If you do not know what a .tar.gz file is, please read the newsgroup news.answers and look for the Unix FAQ. -- nathan laredo, laredo@gnu.ai.mit.edu tinyirc-1.1.dfsg.1/tinyirc.c0000640000175000001440000006007106421501506015271 0ustar decklinusers#undef AUTOJOIN "JOIN :#linuxcon\n" #define COMMANDCHAR '/' #define ASCIIHEXCHAR '@' #define HEXASCIICHAR '#' #define USE_ANSICOLOR /* each line of hist adds 512 bytes to resident size */ #define HISTLEN 8 #ifdef AUTOJOIN #define RELEASE "TinyIRC 1.1 LinuxConv Edition" #else #define RELEASE "TinyIRC 1.1" #endif /* most bytes to try to read from server at one time */ #define IB_SIZE 4096 /* TinyIRC 1.1 Copyright (C) 1991-1996 Nathan I. Laredo This program is modifiable/redistributable under the terms of the GNU General Public Licence. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Send your comments and all your spare pocket change to laredo@gnu.ai.mit.edu (Nathan Laredo) or to PSC1, BOX 709, Lackland AFB, TX, 78236-5128 */ #include #ifndef POSIX #include #define USE_OLD_TTY #include #if !defined(sun) && !defined(sequent) && !defined(__hpux) && \ !defined(_AIX_) #include #define strchr index #else #include #endif #else #include #include #endif #include #include #include #include #include #include #include #include #include #include #include struct dlist { char name[64]; char mode[64]; struct dlist *next; }; #define ischan(x) (*x == '#' || *x == '&' || *x == '+') #define OBJ obj->name #define raise_sig(x) kill(getpid(), x) struct dlist *obj = NULL, *olist = NULL, *newobj; unsigned short IRCPORT = DEFAULTPORT; int my_tcp, sok = 1, my_tty, hline, dumb = 0, CO, LI, column; char *tmp, *linein, *CM, *CS, *CE, *SO, *SE, *DC, *ptr, *term, *fromhost, *TOK[20], IRCNAME[32], IRCLOGIN[64], IRCGECOS[64], inputbuf[512], ib[IB_SIZE], serverdata[512], ch, *bp[1024], lineout[512], *hist[HISTLEN], termcap[1024]; int cursd = 0, curli = 0, curx = 0, noinput = 0, reconnect = 1; fd_set readfs; struct timeval timeout; struct tm *timenow; static time_t idletimer, datenow, wasdate, tmptime; struct passwd *userinfo; #ifdef CURSES #include #else #ifdef POSIX struct termios _tty; tcflag_t _res_oflg, _res_lflg; #define raw() (_tty.c_lflag &= ~(ICANON | ECHO | ICRNL | ISIG), \ _tty.c_oflag &= ~ONLCR, tcsetattr(my_tty, TCSANOW, &_tty)) #define savetty() ((void) tcgetattr(my_tty, &_tty), \ _res_oflg = _tty.c_oflag, _res_lflg = _tty.c_lflag) #define resetty() (_tty.c_oflag = _res_oflg, _tty.c_lflag = _res_lflg,\ (void) tcsetattr(my_tty, TCSADRAIN, &_tty)) #else struct sgttyb _tty; int _res_flg; #define raw() (_tty.sg_flags |= RAW, _tty.sg_flags &= ~(ECHO | CRMOD), \ ioctl(my_tty, TIOCSETP, &_tty)) #define savetty() ((void) ioctl(my_tty, TIOCGETP, &_tty), \ _res_flg = _tty.sg_flags) #define resetty() (_tty.sg_flags = _res_flg, \ (void) ioctl(my_tty, TIOCSETP, &_tty)) #endif #endif int putchar_x(c) int c; { return putchar(c); } #define tputs_x(s) (tputs(s,0,putchar_x)) int my_stricmp(str1, str2) char *str1, *str2; { int cmp; while (*str1 != 0 && str2 != 0) { if (isalpha(*str1) && isalpha(*str2)) { cmp = *str1 ^ *str2; if ((cmp != 32) && (cmp != 0)) return (*str1 - *str2); } else { if (*str1 != *str2) return (*str1 - *str2); } str1++; str2++; } return (*str1 - *str2); } struct dlist *additem(item, p) char *item; struct dlist *p; { newobj = (struct dlist *) malloc(sizeof(struct dlist)); strcpy(newobj->name, item); newobj->mode[0] = '\0'; newobj->next = p; return newobj; } struct dlist *finditem(item, p) char *item; struct dlist *p; { while (p != NULL) if (my_stricmp(item, p->name) == 0) break; else p = p->next; return p; } struct dlist *delitem(item, p) char *item; struct dlist *p; { struct dlist *prev = NULL, *start = p; while (p != NULL) if (my_stricmp(item, p->name) == 0) { newobj = p->next; if (obj == p) obj = NULL; free(p); if (prev == NULL) return newobj; else { prev->next = newobj; return start; } } else { prev = p; p = p->next; } return start; } char encoded[512]; hexascii(s) char *s; { int ch, i, j, k, l; j = k = l = 0; for (i = 0; i < strlen(s) && j < 400; i++) { ch = toupper(s[i]); if (ch >= '0' && ch <= '9') (l = (l << 4) | (ch - '0'), k++); else if (ch >= 'A' && ch <= 'F') (l = (l << 4) | (ch - 'A' + 10), k++); if (k == 2) (encoded[j++] = l, k = 0); } encoded[j] = '\0'; } asciihex(s) char *s; { int i; *encoded = '\0'; for (i = 0; i < strlen(s); i++) sprintf(&encoded[strlen(encoded)], "%02x", s[i]); } int sendline() { if (write(my_tcp, lineout, strlen(lineout)) < 1) return 0; return 1; } void updatestatus() { int n; if (!dumb) { if (60 < (datenow = time(NULL)) - wasdate) { wasdate = datenow; timenow = localtime(&datenow); tputs_x(tgoto(CM, 0, LI - 2)); tputs_x(SO); if (obj != NULL) n = printf("%02d:%02d %s %s (%s) %s", timenow->tm_hour, timenow->tm_min, IRCNAME, OBJ, obj->mode, RELEASE); else n = printf("%02d:%02d %s * * %s", timenow->tm_hour, timenow->tm_min, IRCNAME, RELEASE); for (; n < CO; n++) putchar(' '); tputs_x(SE); } } } static int nop() { return 1; } static int doerror() { column = printf("*** ERROR:"); return 2; } static int doinvite() { printf("*** %s (%s) invites you to join %s.", TOK[0], fromhost, &TOK[3]); return 0; } static int dojoin() { if (strcmp(TOK[0], IRCNAME) == 0) { obj = olist = additem(TOK[2], olist); sprintf(lineout, "MODE :%s\n", OBJ); sendline(); printf("*** Now talking in %s", OBJ); wasdate = 0; } else printf("*** %s (%s) joined %s", TOK[0], fromhost, TOK[2]); return 0; } static int dokick() { printf("*** %s was kicked from %s by %s (%s)", TOK[3], TOK[2], TOK[0], TOK[4]); if (strcmp(TOK[3], IRCNAME) == 0) { olist = delitem(TOK[2], olist); if (obj == NULL) obj = olist; if (obj != NULL) printf("\n\r*** Now talking in %s", OBJ); wasdate = 0; } return 0; } static int dokill() { printf("*** %s killed by %s: ", TOK[3], TOK[0]); if (strcmp(TOK[3], IRCNAME) == 0) reconnect = 0; /* don't reconnect if killed */ return 4; } static int domode() { char *t = TOK[3], op = *TOK[3]; printf("*** %s changed %s to:", TOK[0], TOK[2]); if ((newobj = finditem(TOK[2], olist)) != NULL) { while ((t = strpbrk(t, "-+psitnml")) != NULL) { if (*t == '-' || *t == '+') op = *t; else if (op == '-') for (tmp = strchr(newobj->mode, *t); *tmp != '\0'; tmp++) *tmp = *(tmp + 1); else strncat(newobj->mode, t, 1); t++; } if (newobj == obj) wasdate = 0; } return 3; } static int donick() { if (strcmp(TOK[0], IRCNAME) == 0) { wasdate = 0; strcpy(IRCNAME, TOK[2]); } printf("*** %s is now known as %s", TOK[0], TOK[2]); return 0; } static int donotice() { if (!ischan(TOK[2])) column = printf("-%s-", TOK[0]); else column = printf("-%s:%s-", TOK[0], TOK[2]); return 3; } static int dopart() { printf("*** %s (%s) left %s", TOK[0], fromhost, TOK[2]); if (strcmp(TOK[0], IRCNAME) == 0) { olist = delitem(TOK[2], olist); if (obj == NULL) obj = olist; if (obj != NULL) printf("\n\r*** Now talking in %s", OBJ); wasdate = 0; } return 0; } static int dopong() { column = printf("*** Got PONG from %s:", TOK[0]); return 3; } static int doprivmsg() { #ifdef DO_CTCP if (strncmp(TOK[3], "\01PING", 5) == 0) { /* lame ctcp ping hack */ sprintf(lineout, "NOTICE %s :%s\n", TOK[0], TOK[3]); column = printf("*** CTCP PING from %s", TOK[0]); sendline(); return 0; } else if (strncmp(TOK[3], "\01VERSION", 8) == 0) { /* lame ctcp */ sprintf(lineout, "NOTICE %s :\01VERSION " RELEASE " :*ix\01\n", TOK[0]); column = printf("*** CTCP VERSION from %s", TOK[0]); sendline(); return 0; } #endif if (!ischan(TOK[2])) { #ifdef USE_ANSICOLOR printf("\E[1m"); #endif column = printf("*%s*", TOK[0]); } else if (obj != NULL && my_stricmp(OBJ, TOK[2])) column = printf("<%s:%s>", TOK[0], TOK[2]); else column = printf("<%s>", TOK[0]); return 3; } static int doquit() { printf("*** %s (%s) Quit (%s)", TOK[0], fromhost, TOK[2]); return 0; } static int dosquit() { return 1; } static int dotime() { return 1; } static int dotopic() { printf("*** %s set %s topic to \"%s\"", TOK[0], TOK[2], TOK[3]); return 0; } int donumeric(num) int num; { switch (num) { case 352: column = printf("%-14s %-10s %-3s %s@%s :", TOK[3], TOK[7], TOK[8], TOK[4], TOK[5]); return 9; case 311: column = printf("*** %s is %s@%s", TOK[3], TOK[4], TOK[5]); return 6; case 324: if ((newobj = finditem(TOK[3], olist)) != NULL) { strcpy(newobj->mode, TOK[4]); wasdate = 0; } break; case 329: tmptime = atoi(TOK[4]); strcpy(lineout, ctime(&tmptime)); tmp = strchr(lineout, '\n'); if (tmp != NULL) *tmp = '\0'; column = printf("*** %s formed %s", TOK[3], lineout); return 0; case 333: tmptime = atoi(TOK[5]); strcpy(lineout, ctime(&tmptime)); tmp = strchr(lineout, '\n'); if (tmp != NULL) *tmp = '\0'; column = printf("*** %s topic set by %s on %s", TOK[3], TOK[4], lineout); return 0; case 317: tmptime = atoi(TOK[5]); strcpy(lineout, ctime(&tmptime)); tmp = strchr(lineout, '\n'); if (tmp != NULL) *tmp = '\0'; column = printf("*** %s idle %s second(s), on since %s", TOK[3], TOK[4], lineout); return 0; case 432: case 433: printf("*** You've chosen an invalid nick. Choose again."); tmp = IRCNAME; if (!dumb) { tputs_x(tgoto(CM, 0, LI - 1)); tputs_x(CE); resetty(); } printf("New Nick? "); while ((ch = getchar()) != '\n') if (strlen(IRCNAME) < 9) *(tmp++) = ch; *tmp = '\0'; if (!dumb) { raw(); #ifdef CURSES nonl(); noecho(); #endif tputs_x(tgoto(CM, 0, LI - 1)); tputs_x(CE); } sprintf(lineout, "NICK :%s\n", IRCNAME); sendline(); #ifdef AUTOJOIN sprintf(lineout, AUTOJOIN); sendline(); #endif return wasdate = 0; default: break; } column = printf("%s", TOK[1]); return 3; } #define LISTSIZE 49 static char *clist[LISTSIZE] = {"ADMIN", "AWAY", "CLOSE", "CONNECT", "DIE", "DNS", "ERROR", "HASH", "HELP", "INFO", "INVITE", "ISON", "JOIN", "KICK", "KILL", "LINKS", "LIST", "LUSERS", "MODE", "MOTD", "MSG", "NAMES", "NICK", "NOTE", "NOTICE", "OPER", "PART", "PASS", "PING", "PONG", "PRIVMSG", "QUIT", "REHASH", "RESTART", "SERVER", "SQUIT", "STATS", "SUMMON", "TIME", "TOPIC", "TRACE", "USER", "USERHOST", "USERS", "VERSION", "WALLOPS", "WHO", "WHOIS", "WHOWAS"}; #define DO_JOIN 12 #define DO_MSG 20 #define DO_PART 26 #define DO_PRIVMSG 30 #define DO_QUIT 31 static int numargs[LISTSIZE] = { 15, 1, 15, 3, 15, 15, 15, 1, 15, 15, 15, 15, 15, 3, 2, 15, 15, 15, 15, 15, 2, 1, 1, 2, 2, 15, 15, 1, 1, 1, 2, 1, 15, 15, 15, 2, 15, 15, 15, 2, 15, 4, 15, 15, 15, 1, 15, 15, 15 }; static int (*docommand[LISTSIZE]) () = { nop, nop, nop, nop, nop, nop, doerror, nop, nop, nop, doinvite, nop, dojoin, dokick, dokill, nop, nop, nop, domode, nop, nop, nop, donick, nop, donotice, nop, dopart, nop, nop, dopong, doprivmsg, doquit, nop, nop, nop, dosquit, nop, nop, dotime, dotopic, nop, nop, nop, nop, nop, nop, nop, nop, nop }; int wordwrapout(p, count) char *p; int count; { while (p != NULL) { if (tmp = strchr(p, ' ')) *(tmp++) = '\0'; if (strlen(p) < CO - count) count += printf(" %s", p); else count = printf("\n\r %s", p); p = tmp; } return count; } int parsedata() { int i, found = 0; if (serverdata[0] == 'P') { sprintf(lineout, "PONG :%s\n", IRCNAME); return sendline(); } if (!dumb) tputs_x(tgoto(CM, 0, LI - 3)); TOK[i = 0] = serverdata; TOK[i]++; while (TOK[i] != NULL && i < 15) if (*TOK[i] == ':') break; else { if (tmp = strchr(TOK[i], ' ')) { TOK[++i] = &tmp[1]; *tmp = '\0'; } else TOK[++i] = NULL; } if (TOK[i] != NULL && *TOK[i] == ':') TOK[i]++; TOK[++i] = NULL; if (tmp = strchr(TOK[0], '!')) { fromhost = &tmp[1]; *tmp = '\0'; } else fromhost = NULL; if (!dumb) putchar('\n'); column = 0; if (i = atoi(TOK[1])) i = donumeric(i); else { for (i = 0; i < LISTSIZE && !found; i++) found = (strcmp(clist[i], TOK[1]) == 0); if (found) i = (*docommand[i - 1]) (); else i = nop(); } if (i) { if (*TOK[i] == ASCIIHEXCHAR && TOK[i + 1] == NULL) { hexascii(&TOK[i][1]); #ifdef USE_ANSICOLOR printf("\E[1m"); #endif wordwrapout(encoded); #ifdef USE_ANSICOLOR printf("\E[m"); #endif } else { while (TOK[i]) column = wordwrapout(TOK[i++], column); #ifdef USE_ANSICOLOR printf("\E[m"); #endif } } if (dumb) putchar('\n'); if (strncmp(TOK[1], "Closing", 7) == 0) return (reconnect = 0); return 1; } int serverinput() { int count, i; if ((count = read(my_tcp, ib, IB_SIZE)) < 1) return 0; for (i = 0; i < count; i++) if (ib[i] == '\n') { serverdata[cursd] = '\0'; cursd = 0; if (!parsedata()) return 0; } else if (ib[i] != '\r') serverdata[cursd++] = ib[i]; return 1; } void parseinput() { int i, j, outcol, c, found = 0; if (*linein == '\0') return; strcpy(inputbuf, linein); TOK[i = 0] = inputbuf; while (TOK[i] != NULL && i < 5) if (tmp = strchr(TOK[i], ' ')) { TOK[++i] = &tmp[1]; *tmp = '\0'; } else TOK[++i] = NULL; TOK[++i] = NULL; if (!dumb) { tputs_x(tgoto(CM, 0, LI - 3)); putchar('\n'); } if (*TOK[0] == COMMANDCHAR) { TOK[0]++; for (i = 0; i < strlen(TOK[0]) && isalpha(TOK[0][i]); i++) TOK[0][i] = toupper(TOK[0][i]); for (i = 0; i < LISTSIZE && !found; i++) found = (strncmp(clist[i], TOK[0], strlen(TOK[0])) == 0); i--; #ifdef AUTOJOIN if (!found || i == DO_JOIN || i == DO_PART) { #else if (!found) { #endif printf("*** Invalid command"); return; } #ifndef AUTOJOIN if (i == DO_JOIN) if ((newobj = finditem(TOK[1], olist)) != NULL) { wasdate = 0; obj = newobj; printf("*** Now talking in %s", OBJ); return; } else if (!ischan(TOK[1])) { obj = olist = additem(TOK[1], olist); printf("*** Now talking to %s", OBJ); wasdate = 0; return; } if (i == DO_PART && !ischan(TOK[1])) if ((newobj = finditem(TOK[1], olist)) != NULL) { wasdate = 0; olist = delitem(TOK[1], olist); if (obj == NULL) obj = olist; printf("*** No longer talking to %s", TOK[1]); if (obj != NULL) printf(", now %s", OBJ); wasdate = 0; return; } #endif if (i == DO_MSG) i = DO_PRIVMSG; if (i == DO_PRIVMSG && (TOK[1] == NULL || TOK[2] == NULL)) { printf("*** Unable to parse message"); return; } strcpy(lineout, clist[i]); if (i == DO_QUIT) reconnect = 0; if (i == DO_QUIT && TOK[1] == NULL) strcat(lineout, " :" RELEASE); j = 0; if (i != DO_PRIVMSG || TOK[1] == NULL) outcol = printf("= %s", lineout); else if (ischan(TOK[1])) outcol = printf(">%s>", TOK[1]); else { #ifdef USE_ANSICOLOR printf("\E[1m"); #endif outcol = printf("-> *%s*", TOK[1]); } while (TOK[++j]) { c = strlen(lineout); sprintf(&lineout[c], "%s%s", ((j == numargs[i] && TOK[j + 1] != NULL) ? " :" : " "), TOK[j]); if (j > 1 || i != DO_PRIVMSG) outcol = wordwrapout(TOK[j], outcol); #ifdef USE_ANSICOLOR printf("\E[m"); #endif } strcat(lineout, "\n"); } else { if (obj == NULL) { printf("*** Nowhere to send"); return; } if (*TOK[0] == ASCIIHEXCHAR) { asciihex(&linein[1]); strcpy(&linein[1], encoded); } else if (*TOK[0] == HEXASCIICHAR) { /* display decoded line */ hexascii(&linein[1]); outcol = wordwrapout(encoded); return; } sprintf(lineout, "PRIVMSG %s :%s\n", OBJ, linein); outcol = printf("> %s", TOK[j = 0]); while (TOK[++j]) outcol = wordwrapout(TOK[j], outcol); } sendline(); idletimer = time(NULL); } void mypchar(c) char c; { if (c >= ' ') putchar(c); else { tputs_x(SO); putchar(c + 64); tputs_x(SE); } } void ppart() { int i, x = (curx / CO) * CO; tputs_x(tgoto(CM, 0, LI - 1)); for (i = x; i < x + CO && i < curli; i++) mypchar(linein[i]); tputs_x(CE); tputs_x(tgoto(CM, curx % CO, LI - 1)); } void histupdate() { linein = hist[hline]; curx = curli = strlen(linein); ppart(); } void userinput() { int i, z; if (dumb) { fgets(linein, 500, stdin); tmp = strchr(linein, '\n'); if (tmp != NULL) *tmp = '\0'; parseinput(); putchar('\n'); } else { read(my_tty, &ch, 1); if (ch == '\177') ch = '\10'; switch (ch) { case '\3': raise_sig(SIGINT); break; case '\0': if (curx >= CO) { curx = 0; ppart(); } else tputs_x(tgoto(CM, curx = 0, LI - 1)); break; case '\4': case '\10': if (curx) { if (ch == '\4' && curx < curli) curx++; if (curli == curx) linein[(--curx)] = '\0'; else for (i = (--curx); i < curli; i++) linein[i] = linein[i + 1]; curli--; if (DC != NULL && curx % CO != CO - 1) { tputs_x(tgoto(CM, curx % CO, LI - 1)); tputs_x(DC); } else ppart(); } break; case '\2': if (curx > 0) curx--; if (curx % CO == CO - 1) ppart(); else tputs_x(tgoto(CM, curx % CO, LI - 1)); break; case '\5': curx = curli; case '\14': ppart(); break; case '\6': if (curx < curli) curx++; tputs_x(tgoto(CM, curx % CO, LI - 1)); break; case '\16': if ((++hline) >= HISTLEN) hline = 0; histupdate(); break; case '\20': if ((--hline) < 0) hline = HISTLEN - 1; histupdate(); break; case '\r': case '\n': if (!curli) return; tputs_x(tgoto(CM, 0, LI - 1)); tputs_x(CE); parseinput(); if ((++hline) >= HISTLEN) hline = 0; curx = curli = 0; linein = hist[hline]; break; case '\27': if (obj == NULL) break; obj = obj->next; if (obj == NULL) obj = olist; wasdate = 0; break; case '\32': raise_sig(SIGTSTP); break; default: if (curli < 499) { if (curli == curx) { linein[++curli] = '\0'; linein[curx++] = ch; mypchar(ch); tputs_x(CE); } else { for (i = (++curli); i >= curx; i--) linein[i + 1] = linein[i]; linein[curx] = ch; for (i = (curx % CO); i < CO && (z = (curx / CO) * CO + i) < curli; i++) mypchar(linein[z]); tputs_x(CE); curx++; } } break; } } } void cleanup(sig) int sig; { if (!dumb) { resetty(); tputs_x(tgoto(CS, -1, -1)); tputs_x(tgoto(CM, 0, LI - 1)); fflush(stdout); } #ifndef __hpux psignal(sig, "tinyirc"); #endif if (sig != SIGTSTP) exit(128 + sig); raise_sig(SIGSTOP); } void stopin() { signal(SIGTTIN, stopin); noinput = 1; } void redraw() { signal(SIGCONT, redraw); signal(SIGTSTP, cleanup); if (!dumb) { if (noinput) { raw(); #ifdef CURSES nonl(); noecho(); #endif } wasdate = 0; tputs_x(tgoto(CS, LI - 3, 0)); updatestatus(); tputs_x(tgoto(CM, LI - 3, 0)); } noinput = 0; } int makeconnect(hostname) char *hostname; { struct sockaddr_in sa; struct hostent *hp; int s, t; if ((hp = gethostbyname(hostname)) == NULL) return -1; for (t = 0, s = -1; s < 0 && hp->h_addr_list[t] != NULL; t++) { bzero(&sa, sizeof(sa)); bcopy(hp->h_addr_list[t], (char *) &sa.sin_addr, hp->h_length); sa.sin_family = hp->h_addrtype; sa.sin_port = htons((unsigned short) IRCPORT); s = socket(hp->h_addrtype, SOCK_STREAM, 0); if (s > 0) if (connect(s, (struct sockaddr *) &sa, sizeof(sa)) < 0) { close(s); s = -1; } else { fcntl(s, F_SETFL, O_NDELAY); my_tcp = s; sprintf(lineout, "USER %s * * :%s\n", IRCLOGIN, IRCGECOS); sendline(); sprintf(lineout, "NICK :%s\n", IRCNAME); sendline(); #ifdef AUTOJOIN sprintf(lineout, AUTOJOIN); sendline(); #endif for (obj = olist; obj != NULL; obj = olist->next) { sprintf(lineout, "JOIN %s\n", OBJ); sendline(); } /* error checking will be done later */ } } return s; } main(argc, argv) int argc; char **argv; { struct utmp ut, *utmp; char hostname[64]; int i = 0; printf("%s Copyright (C) 1991-1996 Nathan Laredo\n\ This is free software with ABSOLUTELY NO WARRANTY.\n\ For details please see the file COPYING.\n", RELEASE); if (!(tmp = (char *) getenv("IRCSERVER"))) strcpy(hostname, DEFAULTSERVER); else { while (*tmp && *tmp != ':') hostname[i++] = *(tmp++); hostname[i] = '\0'; if (*tmp == ':') IRCPORT = (unsigned short) atoi(++tmp); } if (argc > 1) { for (i = 1; i < argc; i++) if (argv[i][0] == '-') { if (argv[i][1] == 'd') dumb = 1; else { fprintf(stderr, "usage: %s %s\n", argv[0], "[nick] [server] [port] [-dumb]"); exit(1); } } else if (strchr(argv[i], '.')) strcpy(hostname, argv[i]); else if (atoi(argv[i]) > 255) IRCPORT = atoi(argv[i]); else strncpy(IRCNAME, argv[i], sizeof(IRCNAME)); } if ((my_tty = open("/dev/tty", O_RDWR, 0)) == -1) my_tty = fileno(stdin); IRCGECOS[i = 63] = 0; if (!getpeername(my_tty, IRCGECOS, &i)) { /* inetd */ strcpy(IRCNAME, IRCGECOS); strcpy(IRCLOGIN, "fromident"); setenv("TERM", "vt102", 1); } else { userinfo = getpwuid(getuid()); tmp = (char *) getenv("IRCNICK"); if (tmp == NULL) strncpy(IRCNAME, userinfo->pw_name, sizeof(IRCNAME)); else strncpy(IRCNAME, tmp, sizeof(IRCNAME)); strcpy(IRCLOGIN, userinfo->pw_name); setutent(); strcpy(ut.ut_line, strrchr(ttyname(0), '/') + 1); if ((utmp = getutline(&ut)) == NULL || !(utmp->ut_addr) || *((char *) utmp->ut_host) == ':' /* X connection */ ) tmp = userinfo->pw_gecos; else { struct hostent *h; struct in_addr a; a.s_addr = utmp->ut_addr; if (!(h = gethostbyaddr((char *) &a.s_addr, sizeof(a.s_addr), AF_INET))) tmp = (char *) inet_ntoa(a); else tmp = (char *) h->h_name; } strcpy(IRCGECOS, tmp); endutent(); } fprintf(stderr, "*** User is %s\n", IRCGECOS); printf("*** trying port %d of %s\n\n", IRCPORT, hostname); if (makeconnect(hostname) < 0) { fprintf(stderr, "*** %s refused connection, aborting\n", hostname); exit(0); } idletimer = time(NULL); ptr = termcap; if ((term = (char *) getenv("TERM")) == NULL) { fprintf(stderr, "tinyirc: TERM not set\n"); exit(1); } if (tgetent(bp, term) < 1) { fprintf(stderr, "tinyirc: no termcap entry for %s\n", term); exit(1); } if ((CO = tgetnum("co") - 2) < 20) CO = 78; if ((LI = tgetnum("li")) == -1) LI = 24; if (!dumb) { #define tgs(x) ((char *) tgetstr(x, &ptr)) if ((CM = tgs("cm")) == NULL) CM = tgs("CM"); if ((SO = tgs("so")) == NULL) SO = ""; if ((SE = tgs("se")) == NULL) SE = ""; if (!CM || !(CS = tgs("cs")) || !(CE = tgs("ce"))) { printf("tinyirc: sorry, no termcap cm,cs,ce: dumb mode set\n"); dumb = 1; } if (!dumb) { DC = tgs("dc"); savetty(); raw(); #ifdef CURSES nonl(); noecho(); #endif } } redraw(); signal(SIGINT, cleanup); signal(SIGHUP, cleanup); signal(SIGTERM, cleanup); signal(SIGSEGV, cleanup); signal(SIGTTIN, stopin); for (i = 0; i < HISTLEN; i++) hist[i] = (char *) calloc(512, sizeof(char)); linein = hist[hline = 0]; while (sok) { FD_ZERO(&readfs); FD_SET(my_tcp, &readfs); if (!noinput) FD_SET(my_tty, &readfs); if (!dumb) { timeout.tv_sec = 61; timeout.tv_usec = 0; } if (select(FD_SETSIZE, &readfs, NULL, NULL, (dumb ? NULL : &timeout))) { if (FD_ISSET(my_tty, &readfs)) userinput(); if (FD_ISSET(my_tcp, &readfs)) sok = serverinput(); if (!wasdate) updatestatus(); } else updatestatus(); if (!sok && reconnect) { close(my_tcp); /* dead socket */ printf("*** trying port %d of %s\n\n", IRCPORT, hostname); if (makeconnect(hostname) < 0) { fprintf(stderr, "*** %s refused connection\n", hostname); exit(0); } sok++; } if (!dumb) tputs_x(tgoto(CM, curx % CO, LI - 1)); fflush(stdout); } if (!dumb) { tputs_x(tgoto(CS, -1, -1)); tputs_x(tgoto(CM, 0, LI - 1)); #ifdef CURSES echo(); nl(); #endif resetty(); } exit(0); } /* EOF */ tinyirc-1.1.dfsg.1/server-numerics0000640000175000001440000001776406421501506016533 0ustar decklinusers/************************************************************************ * IRC - Internet Relay Chat, include/numeric.h * Copyright (C) 1990 Jarkko Oikarinen * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 1, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* * -- Avalon -- 1 Sep 1992 * * Added RPL_TRACELOG, RPL_STATSOLINE */ /* * -- Avalon -- 13 Aug 1992 * * Added ERR_BADCHANNELKEY, ERR_KEYSET */ /* * -- Avalon -- 10 Aug 1992 * * Added RPL_SUMMONING */ /* * -- Avalon -- 5 Jul 1992 * * Added ERR_NICKCOLLISION */ /* * -- Avalon -- 14 Jul 1992 * * Added RPL_UNAWAY, RPL_NOWAWAY, ERR_NOORIGIN, ERR_FILEERROR, ERR_NOLOGIN, * ERR_SUMMONDISABLED, ERR_USERSDISABLED, RPL_USERSSTART, RPL_USERS, * RPL_ENDOFUSERS, RPL_NOUSERS */ /* * -- Avalon -- 12 Jul 1992 * * Added RPL_CLOSING RPL_CLOSEEND */ /* * -- Avalon -- 10-11 Jul 1992 * * Added RPL_MOTD, RPL_MOTDSTART, RPL_ENDOFMOTD, ERR_NOMOTD, * RPL_INFO, RPL_INFOSTART, RPL_ENDOFINFO, ERR_CANTKILLSERVER, * RPL_LUSERCLIENT, RPL_LUSEROP, RPL_LUSERUNKNOWN, RPL_LUSERCHAN, RPL_LUSERME, * RPL_STATSUPTIME, RPL_ADMINLOC1, RPL_ADMINLOC2, RPL_ADMINME, * RPL_ADMINEMAIL, ERR_NOADMININFO */ /* * -- Avalon -- 28 Jun 1992 * * Added ERR_BADCHANMASK and RPL_ENDOFWHOWAS */ /* * -- Avalon -- 13 May 1992 * * Added RPL_STATSLLINE */ /* * -- Avalon -- 12 Jan 1992 * * Added RPL_TRACELINK */ /* * -- Wumpus -- 30 Nov 1991 * * It's very important that you never change what a numeric means -- * you can delete old ones (maybe) and add new ones, but never ever * take a number and make it suddenly mean something else, or change * an old number just for the hell of it. */ /* * -- avalon -- 19 Nov 1991 * Added ERR_USERSDONTMATCH * * -- avalon -- 06 Nov 1991 * Added RPL_BANLIST, RPL_BANLISTEND, ERR_BANNEDFROMCHAN * * -- avalon -- 15 Oct 1991 * Added RPL_TRACEs (201-209) * Added RPL_STATSs (211-219) */ /* -- Jto -- 16 Jun 1990 * A couple of new numerics added... */ /* -- Jto -- 03 Jun 1990 * Added ERR_YOUWILLBEBANNED and Check defines (sigh, had to put 'em here..) * Added ERR_UNKNOWNMODE... * Added ERR_CANNOTSENDTOCHAN... */ /* * Reserve numerics 000-099 for server-client connections where the client * is local to the server. If any server is passed a numeric in this range * from another server then it is remapped to 100-199. -avalon */ #define RPL_WELCOME 001 #define RPL_YOURHOST 002 #define RPL_CREATED 003 #define RPL_MYINFO 004 /* * Errors are in the range from 400-599 currently and are grouped by what * commands they come from. */ #define ERR_NOSUCHNICK 401 #define ERR_NOSUCHSERVER 402 #define ERR_NOSUCHCHANNEL 403 #define ERR_CANNOTSENDTOCHAN 404 #define ERR_TOOMANYCHANNELS 405 #define ERR_WASNOSUCHNICK 406 #define ERR_TOOMANYTARGETS 407 #define ERR_NOSUCHSERVICE 408 #define ERR_NOORIGIN 409 #define ERR_NORECIPIENT 411 #define ERR_NOTEXTTOSEND 412 #define ERR_NOTOPLEVEL 413 #define ERR_WILDTOPLEVEL 414 #define ERR_UNKNOWNCOMMAND 421 #define ERR_NOMOTD 422 #define ERR_NOADMININFO 423 #define ERR_FILEERROR 424 #define ERR_NONICKNAMEGIVEN 431 #define ERR_ERRONEUSNICKNAME 432 #define ERR_NICKNAMEINUSE 433 #define ERR_SERVICENAMEINUSE 434 #define ERR_SERVICECONFUSED 435 #define ERR_NICKCOLLISION 436 #define ERR_USERNOTINCHANNEL 441 #define ERR_NOTONCHANNEL 442 #define ERR_USERONCHANNEL 443 #define ERR_NOLOGIN 444 #define ERR_SUMMONDISABLED 445 #define ERR_USERSDISABLED 446 #define ERR_NOTREGISTERED 451 #define ERR_NEEDMOREPARAMS 461 #define ERR_ALREADYREGISTRED 462 #define ERR_NOPERMFORHOST 463 #define ERR_PASSWDMISMATCH 464 #define ERR_YOUREBANNEDCREEP 465 #define ERR_YOUWILLBEBANNED 466 #define ERR_KEYSET 467 #define ERR_CHANNELISFULL 471 #define ERR_UNKNOWNMODE 472 #define ERR_INVITEONLYCHAN 473 #define ERR_BANNEDFROMCHAN 474 #define ERR_BADCHANNELKEY 475 #define ERR_BADCHANMASK 476 #define ERR_NOPRIVILEGES 481 #define ERR_CHANOPRIVSNEEDED 482 #define ERR_CANTKILLSERVER 483 #define ERR_NOOPERHOST 491 #define ERR_NOSERVICEHOST 492 #define ERR_UMODEUNKNOWNFLAG 501 #define ERR_USERSDONTMATCH 502 /* * Numberic replies from server commands. * These are currently in the range 200-399. */ #define RPL_NONE 300 #define RPL_AWAY 301 #define RPL_USERHOST 302 #define RPL_ISON 303 #define RPL_TEXT 304 #define RPL_UNAWAY 305 #define RPL_NOWAWAY 306 #define RPL_WHOISUSER 311 #define RPL_WHOISSERVER 312 #define RPL_WHOISOPERATOR 313 #define RPL_WHOWASUSER 314 /* rpl_endofwho below (315) */ #define RPL_ENDOFWHOWAS 369 #define RPL_WHOISCHANOP 316 /* redundant and not needed but reserved */ #define RPL_WHOISIDLE 317 #define RPL_ENDOFWHOIS 318 #define RPL_WHOISCHANNELS 319 #define RPL_LISTSTART 321 #define RPL_LIST 322 #define RPL_LISTEND 323 #define RPL_CHANNELMODEIS 324 #define RPL_NOTOPIC 331 #define RPL_TOPIC 332 #define RPL_INVITING 341 #define RPL_SUMMONING 342 #define RPL_VERSION 351 #define RPL_WHOREPLY 352 #define RPL_ENDOFWHO 315 #define RPL_NAMREPLY 353 #define RPL_ENDOFNAMES 366 #define RPL_KILLDONE 361 #define RPL_CLOSING 362 #define RPL_CLOSEEND 363 #define RPL_LINKS 364 #define RPL_ENDOFLINKS 365 /* rpl_endofnames above (366) */ #define RPL_BANLIST 367 #define RPL_ENDOFBANLIST 368 /* rpl_endofwhowas above (369) */ #define RPL_INFO 371 #define RPL_MOTD 372 #define RPL_INFOSTART 373 #define RPL_ENDOFINFO 374 #define RPL_MOTDSTART 375 #define RPL_ENDOFMOTD 376 #define RPL_YOUREOPER 381 #define RPL_REHASHING 382 #define RPL_YOURESERVICE 383 #define RPL_MYPORTIS 384 #define RPL_NOTOPERANYMORE 385 #define RPL_TIME 391 #define RPL_USERSSTART 392 #define RPL_USERS 393 #define RPL_ENDOFUSERS 394 #define RPL_NOUSERS 395 #define RPL_TRACELINK 200 #define RPL_TRACECONNECTING 201 #define RPL_TRACEHANDSHAKE 202 #define RPL_TRACEUNKNOWN 203 #define RPL_TRACEOPERATOR 204 #define RPL_TRACEUSER 205 #define RPL_TRACESERVER 206 #define RPL_TRACESERVICE 207 #define RPL_TRACENEWTYPE 208 #define RPL_TRACECLASS 209 #define RPL_STATSLINKINFO 211 #define RPL_STATSCOMMANDS 212 #define RPL_STATSCLINE 213 #define RPL_STATSNLINE 214 #define RPL_STATSILINE 215 #define RPL_STATSKLINE 216 #define RPL_STATSQLINE 217 #define RPL_STATSYLINE 218 #define RPL_ENDOFSTATS 219 #define RPL_UMODEIS 221 #define RPL_SERVICEINFO 231 #define RPL_ENDOFSERVICES 232 #define RPL_SERVICE 233 #define RPL_SERVLIST 234 #define RPL_SERVLISTEND 235 #define RPL_STATSLLINE 241 #define RPL_STATSUPTIME 242 #define RPL_STATSOLINE 243 #define RPL_STATSHLINE 244 #define RPL_STATSSLINE 245 #define RPL_LUSERCLIENT 251 #define RPL_LUSEROP 252 #define RPL_LUSERUNKNOWN 253 #define RPL_LUSERCHANNELS 254 #define RPL_LUSERME 255 #define RPL_ADMINME 256 #define RPL_ADMINLOC1 257 #define RPL_ADMINLOC2 258 #define RPL_ADMINEMAIL 259 #define RPL_TRACELOG 261 tinyirc-1.1.dfsg.1/DCC.doc0000640000175000001440000001277306421501506014532 0ustar decklinusersFrom: jnelson@iastate.edu (Jeremy Nelson) Newsgroups: alt.irc.ircii Subject: Re: Specs for DCC Date: 2 Apr 1994 22:50:53 GMT These are the *original* specifications for dcc. DCC is inherently a feature of ircII, and any implementation had best be able to deal with DCC as currently implemented in ircII at this time. This is over two years old, so it is somewhat out of date, but the mechanism for dcc is still pretty much the same, but the implementation has evolved over time. ------ snip here ----- A description of the DCC protocol ================================= By Troy Rollo (troy@plod.cbme.unsw.oz.au) (In response for requests for the protocol to be documented). The first comment I should make is that the DCC protocol was never designed to be portable to clients other than IRCII. As such I take no responsibility for it being difficult to implement for other clients. Why DCC? ======== DCC allows the user to overcome some limitations of the IRC server network and to have the ultimate in secure chat connections while still in an IRC oriented protocol. DCC uses direct TCP connections between the clients taking part to carry data. There is no flood control, so packets can be sent at full speed, and there is no dependance on server links (or load imposed on them). In addition, since only the initial handshake for DCC conections is passed through the IRC network, it is impossible for Operators with cracked servers to spy on DCC messages. How? ==== The initial socket for a DCC connection is created by the side that initiates (Offers) the connection. This socket should be a TCP socket bound to INADDR_ANY, listening for connections. The Initiating client, on creating the socket, should send its details to the target client using the CTCP command DCC. This command takes the form: DCC type argument address port type - The connection type argument - The connectin type dependant argument address - the host address of the initiator as an integer. port - the port or the socket on which the initiator expects to receive the connection. The address and port should be sent as ascii representations of the decimal integer formed by converting the values to host byte order and treating them as an unsigned long and unsigned short respectively. The following DCC connection types are known to IRCII: Type Purpose Argument CHAT To carry a secure conversation the string "chat" SEND To send a file to the recipient the file name In addition, the following are included in the IRCII DCC command, although they do not transmit a DCC request via IRC: TALK Establishes a TALK connection Implementation ============== The CHAT and SEND connection types should not be accepted automatically as this would create the potential for terrorism. Instead, they should notify the user that an offer has been made, and allow the user to accept it. The recipient should have the opportunity to rename a file send with the DCC SEND command prior to retrieving it. The following are the steps which should occur in the clients: Initiator: DCC command issued. Create a socket, bind it to INADDR_ANY, port 0, and make it passive (a listening socket). Send the recipient a DCC request via CTCP supplying the address and port of the socket. (This is ideally taken from the address of the local side of the socket which is connected to a server. This is presumably the interface on the host which is closest to the rest of the net, and results in one less routing hop in the case of gateway nodes). Continue normally until a connection is received. On a connection: Accept the connection. Close the original passive socket. Conduct transaction on the new socket. Acceptor: CTCP DCC request received. Record information on the DCC request and notify the user. At this point, the USER should be able to abort (close) the request, or accept it. The request should be accepted with a command specifying the sender, type, and argument, or a subset of these where no ambiguity exists. If accepted, create a TCP socket. Connect the new socket to the address and port supplied. Conduct the transaction over the socket. Type specific details. ====================== CHAT Data sent across a CHAT connection should be sent line-by-line without any prefixes or commands. A CHAT connection ends when one party issues the DCC CLOSE command to their clients, which causes the socket to be closed and the information on the connection to be discarded. FILE Data is sent in packets, rather than dumped in a stream manner. This allows the DCC SEND connection to survive where an FTP connection might fail. The size of the packets is up to the client, and may be set by the user. Smaller packets result in a higher probability of survival over bad links. The recipient should acknowledge each packet by transmitting the total number of bytes received as an unsigned, 4 byte integer in network byte order. The sender should not continue to transmit until the recipient has acknowledged all data already transmitted. Additionally, the sender should not close the connection until the last byte has been acknowledged by the recipient. Note that it is not possible for the recipient to tell if the entire file has been received - only the sender has that information, although IRCII does not report it. Users generally verify the transfer by checking file sizes. Note also that no provision is made for text translation. The block size used by IRCII is BIG_BUFFER_SIZE (1024). This should probably be reviewed and reduced. tinyirc-1.1.dfsg.1/COPYING0000640000175000001440000004307606421501506014505 0ustar decklinusers GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 675 Mass Ave, Cambridge, MA 02139, USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19yy name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License.