Internet Relay Chat (IRC) Part 6/6
david bleckmann
bleckmd at jacobs.cs.orst.edu
Tue Jun 20 13:36:38 AEST 1989
---- Cut Here and unpack ----
#!/bin/sh
# this is part 6 of a multipart archive
# do not concatenate these parts, unpack them in order with /bin/sh
# file s_msg.c continued
#
CurArch=6
if test ! -r s2_seq_.tmp
then echo "Please unpack part 1 first!"
exit 1; fi
( read Scheck
if test "$Scheck" != $CurArch
then echo "Please unpack part $Scheck next!"
exit 1;
else exit 0; fi
) < s2_seq_.tmp || exit 1
echo "x - Continuing file s_msg.c"
sed 's/^X//' << 'SHAR_EOF' >> s_msg.c
Xchar *sender, *para1, *para2, *para3, *para4, *para5, *para6;
X{
X m_error(cptr, sptr, sender, "Namreply", para1, para2, para3);
X}
X
Xm_linreply(cptr, sptr, sender, para1, para2, para3, para4, para5, para6)
Xstruct Client *cptr, *sptr;
Xchar *sender, *para1, *para2, *para3, *para4, *para5, *para6;
X{
X m_error(cptr, sptr, sender, "Linreply", para1, para2, para3);
X}
X
Xm_admin(cptr, sptr, sender, para1)
Xstruct Client *cptr, *sptr;
Xchar *sender, *para1;
X{
X struct Confitem *aconf;
X struct Client *acptr;
X if (para1 && *para1 && strcmp(para1, myhostname) &&
X (acptr = find_server(para1, (struct Client *) 0))) {
X sendto_one(acptr, ":%s ADMIN :%s", sptr->nickname, para1);
X return(0);
X }
X if (aconf = find_admin()) {
X sendto_one(sptr, "PRIVMSG %s :### Administrative info about %s",
X sptr->nickname, myhostname);
X sendto_one(sptr, "PRIVMSG %s :### %s", sptr->nickname, aconf->host);
X sendto_one(sptr, "PRIVMSG %s :### %s", sptr->nickname, aconf->passwd);
X sendto_one(sptr, "PRIVMSG %s :### %s", sptr->nickname, aconf->name);
X } else
X sendto_one(sptr,
X "PRIVMSG %s :### No administrative info available about server %s",
X sptr->nickname, myhostname);
X return(0);
X}
X
Xm_trace(cptr, sptr, sender, para1)
Xstruct Client *cptr, *sptr;
Xchar *sender, *para1;
X{
X struct Client *acptr;
X if (sptr->status != STAT_OPER) {
X sendto_one(sptr,
X "PRIVMSG %s :*** Error: %s", sptr->nickname,
X "No mere mortals may trace the nets of the universe");
X return(-1);
X }
X if (para1 && *para1 && strcmp(para1, myhostname) &&
X (acptr = find_server(para1, (struct Client *) 0))) {
X sendto_one(acptr, ":%s TRACE :%s", sptr->nickname, para1);
X sendto_one(sptr, "PRIVMSG %s :*** Link %s ==> %s",
X sptr->nickname, myhostname, para1);
X return(0);
X }
X acptr = client;
X while (acptr) {
X if (acptr->status == STAT_SERVER && acptr->fd >= 0)
X sendto_one(sptr, "PRIVMSG %s :*** Connection %s ==> %s",
X sptr->nickname, myhostname, acptr->host);
X acptr = acptr->next;
X }
X return(0);
X}
X
SHAR_EOF
echo "File s_msg.c is complete"
chmod 0600 s_msg.c || echo "restore of s_msg.c fails"
set `wc -c s_msg.c`;Sum=$1
if test "$Sum" != "36125"
then echo original size 36125, current size $Sum;fi
echo "x - extracting s_sysv.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > s_sysv.c &&
X/*************************************************************************
X ** s_sysv.c Beta v2.0 (22 Aug 1988)
X **
X ** This file is part of Internet Relay Chat v2.0
X **
X ** Author: Jarkko Oikarinen
X ** Internet: jto at tolsun.oulu.fi
X ** UUCP: ...!mcvax!tut!oulu!jto
X ** BITNET: toljto at finou
X **
X ** Copyright (c) 1988 University of Oulu, Computing Center
X **
X ** All rights reserved.
X **
X ** See file COPYRIGHT in this package for full copyright.
X **
X *************************************************************************/
X
Xchar s_sysv_id[]="s_sysv.c v2.0 (c) 1988 University of Oulu, Computing Center";
X
X#include <sys/time.h>
X#include <sys/types.h>
X#include <sys/file.h>
X#include <sys/ioctl.h>
X#include <sys/types.h>
X#include <sys/ipc.h>
X#include <sys/msg.h>
X#include <stdio.h>
X#include <signal.h>
X#include <fcntl.h>
X#include <utmp.h>
X#include "struct.h"
X
Xextern struct Client me;
Xextern struct Client *client;
X
Xdoalrm()
X{
X return(0);
X}
X
Xint
Xopen_port(portnum)
Xint portnum;
X{
X int key, length;
X if ((me.fd = msgget((key_t)portnum, IPC_CREAT | 0622)) == -1)
X perror("Getting SysV messageport");
X return(me.fd);
X}
X
Xinit_sys()
X{
X int fd;
X setlinebuf(stdout);
X setlinebuf(stderr);
X#ifdef NOTTY
X close (0); close(1); close(2);
X if (fork()) exit(0);
X if (setpgrp(0,0) == -1)
X perror("setpgrp");
X#endif
X}
X
Xread_msg(buffer, buflen, from)
Xchar *buffer;
Xint buflen;
Xstruct Client **from;
X{
X static char buf[BUFSIZE], *ptr;
X static struct msgbuf *ipcbuf = (struct msgbuf *) buf;
X int length;
X struct Client *cptr;
X signal(SIGALRM, doalrm);
X length = msgrcv(me.fd, ipcbuf, sizeof (buf), 0, 0);
X if (length < 0)
X return(-1);
X else {
X cptr = client;
X while (cptr) {
X if (cptr->fd == ipcbuf->mtype)
X break;
X cptr = cptr->next;
X }
X if (cptr == NULL) {
X cptr = make_client();
X strcpy(cptr->server, myhostname);
X cptr->fd = ipcbuf->mtype;
X }
X *from = cptr;
X length -= sizeof(ipcbuf->mtype);
X buflen = length;
X ptr = ipcbuf->mtext;
X for (; length; length--, ptr++, buffer++)
X *buffer = *ptr;
X return(length);
X }
X}
X
X
Xconnect_server(host, port)
Xchar *host;
Xint port;
X{
X/* struct sockaddr_in server;
X struct hostent *hp;
X struct Client *acptr;
X struct Client *cptr = make_client();
X int res;
X cptr->fd = socket(AF_INET, SOCK_STREAM, 0);
X if (cptr->fd < 0) {
X perror("opening stream socket to server");
X free(cptr);
X return(-1);
X }
X server.sin_family = AF_INET;
X hp = gethostbyname(host);
X if (hp == 0) {
X close(cptr->fd);
X free(cptr);
X debug(DEBUG_FATAL, "%s: unknown host", host);
X return(-1);
X }
X bcopy(hp->h_addr, &server.sin_addr, hp->h_length);
X server.sin_port = htons(port);
X
X if (connect(cptr->fd, (struct sockaddr *) &server, sizeof(server)) < 0) {
X close(cptr->fd);
X free(cptr);
X perror("connect");
X return(-1);
X }
X strncpy(cptr->fromhost, host, HOSTLEN);
X cptr->fromhost[HOSTLEN] = '\0';
X strncpy(cptr->host, host, HOSTLEN);
X cptr->host[HOSTLEN] = '\0';
X cptr->status = STAT_UNKNOWN;
X strncpy(me.server, host, HOSTLEN);
X me.server[HOSTLEN] = '\0';
X sendto_one(cptr, "SERVER %s",myhostname);
X cptr->next = client;
X client = cptr;
X res = fcntl(cptr->fd, F_GETFL, 0);
X fcntl(cptr->fd, F_SETFL, res | O_NDELAY); */
X}
X
Xint utmp_open()
X{
X int fd;
X return (open(UTMP,O_RDONLY));
X}
X
Xint utmp_read(fd, name, line, host)
Xint fd;
Xchar *name, *line, *host;
X{
X struct utmp ut;
X while (read(fd, &ut, sizeof (struct utmp)) == sizeof (struct utmp)) {
X strncpy(name,ut.ut_name,8); name[8] = '\0';
X strncpy(line,ut.ut_line,8); line[8] = '\0';
X strncpy(host,(ut.ut_host[0]) ? (ut.ut_host) : myhostname, 16);
X if (ut.ut_name[0])
X return(0);
X }
X return(-1);
X}
X
Xint utmp_close(fd)
Xint fd;
X{
X return(close(fd));
X}
X
Xsummon(who, namebuf, linebuf)
Xstruct Client *who;
Xchar *namebuf, *linebuf;
X{
X int fd;
X char line[120], *wrerr = "PRIVMSG %s :Write error. Couldn't summon.";
X if (strlen(linebuf) > 8) {
X sendto_one(who,"PRIVMSG %s :Serious fault in SUMMON.");
X sendto_one(who,"PRIVMSG %s :linebuf too long. Inform Administrator");
X return(-1);
X }
X /* Following line added to prevent cracking to e.g. /dev/kmem if */
X /* UTMP is for some silly reason writable to everyone... */
X if ((linebuf[0] != 't' || linebuf[1] != 't' || linebuf[2] != 'y') &&
X (linebuf[0] != 'c' || linebuf[1] != 'o' || linebuf[2] != 'n')) {
X sendto_one(who,"PRIVMSG %s :Looks like mere mortal souls are trying to");
X sendto_one(who,"PRIVMSG %s :enter the twilight zone... ");
X debug(0, "%s (%s@%s, nick %s, %s)",
X "FATAL: major security hack. Notify Administrator !",
X who->username, who->host, who->nickname, who->realname);
X return(-1);
X }
X strcpy(line,"/dev/");
X strcat(line,linebuf);
X if ((fd = open(line, O_WRONLY)) == -1) {
X sendto_one(who,"PRIVMSG %s :%s seems to have disabled summoning...");
X return(-1);
X }
X strcpy(line,"\007\007ircd: *You* are being summoned to irc by\n");
X if (write(fd, line, strlen(line)) != strlen(line)) {
X sendto_one(who,wrerr,who->nickname);
X return(-1);
X }
X sprintf(line, "ircd: Channel %d: %s@%s (%s) %s\n", who->channel,
X who->username, who->host, who->nickname, who->realname);
X if (write(fd, line, strlen(line)) != strlen(line)) {
X sendto_one(who,wrerr,who->nickname);
X return(-1);
X }
X strcpy(line,"ircd: Respond with irc\n");
X if (write(fd, line, strlen(line)) != strlen(line)) {
X sendto_one(who,wrerr,who->nickname);
X return(-1);
X }
X sendto_one(who, "PRIVMSG %s :%s: Summoning user %s to irc",
X who->nickname, myhostname, namebuf);
X return(0);
X}
X
SHAR_EOF
chmod 0600 s_sysv.c || echo "restore of s_sysv.c fails"
set `wc -c s_sysv.c`;Sum=$1
if test "$Sum" != "5649"
then echo original size 5649, current size $Sum;fi
echo "x - extracting screen.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > screen.c &&
X/*************************************************************************
X ** screen.c Beta v2.0 (22 Aug 1988)
X **
X ** This file is part of Internet Relay Chat v2.0
X **
X ** Author: Jarkko Oikarinen
X ** Internet: jto at tolsun.oulu.fi
X ** UUCP: ...!mcvax!tut!oulu!jto
X ** BITNET: toljto at finou
X **
X ** Copyright (c) 1988 University of Oulu, Computing Center
X **
X ** All rights reserved.
X **
X ** See file COPYRIGHT in this package for full copyright.
X **
X *************************************************************************/
X
Xchar screen_id[] = "screen.c v2.0 (c) 1988 University of Oulu, Computing Center";
X
X#include <stdio.h>
X#include <curses.h>
X
X#ifdef TRUE
X#undef TRUE
X#endif
X#define FALSE (0)
X#define TRUE (!FALSE)
X#ifdef BUFSIZ
X#undef BUFSIZ
X#endif
X#define BUFSIZ 240
X
X#define FROM_START 0
X#define FROM_END 1
X#define RELATIVE 2
X
X#define HIST_SIZ 1000
X
Xstatic char last_line[BUFSIZ+1];
Xstatic char yank_buffer[BUFSIZ+1];
Xstatic char history[HIST_SIZ][BUFSIZ+1];
Xstatic int position=0;
Xstatic int pos_in_history=0;
Xstatic insert=0;
X
Xget_char(pos)
Xint pos;
X{
X if (pos>=BUFSIZ || pos<0)
X return 0;
X return (int)last_line[pos];
X}
X
Xset_char(pos, ch)
Xint pos, ch;
X{
X if (pos<0 || pos>=BUFSIZ)
X return;
X if (ch<0)
X ch=0;
X last_line[pos]=(char)ch;
X}
X
Xget_yank_char(pos)
Xint pos;
X{
X if (pos>=BUFSIZ || pos<0)
X return 0;
X return (int)yank_buffer[pos];
X}
X
Xset_yank_char(pos, ch)
Xint pos, ch;
X{
X if (pos<0 || pos>=BUFSIZ)
X return;
X if (ch<0)
X ch=0;
X yank_buffer[pos]=(char)ch;
X}
X
Xset_position(disp, from)
Xint disp, from;
X{
X int i1;
X
X switch (from) {
X case FROM_START:
X position=disp;
X break;
X case RELATIVE:
X position+=disp;
X break;
X case FROM_END:
X for (i1=0; get_char(i1); i1++);
X position=i1-1;
X break;
X default:
X position=0;
X break;
X }
X}
X
Xget_position()
X{
X return position;
X}
X
Xtoggle_ins()
X{
X insert = ~insert;
X standout();
X if (insert)
X mvaddstr(LINES-2, 75, "INS");
X else
X mvaddstr(LINES-2, 75, "OWR");
X standend();
X}
X
Xin_insert_mode()
X{
X return insert;
X}
X
Xsend_this_line(sock)
X{
X record_line();
X sendit(sock, last_line);
X clear_last_line();
X bol();
X tulosta_viimeinen_rivi();
X refresh();
X}
X
Xrecord_line()
X{
X static int place=0;
X int i1;
X
X for(i1=0; i1<BUFSIZ; i1++)
X history[place][i1]=get_char(i1);
X place++;
X if (place==HIST_SIZ)
X place=0;
X pos_in_history=place;
X}
X
Xclear_last_line()
X{
X int i1;
X
X for(i1=0; i1<BUFSIZ; i1++)
X set_char(i1,(int)'\0');
X}
X
Xkill_eol()
X{
X int i1, i2, i3;
X
X i1=get_position();
X set_position(0, FROM_END);
X i2=get_position();
X for(i3=0; i3<BUFSIZ; i3++)
X set_yank_char(i3,(int)'\0');
X for(i3=0; i3<=(i2-i1); i3++) {
X set_yank_char(i3,get_char(i1+i3));
X set_char(i1+i3, 0);
X }
X set_position(i1, FROM_START);
X}
X
Xnext_in_history()
X{
X int i1=0;
X
X pos_in_history++;
X if (pos_in_history==HIST_SIZ)
X pos_in_history=0;
X clear_last_line();
X while (history[pos_in_history][i1]) {
X set_char(i1, history[pos_in_history][i1]);
X i1++;
X }
X set_position(0, FROM_START);
X}
X
Xprevious_in_history()
X{
X int i1=0;
X
X pos_in_history--;
X if (pos_in_history<0)
X pos_in_history=HIST_SIZ-1;
X clear_last_line();
X while (history[pos_in_history][i1]) {
X set_char(i1, history[pos_in_history][i1]);
X i1++;
X }
X set_position(0, FROM_START);
X}
X
Xkill_whole_line()
X{
X clear_last_line();
X set_position(0, FROM_START);
X}
X
Xyank()
X{
X int i1, i2, i3;
X
X i1=get_position();
X i2=0;
X while (get_yank_char(i2))
X i2++;
X
X for(i3=BUFSIZ-1; i3>=i1+i2; i3--)
X set_char(i3, get_char(i3-i2));
X for(i3=0; i3<i2; i3++)
X set_char(i1+i3, get_yank_char(i3));
X}
X
Xtulosta_viimeinen_rivi()
X{
X static int paikka=0;
X int i1, i2, i3;
X
X i1=get_position();
X /* taytyyko siirtaa puskuria */
X if (i1<(get_disp(paikka)+10) && paikka) {
X paikka--;
X i2=get_disp(paikka);
X } else if (i1>(get_disp(paikka)+70)) {
X paikka++;
X i2=get_disp(paikka);
X } else {
X i2=get_disp(paikka);
X }
X
X move(LINES-1,0);
X for(i3=0; i3<78; i3++)
X if (get_char(i2+i3))
X mvaddch(LINES-1, i3, get_char(i2+i3));
X clrtoeol();
X move(LINES-1, i1-get_disp(paikka));
X refresh();
X return (i1-get_disp(paikka));
X}
X
Xget_disp(paikka)
Xint paikka;
X{
X static int place[]={0,55,110,165,220};
X
X if (paikka>4 || paikka<0)
X return 0;
X return place[paikka];
X}
SHAR_EOF
chmod 0600 screen.c || echo "restore of screen.c fails"
set `wc -c screen.c`;Sum=$1
if test "$Sum" != "4403"
then echo original size 4403, current size $Sum;fi
echo "x - extracting send.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > send.c &&
X/*************************************************************************
X ** send.c Beta v2.0 (22 Aug 1988)
X **
X ** This file is part of Internet Relay Chat v2.0
X **
X ** Author: Jarkko Oikarinen
X ** Internet: jto at tolsun.oulu.fi
X ** UUCP: ...!mcvax!tut!oulu!jto
X ** BITNET: toljto at finou
X **
X ** Copyright (c) 1988 University of Oulu, Computing Center
X **
X ** All rights reserved.
X **
X ** See file COPYRIGHT in this package for full copyright.
X **
X *************************************************************************/
X
Xchar send_id[] = "send.c v2.0 (c) 1988 University of Oulu, Computing Center";
X
X#include "struct.h"
X
X#define NULL ((char *) 0)
X
Xchar sendbuf[1024];
X
Xextern struct Client *client;
Xextern struct Client *find_server();
X
Xsendto_one(to, pattern, para1, para2, para3, para4, para5, para6, para7, para8)
Xstruct Client *to;
Xchar *pattern, *para1, *para2, *para3, *para4, *para5, *para6, *para7, *para8;
X{
X struct Client *cptr;
X sprintf(sendbuf, pattern, para1, para2, para3, para4, para5, para6, para7,
X para8);
X if (to->status != STAT_ME)
X debug(DEBUG_NOTICE,"%s", sendbuf);
X if (to->fd < 0) {
X if (to->fromhost[0] == '\0' && to->status != STAT_ME) {
X debug(DEBUG_ERROR,"Client %s with negative fd and no fromhost... AARGH!",
X to->nickname);
X if (to->fd != -20) m_bye(to, to);
X } else if (to->status != STAT_ME){
X if ((cptr = find_server(to->fromhost, NULL)) == (struct Client *) 0)
X return(-1);
X if (deliver_it(cptr->fd, sendbuf, strlen(sendbuf)) == -1)
X/* m_bye(cptr, cptr); */ ;
X else if (deliver_it(cptr->fd, "\n", 1) == -1)
X/* m_bye(cptr, cptr); */ ;
X }
X } else {
X if (deliver_it(to->fd, sendbuf, strlen(sendbuf)) == -1)
X/* m_bye(cptr, cptr); */ ;
X else if (deliver_it(to->fd, "\n", 1) == -1)
X/* m_bye(cptr, cptr); */ ;
X }
X}
X
Xsendto_channel_butone(one, channel, pattern,
X para1, para2, para3, para4, para5, para6, para7, para8)
Xstruct Client *one;
Xchar *pattern, *para1, *para2, *para3, *para4, *para5, *para6, *para7, *para8;
Xint channel;
X{
X struct Client *cptr=client, *acptr;
X sprintf(sendbuf, pattern, para1, para2, para3, para4, para5, para6, para7,
X para8);
X debug(DEBUG_NOTICE,"%s", sendbuf);
X while (cptr) {
X if (cptr != one && cptr->fd >= 0 &&
X (cptr->status == STAT_SERVER ||
X (cptr->channel == channel &&
X (cptr->status == STAT_OPER || cptr->status == STAT_CLIENT)))) {
X acptr = client;
X if (cptr->status == STAT_SERVER) {
X while (acptr) {
X if (acptr->channel == channel &&
X (acptr->status == STAT_CLIENT || acptr->status == STAT_OPER) &&
X strcmp(acptr->fromhost, cptr->host) == 0 && cptr->host[0])
X break;
X acptr = acptr->next;
X }
X }
X if (acptr) {
X if (deliver_it(cptr->fd, sendbuf, strlen(sendbuf)) == -1)
X/* m_bye(cptr, cptr); */ ;
X else if (deliver_it(cptr->fd, "\n", 1) == -1)
X/* m_bye(cptr, cptr); */ ;
X }
X }
X cptr = cptr->next;
X }
X}
X
Xsendto_serv_butone(one, pattern, para1, para2, para3, para4, para5, para6,
X para7, para8)
Xstruct Client *one;
Xchar *pattern, *para1, *para2, *para3, *para4, *para5, *para6, *para7, *para8;
X{
X struct Client *cptr = client;
X sprintf(sendbuf, pattern, para1, para2, para3, para4, para5, para6, para7,
X para8);
X debug(DEBUG_NOTICE,"%s", sendbuf);
X while(cptr) {
X if (cptr->status == STAT_SERVER && cptr != one && cptr->fd >= 0) {
X if (deliver_it(cptr->fd, sendbuf, strlen(sendbuf)) == -1)
X/* m_bye(cptr, cptr); */ ;
X else if (deliver_it(cptr->fd, "\n", 1) == -1)
X/* m_bye(cptr, cptr); */ ;
X }
X cptr = cptr->next;
X }
X}
X
Xsendto_channel_butserv(channel, pattern,
X para1, para2, para3, para4, para5, para6, para7, para8)
Xint channel;
Xchar *pattern, *para1, *para2, *para3, *para4, *para5, *para6, *para7, *para8;
X{
X struct Client *cptr = client;
X sprintf(sendbuf, pattern, para1, para2, para3, para4, para5, para6, para7,
X para8);
X debug(DEBUG_NOTICE,"%s", sendbuf);
X while(cptr) {
X if (cptr->status != STAT_SERVER && cptr->fd >= 0 &&
X (cptr->channel == channel || channel == 0)) {
X if (deliver_it(cptr->fd, sendbuf, strlen(sendbuf)) == -1)
X/* m_bye(cptr, cptr); */ ;
X else if (deliver_it(cptr->fd, "\n", 1) == -1)
X/* m_bye(cptr, cptr); */ ;
X }
X cptr = cptr->next;
X }
X}
Xsendto_all_butone(one, pattern, para1, para2, para3, para4, para5,
X para6, para7, para8)
Xstruct Client *one;
Xchar *pattern, *para1, *para2, *para3, *para4, *para5, *para6, *para7, *para8;
X{
X struct Client *cptr = client;
X sprintf(sendbuf, pattern, para1, para2, para3, para4, para5, para6, para7,
X para8);
X debug(DEBUG_NOTICE,"%s", sendbuf);
X while(cptr) {
X if (one != cptr) {
X if (deliver_it(cptr->fd, sendbuf, strlen(sendbuf)) == -1)
X /* m_bye(cptr, cptr); */ ;
X else if (deliver_it(cptr->fd, "\n", 1) == -1)
X /* m_bye(cptr, cptr); */ ;
X }
X cptr = cptr->next;
X }
X}
X
SHAR_EOF
chmod 0600 send.c || echo "restore of send.c fails"
set `wc -c send.c`;Sum=$1
if test "$Sum" != "4920"
then echo original size 4920, current size $Sum;fi
echo "x - extracting sock.h (Text)"
sed 's/^X//' << 'SHAR_EOF' > sock.h &&
X/*************************************************************************
X ** sock.h Beta v2.0 (22 Aug 1988)
X **
X ** This file is part of Internet Relay Chat v2.0
X **
X ** Author: Jarkko Oikarinen
X ** Internet: jto at tolsun.oulu.fi
X ** UUCP: ...!mcvax!tut!oulu!jto
X ** BITNET: toljto at finou
X **
X ** Copyright (c) 1988 University of Oulu, Computing Center
X **
X ** All rights reserved.
X **
X ** See file COPYRIGHT in this package for full copyright.
X **
X *************************************************************************/
X
Xchar sockh_id[] = "sock.h v2.0 (c) 1988 University of Oulu, Computing Center";
X
X#define FD_ZERO(set) (((set)->fds_bits[0]) = 0)
X#define FD_SET(s1, set) (((set)->fds_bits[0]) |= 1 << (s1))
X#define FD_ISSET(s1, set) (((set)->fds_bits[0]) & (1 << (s1)))
X#define FD_SETSIZE 30
SHAR_EOF
chmod 0600 sock.h || echo "restore of sock.h fails"
set `wc -c sock.h`;Sum=$1
if test "$Sum" != "862"
then echo original size 862, current size $Sum;fi
echo "x - extracting str.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > str.c &&
X/*************************************************************************
X ** str.c Beta v2.0 (22 Aug 1988)
X **
X ** This file is part of Internet Relay Chat v2.0
X **
X ** Author: Jarkko Oikarinen
X ** Internet: jto at tolsun.oulu.fi
X ** UUCP: ...!mcvax!tut!oulu!jto
X ** BITNET: toljto at finou
X **
X ** Copyright (c) 1988 University of Oulu, Computing Center
X **
X ** All rights reserved.
X **
X ** See file COPYRIGHT in this package for full copyright.
X **
X *************************************************************************/
X
Xchar str_id[] = "str.c v2.0 (c) 1988 University of Oulu, Computing Center";
X
X#include "struct.h"
X#include "sys.h"
X
Xchar *
Xcenter(buf,str,len)
Xchar *buf, *str;
Xint len;
X{
X char i,j,k;
X if ((i = strlen(str)) > len) {
X buf[len-1] = '\0';
X for(len--; len > 0; len--) buf[len-1] = str[len-1];
X return(buf);
X }
X j = (len-i)/2;
X for (k=0; k<j; k++) buf[k] = ' ';
X buf[k] = '\0';
X strcat(buf,str);
X for (k=j+i; k<len; k++) buf[k] = ' ';
X buf[len] = '\0';
X return (buf);
X}
X
X/* William Wisner <wisner at b.cc.umich.edu>, 16 March 1989 */
Xchar *
Xreal_name(user)
X struct passwd *user;
X{
X char *bp, *cp;
X static char name[REALLEN+1];
X
X bp = user->pw_gecos;
X cp = name;
X
X name[REALLEN] = '\0';
X do {
X switch(*bp) {
X case '&':
X *cp = '\0';
X strncat(name, user->pw_name, REALLEN-strlen(name));
X name[REALLEN] = '\0';
X if (islower(*cp))
X *cp = toupper(*cp);
X cp = index(name, '\0');
X bp++;
X break;
X case ',':
X *bp = *cp = '\0';
X break;
X case '\0':
X *cp = *bp;
X break;
X default:
X *cp++ = *bp++;
X }
X } while (*bp != '\0' && strlen(name) < REALLEN);
X return(name);
X}
X
SHAR_EOF
chmod 0600 str.c || echo "restore of str.c fails"
set `wc -c str.c`;Sum=$1
if test "$Sum" != "1728"
then echo original size 1728, current size $Sum;fi
echo "x - extracting struct.h (Text)"
sed 's/^X//' << 'SHAR_EOF' > struct.h &&
X/*************************************************************************
X ** struct.h Beta v2.0 (22 Aug 1988)
X **
X ** This file is part of Internet Relay Chat v2.0
X **
X ** Author: Jarkko Oikarinen
X ** Internet: jto at tolsun.oulu.fi
X ** UUCP: ...!mcvax!tut!oulu!jto
X ** BITNET: toljto at finou
X **
X ** Copyright (c) 1988 University of Oulu, Computing Center
X **
X ** All rights reserved.
X **
X ** See file COPYRIGHT in this package for full copyright.
X **
X *************************************************************************/
X
X/* Type of host... currently only BSD and similar are supported */
X#define BSD42 1 /* Tested on SUN OS 3.4 */
X#define BSD43 0 /* I've heard this works... never have had
X chance to test it by myself... :-) */
X#define HPUX 0 /* HP-UX */
X#define ULTRIX 0 /* Vax Ultrix. */
X#define APOLLO 0 /* Apollo Domain IX. Currently dumps core :-( */
X#define SYSV 0 /* Does not work yet. Under construction */
X
X#define DOMAINNAME 1 /* Define this if your system has */
X /* getdomainname() -call */
X
X/* define NOTTY if you want to run ircd as a daemon. */
X/* (That's the normal way to run it) */
X#define NOTTY 1 /* */
X
X/* Full path name of the server executable */
X#define MYNAME "/usr/users/jto/cta/bbs/ircd"
X
X/* Configurationfile seems to work... */
X#define CONFIGFILE "/usr/users/jto/cta/bbs/irc/irc.conf"
X
X/* Port where ircd resides. NOTE: This *MUST* be greater than 1024, */
X/* if you plan to run ircd under any other uid than root. Command line */
X/* parameter port DOES NOT affect this port, but only the port, where ircd */
X/* tries to connect, ie. the port another server uses, not the one this uses */
X#define PORTNUM 6667
X
X/* Logfile is not in use unless you specifically say sop when starting */
X/* ircd. It might take lots of disk space so I recommend using logfile */
X/* only when you need it for debugging purposes */
X#define LOGFILE "/usr/users/jto/cta/bbs/irc/loki"
X
X#define TIMESEC 60 /* Time interval to wait and if no */
X /* messages has been received, check */
X /* for PINGFREQUENCY and CONNECTFREQUENCY */
X
X#define PINGFREQUENCY 120 /* If daemon doesn't receive anything */
X /* from some daemon/client within */
X /* PINGFREQUENCY seconds, it tries to */
X /* wake it up with PING message */
X /* If no reply is received within */
X /* 2 * PINGFREQUENCY seconds, */
X /* connection will be closed */
X
X#define CONNECTFREQUENCY 1200 /* if connection to to uphost is down, */
X /* try to reconnect about every */
X /* CONNECTFREQUENCY seconds */
X
X#define MAXUSERSPERCHANNEL 10 /* 10 is currently recommended. If this is */
X /* zero or negative, no restrictions exist */
X /* If you are connected to other ircds, do */
X /* NOT change this from default without */
X /* asking from other irc administrators */
X /* first ! */
X
X#define WRITEWAITDELAY 15 /* Number of seconds to wait for write */
X /* to complete if stuck... */
X
X/* You probably shouldn't touch constants after this line... */
X
X#define HOSTLEN 50 /* Length of hostname... this should be changed */
X /* longer due to domain system... */
X#define NICKLEN 10
X#define USERLEN 10
X#define REALLEN 30
X#define HEADERLEN 200
X#define PASSWDLEN 20
X
X#define CHANNELLEN 50
X#define BUFSIZE 256
X#define MAXBUFLEN 512
X
X#define STAT_HANDSHAKE -3
X#define STAT_ME -2
X#define STAT_UNKNOWN -1
X#define STAT_SERVER 0
X#define STAT_CLIENT 1
X#define STAT_LOG 2
X#define STAT_SERVICE 3 /* Services not implemented yet */
X#define STAT_OPER 4 /* Operator */
X
X#define CONF_ILLEGAL 0
X#define CONF_SKIPME 1
X#define CONF_CLIENT 2
X#define CONF_CONNECT_SERVER 4
X#define CONF_NOCONNECT_SERVER 8
X#define CONF_UPHOST 16
X#define CONF_OPERATOR 32
X#define CONF_ME 64
X#define CONF_KILL 128
X#define CONF_ADMIN 256
X
X#define DEBUG_FATAL 0
X#define DEBUG_ERROR 1
X#define DEBUG_NOTICE 2
X#define DEBUG_DEBUG 3
X
X#define IGNORE_TOTAL 3
X#define IGNORE_PRIVATE 1
X#define IGNORE_PUBLIC 2
X
X#define FLAGS_PINGSENT 1
X
X#define FLUSH_BUFFER -2
X#define MAXFD 32
X#define UTMP "/etc/utmp"
X
Xstruct Client {
X struct Client *next;
X char host[HOSTLEN+1];
X char nickname[NICKLEN+1];
X char username[USERLEN+1];
X char realname[REALLEN+1];
X char server[HOSTLEN+1];
X char fromhost[HOSTLEN+1];
X char buffer[MAXBUFLEN+1];
X char sockhost[HOSTLEN+1];
X char passwd[PASSWDLEN+1];
X char *away;
X short status;
X int fd;
X int channel;
X long lasttime;
X short flags;
X};
X
Xstruct Ignore {
X char user[NICKLEN+1];
X int flags;
X struct Ignore *next;
X};
X
Xstruct Channel {
X struct Channel *nextch;
X int channo;
X char name[CHANNELLEN+1];
X int users;
X};
X
Xstruct Confitem {
X int status;
X char host[HOSTLEN+1];
X char passwd[PASSWDLEN+1];
X char name[HOSTLEN+1];
X int port;
X struct Confitem *next;
X};
X
X#ifdef MAIN
Xchar *intro = "Internet Relay Chat v%s";
Xchar *version = "2.01.6";
Xchar *info1 = "Programmed by Jarkko Oikarinen";
Xchar *info2 = "(c) 1988,1989 University of Oulu, Computing Center";
Xchar *info3 = "INTERNET: jto at tolsun.oulu.fi BITNET: toljto at finou";
Xchar myhostname[HOSTLEN+1];
Xchar *HEADER =
X" *** Internet Relay Chat *** Type /help to get help *** Client v%s *** ";
Xchar *welcome1 = "Welcome to Internet Relay Server v";
X#else
Xextern char *version, *info1, *info2, *info3;
Xextern char myhostname[], *HEADER, *welcome1;
Xextern char *intro;
X#endif
X
Xextern struct Client *make_client();
Xextern long getlongtime();
SHAR_EOF
chmod 0600 struct.h || echo "restore of struct.h fails"
set `wc -c struct.h`;Sum=$1
if test "$Sum" != "6336"
then echo original size 6336, current size $Sum;fi
echo "x - extracting swear.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > swear.c &&
X/*************************************************************************
X ** swear.c Beta v2.0 (1 Apr 1989)
X **
X ** This file is part of Internet Relay Chat v2.0
X **
X ** Author: Jarkko Oikarinen
X ** Internet: jto at tolsun.oulu.fi
X ** UUCP: ...!mcvax!tut!oulu!jto
X ** BITNET: toljto at finou
X **
X ** Copyright (c) 1988 University of Oulu, Computing Center
X **
X ** All rights reserved.
X **
X ** See file COPYRIGHT in this package for full copyright.
X **
X *************************************************************************/
X
Xchar swear_id[]="swear.c v2.0 (c) 1988 University of Oulu, Computing Center";
X
X/* Curses replacement routines. Uses termcap */
X
X#include <sys/ioctl.h>
X#include <stdio.h>
X#include <sys/file.h>
X#include <ctype.h>
X#include <strings.h>
X#include "struct.h"
X
X#define LLEN 60
X
Xstatic struct sgttyb oldtty, newtty;
Xstatic char termcapentry[1024];
Xstatic char codes[1024], *cls;
Xstatic char *tgoto();
Xstatic int currow = 0;
Xint lines, columns, scroll = 0;
Xextern int insert;
X
Xmove(row, col)
Xint row, col;
X{
X cls = codes;
X tgetstr("cm",&cls);
X cls = tgoto(codes, col, row);
X printf("%s",cls);
X fflush(stdout);
X}
X
Xclear_to_eol(row, col)
Xint row, col;
X{
X move(row, col);
X cls = codes;
X tgetstr("ce", &cls);
X printf("%s",codes);
X fflush(stdout);
X}
X
Xclearscreen()
X{
X cls = codes;
X tgetstr("cl",&cls);
X printf("%s",codes);
X fflush(stdout);
X currow = 0;
X}
X
Xint
Xio_on(flag)
Xint flag;
X{
X if (ioctl(0, TIOCGETP, &oldtty) < 0)
X return(-1);
X newtty = oldtty;
X newtty.sg_flags &= ~ECHO;
X newtty.sg_flags |= CBREAK;
X ioctl(0, TIOCSETP, &newtty);
X tgetent(termcapentry,"screen");
X lines = tgetnum("li");
X columns = tgetnum("co");
X return(0);
X}
X
Xint
Xio_off()
X{
X if (scroll)
X scroll_off();
X if (ioctl(0, TIOCSETP, &oldtty) < 0)
X return(-1);
X return(0);
X}
X
Xscroll_off()
X{
X cls = codes;
X tgetstr("cs",&cls);
X cls = tgoto(codes, lines-1, 0);
X printf("%s",cls);
X scroll = 0;
X}
X
Xscroll_on()
X{
X cls = codes;
X tgetstr("cm",&cls);
X cls = tgoto(codes, 0, 0);
X printf("%s",cls);
X cls = codes;
X tgetstr("cs",&cls);
X cls = tgoto(codes, lines-3, 0);
X printf("%s",cls);
X fflush(stdout);
X scroll = 1;
X}
X
Xput_insflag(flag)
Xint flag;
X{
X flag = insert;
X move(lines - 2, columns - 5);
X cls = codes;
X tgetstr("mr",&cls);
X printf("%s",codes);
X printf((flag) ? "INS" : "OWR");
X cls = codes;
X tgetstr("me",&cls);
X printf("%s",codes);
X fflush(stdout);
X}
X
Xput_statusline()
X{
X move (lines - 2, 0);
X cls = codes;
X tgetstr("mr",&cls);
X printf("%s",codes);
X printf(HEADER, version);
X cls = codes;
X tgetstr("me",&cls);
X printf("%s",codes);
X fflush(stdout);
X}
X
Xputline(line)
Xchar *line;
X{
X char *ptr = line, *ptr2 = NULL, *newl;
X char ch='\0';
X while (ptr) {
X if (strlen(ptr) > columns-1) {
X ch = ptr[columns-1];
X ptr[columns-1] = '\0';
X ptr2 = &ptr[columns-2];
X }
X else
X ptr2 = NULL;
X if (scroll) {
X move(lines-3, 0);
X } else {
X move(currow++,0);
X if (currow > lines - 4) currow = 0;
X }
X while (newl = index(ptr,'\n'))
X *newl = '\0';
X printf("%s",ptr);
X if (scroll)
X printf("\n",ptr);
X else {
X if (currow == 0) {
X clear_to_eol(1,0);
X clear_to_eol(2,0);
X }
X else if (currow == lines - 4) {
X clear_to_eol(lines-4,0);
X clear_to_eol(0,0);
X }
X else {
X clear_to_eol(currow+1,0);
X clear_to_eol(currow+2,0);
X }
X }
X ptr = ptr2;
X if (ptr2) {
X *ptr2++ = '+';
X *ptr2 = ch;
X }
X }
X fflush(stdout);
X}
X
X/*
Xmain()
X{
X int i;
X io_on();
X scroll_on();
X put_statusline();
X put_insflag(0);
X for (i=0; i<40; i++) {
X if (i == 15) {
X sprintf(kissa,"test #%d v{h{n lis{{ ja %s", i,
X "jonkinlainen apustringi, ett{ saadaan pitk{{{{{{{{ rivi");
X }
X else
X sprintf(kissa,"test #%d", i);
X putline(kissa);
X if (i == 15)
X sleep(5);
X }
X getchar();
X io_off();
X}
X*/
SHAR_EOF
chmod 0600 swear.c || echo "restore of swear.c fails"
set `wc -c swear.c`;Sum=$1
if test "$Sum" != "3925"
then echo original size 3925, current size $Sum;fi
echo "x - extracting sys.h (Text)"
sed 's/^X//' << 'SHAR_EOF' > sys.h &&
X/*************************************************************************
X ** bsd.h Beta v2.0 (22 Aug 1988)
X **
X ** This file is part of Internet Relay Chat v2.0
X **
X ** Author: Jarkko Oikarinen
X ** Internet: jto at tolsun.oulu.fi
X ** UUCP: ...!mcvax!tut!oulu!jto
X ** BITNET: toljto at finou
X **
X ** Copyright (c) 1988 University of Oulu, Computing Center
X **
X ** All rights reserved.
X **
X ** See file COPYRIGHT in this package for full copyright.
X **
X *************************************************************************/
X
X#if HPUX
X#include <string.h>
X#define index strchr
X#define rindex strrchr
X#define bcopy(a,b,s) memcpy(b,a,s)
X#define bzero(a,s) memset(a,0,s)
Xextern char *strchr(), *strrchr();
Xextern char *inet_ntoa();
X#else
X#include <strings.h>
X#endif
X#include <ctype.h>
X#include <pwd.h>
SHAR_EOF
chmod 0600 sys.h || echo "restore of sys.h fails"
set `wc -c sys.h`;Sum=$1
if test "$Sum" != "866"
then echo original size 866, current size $Sum;fi
echo "x - extracting sysv.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > sysv.c &&
X/*************************************************************************
X ** bsd.c Beta v2.0 (22 Aug 1988)
X **
X ** This file is part of Internet Relay Chat v2.0
X **
X ** Author: Jarkko Oikarinen
X ** Internet: jto at tolsun.oulu.fi
X ** UUCP: ...!mcvax!tut!oulu!jto
X ** BITNET: toljto at finou
X **
X ** Copyright (c) 1988 University of Oulu, Computing Center
X **
X ** All rights reserved.
X **
X ** See file COPYRIGHT in this package for full copyright.
X **
X *************************************************************************/
X
Xchar bsd_id[] = "bsd.c v2.0 (c) 1988 University of Oulu, Computing Center";
X
Xdeliver_it(fd, str, len)
Xint fd, len;
Xchar *str;
X{
X return (write(fd, str, len));
X}
X
SHAR_EOF
chmod 0600 sysv.c || echo "restore of sysv.c fails"
set `wc -c sysv.c`;Sum=$1
if test "$Sum" != "737"
then echo original size 737, current size $Sum;fi
echo "x - extracting sysv.h (Text)"
sed 's/^X//' << 'SHAR_EOF' > sysv.h &&
X/*************************************************************************
X ** bsd.h Beta v2.0 (22 Aug 1988)
X **
X ** This file is part of Internet Relay Chat v2.0
X **
X ** Author: Jarkko Oikarinen
X ** Internet: jto at tolsun.oulu.fi
X ** UUCP: ...!mcvax!tut!oulu!jto
X ** BITNET: toljto at finou
X **
X ** Copyright (c) 1988 University of Oulu, Computing Center
X **
X ** All rights reserved.
X **
X ** See file COPYRIGHT in this package for full copyright.
X **
X *************************************************************************/
X
X#include <strings.h>
SHAR_EOF
chmod 0600 sysv.h || echo "restore of sysv.h fails"
set `wc -c sysv.h`;Sum=$1
if test "$Sum" != "595"
then echo original size 595, current size $Sum;fi
rm -f s2_seq_.tmp
echo "You have unpacked the last part"
exit 0
More information about the Alt.sources
mailing list