Internet Relay Chat (IRC) Part 3/6

david bleckmann bleckmd at jacobs.cs.orst.edu
Tue Jun 20 13:32:27 AEST 1989


---- Cut Here and unpack ----
#!/bin/sh
# this is part 3 of a multipart archive
# do not concatenate these parts, unpack them in order with /bin/sh
# file c_msg.c continued
#
CurArch=3
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 c_msg.c"
sed 's/^X//' << 'SHAR_EOF' >> c_msg.c
X      (iptr->flags & IGNORE_PRIVATE) && (iptr->flags & IGNORE_PUBLIC)) {
X	sendto_one(client,
X		   "PRIVMSG %s :*** Automatic reply: You have been ignored");
X	return(0);
X      }
X  sprintf(mybuf,"*** %s Invites you to channel %s", sender, buf2);
X  putline(mybuf);
X}
X
Xm_error(sptr, cptr, sender, buf, buf2)
Xstruct Client *sptr, *cptr;
Xchar *buf, *buf2, *sender;
X{
X  sprintf(mybuf,"*** Error: %s %s", buf, (buf2) ? buf2 : "");
X  putline(mybuf);
X}
SHAR_EOF
echo "File c_msg.c is complete"
chmod 0600 c_msg.c || echo "restore of c_msg.c fails"
set `wc -c c_msg.c`;Sum=$1
if test "$Sum" != "7884"
then echo original size 7884, current size $Sum;fi
echo "x - extracting c_sysv.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > c_sysv.c &&
X/*************************************************************************
X ** c_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 c_sysv_id[]="c_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 <stdio.h>
X#include <signal.h>
X#include <fcntl.h>
X#include <curses.h>
X#include "struct.h"
X#ifdef BSD42
X#include "sock.h"
X#endif
X
Xextern struct Client me;
Xint
Xclient_init(host, portnum)
Xchar *host;
Xint portnum;
X{
X  int sock;
X  static struct hostent *hp;
X  static struct sockaddr_in server;
X  sock = msgget(portnum, 0);
X  if (sock < 0) {
X    perror("opening stream socket");
X    exit(1);
X  }
X  server.sin_family = AF_INET;
X  gethostname(me.host,HOSTLEN);
X  hp = gethostbyname(host);
X  if (hp == 0) {
X    fprintf(stderr, "%s: unknown host", host);
X    exit(2);
X  }
X  bcopy(hp->h_addr, &server.sin_addr, hp->h_length);
X  server.sin_port = htons(portnum);
X  if (connect(sock, (struct sockaddr *) &server, sizeof(server)) < 0) {
X    perror("connect");
X    exit(3);
X  }
X  return(sock);
X}
X
Xclient_loop(sock)
Xint sock;
X{
X  int i = 0, size;
X  char apubuf[101], ch;
X  fd_set ready;
X  do {
X    ready.fds_bits[0] = (1 << sock) | 1;
X    move(LINES-1,i); refresh();
X    if (select(sock+1, &ready, 0, 0, NULL) < 0) {
X      perror("select");
X      continue;
X    }
X    if (ready.fds_bits[0] & (1 << sock)) {
X      if ((size = read(sock, apubuf, 100)) < 0)
X	perror("receiving stream packet");
X      if (size == 0) return(-1);
X      dopacket(&me, apubuf, size);
X    }
X    if (ready.fds_bits[0] & 1) {
X      if ((ch = getchar()) == -1) {
X	move(0,0);
X	addstr("\rFATAL ERROR: End of stdin file !\n\r");
X	refresh();
X	return;
X      }
X      i=do_char(ch);
X    }
X  } while (1);
X}
SHAR_EOF
chmod 0600 c_sysv.c || echo "restore of c_sysv.c fails"
set `wc -c c_sysv.c`;Sum=$1
if test "$Sum" != "2209"
then echo original size 2209, current size $Sum;fi
echo "x - extracting card.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > card.c &&
X/*************************************************************************
X ** card.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 card_id[]="card.c v2.0 (c) 1988 University of Oulu, Computing Center";
X
X#include <sys/types.h>
X#include <stdio.h>
X#include <signal.h>
X#include "sys.h"
X
X#define MAIN
X#define DEPTH 10
X#include "struct.h"
X#include "msg.h"
X#undef MAIN
X
X#define NICKNAME "Bartender"
X#define USERNAME "ron"
X#define REALNAME "Ron the Bartender"
X
Xchar *makeclientbuf();
X
Xint timeout();
Xchar buf[BUFSIZE];
Xchar *mycncmp(), *real_name();
Xstruct Client me;
Xstruct Client *client = &me;
Xint portnum;
Xint debuglevel;
X
Xmain(argc, argv)
X     int argc;
X     char *argv[];
X{
X  int sock,length, streamfd, msgsock, i;
X  struct passwd *userdata;
X  char *ch, *argv0=argv[0], *nickptr, *servptr, *getenv();
X  extern int exit();
X  portnum = PORTNUM;
X/*  signal(SIGTSTP, SIG_IGN); */
X  buf[0] = '\0';
X  initconf(buf, me.passwd, me.host, &me.channel);
X  while (argc > 1 && argv[1][0] == '-') {
X    switch(argv[1][1]) {
X      case 'p':
X        if ((length = atoi(&argv[1][2])) > 0)
X          portnum = length;
X        break;
X    }
X    argv++; argc--;
X  }
X  me.buffer[0] = '\0'; me.next = NULL;
X  me.status = STAT_ME;
X  if (servptr = getenv("IRCSERVER")) {
X    strncpy(buf, servptr, HOSTLEN);
X    buf[HOSTLEN] = '\0';
X  }
X  sock = client_init((argc > 2) ? argv[2] : ((buf[0]) ? buf : me.host),
X		     (me.channel > 0) ? me.channel : portnum);
X  userdata = getpwuid(getuid());
X  if (strlen(userdata->pw_name) >= USERLEN) {
X    userdata->pw_name[USERLEN-1] = '\0';
X  }
X  if (strlen(userdata->pw_gecos) >= REALLEN) {
X    userdata->pw_gecos[REALLEN-1] = '\0';
X  }
X  /* FIX:    jtrim at orion.cair.du.edu -- 3/14/88 
X           & jto at tolsun.oulu.fi */
X  if (argc >= 2) {
X    strncpy(me.nickname, argv[1], NICKLEN);
X  } else if (nickptr = getenv("IRCNICK")) {
X    strncpy(me.nickname, nickptr, NICKLEN);
X  } else
X    strncpy(me.nickname,NICKNAME,NICKLEN);
X
X  me.nickname[NICKLEN] = '\0';
X  /* END FIX */
X
X  if (argv0[0] == ':') {
X    strcpy(me.host,"OuluBox");
X    strncpy(me.realname, &argv0[1], REALLEN);
X    strncpy(me.username, argv[1], USERLEN);
X  }
X  else {
X    strncpy(me.realname,REALNAME,REALLEN);
X    strncpy(me.username,USERNAME,USERLEN);
X  }
X  strcpy(me.server,me.host);
X  me.username[USERLEN] = '\0';
X  me.realname[REALLEN] = '\0';
X  me.fd = sock;
X  if (me.passwd[0])
X    sendto_one(&me, "PASS %s", me.passwd);
X  sendto_one(&me, "NICK %s", me.nickname);
X  sendto_one(&me, "USER %s %s %s %s", me.username, me.host,
X	     me.server, me.realname);
X  myloop(sock,streamfd);
X}
X
Xmyloop(sock,fd)
Xint sock,fd;
X{
X  client_loop(sock);
X}
X
X/*
Xsendit(sock,line)
Xint sock;
Xchar *line;
X{
X  static char queryuser[NICKLEN+2];
X  static char cmdch = '/';
X  int i;
X  char *ptr, *ptr2;
X  if (line[0] != cmdch) {
X    if (*queryuser) {
X      m_myprivate(NULL, NULL, NULL, queryuser, line);
X      sendto_one(&me, "PRIVMSG %s :%s", queryuser, line);
X    }
X    else {
X      sendto_one(&me, "MSG :%s", line);
X      m_mytext(NULL, NULL, NULL, line);
X    }
X  }
X  else {
X    if (mycncmp(&line[1],"SIGNOFF", 1))
X      sendto_one(&me, "QUIT");
X    else if (mycncmp(&line[1],"BYE", 1))
X      sendto_one(&me, "QUIT");
X    else if (mycncmp(&line[1],"EXIT", 1))
X      sendto_one(&me, "QUIT");
X    else if (mycncmp(&line[1],"QUIT", 1))
X      sendto_one(&me, "QUIT");
X    else if (ptr=mycncmp(&line[1],"KILL", 2)) {
X      if (unixuser())
X	sendto_one(&me, "KILL %s", ptr);
X      else
X	putline("`tis is no game for mere mortal souls...");
X    }
X    else if (ptr=mycncmp(&line[1],"SUMMON", 2)) {
X	sendto_one(&me, "SUMMON %s", ptr);
X    }
X    else if (ptr=mycncmp(&line[1],"STATS", 2)) 
X      sendto_one(&me, "STATS %s", ptr);
X    else if (ptr=mycncmp(&line[1],"USERS", 1)) 
X      sendto_one(&me, "USERS %s", ptr);
X    else if (ptr=mycncmp(&line[1],"TIME", 1))
X      sendto_one(&me, "TIME %s", ptr);
X    else if (ptr=mycncmp(&line[1],"DATE", 1))
X      sendto_one(&me, "TIME %s", ptr);
X    else if (ptr=mycncmp(&line[1],"NICK", 1)) 
X      sendto_one(&me, "NICK %s", ptr);
X    else if (ptr=mycncmp(&line[1],"WHOIS", 4)) 
X      sendto_one(&me, "WHOIS %s", ptr);
X    else if (ptr=mycncmp(&line[1],"WHO", 1)) 
X      sendto_one(&me, "WHO %s", ptr);
X    else if (ptr=mycncmp(&line[1],"JOIN", 1))
X      sendto_one(&me, "CHANNEL %s", ptr);
X    else if (ptr=mycncmp(&line[1],"WALL", 2))
X      sendto_one(&me, "WALL %s", ptr);
X    else if (ptr=mycncmp(&line[1],"CHANNEL", 1))
X      sendto_one(&me, "CHANNEL %s", ptr);
X    else if (ptr=mycncmp(&line[1],"AWAY", 1))
X      sendto_one(&me, "AWAY %s", ptr);
X    else if (ptr=mycncmp(&line[1],"MSG", 1)) {
X      if ((ptr2 = index(ptr, ' ')) == NULL)
X	putline("ERROR: No message");
X      else {
X	*ptr2 = '\0';
X	sendto_one(&me, "PRIVMSG %s :%s", ptr, ++ptr2);
X	m_myprivate(NULL, NULL, NULL, ptr, ptr2);
X      }
X    }
X    else if (ptr=mycncmp(&line[1],"TOPIC", 1))
X      sendto_one(&me, "TOPIC :%s", ptr);
X    else if (ptr=mycncmp(&line[1],"CMDCH", 2)) {
X      if (ptr && *ptr) {
X	sprintf(buf, "*** Command character changed from '%c' to '%c'",
X		cmdch, *ptr);
X	cmdch = *ptr;
X	putline(buf);
X      } else {
X	putline("*** Error: Command character not changed");
X      }
X    }
X    else if (ptr=mycncmp(&line[1],"INVITE", 2))
X      sendto_one(&me, "INVITE %s", ptr);
X    else if (ptr=mycncmp(&line[1],"INFO", 2))
X      sendto_one(&me, "INFO");
X    else if (ptr=mycncmp(&line[1],"LIST", 1))
X      sendto_one(&me, "LIST %s",ptr);
X    else if (ptr=mycncmp(&line[1],"KILL", 1))
X      sendto_one(&me, "KILL %s",ptr);
X    else if (ptr=mycncmp(&line[1],"OPER", 1))
X      sendto_one(&me, "OPER %s",ptr);
X    else if (ptr=mycncmp(&line[1],"QUOTE", 1))
X      sendto_one(&me, "%s",ptr);
X    else if (ptr=mycncmp(&line[1],"LINKS", 2)) 
X      sendto_one(&me, "LINKS %s", ptr);
X    else if (ptr=mycncmp(&line[1],"HELP", 1))
X      help(ptr);
X    else if (mycncmp(&line[1],"VERSION", 1))
X      sendto_one(&me, "VERSION");
X    else if (mycncmp(&line[1],"CLEAR", 1))
X      doclear();
X    else if (mycncmp(&line[1],"REHASH", 1))
X      sendto_one(&me, "REHASH");
X    else if (ptr=mycncmp(&line[1],"QUERY", 2)) {
X      if (ptr == NULL || *ptr == '\0') {
X	sprintf(buf,"NOTE: Finished chatting with %s",queryuser);
X	putline(buf);
X        queryuser[0] = '\0';
X      }
X      else {
X	strncpy(queryuser,ptr,NICKLEN);
X	queryuser[NICKLEN] = '\0';
X	if (ptr = index(queryuser,' ')) *ptr = '\0';
X	sprintf(buf,"NOTE: Beginning private chat with %s",queryuser);
X	putline(buf);
X      }
X    }
X    else
X      putline("* Illegal Command *");
X  } 
X} */
X
Xchar *mycncmp(str1, str2, len)
Xchar *str1, *str2;
Xint len;
X{
X  int flag = 0;
X  char *s1;
X  for (s1 = str1; *s1 != ' ' && *s1 && *str2; s1++, str2++) {
X    if (!isascii(*s1)) return 0;
X    if (islower(*s1)) *s1 = toupper(*s1);
X    if (*s1 != *str2) flag = 1;
X  }
X  if (flag) return 0;
X  if (len != 0 && s1 - str1 < len)
X    return 0;
X  if (*s1) return s1 + 1;
X  else return s1;
X}
X/*
Xstatic int apu = 0;
X
Xdoclear()
X{
X  char header[HEADERLEN];
X  apu = 0;
X  sprintf(header,HEADER,version);
X  clear();
X  standout();
X  mvaddstr(LINES - 2, 0, header);
X  standend();
X  refresh();
X}
X
Xputline(line)
Xchar *line;
X{
X  char *ptr = line, *ptr2 = NULL;
X  char ch='\0';
X  static char blanko[] = "                                        ";
X  while (ptr) {
X    if (strlen(ptr) > COLS) {
X      ch = ptr[COLS];
X      ptr[COLS] = '\0';
X      ptr2 = &ptr[COLS-1];
X    } 
X    else
X      ptr2 = NULL;
X    move(apu++,0);
X    if (apu > LINES - 4) apu = 0;
X    addstr(ptr);
X    if (apu == 0) 
X      mvaddstr(0,0,"\n\n");
X    else if (apu == LINES - 4) {
X      mvaddstr(LINES - 4, 0, "\n");
X      mvaddstr(0,0,"\n");
X    }
X    else {
X      addstr(blanko); addstr(blanko);
X      addstr("\n");
X      addstr(blanko); addstr(blanko);
X    }
X    ptr = ptr2;
X    if (ptr2) {
X      *ptr2++ = '+';
X      *ptr2 = ch;
X    }
X  }
X  refresh();
X}
X*/
Xint
Xunixuser()
X{
X  return(strcmp(me.host,"OuluBox"));
X}
X
Xstruct Client *
Xmake_client()
X{
X  return(NULL);
X}
X
Xputline(str)
Xchar *str;
X{
X  printf("%s\n",str);
X}
SHAR_EOF
chmod 0600 card.c || echo "restore of card.c fails"
set `wc -c card.c`;Sum=$1
if test "$Sum" != "8400"
then echo original size 8400, current size $Sum;fi
echo "x - extracting card.h (Text)"
sed 's/^X//' << 'SHAR_EOF' > card.h &&
X/*************************************************************************
X ** msg.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#define CMD_RESET   "RESET"
X#define CMD_SHUFFLE "SHUFFLE"
X#define CMD_GAME    "GAME"
X#define CMD_DEAL    "DEAL"
X#define CMD_BET     "BET"
X#define CMD_DROP    "DROP"
X#define CMD_TAKE    "TAKE"
X#define CMD_PLAYER  "PLAYER"
X#define CMD_SWITCH  "SWITCH"
X#define CMD_PUT     "PUT"
X
Xstruct Game {
X  char *name;
X  int decks;           /* Decks in use in the game */
X  int jokers;          /* No. of jokers in game */
X  int initial_cards;   /* Initial cards delt to players */
X  int newcardtimes;    /* How many times a player can take new cards */
X  int newcardflag;     /* flag = 0, player can take new cards with
X                                    no restriction.
X                          flag = 1, player can take one new card at a time
X                          flag = 2, player can switch some of his cards to
X                                    new ones
X                          flag = 4, player can always take new cards so that
X                                    he always has them number of initial_cards
X		        */
X  int (*cmp)();        /* Compare function used to detect who won the game */
X  int betflag;         /* flag = 0, players can make bets always after
X                                    new cards have been dealt
X                          flag = 1, players can make bet at the start of game
X                          flag = 2, players can make bet after first deal */
X  int basicpot;        /* Total amount of basic pot */
X};
X                          
Xextern int r_reset(), r_shuffle(), r_game(), r_deal(), r_bet(), r_drop();
Xextern int r_take(), r_player(), r_switch();
X
Xstruct Message cmdtab[] = {
X  { CMD_RESET,   r_reset 0, 3 },
X  { CMD_SHUFFLE, r_shuffle 0, 3 },
X  { CMD_GAME,    r_game 0, 3 },
X  { CMD_DEAL,    r_deal 0, 3 },
X  { CMD_BET,     r_bet 0, 3 },
X  { CMD_DROP,    r_drop 0, 3 },
X  { CMD_TAKE,    r_take 0, 3 },
X  { CMD_PLAYER,  r_player 0, 3 },
X  { CMD_SWITCH,  r_switch 0, 3 },
X  { CMD_PUT,     r_put 0, 3 },
X  { NULL,        (int (*)()) 0, 0, 3 }
X};
SHAR_EOF
chmod 0600 card.h || echo "restore of card.h fails"
set `wc -c card.h`;Sum=$1
if test "$Sum" != "2565"
then echo original size 2565, current size $Sum;fi
echo "x - extracting channel.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > channel.c &&
X/*************************************************************************
X ** channel.c  Beta  v2.0    (27 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 channel_id[] = "channel.c v2.0 (c) 1988 University of Oulu, Computing Center";
X
X#include "struct.h"
Xextern struct Channel *channel;
X
Xint
Xchan_isprivate(channel)
Xstruct Channel *channel;
X{
X  if (channel->channo > 999 || channel->channo < 1)
X    return 1;
X  else
X    return 0;
X}
X
Xint
Xchan_conv(name)
Xchar *name;
X{
X  return (atoi(name));
X}
X
Xint
Xchan_match(channel, channo)
Xstruct Channel *channel;
Xint channo;
X{
X  if (channel->channo == channo)
X    return 1;
X  else
X    return 0;
X}
X
Xint
Xchan_issecret(channel)
Xstruct Channel *channel;
X{
X  if (channel->channo < 0)
X    return 1;
X  else
X    return 0;
X}
X
Xstruct Channel *
Xfind_channel(chname, para)
Xchar *chname;
Xstruct Channel *para;
X{
X  struct Channel *ch2ptr = channel;
X  char *ch = chname;
X  int chan;
X  while (*ch) {
X    if (*ch < '0' || *ch > '9')
X      break;
X    ch++;
X  }
X  if (*ch)
X    return (para);
X  if ((chan = atoi(chname)) == 0)
X    return (para);
X  while (ch2ptr) {
X    if (ch2ptr->channo == chan)
X      break;
X    ch2ptr = ch2ptr->nextch;
X  }
X  if (ch2ptr)
X    return (ch2ptr);
X  else
X    return (para);
X}
SHAR_EOF
chmod 0600 channel.c || echo "restore of channel.c fails"
set `wc -c channel.c`;Sum=$1
if test "$Sum" != "1651"
then echo original size 1651, current size $Sum;fi
echo "x - extracting conf.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > conf.c &&
X/*************************************************************************
X ** conf.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 conf_id[] = "conf.c v2.0 (c) 1988 University of Oulu, Computing Center";
X
X#include <stdio.h>
X#include "struct.h"
X#include "sys.h"
X
X#ifdef SERVER
X
Xstruct Confitem *conf = NULL;
Xextern int portnum;
X
Xstruct Confitem *
Xmake_conf()
X{
X  struct Confitem *cptr;
X  if ((cptr = (struct Confitem *) malloc(sizeof (struct Confitem))) == 
X      (struct Confitem *) 0)
X    {
X      perror("malloc");
X      debug(DEBUG_FATAL, "Out of memory: restarting server...");
X      restart();
X    }
X  else {
X    cptr->next = conf;
X    conf = cptr;
X    cptr->host[0] = cptr->passwd[0] = cptr->name[0] = '\0';
X    cptr->status = CONF_ILLEGAL;
X    cptr->port = 0;
X  }
X  return (cptr);
X}
X
Xmatches(name1, name2)
Xchar *name1, *name2;
X{
X  char c1, c2;
X  for (; *name1 && *name2; name1++, name2++) {
X    if (isupper(*name1))
X      c1 = tolower(*name1);
X    else
X      c1 = *name1;
X    if (isupper(*name2))
X      c2 = tolower(*name2);
X    else
X      c2 = *name2;
X    if (c1 == c2) 
X      continue;
X    if (c1 == '?' || c2 == '?')
X      continue;
X    if (*name1 == '*') {
X      if (*(++name1) == '\0')
X	return(0);
X      for (; *name2 && matches(name1, name2); name2++);
X      if (*name2)
X	return(0);
X      else
X	return(1);
X    }
X/*    if (*name2 == '*') {
X      if (*(++name2) == '\0')
X	return(0);
X      for (; *name1 && matches(name1, name2); name1++);
X      if (*name1)
X	return(0);
X      else
X	return(1);
X    } */
X    break;
X  }
X  if (*name1 == '\0' && *name2 == '\0')
X    return(0);
X  else
X    return(1);
X}
X
Xstruct Confitem *
Xfind_admin()
X{
X  struct Confitem *aconf = conf;
X  while (aconf) {
X    if (aconf->status & CONF_ADMIN)
X      break;
X    aconf = aconf->next;
X  }
X  return (aconf);
X}
X
Xstruct Confitem *
Xfind_me()
X{
X  struct Confitem *aconf = conf;
X  while (aconf) {
X    if (aconf->status & CONF_ME)
X      break;
X    aconf = aconf->next;
X  }
X  return (aconf);
X}
X
Xstruct Confitem *
Xfind_conf(host, aconf, name, statmask)
Xchar *host, *name;
Xstruct Confitem *aconf;
Xint statmask;
X{
X  struct Confitem *tmp = conf;
X  int len = strlen(host);
X  int namelen;
X  if (name)
X    namelen = strlen(name);
X  while (tmp) {
X    if ((tmp->status & statmask) && len < HOSTLEN &&
X	matches(tmp->host, host) == 0) 
X      if (name == NULL || (matches(tmp->name, name) == 0 &&
X			   namelen < HOSTLEN))
X      break;
X    tmp = tmp->next;
X  }
X  return((tmp) ? tmp : aconf);
X}
X
X#endif
X
Xchar *
Xgetfield(newline)
Xchar *newline;
X{
X  static char *line = NULL;
X  char *end, *field;
X
X  if (newline)
X    line = newline;
X  if (line == NULL)
X    return(NULL);
X  field = line;
X  if ((end = index(line,':')) == NULL) {
X    line = NULL;
X    if ((end = index(field,'\n')) == NULL)
X      end = field + strlen(field);
X  } else
X    line = end + 1;
X  *end = '\0';
X  return(field);
X}
X
X#ifdef SERVER
X
Xrehash()
X{
X  struct Confitem *tmp = conf, *tmp2;
X  while (tmp) {
X    tmp2 = tmp->next;
X    free(tmp);
X    tmp = tmp2;
X  }
X  conf = (struct Confitem *) 0;
X  initconf();
X}
X
Xinitconf()
X{
X  FILE *fd;
X  char line[256], *tmp;
X  struct Confitem *aconf;
X  if ((fd = fopen(CONFIGFILE,"r")) == NULL)
X    return(-1);
X  while (fgets(line,255,fd)) {
X    if (line[0] == '#' || line[0] == '\n' || line[0] == ' ' || line[0] == '\t')
X      continue;
X    aconf = make_conf();
X    aconf->status = CONF_ILLEGAL;
X    switch (*getfield(line)) {
X    case 'C':   /* Server where I should try to connect */
X    case 'c':   /* in case of link failures             */
X      aconf->status = CONF_CONNECT_SERVER;
X      break;
X    case 'I':   /* Just plain normal irc client trying  */
X    case 'i':   /* to connect me */
X      aconf->status = CONF_CLIENT;
X      break;
X    case 'K':   /* Kill user line on irc.conf           */
X    case 'k':
X      aconf->status = CONF_KILL;
X      break;
X    case 'N':   /* Server where I should NOT try to     */
X    case 'n':   /* connect in case of link failures     */
X                /* but which tries to connect ME        */
X      aconf->status = CONF_NOCONNECT_SERVER;
X      break;
X    case 'U':   /* Uphost, ie. host where client reading */
X    case 'u':   /* this should connect.                  */
X                /* This is for client only, I must ignore this */
X      aconf->status = CONF_SKIPME;
X      break;    
X    case 'O':   /* Operator. Line should contain at least */
X    case 'o':   /* password and host where connection is  */
X      aconf->status = CONF_OPERATOR;      /* allowed from */
X      break;
X    case 'M':   /* Me. Host field is name used for this host */
X    case 'm':   /* and port number is the number of the port */
X      aconf->status = CONF_ME;
X      break;
X    case 'A':   /* Name, e-mail address of administrator of this */
X    case 'a':   /* server. */
X      aconf->status = CONF_ADMIN;
X      break;
X    default:
X      debug(DEBUG_ERROR, "Error in config file: %s", line);
X      break;
X    }
X    if (aconf->status == CONF_SKIPME || aconf->status == CONF_ILLEGAL) {
X      conf = aconf->next;
X      free(aconf);
X      continue;
X    }
X    if (tmp = getfield(NULL)) {
X      strncpy(aconf->host, tmp, HOSTLEN - 1);
X      aconf->host [HOSTLEN - 1] = '\0';
X      if (tmp = getfield(NULL)) {
X	strncpy(aconf->passwd, tmp, PASSWDLEN - 1);
X	aconf->passwd [PASSWDLEN - 1] = '\0';
X	if (tmp = getfield(NULL)) {
X	  strncpy(aconf->name, tmp, HOSTLEN - 1);
X	  aconf->name [HOSTLEN - 1] = '\0';
X	  if (tmp = getfield(NULL))
X	    if ((aconf->port = atoi(tmp)) == 0)
X	      debug(DEBUG_ERROR, "Error in config file, illegal port field");
X	}
X      }
X    }
X    if (aconf->status == CONF_ME) {
X      if (aconf->port > 0)
X	portnum = aconf->port;
X      if (aconf->host[0]) {
X	strncpy(myhostname,aconf->host,HOSTLEN);
X	myhostname[HOSTLEN] = '\0';
X      }
X    }
X    debug(DEBUG_NOTICE, "Read Init: (%d) (%s) (%s) (%s) (%d)",
X	  aconf->status, aconf->host, aconf->passwd,
X	  aconf->name, aconf->port);
X  }
X}
X
X#endif
X#ifdef CLIENT
X
Xinitconf(host, passwd, myname, port)
Xchar *host, *passwd, *myname;
Xint *port;
X{
X  FILE *fd;
X  char line[256], *tmp;
X  if ((fd = fopen(CONFIGFILE,"r")) == NULL)
X    return(-1);
X  while (fgets(line,255,fd)) {
X    if (line[0] == '#' || line[0] == '\n' || line[0] == ' ' || line[0] == '\t')
X      continue;
X    switch (*getfield(line)) {
X    case 'C':   /* Server where I should try to connect */
X    case 'c':   /* in case of link failures             */
X    case 'I':   /* Just plain normal irc client trying  */
X    case 'i':   /* to connect me */
X    case 'N':   /* Server where I should NOT try to     */
X    case 'n':   /* connect in case of link failures     */
X                /* but which tries to connect ME        */
X    case 'O':   /* Operator. Line should contain at least */
X    case 'o':   /* password and host where connection is  */
X                /* allowed from */
X    case 'M':   /* Me. Host field is name used for this host */
X    case 'm':   /* and port number is the number of the port */
X    case 'a':
X    case 'A':
X    case 'k':
X    case 'K':
X      break;
X    case 'U':   /* Uphost, ie. host where client reading */
X    case 'u':   /* this should connect.                  */
X      if (tmp = getfield(NULL)) {
X	strncpy(host, tmp, HOSTLEN - 1);
X	host[HOSTLEN-1] = '\0';
X	if (tmp = getfield(NULL)) {
X	  strncpy(passwd, tmp, PASSWDLEN - 1);
X	  passwd[PASSWDLEN-1] = '\0';
X	  if (tmp = getfield(NULL)) {
X	    strncpy(myname, tmp, HOSTLEN - 1);
X	    myname[HOSTLEN-1] = '\0';
X	    if (tmp = getfield(NULL)) {
X	      if ((*port = atoi(tmp)) == 0)
X		debug(DEBUG_ERROR, "Error in config file, illegal port field");
X	    }
X	  }
X	}
X      }
X      break;    
X    default:
X      debug(DEBUG_ERROR, "Error in config file: %s", line);
X      break;
X    }
X}
X}
X
X#endif
X
X  
SHAR_EOF
chmod 0600 conf.c || echo "restore of conf.c fails"
set `wc -c conf.c`;Sum=$1
if test "$Sum" != "8132"
then echo original size 8132, current size $Sum;fi
echo "x - extracting date.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > date.c &&
X/*************************************************************************
X ** date.c  Beta v2.0    (23 Mar 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 date_id[]="date.c v2.0 (c) 1988 University of Oulu, Computing Center";
X
X#include <time.h>
X
Xstatic char *months[] = {
X	"January",	"February",	"March",	"April",
X	"May",	        "June",	        "July",	        "August",
X	"September",	"October",	"November",	"December"
X};
X
Xstatic char *weekdays[] = {
X	"Sunday",	"Monday",	"Tuesday",	"Wednesday",
X	"Thursday",	"Friday",	"Saturday"
X};
X
Xchar *date() {
X	long clock;
X	struct tm *ltbuf;
X	static char buf[80];
X
X	time(&clock);
X	ltbuf = localtime(&clock);
X	sprintf(buf, "%s %s %d 19%02d -- %d:%02d",
X		weekdays[ltbuf->tm_wday], months[ltbuf->tm_mon],
X		ltbuf->tm_mday, ltbuf->tm_year, ltbuf->tm_hour, ltbuf->tm_min);
X	return buf;
X}
SHAR_EOF
chmod 0600 date.c || echo "restore of date.c fails"
set `wc -c date.c`;Sum=$1
if test "$Sum" != "1246"
then echo original size 1246, current size $Sum;fi
echo "x - extracting debug.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > debug.c &&
X/*************************************************************************
X ** debug.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 debug_id[] = "debug.c v2.0 (c) 1988 University of Oulu, Computing Center";
X
X#include <sys/types.h>
X#include <sys/file.h>
X#include <stdio.h>
X#include "struct.h"
X#if HPUX
X#include <fcntl.h>
X#endif
X
Xextern int debuglevel;
X
Xdebug(level, form, para1, para2, para3, para4, para5, para6)
Xint level;
Xchar *form, *para1, *para2, *para3, *para4, *para5, *para6;
X{
X  if (debuglevel >= 0) 
X    if (level <= debuglevel) { 
X      fprintf(stderr, form, para1, para2, para3, para4, para5, para6);
X      fprintf(stderr, "\n");
X    } 
X}
X
Xopenlog()
X{
X  int fd;
X#ifdef NOTTY
X  if (debuglevel >= 0) {
X    if ((fd = open(LOGFILE, O_WRONLY | O_CREAT, 0600)) < 0) 
X      if ((fd = open("/dev/null", O_WRONLY)) < 0)
X        exit(-1);
X    if (fd != 2) {
X      dup2(fd, 2);
X      close(fd); 
X    }
X  } else {
X    if ((fd = open("/dev/null", O_WRONLY)) < 0) 
X      exit(-1);
X    if (fd != 2) {
X      dup2(fd, 2);
X      close(fd);
X    }
X  }
X#endif
X}
SHAR_EOF
chmod 0600 debug.c || echo "restore of debug.c fails"
set `wc -c debug.c`;Sum=$1
if test "$Sum" != "1501"
then echo original size 1501, current size $Sum;fi
echo "x - extracting deck.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > deck.c &&
X/*************************************************************************
X ** deck.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 deck_id[] = "deck.c v2.0 (c) 1988 University of Oulu, Computing Center";
X
X#include "struct.h"
X#include "deck.h"
X
X#define STATE_NONE   1
X#define STATE_START  2
X#define STATE_BET    3
X#define STATE_TAKE   4
X#define STATE_END    5
X
X#define ST_INGAME    1
X#define ST_GIVEUP    2
X#define ST_NOMORE    3
X#define ST_NEWUSER   4
X
Xstruct Card {
X  char suite;
X  char card;
X  struct Card *next;
X};
X
Xstruct Player {
X  char name[NICKLEN+1];
X  struct Card *cards;
X  int status;
X  int saldo;
X  int pot;
X  struct Player *next;
X};
X
Xstatic int state = STATE_NONE;
Xstatic int pot = 0;
X
Xextern struct Client *client;
X
Xstatic char *suites[] = {
X  "Spade", "Heart", "Diamonds", "Club"
X  };
X
Xstatic char *cards[] = {
X  "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten",
X  "jack", "queen", "king", "ace", "joker"
X  };
X
Xstatic struct Player *player = (struct Player *) 0;
Xstatuc struct Card *trash = (struct Card *) 0;
Xstatic struct Card *deck = (struct Card *) 0;
Xstatic struct Player *turn = (struct Player *) 0, *first = (struct Player *) 0;
Xstatic int cardsondeck = 0;
Xstatic int cardsperdeal = 0;
Xstatic int noofplayers = 0;
X
Xr_reset(user)
Xchar *user;
X{
X  struct Card *ctmp = deck, *ctmp2;
X  struct Player *ptmp = player, *ptmp2;
X  sendto_one(client, "MSG :%s requested game reset...", user);
X  while (ctmp) {
X    ctmp2 = ctmp->next;
X    free (ctmp);
X    ctmp = ctmp2;
X  }
X  while (player) {
X    ctmp = player->cards;
X    while (ctmp) {
X      ctmp2 = ctmp->next;
X      free (ctmp);
X      ctmp = ctmp2;
X    }
X    ptmp2 = ptmp->next;
X    free(ptmp);
X    ptmp = ptmp2;
X  }
X  ctmp = trash;
X  while (ctmp) {
X    ctmp2 = ctmp->next;
X    free(ctmp);
X    ctmp = ctmp2;
X  }
X  cardsondeck = cardsperdeal = noofplayers = 0;
X  deck = trash = (struct Card *) 0;
X  player = turn = first = (struct Player *) 0;
X  return(1);
X}
X
Xstruct Player *nextplayer()
X{
X  if (noofplayers == 0)
X    return (struct Player *) 0;
X  if (turn == (struct Player *) 0)
X    turn = first;
X  do {
X    turn++;
X    if (turn > &(players[MAXPLAYERS-1]))
X      turn = &(players[0]);
X  } while (turn->name[0] == '\0');
X  return (turn);
X}
X
Xshuffle(name)
Xchar *name;
X{
X  int i,j;
X  if (state != START && state != END && state != NO_INIT) {
X    sendto_one(client, "MSG :Shuffling in the middle of game don't work...");
X    return(0);
X  }
X  if (state == NO_INIT) {
X    state = START;
X    init_game(5);
X    return (0);
X  }
X  sendto_one(client, "MSG :%s is shuffling the deck ...", name);
X  cardsondeck = 54;
X  for (i = 0; i < 13; i++)
X    for (j = 0; j < 4; j++) {
X      deck[i + j * 13].suite = j;
X      deck[i + j * 13].card = i+2;
X      deck[i + j * 13].next = &(deck[i + j * 13 + 1]);
X    }
X  deck[52].next = &(deck[53]);
X  deck[53].next = (struct Card *) 0;
X  deck[53].suite = deck[52].suite = 4;
X  deck[53].card = deck[52].card = 15;
X  decktop = &deck[0];
X}
X
Xinit_game(x)
Xint x;
X{
X  int i;
X  shuffle();
X  cardsperdeal = x;
X  for (i=0; i < MAXPLAYERS; i++) {
X    players[i].name[0] = '\0';
X    players[i].cards = (struct Card *) 0;
X    players[i].pot = 0;
X    players[i].saldo = 0;
X  }
X  srandom(time(0));
X  state = START;
X}
X
Xplayer(user)
Xchar *user;
X{
X  int i;
X  if (state != START) {
X    sendto_one(client,"PRIVMSG %s :You cannot enter in the middle of game",
X	       user);
X    return(-1);
X  }
X  for (i=0; players[i].name[0] && i < MAXPLAYERS; i++);
X  if (i == MAXPLAYERS) {
X    sendto_one(client,"PRIVMSG %s :Sorry, no room for more players...",
X	       user);
X    return(-1);
X  }
X  noofplayers++;
X  strncpy(players[i].name, user, NICKLEN);
X  players[i].name[NICKLEN] = '\0';
X  players[i].pot = 0;
X  players[i].saldo = 0;
X  players[i].status = ST_INGAME;
X  sendto_one(client,"MSG :Player %s entered the game...", user);
X  return(0);
X}
X
Xnames()
X{
X  int i;
X  sendto_one(client,"MSG :Players on game:");
X  for (i=0; i<MAXPLAYERS; i++) {
X    if (players[i].name[0])
X      sendto_one(client,"MSG :%s", players[i].name);
X  }
X}
X
Xstruct Player *getplayer(name)
Xchar *name;
X{
X  int i;
X  for (i=0; i<MAXPLAYERS; i++)
X    if (strncmp(name, players[i].name) == 0)
X      break;
X  if (i < MAXPLAYERS)
X    return (&players[i]);
X  else
X    return (struct Player *) 0;
X}
X
Xstruct Card *pickcard()
X{
X  int i;
X  struct Card *cp1 = (struct Card *) 0, *cp2 = decktop;
X  if (cardsondeck < 1)
X    return (struct Card *) 0;
X  i = random() % cardsondeck;
X  cardsondeck--;
X  while (i-- > 0) {
X    cp1 = cp2;
X    cp2 = cp2->next;
X  }
X  if (cp1)
X    cp1->next = cp2->next;
X  cp2->next = (struct Card *) 0;
X  return cp2;
X}
X
Xdeal()
X{
X  int i,j;
X  struct Card *tmp;
X  if (state != START) {
X    sendto_one(client, "MSG :Cannot deal now...");
X    return(-1);
X  }
X  state = DEAL;
X  sendto_one(client, "MSG :Dealing cards ...");
X  for (i=0; i<MAXPLAYERS; i++)
X    if (players[i].name[0]) {
X      sendto_one(client, "MSG :Player %s... %d cards",
X		 players[i].name, cardsperdeal);
X      for (j=0; j<cardsperdeal; j++) {
X	tmp = pickcard();
X	if (tmp == (struct Card *) 0) {
X	  sendto_one(client, "MSG :No more cards... player %s got only %d..",
X		     players[i].name, j);
X	  break;
X	}
X	tmp->next = players[i].cards;
X	players[i].cards = tmp;
X      }
X    }
X}
X
Xhand(sender)
Xchar *sender;
X{
X  struct Card *tmp;
X  struct Player *playerptr = getplayer(sender);
X  if (playerptr == (struct Player *) 0) {
X    sendto_one(client,"PRIVMSG %s :You are not playing !");
X    return(-1);
X  }
X  if (state == START) {
X    sendto_one(client,"PRIVMSG %s :Game has not started yet !");
X    return(-1);
X  }
X  tmp = playerptr->cards;
X  sendto_one(client,"PRIVMSG %s :Your cards:", sender);
X  sendto_one(client,"MSG :%s is having a look at his cards...", sender);
X  while (tmp) {
X    sendto_one(client, "PRIVMSG %s :%s of %s", sender,
X		   cards[tmp->card - 2], suites[tmp->suite]);
X    tmp = tmp->next;
X  }
X}
X
X  
SHAR_EOF
chmod 0600 deck.c || echo "restore of deck.c fails"
set `wc -c deck.c`;Sum=$1
if test "$Sum" != "6293"
then echo original size 6293, current size $Sum;fi
echo "x - extracting edit.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > edit.c &&
X/*************************************************************************
X ** edit.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 edit_id[] = "edit.c v2.0 (c) 1988 University of Oulu, Computing Center";
X
X#include <curses.h>
X#include <signal.h>
X#include "struct.h"
X
X#ifdef TRUE
X#undef TRUE
X#endif
X#define FALSE (0)
X#define TRUE  (!FALSE)
X
X#define FROM_START 0
X#define FROM_END   1
X#define RELATIVE   2
X
Xstatic int esc=0;
Xstatic int literal=0;
X
Xdo_char(ch, sock)
Xchar ch;
X{
X    static int first_time=0;
X
X    if (!first_time) {
X	toggle_ins();
X	toggle_ins();
X	first_time=1;
X	refresh();
X    }
X    if (esc==1) {
X	do_after_esc(ch);
X	return tulosta_viimeinen_rivi();
X    }
X    switch (ch) {
X    case '\000':		/* NULL */
X	break;
X    case '\001':		/* ^A */
X	bol();			/* beginning of line */
X	break;
X    case '\002':		/* ^B */
X	back_ch();		/* backward char */
X	break;
X    case '\003':		/* ^C */
X	rev_line();		/* reverse line */
X	break;
X    case '\004':		/* ^D */
X	del_ch_right();		/* delete char from right */
X	break;
X    case '\005':		/* ^E */
X	eol();			/* end of line */
X	break;
X    case '\006':		/* ^F */
X	forw_ch();		/* forward char */
X	break;
X    case '\007':		/* ^G */
X	add_ch(ch);		/* bell */
X	break;
X    case '\010':		/* ^H */
X	del_ch_left();		/* delete char to left */
X	break;
X    case '\011':		/* TAB */
X	toggle_ins();		/* toggle insert mode */
X	break;
X    case '\012':		/* ^J */
X	send_this_line(sock);	/* send this line */
X	break;
X    case '\013':		/* ^K */
X	kill_eol();		/* kill to end of line */
X	break;
X    case '\014':		/* ^L */
X	refresh_screen();	/* refresh screen */
X	break;
X    case '\015':		/* ^M */
X	send_this_line(sock);	/* send this line */
X	break;
X    case '\016':		/* ^N */
X	next_in_history();	/* next in history */
X	break;
X    case '\017':		/* ^O */
X	break;
X    case '\020':		/* ^P */
X	previous_in_history();	/* previous in history */
X	break;
X    case '\021':		/* ^Q */
X	break;
X    case '\022':		/* ^R */
X    case '\023':		/* ^S */
X    case '\024':		/* ^T */
X	break;
X    case '\025':		/* ^U */
X	kill_whole_line();	/* kill whole line */
X	break;
X    case '\026':		/* ^V */
X	literal_next();		/* literal next */
X	break;
X    case '\027':		/* ^W */
X	del_word_left();        /* delete word left */
X	break;
X    case '\030':		/* ^X */
X	break;
X    case '\031':		/* ^Y */
X	yank();			/* yank */
X	break;
X    case '\032':		/* ^Z */
X	suspend_irc();		/* suspend irc */
X	break;
X    case '\033':		/* ESC */
X	got_esc();
X	break;
X    case '\177':		/* DEL */
X	del_ch_left();		/* delete char to left */
X	break;
X    default:
X	add_ch(ch);
X	break;
X    }
X    return tulosta_viimeinen_rivi();
X}
X
Xbol()
X{
X    set_position(0, FROM_START);
X}
X
Xeol()
X{
X    set_position(0, FROM_END);
X    set_position(1, RELATIVE);
X}
X
Xback_ch()
X{
X    set_position(-1, RELATIVE);
X}
X
Xforw_ch()
X{
X    set_position(1, RELATIVE);
X}
X
Xrev_line()
X{
X    int i1, i2, i3, i4;
X    
X    i4=get_position();
X    set_position(0, FROM_START);
X    i1=get_position();
X    set_position(0, FROM_END);
X    i1=get_position()-i1;
X    set_position(i4, FROM_START);
X
X    for( i2=0; i2>i1/2; i2++) {
X	i3=get_char(i2);
X	set_char(i2, get_char(i1-i2-1));
X	set_char(i1-i2-1, i3);
X    }
X}
X
Xdel_ch_right()
X{
X    int i1, i2, i3;
X
X    i1=get_position();
X    
X    if (!get_char(i1))
X	return;			/* last char in line */
X    set_position(0, FROM_END);
X    i2=get_position();
X    for (i3=i1; i3<i2; i3++)
X	set_char(i3, get_char(i3+1));
X    set_char(i3, 0);
X    set_position(i1, FROM_START);
X}
X
Xdel_ch_left()
X{
X    int i1, i2, i3;
X
X    i1=get_position();
X    
X    if (!i1)
X	return;			/* first pos in line */
X    set_position(0, FROM_END);
X    i2=get_position();
X    for (i3=i1-1; i3<i2; i3++)
X	set_char(i3, get_char(i3+1));
X    set_char(i3, 0);
X    set_position(i1, FROM_START);
X    set_position(-1, RELATIVE);
X}
X
Xsuspend_irc()
X{
X#if HPUX
X#ifdef SIGSTOP
X  kill(getpid(), SIGSTOP);
X#endif
X#else
X  tstp(); 
X#endif
X}
X
Xgot_esc()
X{
X    esc = 1;
X}
X
Xdo_after_esc(ch)
Xchar ch;
X{
X    if (literal) {
X	literal=0;
X	add_ch(ch);
X	return;
X    }
X    esc = 0;
X    switch (ch) {
X    case 'b':
X	word_back();
X	break;
X    case 'd':
X	del_word_right();
X	break;
X    case 'f':
X	word_forw();
X	break;
X    case 'y':
X	yank();
X	break;
X    case '\177':
X	del_word_left();
X	break;
X    default:
X	break;
X    }
X}
X
Xrefresh_screen()
X{
X
X    clearok(curscr, TRUE);
X    refresh();
X}
X
Xadd_ch(ch)
Xint ch;
X{
X    int i1, i2, i3;
X    if (in_insert_mode()) {
X	i1=get_position();
X	set_position(0, FROM_END);
X	i2=get_position();
X	for (i3=i2; i3>=0; i3--)
X	    set_char(i1+i3+1, get_char(i3+i1));
X	set_char(i1, ch);
X	set_position(i1, FROM_START);
X	set_position(1, RELATIVE);
X    } else {
X	i1=get_position();
X	set_char(i1, ch);
X	set_position(i1, FROM_START);
X	set_position(1, RELATIVE);
X    }
X}
X
Xliteral_next()
X{
X    got_esc();
X    literal=1;
X}
X
Xword_forw()
X{
X    int i1,i2;
X
X    i1=get_position();
X    while( i2=get_char(i1) )
X	if ((i2==(int)' ') ||
X	    (i2==(int)'\t') ||
X	    (i2==(int)'_') ||
X	    (i2==(int)'-'))
X	    i1++;
X	else
X	    break;
X    while( i2=get_char(i1) )
X	if ((i2==(int)' ') ||
X	    (i2==(int)'\t') ||
X	    (i2==(int)'_') ||
X	    (i2==(int)'-'))
X	    break;
X	else
X	    i1++;
X    set_position(i1, FROM_START);
X}
X
Xword_back()
X{
X    int  i1,i2;
X
X    i1=get_position();
X    if (i1!=0)
X	i1--;
X    while( i2=get_char(i1) )
X	if ((i2==(int)' ') ||
X	    (i2==(int)'\t') ||
X	    (i2==(int)'_') ||
X	    (i2==(int)'-'))
X	    i1--;
X	else
X	    break;
X    while( i2=get_char(i1) )
X	if ((i2==(int)' ') ||
X	    (i2==(int)'\t') ||
X	    (i2==(int)'_') ||
X	    (i2==(int)'-'))
X	    break;
X	else
X	    i1--;
X    if (i1<=0)
X	i1=0;
X    else
X	i1++;
X    set_position(i1, FROM_START);
X}
X
Xdel_word_left()
X{
X    int i1, i2, i3, i4;
X
X    i1=get_position();
X    word_back();
X    i2=get_position();
X    set_position(0, FROM_END);
X    i3=get_position();
X    for(i4=i2; i4<=i3-(i1-i2); i4++)
X	set_char(i4, get_char(i4+(i1-i2)));
X    for(; i4<=i3; i4++)
X	set_char(i4, (int)'\0');
X    set_position(i2, FROM_START);
X}
X
Xdel_word_right()
X{
X    int i1, i2, i3, i4;
X
X    i2=get_position();
X    word_forw();
X    i1=get_position();
X    set_position(0, FROM_END);
X    i3=get_position();
X    for(i4=i2; i4<=i3-(i1-i2); i4++)
X	set_char(i4, get_char(i4+(i1-i2)));
X    for(; i4<=i3; i4++)
X	set_char(i4, (int)'\0');
X    set_position(i2, FROM_START);
X}
X
X
SHAR_EOF
chmod 0600 edit.c || echo "restore of edit.c fails"
set `wc -c edit.c`;Sum=$1
if test "$Sum" != "6649"
then echo original size 6649, current size $Sum;fi
echo "x - extracting example.conf (Text)"
sed 's/^X//' << 'SHAR_EOF' > example.conf &&
X# Example file how to set up your irc.conf file. 
X# First, you should find out your hostname (full domainname).
X# Replace my.domain.name in next line (and everywhere in this file)
X# with it.
XM:my.domain.name:*:*:6667
X#
X# Next, you should find out all machines where you want to allow
X# clients (that is: irc users, NOT servers) to connect you. Those
X# machines should be systems on the same cluster or department as
X# you so it is not necessary to start separate irc daemons for
X# each of them. Let's assume that you want to give client access
X# to hosts dog.zoo.xx, cat.zoo.xx, cow.zoo.xx, tolsun.oulu.fi and
X# my.domain.name
XI:my.domain.name::my.domain.name
XI:tolsun.oulu.fi::tolsun.oulu.fi
XI:dog.zoo.xx::dog.zoo.xx
XI:cat.zoo.xx::cat.zoo.xx
XI:cow.zoo.xx::cow.zoo.xx
X# The empty fields in previous lines are for passwords, so if you
X# want to set up passwords, you should insert that password in between
X# those colons. Like:
X# I:dog.zoo.xx:password:dog.zoo.xx
X#
X# Next, you should set up a operator access. 
X# Remember that operator has responsibility and power in IRCnet, so
X# you should not allow anyone to be operator. That is why password
X# is always needed with operator account.
X# The first field (tolsun.oulu.fi) is the name of the system where
X# operator is allowed to log into irc. Second field (poiuyt) is password
X# field and third field is operator nickname in IRCnet.
XO:tolsun.oulu.fi:poiuyt:wiz
X#
X# Next line is only for irc clients. You do not need this unless
X# this irc.conf file is used by systems without ircdaemon and they
X# should connect to daemon on this host OR if you have set up
X# passwords for irc clients above (lines beginning with I:).
X# If you have not set uo any passwords for clients, you MUST leave
X# this password field empty. The second field (before password)
X# contains name of the host clients should connect to. (Typically
X# your hostname).
XU:tolsun.oulu.fi:password:tolsun.oulu.fi:6667
X#
X# By now you have working irc.conf for ONE SERVER ircd system. That is,
X# you cannot connect to other ircds yet. For those connections you need
X# to set up a couple of lines for each other ircdaemon you wish
X# your daemon to be directly connected. You should ASK those systems
X# (and passwords for all of them) from the nearest IRC administrator.
X# If in doubt, mail irc at tolsun.oulu.fi and ask there.
X#
X# Now we assume you have a list of hosts available. You should have one
X# of them marked as your UPHOST. (At first you normally have just this
X# one host, no more). It might also be possible to have several UPHOSTs.
X# Next two lines are an example of uphost configuration.
XC:tolsun.oulu.fi:tolsun_password:tolsun.oulu.fi:6667
XN:tolsun.oulu.fi:my_password_for_tolsun:tolsun.oulu.fi
X# If you do not have passwords, just leave those couple of lines empty.
X#
X# Next, you might also have a list of other hosts that might try to
X# connect you (also YOU are their UPHOST). An example configuration
X# file for host 'hal.oce.orst.edu'
XC:hal.oce.orst.edu:hal_password:hal.oce.orst.edu
XN:hal.oce.orst.edu:my_password_for_hal:hal.oce.orst.edu
X# Note that the only difference is the lack of PORT number. That
X# one number is quite important and it makes the difference between
X# UPHOST and DOWNHOST. You should never have too many UPHOSTs, that
X# might cause severe problems on IRCnet.
X# Now your irc.conf installation should be ok. Try to start ircd and
X# then after a short while try to start irc and see how it works.
X#
X# If you happen to be installing another ircd connecting to this
X# one, then you might need some instructions more. Let's assume you're
X# trying to connect hal.oce.orst.edu's daemon to my.domain.name
X# (this example file was made for an imaginary system called my.domain.name).
X# Also you have the following lines in my.domain.name for hal.oce.orst.edu.
X# C:hal.oce.orst.edu:hal_password:hal.oce.orst.edu
X# N:hal.oce.orst.edu:my_password_for_hal:hal.oce.orst.edu
X# What lines should you add to hal.oce.orst.edu's irc.conf-file for
X# my.domain.name ? They are:
X# C:my.domain.name:my_password_for_hal:my.domain.name
X# N:my.domain.name:hal_password:my.domain.name
X#
X# Good Luck ! (You're going to need it ;-)
SHAR_EOF
chmod 0600 example.conf || echo "restore of example.conf fails"
set `wc -c example.conf`;Sum=$1
if test "$Sum" != "4150"
then echo original size 4150, current size $Sum;fi
echo "x - extracting help.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > help.c &&
X/*************************************************************************
X ** help.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 help_id[]="help.c v2.0 (c) 1988 University of Oulu, Computing Center";
X
X#include "struct.h"
X#include "sys.h"
X#include "help.h"
X
Xchar helpbuf[80];
X
Xhelp(ptr)
Xchar *ptr;
X{
X  struct Help *hptr;
X  int count;
X  char *ch;
X
X  if (ptr == NULL || *ptr == '\0') {
X    sprintf(helpbuf, "*** Help: Internet Relay Chat v%s Commands:", version);
X    putline(helpbuf);
X    count = 0;
X    for (hptr = helplist; hptr->command; hptr++) {
X      sprintf(&helpbuf[count*10], "%10s", hptr->command);
X      if (++count >= 4) {
X	count = 0;
X	putline(helpbuf);
X      }
X    }
X    if (count)
X      putline(helpbuf);
X    putline("Write /help <command> to get help about particular command");
X    putline("For example /help signoff gives you help about command signoff");
X    putline("To use a command you must prefix it with a slash (/),");
X    putline("For example, to signoff IRC you write /SIGNOFF");
X    putline("*** End Help");
X  } else {
X/*    for (ch = ptr; *ch; ch++)
X      if (islower(*ch))
X	*ch = toupper(*ch); */
X    hptr = helplist;
X    while (hptr->command) {
X      if (mycncmp(ptr, hptr->command, 0)) 
X	break;
X      hptr++;
X    }
X    if (hptr->command == (char *) 0) {
X      putline("*** Error: No such command available via help");
X      putline("*** Write /help to get general help");
X      return(0);
X    }
X    sprintf(helpbuf, "*** Help: %s", hptr->syntax);
SHAR_EOF
echo "End of part 3"
echo "File help.c is continued in part 4"
echo "4" > s2_seq_.tmp
exit 0



More information about the Alt.sources mailing list